@@ -19,6 +19,15 @@ use std::cmp;
19
19
20
20
use super :: report_unexpected_variant_res;
21
21
22
+ const CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ : & str = "\
23
+ This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \
24
+ pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \
25
+ this type has no compile-time size. Therefore, all accesses to trait types must be through \
26
+ pointers. If you encounter this error you should try to avoid dereferencing the pointer.
27
+
28
+ You can read more about trait objects in the Trait Objects section of the Reference: \
29
+ https://doc.rust-lang.org/reference/types.html#trait-objects";
30
+
22
31
impl < ' a , ' tcx > FnCtxt < ' a , ' tcx > {
23
32
/// `discrim_span` argument having a `Span` indicates that this pattern is part of a match
24
33
/// expression arm guard, and it points to the match discriminant to add context in type errors.
@@ -607,14 +616,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
607
616
) ;
608
617
err. span_label ( span, format ! ( "type `{}` cannot be dereferenced" , type_str) ) ;
609
618
if self . tcx . sess . teach ( & err. get_code ( ) . unwrap ( ) ) {
610
- err. note ( "\
611
- This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \
612
- pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \
613
- this type has no compile-time size. Therefore, all accesses to trait types must be through \
614
- pointers. If you encounter this error you should try to avoid dereferencing the pointer.
615
-
616
- You can read more about trait objects in the Trait Objects section of the Reference: \
617
- https://doc.rust-lang.org/reference/types.html#trait-objects") ;
619
+ err. note ( CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ ) ;
618
620
}
619
621
err. emit ( ) ;
620
622
return false
0 commit comments