File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed
compiler/rustc_errors/src Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -1261,16 +1261,23 @@ impl EmitterWriter {
12611261 return 0 ;
12621262 } ;
12631263
1264+ let will_be_emitted = |span : Span | {
1265+ !span. is_dummy ( ) && {
1266+ let file = sm. lookup_source_file ( span. hi ( ) ) ;
1267+ sm. ensure_source_file_source_present ( file)
1268+ }
1269+ } ;
1270+
12641271 let mut max = 0 ;
12651272 for primary_span in msp. primary_spans ( ) {
1266- if !primary_span . is_dummy ( ) {
1273+ if will_be_emitted ( * primary_span ) {
12671274 let hi = sm. lookup_char_pos ( primary_span. hi ( ) ) ;
12681275 max = ( hi. line ) . max ( max) ;
12691276 }
12701277 }
12711278 if !self . short_message {
12721279 for span_label in msp. span_labels ( ) {
1273- if ! span_label. span . is_dummy ( ) {
1280+ if will_be_emitted ( span_label. span ) {
12741281 let hi = sm. lookup_char_pos ( span_label. span . hi ( ) ) ;
12751282 max = ( hi. line ) . max ( max) ;
12761283 }
Original file line number Diff line number Diff line change 1+ // compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z ui-testing=no
2+ // only-x86_64-unknown-linux-gnu
3+ //---^ Limiting target as the above unstable flags don't play well on some environment.
4+
5+ struct MyError ;
6+ impl std:: error:: Error for MyError { }
7+ //~^ ERROR: `MyError` doesn't implement `std::fmt::Display`
8+ //~| ERROR: `MyError` doesn't implement `Debug`
9+
10+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error[E0277]: `MyError` doesn't implement `std::fmt::Display`
2+ --> $DIR/issue-71363.rs:6:6
3+ |
4+ 6 | impl std::error::Error for MyError {}
5+ | ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted with the default formatter
6+ |
7+ = help: the trait `std::fmt::Display` is not implemented for `MyError`
8+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9+ note: required by a bound in `std::error::Error`
10+
11+ error[E0277]: `MyError` doesn't implement `Debug`
12+ --> $DIR/issue-71363.rs:6:6
13+ |
14+ 6 | impl std::error::Error for MyError {}
15+ | ^^^^^^^^^^^^^^^^^ `MyError` cannot be formatted using `{:?}`
16+ |
17+ = help: the trait `Debug` is not implemented for `MyError`
18+ = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError`
19+ note: required by a bound in `std::error::Error`
20+ help: consider annotating `MyError` with `#[derive(Debug)]`
21+ |
22+ 5 | #[derive(Debug)]
23+ |
24+
25+ error: aborting due to 2 previous errors
26+
27+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments