-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#[deriving(Clone)]
et al. should ask for Clone
bounds on fields, not on generic parameters
#19839
Comments
@japaric currently we accept both forms but as Niko pointed out the RFC technically disallows the bounding of arbitrary types, so the second bound ( |
@jroesch the good news is that fixing deriving doesn't need to care about whether or not types that don't contain type params can be bounded. Because it can simply not bound those. |
FWIW, this bug is basically the same as #7671. |
This isn't really a dupe of #7671, because this is specifically about fields. For example, the following does not work: foo.rs: #[derive(Clone)]
pub struct Foo<'a, T: 'a>(&'a T);
pub struct Bar;
fn main() {
let foo = Foo(&Bar);
foo.clone();
} Output:
Supporting this would reduce a lot of boilerplate, especially for by-reference iterators. |
I think this should be reopened—even though #7671 is fixed, @apasel422’s example still doesn’t work, although it should. |
The FIXME refers to this issue: https://github.com/rust-lang/rust/blob/master/src/liballoc/binary_heap.rs#L929 If this is fixed, we can remove the FIXME. If we can't remove the FIXME, than we should reopen the issue. |
remove FIXME(rust-lang#13101) since `assert_receiver_is_total_eq` stays. remove FIXME(rust-lang#19649) now that stability markers render. remove FIXME(rust-lang#13642) now the benchmarks were moved. remove FIXME(rust-lang#6220) now that floating points can be formatted. remove FIXME(rust-lang#18248) and write tests for `Rc<str>` and `Rc<[u8]>` remove reference to irelevent issues in FIXME(rust-lang#1697, rust-lang#2178...) update FIXME(rust-lang#5516) to point to getopts issue 7 update FIXME(rust-lang#7771) to point to RFC 628 update FIXME(rust-lang#19839) to point to issue 26925
For example:
expands to:
The
A: Clone
bound is incorrect. Insteadderiving
should expand to:This requires generalized
where
clauses to handle more complex fields like&'a T: Clone
.@nikomatsakis Are where clauses like
&'a int: Clone
(note: no generic parameter) going to be allowed? If not, writing the syntax extension is going to be harder.The text was updated successfully, but these errors were encountered: