-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Don't suggest restricting bound with unstable traits on stable and mention it's unstable on nightly #133522
Merged
Merged
Don't suggest restricting bound with unstable traits on stable and mention it's unstable on nightly #133522
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
68253e1
Don't suggest restricting bound with unstable traits on stable
estebank d13c348
reword trait bound suggestion message to include the bounds
estebank 568b0ac
Add test for lack of suggestion in stable
estebank 3f2a63a
Use trait name instead of full constraint in suggestion message
estebank d860e5b
Mention type parameter in more cases and don't suggest ~const bound a…
estebank cb4db0a
Account for `impl Trait` in "add bound" suggestion message
estebank af09423
fix rustdoc test
estebank b466405
Do not talk about "trait `<Foo = Bar>`"
estebank 6277fb0
Use run-make `diff` output for stable output test
estebank 25ad047
Tweak wording
estebank 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
Next
Next commit
Don't suggest restricting bound with unstable traits on stable
On nightly, we mention the trait is unstable ``` error[E0277]: the trait bound `T: Unstable` is not satisfied --> $DIR/unstable-trait-suggestion.rs:13:9 | LL | foo(t) | --- ^ the trait `Unstable` is not implemented for `T` | | | required by a bound introduced by this call | note: required by a bound in `foo` --> $DIR/unstable-trait-suggestion.rs:9:11 | LL | fn foo<T: Unstable>(_: T) {} | ^^^^^^^^ required by this bound in `foo` help: consider restricting type parameter `T` but it is an `unstable` trait | LL | pub fn demo<T: Unstable>(t: T) { | ++++++++++ ``` On stable, we don't suggest the trait at all ``` error[E0277]: the trait bound `T: Unstable` is not satisfied --> $DIR/unstable-trait-suggestion.rs:13:9 | LL | foo(t) | --- ^ the trait `Unstable` is not implemented for `T` | | | required by a bound introduced by this call | note: required by a bound in `foo` --> $DIR/unstable-trait-suggestion.rs:9:11 | LL | fn foo<T: Unstable>(_: T) {} | ^^^^^^^^ required by this bound in `foo` ```
- Loading branch information
commit 68253e14ee3d0e81881bc908b07b5ba141daf226
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![feature(staged_api)] | ||
#![allow(internal_features)] | ||
#![stable(feature = "unit_test", since = "1.0.0")] | ||
|
||
#[unstable(feature = "step_trait", issue = "42168")] | ||
pub trait Unstable {} | ||
|
||
#[stable(feature = "unit_test", since = "1.0.0")] | ||
fn foo<T: Unstable>(_: T) {} | ||
|
||
#[stable(feature = "unit_test", since = "1.0.0")] | ||
pub fn demo<T>(t: T) { //~ HELP consider restricting type parameter `T` but it is an `unstable` trait | ||
foo(t) //~ ERROR E0277 | ||
} | ||
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 @@ | ||
error[E0277]: the trait bound `T: Unstable` is not satisfied | ||
--> $DIR/unstable-trait-suggestion.rs:13:9 | ||
| | ||
LL | foo(t) | ||
| --- ^ the trait `Unstable` is not implemented for `T` | ||
| | | ||
| required by a bound introduced by this call | ||
| | ||
note: required by a bound in `foo` | ||
--> $DIR/unstable-trait-suggestion.rs:9:11 | ||
| | ||
LL | fn foo<T: Unstable>(_: T) {} | ||
| ^^^^^^^^ required by this bound in `foo` | ||
help: consider restricting type parameter `T` but it is an `unstable` trait | ||
| | ||
LL | pub fn demo<T: Unstable>(t: T) { | ||
| ++++++++++ | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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
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.
nit:
unstable
is not a keyword, and "but" feels awkward here... maybe put it in parens and use "although" instead?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.
maybe "although note that it is unstable" in the parentheses?
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 also think the "it" here is a bit unclear, on first reading I thought "it" referred to
T
and was then thrown off byT
being an unstable traitPerhaps the trait could be named or something like "the new bound" or "the bound added below" be used instead?
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.
the "it" is the trait, not really the 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.
"but note that the trait is unstable"?
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.
sure, but if you're going to use "but" please still put it in parentheses or at least add a comma, since it's still a bit awkward grammatically
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.
Drive-by comment: perhaps it would be easier if the types were explicitly named? For example:
Then the stability or non-stability can be added via the phrase "consider adding the trait
Tuple
to the bounds ofA
" / "consider adding the unstable traitTuple
to the bounds of A`".Alternatively, it could be suggested via a separate note:
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.
Changed to "help: consider restricting type parameter
T
with unstable traitUnstable
".