File tree Expand file tree Collapse file tree 4 files changed +21
-8
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 4 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -276,10 +276,23 @@ impl<'tcx> Ty<'tcx> {
276276 }
277277 ty:: Slice ( ty) if ty. is_simple_ty ( ) => format ! ( "slice `{}`" , self ) . into ( ) ,
278278 ty:: Slice ( _) => "slice" . into ( ) ,
279- ty:: RawPtr ( _) => "*-ptr" . into ( ) ,
279+ ty:: RawPtr ( tymut) => {
280+ let tymut_string = match tymut. mutbl {
281+ hir:: Mutability :: Mut => tymut. to_string ( ) ,
282+ hir:: Mutability :: Not => format ! ( "const {}" , tymut. ty) ,
283+ } ;
284+
285+ if tymut_string != "_" && ( tymut. ty . is_simple_text ( ) || tymut_string. len ( ) < "const raw pointer" . len ( ) ) {
286+ format ! ( "`*{}`" , tymut_string) . into ( )
287+ } else {
288+ // Unknown type name, it's long or has type arguments
289+ "raw pointer" . into ( )
290+ }
291+ } ,
280292 ty:: Ref ( _, ty, mutbl) => {
281293 let tymut = ty:: TypeAndMut { ty, mutbl } ;
282294 let tymut_string = tymut. to_string ( ) ;
295+
283296 if tymut_string != "_"
284297 && ( ty. is_simple_text ( ) || tymut_string. len ( ) < "mutable reference" . len ( ) )
285298 {
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ error[E0308]: mismatched types
106106 --> $DIR/type-check-1.rs:60:26
107107 |
108108LL | asm!("{}", const 0 as *mut u8);
109- | ^^^^^^^^^^^^ expected integer, found *-ptr
109+ | ^^^^^^^^^^^^ expected integer, found `*mut u8`
110110 |
111111 = note: expected type `{integer}`
112112 found raw pointer `*mut u8`
@@ -133,7 +133,7 @@ error[E0308]: mismatched types
133133 --> $DIR/type-check-1.rs:78:25
134134 |
135135LL | global_asm!("{}", const 0 as *mut u8);
136- | ^^^^^^^^^^^^ expected integer, found *-ptr
136+ | ^^^^^^^^^^^^ expected integer, found `*mut u8`
137137 |
138138 = note: expected type `{integer}`
139139 found raw pointer `*mut u8`
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ error[E0308]: mismatched types
22 --> $DIR/dst-bad-coercions.rs:14:17
33 |
44LL | let y: &S = x;
5- | -- ^ expected `&S`, found *-ptr
5+ | -- ^ expected `&S`, found `*const S`
66 | |
77 | expected due to this
88 |
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
1313 --> $DIR/dst-bad-coercions.rs:15:21
1414 |
1515LL | let y: &dyn T = x;
16- | ------ ^ expected `&dyn T`, found *-ptr
16+ | ------ ^ expected `&dyn T`, found `*const S`
1717 | |
1818 | expected due to this
1919 |
@@ -24,7 +24,7 @@ error[E0308]: mismatched types
2424 --> $DIR/dst-bad-coercions.rs:19:17
2525 |
2626LL | let y: &S = x;
27- | -- ^ expected `&S`, found *-ptr
27+ | -- ^ expected `&S`, found `*mut S`
2828 | |
2929 | expected due to this
3030 |
@@ -35,7 +35,7 @@ error[E0308]: mismatched types
3535 --> $DIR/dst-bad-coercions.rs:20:21
3636 |
3737LL | let y: &dyn T = x;
38- | ------ ^ expected `&dyn T`, found *-ptr
38+ | ------ ^ expected `&dyn T`, found `*mut S`
3939 | |
4040 | expected due to this
4141 |
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ error[E0308]: mismatched types
44LL | fn function(t: &mut dyn Trait) {
55 | - help: try adding a return type: `-> *mut dyn Trait`
66LL | t as *mut dyn Trait
7- | ^^^^^^^^^^^^^^^^^^^ expected `()`, found *-ptr
7+ | ^^^^^^^^^^^^^^^^^^^ expected `()`, found `*mut dyn Trait`
88 |
99 = note: expected unit type `()`
1010 found raw pointer `*mut dyn Trait`
You can’t perform that action at this time.
0 commit comments