File tree 3 files changed +12
-7
lines changed
rustc_trait_selection/src/traits/error_reporting
3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -491,6 +491,10 @@ impl SpanData {
491
491
pub fn is_dummy ( self ) -> bool {
492
492
self . lo . 0 == 0 && self . hi . 0 == 0
493
493
}
494
+ #[ inline]
495
+ pub fn is_visible ( self , sm : & SourceMap ) -> bool {
496
+ !self . is_dummy ( ) && sm. is_span_accessible ( self . span ( ) )
497
+ }
494
498
/// Returns `true` if `self` fully encloses `other`.
495
499
pub fn contains ( self , other : Self ) -> bool {
496
500
self . lo <= other. lo && other. hi <= self . hi
@@ -556,6 +560,11 @@ impl Span {
556
560
self . data_untracked ( ) . is_dummy ( )
557
561
}
558
562
563
+ #[ inline]
564
+ pub fn is_visible ( self , sm : & SourceMap ) -> bool {
565
+ self . data_untracked ( ) . is_visible ( sm)
566
+ }
567
+
559
568
/// Returns `true` if this span comes from any kind of macro, desugaring or inlining.
560
569
#[ inline]
561
570
pub fn from_expansion ( self ) -> bool {
Original file line number Diff line number Diff line change @@ -2413,19 +2413,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
2413
2413
| ObligationCauseCode :: ExprBindingObligation ( item_def_id, span, ..) => {
2414
2414
let item_name = tcx. def_path_str ( item_def_id) ;
2415
2415
let mut multispan = MultiSpan :: from ( span) ;
2416
+ let sm = tcx. sess . source_map ( ) ;
2416
2417
if let Some ( ident) = tcx. opt_item_ident ( item_def_id) {
2417
- let sm = tcx. sess . source_map ( ) ;
2418
2418
let same_line =
2419
2419
match ( sm. lookup_line ( ident. span . hi ( ) ) , sm. lookup_line ( span. lo ( ) ) ) {
2420
2420
( Ok ( l) , Ok ( r) ) => l. line == r. line ,
2421
2421
_ => true ,
2422
2422
} ;
2423
- if ! ident. span . is_dummy ( ) && !ident. span . overlaps ( span) && !same_line {
2423
+ if ident. span . is_visible ( sm ) && !ident. span . overlaps ( span) && !same_line {
2424
2424
multispan. push_span_label ( ident. span , "required by a bound in this" ) ;
2425
2425
}
2426
2426
}
2427
2427
let descr = format ! ( "required by a bound in `{}`" , item_name) ;
2428
- if ! span. is_dummy ( ) {
2428
+ if span. is_visible ( sm ) {
2429
2429
let msg = format ! ( "required by this bound in `{}`" , item_name) ;
2430
2430
multispan. push_span_label ( span, msg) ;
2431
2431
err. span_note ( multispan, & descr) ;
Original file line number Diff line number Diff line change @@ -8,8 +8,6 @@ error[E0277]: `MyError` doesn't implement `std::fmt::Display`
8
8
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9
9
note: required by a bound in `std::error::Error`
10
10
--> $SRC_DIR/core/src/error.rs:LL:COL
11
- |
12
- = note: required by this bound in `std::error::Error`
13
11
14
12
error[E0277]: `MyError` doesn't implement `Debug`
15
13
--> $DIR/issue-71363.rs:4:6
@@ -21,8 +19,6 @@ error[E0277]: `MyError` doesn't implement `Debug`
21
19
= note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
22
20
note: required by a bound in `std::error::Error`
23
21
--> $SRC_DIR/core/src/error.rs:LL:COL
24
- |
25
- = note: required by this bound in `std::error::Error`
26
22
help: consider annotating `MyError` with `#[derive(Debug)]`
27
23
|
28
24
3 | #[derive(Debug)]
You can’t perform that action at this time.
0 commit comments