-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 #111610 - bvanjoi:fix-99597, r=compiler-errors
fix(diagnostic): wrap parens for ref impl trait param Fixes #99597 When parameters are an `impl_trait` which it needed to add trait, and it is a reference, add parentheses to the type of the parameter in the suggestion
- Loading branch information
Showing
3 changed files
with
76 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![allow(dead_code)] | ||
|
||
trait T1 { } | ||
|
||
trait T2 { | ||
fn test(&self) { } | ||
} | ||
|
||
fn go(s: &impl T1) { | ||
//~^ SUGGESTION ( | ||
s.test(); | ||
//~^ ERROR no method named `test` | ||
} | ||
|
||
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,15 @@ | ||
error[E0599]: no method named `test` found for reference `&impl T1` in the current scope | ||
--> $DIR/issue-99597.rs:11:7 | ||
| | ||
LL | s.test(); | ||
| ^^^^ method not found in `&impl T1` | ||
| | ||
= help: items from traits can only be used if the type parameter is bounded by the trait | ||
help: the following trait defines an item `test`, perhaps you need to restrict type parameter `impl T1` with it: | ||
| | ||
LL | fn go(s: &(impl T1 + T2)) { | ||
| + +++++ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |