Skip to content

Commit

Permalink
Use more targetted span for error label
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Mar 22, 2020
1 parent 854b78f commit 9175940
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions src/librustc_typeck/check/method/suggest.rs
Expand Up @@ -758,11 +758,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
MethodError::Ambiguity(sources) => {
let mut err = struct_span_err!(
self.sess(),
span,
item_name.span,
E0034,
"multiple applicable items in scope"
);
err.span_label(span, format!("multiple `{}` found", item_name));
err.span_label(item_name.span, format!("multiple `{}` found", item_name));

report_candidates(span, &mut err, sources, sugg_span);
err.emit();
Expand All @@ -772,13 +772,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let kind = kind.descr(def_id);
let mut err = struct_span_err!(
self.tcx.sess,
span,
item_name.span,
E0624,
"{} `{}` is private",
kind,
item_name
);
err.span_label(span, &format!("private {}", kind));
err.span_label(item_name.span, &format!("private {}", kind));
self.suggest_valid_traits(&mut err, out_of_scope_traits);
err.emit();
}
Expand Down
@@ -1,8 +1,8 @@
error[E0034]: multiple applicable items in scope
--> $DIR/associated-const-ambiguity-report.rs:17:16
--> $DIR/associated-const-ambiguity-report.rs:17:23
|
LL | const X: i32 = <i32>::ID;
| ^^^^^^^^^ multiple `ID` found
| ^^ multiple `ID` found
|
note: candidate #1 is defined in an impl of the trait `Foo` for the type `i32`
--> $DIR/associated-const-ambiguity-report.rs:10:5
Expand Down
@@ -1,8 +1,8 @@
error[E0624]: associated constant `ID` is private
--> $DIR/associated-const-private-impl.rs:13:19
--> $DIR/associated-const-private-impl.rs:13:30
|
LL | assert_eq!(1, bar1::Foo::ID);
| ^^^^^^^^^^^^^ private associated constant
| ^^ private associated constant

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0034.stderr
@@ -1,8 +1,8 @@
error[E0034]: multiple applicable items in scope
--> $DIR/E0034.rs:20:5
--> $DIR/E0034.rs:20:11
|
LL | Test::foo()
| ^^^^^^^^^ multiple `foo` found
| ^^^ multiple `foo` found
|
note: candidate #1 is defined in an impl of the trait `Trait1` for the type `Test`
--> $DIR/E0034.rs:12:5
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-21202.stderr
@@ -1,8 +1,8 @@
error[E0624]: associated function `foo` is private
--> $DIR/issue-21202.rs:10:9
--> $DIR/issue-21202.rs:10:14
|
LL | Foo::foo(&f);
| ^^^^^^^^ private associated function
| ^^^ private associated function

error: aborting due to previous error

Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-53498.stderr
@@ -1,8 +1,8 @@
error[E0624]: associated function `foo` is private
--> $DIR/issue-53498.rs:16:5
--> $DIR/issue-53498.rs:16:27
|
LL | test::Foo::<test::B>::foo();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ private associated function
| ^^^ private associated function

error: aborting due to previous error

Expand Down
@@ -1,8 +1,8 @@
error[E0034]: multiple applicable items in scope
--> $DIR/method-ambig-two-traits-from-impls2.rs:15:5
--> $DIR/method-ambig-two-traits-from-impls2.rs:15:9
|
LL | AB::foo();
| ^^^^^^^ multiple `foo` found
| ^^^ multiple `foo` found
|
note: candidate #1 is defined in an impl of the trait `A` for the type `AB`
--> $DIR/method-ambig-two-traits-from-impls2.rs:7:5
Expand Down
16 changes: 8 additions & 8 deletions src/test/ui/privacy/privacy1.stderr
Expand Up @@ -155,28 +155,28 @@ LL | trait B {
| ^^^^^^^

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

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

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

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

error[E0624]: associated function `bar2` is private
--> $DIR/privacy1.rs:108:23
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/privacy/restricted/test.stderr
Expand Up @@ -59,10 +59,10 @@ LL | S::default().f();
| ^ private associated function

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

error[E0616]: field `y` of struct `pub_restricted::Universe` is private
--> $DIR/test.rs:42:15
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/static/static-method-privacy.stderr
@@ -1,8 +1,8 @@
error[E0624]: associated function `new` is private
--> $DIR/static-method-privacy.rs:9:13
--> $DIR/static-method-privacy.rs:9:19
|
LL | let _ = a::S::new();
| ^^^^^^^^^ private associated function
| ^^^ private associated function

error: aborting due to previous error

Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/traits/trait-item-privacy.stderr
Expand Up @@ -74,10 +74,10 @@ LL | use method::B;
|

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

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

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

error[E0038]: the trait `assoc_const::C` cannot be made into an object
--> $DIR/trait-item-privacy.rs:101:5
Expand Down
8 changes: 4 additions & 4 deletions src/test/ui/xc-private-method.stderr
@@ -1,14 +1,14 @@
error[E0624]: associated function `static_meth_struct` is private
--> $DIR/xc-private-method.rs:6:13
--> $DIR/xc-private-method.rs:6:44
|
LL | let _ = xc_private_method_lib::Struct::static_meth_struct();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ private associated function
| ^^^^^^^^^^^^^^^^^^ private associated function

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

error: aborting due to 2 previous errors

Expand Down

0 comments on commit 9175940

Please sign in to comment.