forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
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#127844 - chenyukang:yukang-fix-type-bound-1…
…27555, r=jieyouxu Remove invalid further restricting suggestion for type bound This PR partially addresses rust-lang#127555, it will remove the obvious error suggestion: ```console | ^^^^ required by this bound in `<Baz as Foo>::bar` help: consider further restricting this bound | 12 | F: FnMut() + Send + std::marker::Send, | +++++++++++++++++++ ``` I may create another PR to get a better diagnostic for `impl has stricter requirements than trait` scenario.
- Loading branch information
Showing
9 changed files
with
70 additions
and
33 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
23 changes: 23 additions & 0 deletions
23
tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs
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,23 @@ | ||
//@ edition:2021 | ||
// issue: rust-lang/rust#127555 | ||
|
||
pub trait Foo { | ||
fn bar<F>(&mut self, func: F) -> impl std::future::Future<Output = ()> + Send | ||
where | ||
F: FnMut(); | ||
} | ||
|
||
struct Baz {} | ||
|
||
impl Foo for Baz { | ||
async fn bar<F>(&mut self, _func: F) -> () | ||
//~^ ERROR `F` cannot be sent between threads safely | ||
where | ||
F: FnMut() + Send, | ||
//~^ ERROR impl has stricter requirements than trait | ||
{ | ||
() | ||
} | ||
} | ||
|
||
fn main() {} |
33 changes: 33 additions & 0 deletions
33
tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
error[E0277]: `F` cannot be sent between threads safely | ||
--> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:13:5 | ||
| | ||
LL | / async fn bar<F>(&mut self, _func: F) -> () | ||
LL | | | ||
LL | | where | ||
LL | | F: FnMut() + Send, | ||
| |__________________________^ `F` cannot be sent between threads safely | ||
| | ||
note: required by a bound in `<Baz as Foo>::bar` | ||
--> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:16:22 | ||
| | ||
LL | async fn bar<F>(&mut self, _func: F) -> () | ||
| --- required by a bound in this associated function | ||
... | ||
LL | F: FnMut() + Send, | ||
| ^^^^ required by this bound in `<Baz as Foo>::bar` | ||
|
||
error[E0276]: impl has stricter requirements than trait | ||
--> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:16:22 | ||
| | ||
LL | / fn bar<F>(&mut self, func: F) -> impl std::future::Future<Output = ()> + Send | ||
LL | | where | ||
LL | | F: FnMut(); | ||
| |___________________- definition of `bar` from trait | ||
... | ||
LL | F: FnMut() + Send, | ||
| ^^^^ impl has extra requirement `F: Send` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
Some errors have detailed explanations: E0276, E0277. | ||
For more information about an error, try `rustc --explain E0276`. |
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