diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-07-11 17:46:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-11 17:46:18 +0200 |
| commit | c6df564b8c81c6f2298f617104cd201c8d5131c8 (patch) | |
| tree | 2acdf01bf3e9438385474059c96cd09586ecd25f /tests | |
| parent | 3f73a7dba3550228bf915d7a9a5fa445a17425df (diff) | |
| parent | b5208b36114ce3cb17835f22ea23fd3310e281c9 (diff) | |
| download | rust-c6df564b8c81c6f2298f617104cd201c8d5131c8.tar.gz rust-c6df564b8c81c6f2298f617104cd201c8d5131c8.zip | |
Rollup merge of #113310 - jieyouxu:dont-suggest-impl-trait-in-paths, r=lcnr
Don't suggest `impl Trait` in path position Fixes #113264.
Diffstat (limited to 'tests')
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs new file mode 100644 index 00000000000..5a893f2d8ad --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.rs @@ -0,0 +1,12 @@ +trait T {} + +struct S {} + +impl S { + fn owo(&self, _: Option<&impl T>) {} +} + +fn main() { + (S {}).owo(None) + //~^ ERROR type annotations needed +} diff --git a/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr new file mode 100644 index 00000000000..0ec219415ab --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-113264-incorrect-impl-trait-in-path-suggestion.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/issue-113264-incorrect-impl-trait-in-path-suggestion.rs:10:16 + | +LL | (S {}).owo(None) + | ^^^^ cannot infer type of the type parameter `T` declared on the enum `Option` + | +help: consider specifying the generic argument + | +LL | (S {}).owo(None::<&_>) + | ++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. |
