File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed
compiler/rustc_errors/src Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -1131,16 +1131,23 @@ impl EmitterWriter {
1131
1131
None => return 0 ,
1132
1132
} ;
1133
1133
1134
+ let will_be_emitted = |span : & Span | {
1135
+ !span. is_dummy ( ) && {
1136
+ let file = sm. lookup_source_file ( span. hi ( ) ) ;
1137
+ sm. ensure_source_file_source_present ( file)
1138
+ }
1139
+ } ;
1140
+
1134
1141
let mut max = 0 ;
1135
1142
for primary_span in msp. primary_spans ( ) {
1136
- if !primary_span . is_dummy ( ) {
1143
+ if will_be_emitted ( primary_span ) {
1137
1144
let hi = sm. lookup_char_pos ( primary_span. hi ( ) ) ;
1138
1145
max = ( hi. line ) . max ( max) ;
1139
1146
}
1140
1147
}
1141
1148
if !self . short_message {
1142
1149
for span_label in msp. span_labels ( ) {
1143
- if ! span_label. span . is_dummy ( ) {
1150
+ if will_be_emitted ( & span_label. span ) {
1144
1151
let hi = sm. lookup_char_pos ( span_label. span . hi ( ) ) ;
1145
1152
max = ( hi. line ) . max ( max) ;
1146
1153
}
Original file line number Diff line number Diff line change
1
+ // check-fail
2
+ // compile-flags: -Z simulate-remapped-rust-src-base=/rustc/xyz -Z ui-testing=no
3
+
4
+ #[ derive( Debug ) ]
5
+ struct Test ;
6
+ impl std:: error:: Error for Test { }
7
+ //~^ ERROR `Test` doesn't implement `std::fmt::Display`
8
+
9
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0277]: `Test` doesn't implement `std::fmt::Display`
2
+ --> $DIR/issue-71363.rs:6:6
3
+ |
4
+ 6 | impl std::error::Error for Test {}
5
+ | ^^^^^^^^^^^^^^^^^ `Test` cannot be formatted with the default formatter
6
+ |
7
+ = help: the trait `std::fmt::Display` is not implemented for `Test`
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: aborting due to previous error
12
+
13
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments