-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Reject ?Trait
bounds in various places where we unconditionally warned since 1.0
#135841
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
Merged
Merged
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions
8
tests/ui/diagnostic-flags/allow-non-lint-warnings.without_flag.stderr
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,8 +1,8 @@ | ||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/allow-non-lint-warnings.rs:26:13 | ||
warning: unexpected annotation used with `#[rustc_error(...)]`! | ||
--> $DIR/allow-non-lint-warnings.rs:25:1 | ||
| | ||
LL | pub fn f<T: ?Trait>() {} | ||
| ^^^^^^ | ||
LL | fn main() {} | ||
| ^^^^^^^^^ | ||
|
||
warning: 1 warning emitted | ||
|
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! Regression test for ICE https://github.com/rust-lang/rust/issues/135730 | ||
//! This used | ||
use std::future::Future; | ||
fn foo() -> impl ?Future<Output = impl Send> { | ||
//~^ ERROR: relaxing a default bound only does something for `?Sized` | ||
//~| ERROR: relaxing a default bound only does something for `?Sized` | ||
() | ||
} | ||
|
||
pub 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,16 @@ | ||
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/opt-out-bound-not-satisfied.rs:5:18 | ||
| | ||
LL | fn foo() -> impl ?Future<Output = impl Send> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/opt-out-bound-not-satisfied.rs:5:18 | ||
| | ||
LL | fn foo() -> impl ?Future<Output = impl Send> { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` | ||
|
||
error: aborting due to 2 previous errors | ||
|
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,5 +1,5 @@ | ||
struct Foo<T: ?Hash> {} | ||
//~^ ERROR expected trait, found derive macro `Hash` | ||
//~| WARN relaxing a default bound only does something for `?Sized` | ||
//~| ERROR 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
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
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,20 +1,20 @@ | ||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-polarity-pass.rs:14:20 | ||
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-polarity-pass.rs:12:20 | ||
| | ||
LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | ||
| ^^^^^^^ | ||
|
||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-polarity-pass.rs:14:30 | ||
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-polarity-pass.rs:12:30 | ||
| | ||
LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | ||
| ^^^^^^^ | ||
|
||
warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-polarity-pass.rs:14:40 | ||
error: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default | ||
--> $DIR/maybe-polarity-pass.rs:12:40 | ||
| | ||
LL | fn bar<T: ?Sized + ?Trait2 + ?Trait1 + ?Trait4>(_: &T) {} | ||
| ^^^^^^^ | ||
|
||
warning: 3 warnings emitted | ||
error: aborting due to 3 previous errors | ||
|
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
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.
I don't want to block this PR on surface level things like phrasing, so feel free to ignore this and I'll submit this as a follow-up PR. I've never liked how this specific diagnostic is formulated, it's super verbose.
Now with this being a hard error this sentence doesn't quite make sense anymore. I'd rather see a message that's straight to the point like
`?` can only be applied to `Sized`
(similar to`~const` can only be applied to `#[const_trait]` traits
or`async` bound modifier only allowed on `Fn`/`FnMut`/`FnOnce` traits
) and defer any further explanations to diagnostic note/help messages if at all (cc error codes).If we wanted to feel fancy we could provide a structured suggestion for removing the entire bound.
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.
How about we do this as a follow-up