-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
base: master
Are you sure you want to change the base?
Conversation
@@ -6,7 +6,7 @@ LL | impl<A, B> FnOnce<A> for CachedFun<A, B> | |||
| | |||
note: required by a bound in `FnOnce` | |||
--> $SRC_DIR/core/src/ops/function.rs:LL:COL | |||
help: consider further restricting this bound | |||
help: consider further restricting this bound but it is an `unstable` trait |
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?
consider further restricting this bound (although this is an unstable trait)
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 by T
being an unstable trait
Perhaps 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:
error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5
|
LL | extern "rust-call" fn call_once(mut self, a: A) -> Self::Output {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A`
|
help: consider adding the unstable trait `Tuple` to the bounds of `A`
|
LL | A: Eq + Hash + Clone + std::marker::Tuple,
| ++++++++++++++++++++
Then the stability or non-stability can be added via the phrase "consider adding the trait Tuple
to the bounds of A
" / "consider adding the unstable trait Tuple
to the bounds of A`".
Alternatively, it could be suggested via a separate note:
error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument
--> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5
|
LL | extern "rust-call" fn call_once(mut self, a: A) -> Self::Output {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A`
|
help: consider adding the trait `Tuple` to the bounds of `A`
|
LL | A: Eq + Hash + Clone + std::marker::Tuple,
| ++++++++++++++++++++
note: the trait `Tuple` 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.
Changed to "help: consider restricting type parameter T
with unstable trait Unstable
".
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` ```
932462b
to
e3dfae8
Compare
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `C: Bar<5>` is not satisfied | |||
LL | pub struct Structure<C: Tec> { | |||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar<5>` is not implemented for `C` | |||
| | |||
help: consider further restricting this bound | |||
help: consider further restricting this bound with trait `Bar<5>` |
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.
Could you change this to use print_only_trait_name
rather than printing the binder and the args?
I first of all don't think mentioning the name is really that useful, since it's already there in the suggestion, but if we're going to mention it at all, it's probably only worthwhile to suggest only the trait name.
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.
Rendering the binder and substs runs the risk of printing a really overly long trait ref here, since we may have large types in the args.
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.
We could only mention the trait for unsafe ones (as I originally intended in the PR, to keep the diff small).
The only issue against using the "name only" is when we have more than one bound being suggested, but we have to handle that anyways...
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 think it's fine either way, was just mentioning that it feels a bit redundant. Name only seems like a good compromise.
This test will break when `Step` gets stabilized, but punt until then.
This PR modifies cc @jieyouxu |
The job Click to see the possible cause of the failure (guessed by this bot)
|
On nightly, we mention the trait is unstable
On stable, we don't suggest the trait at all
Fix #133511.