-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix validation when lowering ?
trait bounds
#132209
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
^(a handful of lines above) we were probably also allowing
?std::ops::Fn<T>
but i dont care to write a test for that.