File tree 4 files changed +21
-8
lines changed
compiler/rustc_middle/src/ty
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> {
276
276
}
277
277
ty:: Slice ( ty) if ty. is_simple_ty ( ) => format ! ( "slice `{}`" , self ) . into ( ) ,
278
278
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
+ } ,
280
292
ty:: Ref ( _, ty, mutbl) => {
281
293
let tymut = ty:: TypeAndMut { ty, mutbl } ;
282
294
let tymut_string = tymut. to_string ( ) ;
295
+
283
296
if tymut_string != "_"
284
297
&& ( ty. is_simple_text ( ) || tymut_string. len ( ) < "mutable reference" . len ( ) )
285
298
{
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ error[E0308]: mismatched types
106
106
--> $DIR/type-check-1.rs:60:26
107
107
|
108
108
LL | asm!("{}", const 0 as *mut u8);
109
- | ^^^^^^^^^^^^ expected integer, found *-ptr
109
+ | ^^^^^^^^^^^^ expected integer, found `*mut u8`
110
110
|
111
111
= note: expected type `{integer}`
112
112
found raw pointer `*mut u8`
@@ -133,7 +133,7 @@ error[E0308]: mismatched types
133
133
--> $DIR/type-check-1.rs:78:25
134
134
|
135
135
LL | global_asm!("{}", const 0 as *mut u8);
136
- | ^^^^^^^^^^^^ expected integer, found *-ptr
136
+ | ^^^^^^^^^^^^ expected integer, found `*mut u8`
137
137
|
138
138
= note: expected type `{integer}`
139
139
found raw pointer `*mut u8`
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ error[E0308]: mismatched types
2
2
--> $DIR/dst-bad-coercions.rs:14:17
3
3
|
4
4
LL | let y: &S = x;
5
- | -- ^ expected `&S`, found *-ptr
5
+ | -- ^ expected `&S`, found `*const S`
6
6
| |
7
7
| expected due to this
8
8
|
@@ -13,7 +13,7 @@ error[E0308]: mismatched types
13
13
--> $DIR/dst-bad-coercions.rs:15:21
14
14
|
15
15
LL | let y: &dyn T = x;
16
- | ------ ^ expected `&dyn T`, found *-ptr
16
+ | ------ ^ expected `&dyn T`, found `*const S`
17
17
| |
18
18
| expected due to this
19
19
|
@@ -24,7 +24,7 @@ error[E0308]: mismatched types
24
24
--> $DIR/dst-bad-coercions.rs:19:17
25
25
|
26
26
LL | let y: &S = x;
27
- | -- ^ expected `&S`, found *-ptr
27
+ | -- ^ expected `&S`, found `*mut S`
28
28
| |
29
29
| expected due to this
30
30
|
@@ -35,7 +35,7 @@ error[E0308]: mismatched types
35
35
--> $DIR/dst-bad-coercions.rs:20:21
36
36
|
37
37
LL | let y: &dyn T = x;
38
- | ------ ^ expected `&dyn T`, found *-ptr
38
+ | ------ ^ expected `&dyn T`, found `*mut S`
39
39
| |
40
40
| expected due to this
41
41
|
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ error[E0308]: mismatched types
4
4
LL | fn function(t: &mut dyn Trait) {
5
5
| - help: try adding a return type: `-> *mut dyn Trait`
6
6
LL | t as *mut dyn Trait
7
- | ^^^^^^^^^^^^^^^^^^^ expected `()`, found *-ptr
7
+ | ^^^^^^^^^^^^^^^^^^^ expected `()`, found `*mut dyn Trait`
8
8
|
9
9
= note: expected unit type `()`
10
10
found raw pointer `*mut dyn Trait`
You can’t perform that action at this time.
0 commit comments