Skip to content

Commit 9175940

Browse files
committed
Use more targetted span for error label
1 parent 854b78f commit 9175940

12 files changed

+36
-36
lines changed

src/librustc_typeck/check/method/suggest.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
758758
MethodError::Ambiguity(sources) => {
759759
let mut err = struct_span_err!(
760760
self.sess(),
761-
span,
761+
item_name.span,
762762
E0034,
763763
"multiple applicable items in scope"
764764
);
765-
err.span_label(span, format!("multiple `{}` found", item_name));
765+
err.span_label(item_name.span, format!("multiple `{}` found", item_name));
766766

767767
report_candidates(span, &mut err, sources, sugg_span);
768768
err.emit();
@@ -772,13 +772,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
772772
let kind = kind.descr(def_id);
773773
let mut err = struct_span_err!(
774774
self.tcx.sess,
775-
span,
775+
item_name.span,
776776
E0624,
777777
"{} `{}` is private",
778778
kind,
779779
item_name
780780
);
781-
err.span_label(span, &format!("private {}", kind));
781+
err.span_label(item_name.span, &format!("private {}", kind));
782782
self.suggest_valid_traits(&mut err, out_of_scope_traits);
783783
err.emit();
784784
}

src/test/ui/associated-const/associated-const-ambiguity-report.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0034]: multiple applicable items in scope
2-
--> $DIR/associated-const-ambiguity-report.rs:17:16
2+
--> $DIR/associated-const-ambiguity-report.rs:17:23
33
|
44
LL | const X: i32 = <i32>::ID;
5-
| ^^^^^^^^^ multiple `ID` found
5+
| ^^ multiple `ID` found
66
|
77
note: candidate #1 is defined in an impl of the trait `Foo` for the type `i32`
88
--> $DIR/associated-const-ambiguity-report.rs:10:5

src/test/ui/associated-const/associated-const-private-impl.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0624]: associated constant `ID` is private
2-
--> $DIR/associated-const-private-impl.rs:13:19
2+
--> $DIR/associated-const-private-impl.rs:13:30
33
|
44
LL | assert_eq!(1, bar1::Foo::ID);
5-
| ^^^^^^^^^^^^^ private associated constant
5+
| ^^ private associated constant
66

77
error: aborting due to previous error
88

src/test/ui/error-codes/E0034.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0034]: multiple applicable items in scope
2-
--> $DIR/E0034.rs:20:5
2+
--> $DIR/E0034.rs:20:11
33
|
44
LL | Test::foo()
5-
| ^^^^^^^^^ multiple `foo` found
5+
| ^^^ multiple `foo` found
66
|
77
note: candidate #1 is defined in an impl of the trait `Trait1` for the type `Test`
88
--> $DIR/E0034.rs:12:5

src/test/ui/issues/issue-21202.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0624]: associated function `foo` is private
2-
--> $DIR/issue-21202.rs:10:9
2+
--> $DIR/issue-21202.rs:10:14
33
|
44
LL | Foo::foo(&f);
5-
| ^^^^^^^^ private associated function
5+
| ^^^ private associated function
66

77
error: aborting due to previous error
88

src/test/ui/issues/issue-53498.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0624]: associated function `foo` is private
2-
--> $DIR/issue-53498.rs:16:5
2+
--> $DIR/issue-53498.rs:16:27
33
|
44
LL | test::Foo::<test::B>::foo();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ private associated function
5+
| ^^^ private associated function
66

77
error: aborting due to previous error
88

src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0034]: multiple applicable items in scope
2-
--> $DIR/method-ambig-two-traits-from-impls2.rs:15:5
2+
--> $DIR/method-ambig-two-traits-from-impls2.rs:15:9
33
|
44
LL | AB::foo();
5-
| ^^^^^^^ multiple `foo` found
5+
| ^^^ multiple `foo` found
66
|
77
note: candidate #1 is defined in an impl of the trait `A` for the type `AB`
88
--> $DIR/method-ambig-two-traits-from-impls2.rs:7:5

src/test/ui/privacy/privacy1.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -155,28 +155,28 @@ LL | trait B {
155155
| ^^^^^^^
156156

157157
error[E0624]: associated function `bar` is private
158-
--> $DIR/privacy1.rs:77:9
158+
--> $DIR/privacy1.rs:77:23
159159
|
160160
LL | self::baz::A::bar();
161-
| ^^^^^^^^^^^^^^^^^ private associated function
161+
| ^^^ private associated function
162162

163163
error[E0624]: associated function `bar` is private
164-
--> $DIR/privacy1.rs:95:5
164+
--> $DIR/privacy1.rs:95:13
165165
|
166166
LL | bar::A::bar();
167-
| ^^^^^^^^^^^ private associated function
167+
| ^^^ private associated function
168168

169169
error[E0624]: associated function `bar` is private
170-
--> $DIR/privacy1.rs:102:9
170+
--> $DIR/privacy1.rs:102:19
171171
|
172172
LL | ::bar::A::bar();
173-
| ^^^^^^^^^^^^^ private associated function
173+
| ^^^ private associated function
174174

175175
error[E0624]: associated function `bar` is private
176-
--> $DIR/privacy1.rs:105:9
176+
--> $DIR/privacy1.rs:105:24
177177
|
178178
LL | ::bar::baz::A::bar();
179-
| ^^^^^^^^^^^^^^^^^^ private associated function
179+
| ^^^ private associated function
180180

181181
error[E0624]: associated function `bar2` is private
182182
--> $DIR/privacy1.rs:108:23

src/test/ui/privacy/restricted/test.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ LL | S::default().f();
5959
| ^ private associated function
6060

6161
error[E0624]: associated function `g` is private
62-
--> $DIR/test.rs:33:5
62+
--> $DIR/test.rs:33:8
6363
|
6464
LL | S::g();
65-
| ^^^^ private associated function
65+
| ^ private associated function
6666

6767
error[E0616]: field `y` of struct `pub_restricted::Universe` is private
6868
--> $DIR/test.rs:42:15

src/test/ui/static/static-method-privacy.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error[E0624]: associated function `new` is private
2-
--> $DIR/static-method-privacy.rs:9:13
2+
--> $DIR/static-method-privacy.rs:9:19
33
|
44
LL | let _ = a::S::new();
5-
| ^^^^^^^^^ private associated function
5+
| ^^^ private associated function
66

77
error: aborting due to previous error
88

src/test/ui/traits/trait-item-privacy.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ LL | use method::B;
7474
|
7575

7676
error[E0624]: associated function `a` is private
77-
--> $DIR/trait-item-privacy.rs:84:5
77+
--> $DIR/trait-item-privacy.rs:84:8
7878
|
7979
LL | C::a(&S);
80-
| ^^^^ private associated function
80+
| ^ private associated function
8181

8282
error[E0599]: no associated item named `A` found for struct `S` in the current scope
8383
--> $DIR/trait-item-privacy.rs:97:8
@@ -111,10 +111,10 @@ LL | use assoc_const::B;
111111
|
112112

113113
error[E0624]: associated constant `A` is private
114-
--> $DIR/trait-item-privacy.rs:101:5
114+
--> $DIR/trait-item-privacy.rs:101:8
115115
|
116116
LL | C::A;
117-
| ^^^^ private associated constant
117+
| ^ private associated constant
118118

119119
error[E0038]: the trait `assoc_const::C` cannot be made into an object
120120
--> $DIR/trait-item-privacy.rs:101:5

src/test/ui/xc-private-method.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0624]: associated function `static_meth_struct` is private
2-
--> $DIR/xc-private-method.rs:6:13
2+
--> $DIR/xc-private-method.rs:6:44
33
|
44
LL | let _ = xc_private_method_lib::Struct::static_meth_struct();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private associated function
5+
| ^^^^^^^^^^^^^^^^^^ private associated function
66

77
error[E0624]: associated function `static_meth_enum` is private
8-
--> $DIR/xc-private-method.rs:9:13
8+
--> $DIR/xc-private-method.rs:9:42
99
|
1010
LL | let _ = xc_private_method_lib::Enum::static_meth_enum();
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private associated function
11+
| ^^^^^^^^^^^^^^^^ private associated function
1212

1313
error: aborting due to 2 previous errors
1414

0 commit comments

Comments
 (0)