summaryrefslogtreecommitdiffstats
path: root/src/test/ui/missing/missing-items
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/missing/missing-items')
-rw-r--r--src/test/ui/missing/missing-items/auxiliary/m1.rs9
-rw-r--r--src/test/ui/missing/missing-items/m2.rs12
-rw-r--r--src/test/ui/missing/missing-items/m2.stderr17
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter.rs5
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter.stderr14
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter2.rs19
-rw-r--r--src/test/ui/missing/missing-items/missing-type-parameter2.stderr121
7 files changed, 197 insertions, 0 deletions
diff --git a/src/test/ui/missing/missing-items/auxiliary/m1.rs b/src/test/ui/missing/missing-items/auxiliary/m1.rs
new file mode 100644
index 000000000..fcf52c9e8
--- /dev/null
+++ b/src/test/ui/missing/missing-items/auxiliary/m1.rs
@@ -0,0 +1,9 @@
+pub trait X {
+ const CONSTANT: u32;
+ type Type;
+ fn method(&self, s: String) -> Self::Type;
+ fn method2(self: Box<Self>, s: String) -> Self::Type;
+ fn method3(other: &Self, s: String) -> Self::Type;
+ fn method4(&self, other: &Self) -> Self::Type;
+ fn method5(self: &Box<Self>) -> Self::Type;
+}
diff --git a/src/test/ui/missing/missing-items/m2.rs b/src/test/ui/missing/missing-items/m2.rs
new file mode 100644
index 000000000..c2a6914ab
--- /dev/null
+++ b/src/test/ui/missing/missing-items/m2.rs
@@ -0,0 +1,12 @@
+// aux-build:m1.rs
+
+
+extern crate m1;
+
+struct X {
+}
+
+impl m1::X for X { //~ ERROR not all trait items implemented
+}
+
+fn main() {}
diff --git a/src/test/ui/missing/missing-items/m2.stderr b/src/test/ui/missing/missing-items/m2.stderr
new file mode 100644
index 000000000..d18fb443a
--- /dev/null
+++ b/src/test/ui/missing/missing-items/m2.stderr
@@ -0,0 +1,17 @@
+error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5`
+ --> $DIR/m2.rs:9:1
+ |
+LL | impl m1::X for X {
+ | ^^^^^^^^^^^^^^^^ missing `CONSTANT`, `Type`, `method`, `method2`, `method3`, `method4`, `method5` in implementation
+ |
+ = help: implement the missing item: `const CONSTANT: u32 = 42;`
+ = help: implement the missing item: `type Type = Type;`
+ = help: implement the missing item: `fn method(&self, _: String) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method2(self: Box<Self>, _: String) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method3(_: &Self, _: String) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method4(&self, _: &Self) -> <Self as m1::X>::Type { todo!() }`
+ = help: implement the missing item: `fn method5(self: &Box<Self>) -> <Self as m1::X>::Type { todo!() }`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0046`.
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter.rs b/src/test/ui/missing/missing-items/missing-type-parameter.rs
new file mode 100644
index 000000000..8a64053a4
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter.rs
@@ -0,0 +1,5 @@
+fn foo<X>() { }
+
+fn main() {
+ foo(); //~ ERROR type annotations needed
+}
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter.stderr b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
new file mode 100644
index 000000000..722539fca
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter.stderr
@@ -0,0 +1,14 @@
+error[E0282]: type annotations needed
+ --> $DIR/missing-type-parameter.rs:4:5
+ |
+LL | foo();
+ | ^^^ cannot infer type of the type parameter `X` declared on the function `foo`
+ |
+help: consider specifying the generic argument
+ |
+LL | foo::<X>();
+ | +++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.rs b/src/test/ui/missing/missing-items/missing-type-parameter2.rs
new file mode 100644
index 000000000..e9b32fb71
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter2.rs
@@ -0,0 +1,19 @@
+struct X<const N: u8>();
+
+impl X<N> {}
+//~^ ERROR cannot find type `N` in this scope
+//~| ERROR unresolved item provided when a constant was expected
+impl<T, const A: u8 = 2> X<N> {}
+//~^ ERROR cannot find type `N` in this scope
+//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+//~| ERROR unresolved item provided when a constant was expected
+
+fn foo(_: T) where T: Send {}
+//~^ ERROR cannot find type `T` in this scope
+//~| ERROR cannot find type `T` in this scope
+
+fn bar<const N: u8>(_: A) {}
+//~^ ERROR cannot find type `A` in this scope
+
+fn main() {
+}
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr
new file mode 100644
index 000000000..f33951c98
--- /dev/null
+++ b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr
@@ -0,0 +1,121 @@
+error[E0412]: cannot find type `N` in this scope
+ --> $DIR/missing-type-parameter2.rs:3:8
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+LL |
+LL | impl X<N> {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | impl X<X> {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | impl<N> X<N> {}
+ | +++
+
+error[E0412]: cannot find type `N` in this scope
+ --> $DIR/missing-type-parameter2.rs:6:28
+ |
+LL | impl<T, const A: u8 = 2> X<N> {}
+ | - ^
+ | |
+ | similarly named type parameter `T` defined here
+ |
+help: a type parameter with a similar name exists
+ |
+LL | impl<T, const A: u8 = 2> X<T> {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | impl<T, const A: u8 = 2, N> X<N> {}
+ | +++
+
+error[E0412]: cannot find type `T` in this scope
+ --> $DIR/missing-type-parameter2.rs:11:20
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+...
+LL | fn foo(_: T) where T: Send {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | fn foo(_: T) where X: Send {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | fn foo<T>(_: T) where T: Send {}
+ | +++
+
+error[E0412]: cannot find type `T` in this scope
+ --> $DIR/missing-type-parameter2.rs:11:11
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+...
+LL | fn foo(_: T) where T: Send {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | fn foo(_: X) where T: Send {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | fn foo<T>(_: T) where T: Send {}
+ | +++
+
+error[E0412]: cannot find type `A` in this scope
+ --> $DIR/missing-type-parameter2.rs:15:24
+ |
+LL | struct X<const N: u8>();
+ | ------------------------ similarly named struct `X` defined here
+...
+LL | fn bar<const N: u8>(_: A) {}
+ | ^
+ |
+help: a struct with a similar name exists
+ |
+LL | fn bar<const N: u8>(_: X) {}
+ | ~
+help: you might be missing a type parameter
+ |
+LL | fn bar<const N: u8, A>(_: A) {}
+ | +++
+
+error[E0747]: unresolved item provided when a constant was expected
+ --> $DIR/missing-type-parameter2.rs:3:8
+ |
+LL | impl X<N> {}
+ | ^
+ |
+help: if this generic argument was intended as a const parameter, surround it with braces
+ |
+LL | impl X<{ N }> {}
+ | + +
+
+error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+ --> $DIR/missing-type-parameter2.rs:6:9
+ |
+LL | impl<T, const A: u8 = 2> X<N> {}
+ | ^^^^^^^^^^^^^^^
+
+error[E0747]: unresolved item provided when a constant was expected
+ --> $DIR/missing-type-parameter2.rs:6:28
+ |
+LL | impl<T, const A: u8 = 2> X<N> {}
+ | ^
+ |
+help: if this generic argument was intended as a const parameter, surround it with braces
+ |
+LL | impl<T, const A: u8 = 2> X<{ N }> {}
+ | + +
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0412, E0747.
+For more information about an error, try `rustc --explain E0412`.