File tree 4 files changed +63
-2
lines changed
4 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -270,8 +270,10 @@ impl EmitterWriter {
270
270
line : & Line ,
271
271
width_offset : usize ,
272
272
code_offset : usize ) -> Vec < ( usize , Style ) > {
273
- let source_string = file. get_line ( line. line_index - 1 )
274
- . unwrap_or ( "" ) ;
273
+ let source_string = match file. get_line ( line. line_index - 1 ) {
274
+ Some ( s) => s,
275
+ None => return Vec :: new ( ) ,
276
+ } ;
275
277
276
278
let line_offset = buffer. num_lines ( ) ;
277
279
@@ -909,6 +911,11 @@ impl EmitterWriter {
909
911
910
912
// Print out the annotate source lines that correspond with the error
911
913
for annotated_file in annotated_files {
914
+ // we can't annotate anything if the source is unavailable.
915
+ if annotated_file. file . src . is_none ( ) {
916
+ continue ;
917
+ }
918
+
912
919
// print out the span location and spacer before we print the annotated source
913
920
// to do this, we need to know if this span will be primary
914
921
let is_primary = primary_lo. file . name == annotated_file. file . name ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ pub trait Tr {
12
+ // Note: The function needs to be declared over multiple lines to reproduce
13
+ // the crash. DO NOT reformat.
14
+ fn f ( )
15
+ where Self : Sized ;
16
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ // aux-build:issue_41652_b.rs
12
+
13
+ extern crate issue_41652_b;
14
+
15
+ struct S ;
16
+
17
+ impl issue_41652_b:: Tr for S {
18
+ fn f ( ) {
19
+ 3 . f ( )
20
+ //~^ ERROR no method named `f` found for type `{integer}` in the current scope
21
+ //~| NOTE found the following associated functions
22
+ //~| NOTE candidate #1 is defined in the trait `issue_41652_b::Tr`
23
+ }
24
+ }
25
+
26
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: no method named `f` found for type `{integer}` in the current scope
2
+ --> $DIR/issue_41652.rs:19:11
3
+ |
4
+ 19 | 3.f()
5
+ | ^
6
+ |
7
+ = note: found the following associated functions; to be used as methods, functions must have a `self` parameter
8
+ note: candidate #1 is defined in the trait `issue_41652_b::Tr`
9
+ = help: to disambiguate the method call, write `issue_41652_b::Tr::f(3)` instead
10
+
11
+ error: aborting due to previous error
12
+
You can’t perform that action at this time.
0 commit comments