Skip to content

Commit dbe6d59

Browse files
committed
typeck/pat.rs: move note out of check_dereferenceable as it angers VSCode.
1 parent 11d4091 commit dbe6d59

File tree

1 file changed

+10
-8
lines changed
  • src/librustc_typeck/check

1 file changed

+10
-8
lines changed

src/librustc_typeck/check/pat.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ use std::cmp;
1919

2020
use super::report_unexpected_variant_res;
2121

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+
2231
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
2332
/// `discrim_span` argument having a `Span` indicates that this pattern is part of a match
2433
/// 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> {
607616
);
608617
err.span_label(span, format!("type `{}` cannot be dereferenced", type_str));
609618
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);
618620
}
619621
err.emit();
620622
return false

0 commit comments

Comments
 (0)