-
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
Trait bounds on struct type parameters aren't always enforced (depending on the order of impls) #21837
Comments
P-high, not 1.0. (But definitely a weird bug that we would like to fix.) |
cc me |
@nikomatsakis, @pnkfelix: should this be P-backcompat-lang since the compiler accepts code that it should not? |
@SSheldon I think we decided this is one of those edge cases where the amount of breakage (that fixing this is expected to incur) was deemed acceptable for fixing post 1.0. At the time this was last triaged, there was a general rule that if something was tagged P-backcompat-lang, then it must also be set for the 1.0 milestone (at the latest). However, since then during recent triage meetings, we have been more willing to tag things as P-backcompat-lang even if they were not attached to the 1.0 milestone. So, with that in mind: triage: P-backcompat-lang, not P-high |
This causes an RFC1214 warning in 1.4+. |
triage: P-medium Looks like this is already fixed by RFC 1214, as @arielb1 reports. |
Tagging as E-needstest, since we should be able to add a test with |
Tagging as mentor just because I can give advice on how to craft a suitable test ( |
Triaging: Both examples causes error on nightly
@nikomatsakis I would like to help with the test if you don't mind giving initial directions. |
@bltavares, that repro case was from pre-1.0, here's the updated repro case: pub trait Bound { }
pub struct Foo<T: Bound>(T);
pub trait Trait1 { }
impl<T: Bound> Trait1 for Foo<T> { }
pub trait Trait2 { }
impl<T> Trait2 for Foo<T> { }
fn main() { } That code will compile with |
@arielb1 This seems to have been fixed by RFC 1214. Can it be closed? |
@brson I think it needs a test. I probably should not be assigned to it since I don't plan to spend time making a test. |
So all there is to do is add a test which checks that Ssheldons code does not compile? |
@martinhath yes :) |
Add regression test for Issue rust-lang#21837 This PR adds a regression test for Issue rust-lang#21837, as explained in the comments of the issue.
Fixed now with a test merged in #36941 |
The following compiles without issue, even though the impl of
Trait2
is missing a trait bound thatT
implementsBound
:However, if you switch the order of the impls...
You suddenly start getting this error:
I did not expect the ordering of the impls to matter here. I'm using
rustc 1.0.0-nightly (1d00c545e 2015-01-30 19:56:34 +0000)
.The text was updated successfully, but these errors were encountered: