Use more targetted span for error label

This commit is contained in:
Esteban Küber 2020-03-22 16:09:42 -07:00
parent 854b78fe22
commit 9175940c92
12 changed files with 36 additions and 36 deletions

View File

@ -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();
@ -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();
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
@ -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

View File

@ -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