about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-09-30 19:06:05 +0200
committerGitHub <noreply@github.com>2022-09-30 19:06:05 +0200
commitf7f253ea47f8782f7f09e76bdde5a03c60fab318 (patch)
treea3e053693e5e6470291d0e55f81ca8d1b0a358d7 /src
parente2bc6b8172dd122b31019fc0b0de179ae5215f31 (diff)
parent523a76a2ebd5c1763665e2d51fa65f8304fc46af (diff)
downloadrust-f7f253ea47f8782f7f09e76bdde5a03c60fab318.tar.gz
rust-f7f253ea47f8782f7f09e76bdde5a03c60fab318.zip
Rollup merge of #102421 - lyming2007:issue-101866, r=lcnr
remove the unused :: between trait and type to give user correct diag…

…nostic information

	modified:   compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
	new file:   src/test/ui/type/issue-101866.rs
	new file:   src/test/ui/type/issue-101866.stderr
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/type/issue-101866.rs15
-rw-r--r--src/test/ui/type/issue-101866.stderr18
2 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/type/issue-101866.rs b/src/test/ui/type/issue-101866.rs
new file mode 100644
index 00000000000..d332c4adb00
--- /dev/null
+++ b/src/test/ui/type/issue-101866.rs
@@ -0,0 +1,15 @@
+trait TraitA<T> {
+    fn func();
+}
+
+struct StructA {}
+
+impl TraitA<i32> for StructA {
+    fn func() {}
+}
+
+fn main() {
+    TraitA::<i32>::func();
+    //~^ ERROR: cannot call associated function on trait without specifying the corresponding `impl` type [E0790]
+    //~| help: use the fully-qualified path to the only available implementation
+}
diff --git a/src/test/ui/type/issue-101866.stderr b/src/test/ui/type/issue-101866.stderr
new file mode 100644
index 00000000000..788e54b9381
--- /dev/null
+++ b/src/test/ui/type/issue-101866.stderr
@@ -0,0 +1,18 @@
+error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
+  --> $DIR/issue-101866.rs:12:5
+   |
+LL |     fn func();
+   |     ---------- `TraitA::func` defined here
+...
+LL |     TraitA::<i32>::func();
+   |     ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
+   |
+help: use the fully-qualified path to the only available implementation
+   |
+LL -     TraitA::<i32>::func();
+LL +     <::StructA as TraitA<i32>>::func();
+   |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0790`.