forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#132209 - compiler-errors:modifiers, r=fmease Fix validation when lowering `?` trait bounds Pass the unlowered (`rustc_hir`) polarity to `lower_poly_trait_ref`. This allows us to actually *validate* that generic args are actually valid on `?Trait` paths. This actually regressed in rust-lang#113671 because that PR changed the behavior where we were inadvertently re-lowering paths as `BoundPolarity::Positive`, which was also coincidentally the only place we were enforcing the generics on `?Trait` paths were correct.
- Loading branch information
Showing
13 changed files
with
119 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
struct Foo<T: ?Hash> {} | ||
//~^ ERROR expected trait, found derive macro `Hash` | ||
//~^^ ERROR parameter `T` is never used | ||
//~^^^ WARN relaxing a default bound only does something for `?Sized` | ||
//~| WARN relaxing a default bound only does something for `?Sized` | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn uwu<T: ?Sized<i32>>() {} | ||
//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied | ||
--> $DIR/maybe-bound-generics-deny.rs:1:12 | ||
| | ||
LL | fn uwu<T: ?Sized<i32>>() {} | ||
| ^^^^^----- help: remove the unnecessary generics | ||
| | | ||
| expected 0 generic arguments | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0107`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
trait Trait {} | ||
|
||
fn test<T: ?self::<i32>::Trait>() {} | ||
//~^ ERROR type arguments are not allowed on this type | ||
//~| WARN relaxing a default bound only does something for `?Sized` | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-bound-has-path-args.rs:3:12 | ||
| | ||
LL | fn test<T: ?self::<i32>::Trait>() {} | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0109]: type arguments are not allowed on this type | ||
--> $DIR/maybe-bound-has-path-args.rs:3:20 | ||
| | ||
LL | fn test<T: ?self::<i32>::Trait>() {} | ||
| ---- ^^^ type argument not allowed | ||
| | | ||
| not allowed on this type | ||
|
||
error: aborting due to 1 previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0109`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
trait HasAssoc { | ||
type Assoc; | ||
} | ||
fn hasassoc<T: ?HasAssoc<Assoc = ()>>() {} | ||
//~^ WARN relaxing a default bound | ||
|
||
trait NoAssoc {} | ||
fn noassoc<T: ?NoAssoc<Missing = ()>>() {} | ||
//~^ WARN relaxing a default bound | ||
//~| ERROR associated type `Missing` not found for `NoAssoc` | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-bound-with-assoc.rs:4:16 | ||
| | ||
LL | fn hasassoc<T: ?HasAssoc<Assoc = ()>>() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-bound-with-assoc.rs:8:15 | ||
| | ||
LL | fn noassoc<T: ?NoAssoc<Missing = ()>>() {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0220]: associated type `Missing` not found for `NoAssoc` | ||
--> $DIR/maybe-bound-with-assoc.rs:8:24 | ||
| | ||
LL | fn noassoc<T: ?NoAssoc<Missing = ()>>() {} | ||
| ^^^^^^^ associated type `Missing` not found | ||
|
||
error: aborting due to 1 previous error; 2 warnings emitted | ||
|
||
For more information about this error, try `rustc --explain E0220`. |