diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-05-16 20:12:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-16 20:12:18 +0200 |
| commit | d2e52ea127fea8d3c8eef3815cb52935f85605a3 (patch) | |
| tree | b3acd36492dba773e18651e4813f99732da61361 /tests/ui | |
| parent | 20f6aa1365d556edf4804fc502f1f29c1ef9fdcb (diff) | |
| parent | b2b2be1cad5a3009f53f490ae09abf33958e40df (diff) | |
| download | rust-d2e52ea127fea8d3c8eef3815cb52935f85605a3.tar.gz rust-d2e52ea127fea8d3c8eef3815cb52935f85605a3.zip | |
Rollup merge of #111610 - bvanjoi:fix-99597, r=compiler-errors
fix(diagnostic): wrap parens for ref impl trait param Fixes https://github.com/rust-lang/rust/issues/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
Diffstat (limited to 'tests/ui')
| -rw-r--r-- | tests/ui/suggestions/issue-99597.rs | 15 | ||||
| -rw-r--r-- | tests/ui/suggestions/issue-99597.stderr | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/suggestions/issue-99597.rs b/tests/ui/suggestions/issue-99597.rs new file mode 100644 index 00000000000..8ba9e1fdd62 --- /dev/null +++ b/tests/ui/suggestions/issue-99597.rs @@ -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() { } diff --git a/tests/ui/suggestions/issue-99597.stderr b/tests/ui/suggestions/issue-99597.stderr new file mode 100644 index 00000000000..bdf2a07c143 --- /dev/null +++ b/tests/ui/suggestions/issue-99597.stderr @@ -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`. |
