File tree 3 files changed +63
-2
lines changed
compiler/rustc_middle/src/ty
tests/ui/traits/new-solver
3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -653,8 +653,8 @@ pub enum AliasRelationDirection {
653
653
impl std:: fmt:: Display for AliasRelationDirection {
654
654
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
655
655
match self {
656
- AliasRelationDirection :: Equate => write ! ( f, " == " ) ,
657
- AliasRelationDirection :: Subtype => write ! ( f, " <: " ) ,
656
+ AliasRelationDirection :: Equate => write ! ( f, "== " ) ,
657
+ AliasRelationDirection :: Subtype => write ! ( f, "<: " ) ,
658
658
}
659
659
}
660
660
}
Original file line number Diff line number Diff line change
1
+ // compile-flags: -Ztrait-solver=next
2
+
3
+ #![ feature( specialization) ]
4
+ //~^ WARN the feature `specialization` is incomplete
5
+
6
+ trait Default {
7
+ type Id ;
8
+
9
+ fn intu ( & self ) -> & Self :: Id ;
10
+ }
11
+
12
+ impl < T > Default for T {
13
+ default type Id = T ;
14
+
15
+ fn intu ( & self ) -> & Self :: Id {
16
+ self
17
+ //~^ ERROR cannot satisfy `T <: <T as Default>::Id`
18
+ }
19
+ }
20
+
21
+ fn transmute < T : Default < Id = U > , U : Copy > ( t : T ) -> U {
22
+ * t. intu ( )
23
+ }
24
+
25
+ use std:: num:: NonZeroU8 ;
26
+ fn main ( ) {
27
+ let s = transmute :: < u8 , Option < NonZeroU8 > > ( 0 ) ;
28
+ //~^ ERROR cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>
29
+ assert_eq ! ( s, None ) ;
30
+ }
Original file line number Diff line number Diff line change
1
+ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
2
+ --> $DIR/specialization-transmute.rs:3:12
3
+ |
4
+ LL | #![feature(specialization)]
5
+ | ^^^^^^^^^^^^^^
6
+ |
7
+ = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information
8
+ = help: consider using `min_specialization` instead, which is more stable and complete
9
+ = note: `#[warn(incomplete_features)]` on by default
10
+
11
+ error[E0284]: type annotations needed: cannot satisfy `T <: <T as Default>::Id`
12
+ --> $DIR/specialization-transmute.rs:16:9
13
+ |
14
+ LL | self
15
+ | ^^^^ cannot satisfy `T <: <T as Default>::Id`
16
+
17
+ error[E0284]: type annotations needed: cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>`
18
+ --> $DIR/specialization-transmute.rs:27:13
19
+ |
20
+ LL | let s = transmute::<u8, Option<NonZeroU8>>(0);
21
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>`
22
+ |
23
+ note: required by a bound in `transmute`
24
+ --> $DIR/specialization-transmute.rs:21:25
25
+ |
26
+ LL | fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U {
27
+ | ^^^^^^ required by this bound in `transmute`
28
+
29
+ error: aborting due to 2 previous errors; 1 warning emitted
30
+
31
+ For more information about this error, try `rustc --explain E0284`.
You can’t perform that action at this time.
0 commit comments