File tree 2 files changed +55
-0
lines changed
tests/ui/type-alias-impl-trait
2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( type_alias_impl_trait) ]
2
+
3
+ // This test ensures that unnameable types stay unnameable
4
+ // https://github.com/rust-lang/rust/issues/63063#issuecomment-1360053614
5
+
6
+ // library
7
+ mod private {
8
+ pub struct Private ;
9
+ pub trait Trait {
10
+ fn dont_define_this ( _private : Private ) { }
11
+ }
12
+ }
13
+
14
+ use private:: Trait ;
15
+
16
+ // downstream
17
+ type MyPrivate = impl Sized ;
18
+ //~^ ERROR: unconstrained opaque type
19
+ impl Trait for u32 {
20
+ fn dont_define_this ( _private : MyPrivate ) { }
21
+ //~^ ERROR: incompatible type for trait
22
+ }
23
+
24
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: unconstrained opaque type
2
+ --> $DIR/unnameable_type.rs:17:18
3
+ |
4
+ LL | type MyPrivate = impl Sized;
5
+ | ^^^^^^^^^^
6
+ |
7
+ = note: `MyPrivate` must be used in combination with a concrete type within the same module
8
+
9
+ error[E0053]: method `dont_define_this` has an incompatible type for trait
10
+ --> $DIR/unnameable_type.rs:20:35
11
+ |
12
+ LL | type MyPrivate = impl Sized;
13
+ | ---------- the found opaque type
14
+ ...
15
+ LL | fn dont_define_this(_private: MyPrivate) {}
16
+ | ^^^^^^^^^
17
+ | |
18
+ | expected struct `Private`, found opaque type
19
+ | help: change the parameter type to match the trait: `Private`
20
+ |
21
+ note: type in trait
22
+ --> $DIR/unnameable_type.rs:10:39
23
+ |
24
+ LL | fn dont_define_this(_private: Private) {}
25
+ | ^^^^^^^
26
+ = note: expected signature `fn(Private)`
27
+ found signature `fn(MyPrivate)`
28
+
29
+ error: aborting due to 2 previous errors
30
+
31
+ For more information about this error, try `rustc --explain E0053`.
You can’t perform that action at this time.
0 commit comments