Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upGeneric type defaults should not be allowed if they don’t satisfy type constraints #28024
Comments
This comment has been minimized.
This comment has been minimized.
|
triage: I-nominated |
rust-highfive
added
the
I-nominated
label
Aug 26, 2015
alexcrichton
added
the
T-lang
label
Sep 9, 2015
nikomatsakis
self-assigned this
Oct 1, 2015
This comment has been minimized.
This comment has been minimized.
|
triage: P-high Seems like a straightforward oversight in the WF checker. |
rust-highfive
added
P-high
and removed
I-nominated
labels
Oct 1, 2015
This comment has been minimized.
This comment has been minimized.
|
Hmm, thinking more about this, it's perhaps not as straightforward as I originally thought. It gets into problems much like higher-ranked regions etc. For example: fn foo<T,U = T>()
where U: Clone
{
}Here, we can't fully check the value of the default ahead of time, because it references another type parameter ( |
This comment has been minimized.
This comment has been minimized.
|
Nominating for discussion. |
nikomatsakis
added
the
I-nominated
label
Oct 7, 2015
This comment has been minimized.
This comment has been minimized.
|
I'm also going to lower the triage. It seems unlikely that anyone would intentionally abuse this, and I think we'll be able to fix this without undue anger or breakage out there in the wild. triage: P-medium |
rust-highfive
added
P-medium
and removed
I-nominated
P-high
labels
Oct 7, 2015
brson
added
the
A-typesystem
label
Jul 14, 2016
This comment has been minimized.
This comment has been minimized.
|
Triage: still a problem. @nikomatsakis Long time since any update. Do you know how to fix this and can mentor? |
This comment has been minimized.
This comment has been minimized.
|
So it's worth noting that this will compile (modulo some minor fixes), but, if you try to actually use
gives
|
This comment has been minimized.
This comment has been minimized.
|
In general, type defaults have been kind of stalled; we've been wanting to rethink the design overall, which has led to a lack of motivation to fixing details of the implementation. I wouldn't in any case tackle this bug first -- the overall algorithm isn't really following the RFC, so I'd fix that first. Not sure if there's an issue about that though. |
nagisa commentedAug 26, 2015
As spotted in this internals thread:
compiles. Lack of early error/warning/lint here might be hiding bugs in API design if the default never actually kicks in inside the library.