]> git.lizzy.rs Git - rust.git/commitdiff
typeck/pat.rs: move note out of `check_dereferenceable` as it angers VSCode.
authorMazdak Farrokhzad <twingoow@gmail.com>
Fri, 23 Aug 2019 13:05:58 +0000 (15:05 +0200)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sat, 24 Aug 2019 17:13:53 +0000 (19:13 +0200)
src/librustc_typeck/check/pat.rs

index e2d0f485bdf01b06aa8ff2bfd076078860750557..d8c6438817413452b587f6ae34f4feee21dd9b4d 100644 (file)
 
 use super::report_unexpected_variant_res;
 
+const CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ: &str = "\
+This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \
+pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \
+this type has no compile-time size. Therefore, all accesses to trait types must be through \
+pointers. If you encounter this error you should try to avoid dereferencing the pointer.
+
+You can read more about trait objects in the Trait Objects section of the Reference: \
+https://doc.rust-lang.org/reference/types.html#trait-objects";
+
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     /// `discrim_span` argument having a `Span` indicates that this pattern is part of a match
     /// expression arm guard, and it points to the match discriminant to add context in type errors.
@@ -607,14 +616,7 @@ pub fn check_dereferencable(&self, span: Span, expected: Ty<'tcx>, inner: &hir::
                     );
                     err.span_label(span, format!("type `{}` cannot be dereferenced", type_str));
                     if self.tcx.sess.teach(&err.get_code().unwrap()) {
-                        err.note("\
-This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \
-pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \
-this type has no compile-time size. Therefore, all accesses to trait types must be through \
-pointers. If you encounter this error you should try to avoid dereferencing the pointer.
-
-You can read more about trait objects in the Trait Objects section of the Reference: \
-https://doc.rust-lang.org/reference/types.html#trait-objects");
+                        err.note(CANNOT_IMPLICITLY_DEREF_POINTER_TRAIT_OBJ);
                     }
                     err.emit();
                     return false