Skip to content

Commit 1e450c7

Browse files
committed
Remove redundancy in resolve error between main message and primary label
``` error[E0576]: cannot find method or associated constant `BAR` --> $DIR/issue-87638.rs:20:27 | LL | let _ = <S as Trait>::BAR; | ^^^ not found in trait `Trait` ``` instead of ``` error[E0576]: cannot find method or associated constant `BAR` in trait `Trait` --> $DIR/issue-87638.rs:20:27 | LL | let _ = <S as Trait>::BAR; | ^^^ not found in `Trait` ``` The general rule is that the primary span label should work well on its own (suitable to be shown in editors), while the main message provides additional context of the general case. When using `--error-format=short`, we concatenate the main message and the primary labels, so they should be complementary.
1 parent 33422e7 commit 1e450c7

File tree

736 files changed

+1572
-1572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

736 files changed

+1572
-1572
lines changed

Diff for: compiler/rustc_resolve/src/late/diagnostics.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,11 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
347347
} else {
348348
suggestion
349349
};
350-
(format!("not found in {mod_str}"), override_suggestion)
350+
(format!("not found in {mod_prefix}{mod_str}"), override_suggestion)
351351
};
352352

353353
BaseError {
354-
msg: format!("cannot find {expected} `{item_str}` in {mod_prefix}{mod_str}"),
354+
msg: format!("cannot find {expected} `{item_str}`"),
355355
fallback_label,
356356
span: item_span,
357357
span_label,

Diff for: src/tools/clippy/tests/ui/crashes/ice-6252.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `PhantomData` in this scope
1+
error[E0412]: cannot find type `PhantomData`
22
--> tests/ui/crashes/ice-6252.rs:9:9
33
|
44
LL | _n: PhantomData,
@@ -9,7 +9,7 @@ help: consider importing this struct
99
LL + use std::marker::PhantomData;
1010
|
1111

12-
error[E0412]: cannot find type `VAL` in this scope
12+
error[E0412]: cannot find type `VAL`
1313
--> tests/ui/crashes/ice-6252.rs:11:63
1414
|
1515
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}

Diff for: src/tools/clippy/tests/ui/option_map_unit_fn_unfixable.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
error[E0425]: cannot find value `x` in this scope
1+
error[E0425]: cannot find value `x`
22
--> tests/ui/option_map_unit_fn_unfixable.rs:17:5
33
|
44
LL | x.field.map(|value| { do_nothing(value); do_nothing(value) });
55
| ^ not found in this scope
66

7-
error[E0425]: cannot find value `x` in this scope
7+
error[E0425]: cannot find value `x`
88
--> tests/ui/option_map_unit_fn_unfixable.rs:19:5
99
|
1010
LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
1111
| ^ not found in this scope
1212

13-
error[E0425]: cannot find value `x` in this scope
13+
error[E0425]: cannot find value `x`
1414
--> tests/ui/option_map_unit_fn_unfixable.rs:23:5
1515
|
1616
LL | x.field.map(|value| {
1717
| ^ not found in this scope
1818

19-
error[E0425]: cannot find value `x` in this scope
19+
error[E0425]: cannot find value `x`
2020
--> tests/ui/option_map_unit_fn_unfixable.rs:27:5
2121
|
2222
LL | x.field.map(|value| { do_nothing(value); do_nothing(value); });

Diff for: tests/rustdoc-ui/doctest/failed-doctest-output.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ test $DIR/failed-doctest-output.rs - SomeStruct (line 15) ... FAILED
66
failures:
77

88
---- $DIR/failed-doctest-output.rs - OtherStruct (line 25) stdout ----
9-
error[E0425]: cannot find value `no` in this scope
9+
error[E0425]: cannot find value `no`
1010
--> $DIR/failed-doctest-output.rs:26:1
1111
|
1212
LL | no

Diff for: tests/rustdoc-ui/impl-fn-nesting.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@ pub trait NeedsBody {
99

1010
/// This function has docs
1111
pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
12-
//~^ ERROR cannot find trait `UnknownBound` in this scope
13-
//~| ERROR cannot find type `UnknownType` in this scope
12+
//~^ ERROR cannot find trait `UnknownBound`
13+
//~| ERROR cannot find type `UnknownType`
1414
impl UnknownTrait for ValidType {} //~ ERROR cannot find trait `UnknownTrait`
1515
impl<T: UnknownBound> UnknownTrait for T {}
16-
//~^ ERROR cannot find trait `UnknownBound` in this scope
17-
//~| ERROR cannot find trait `UnknownTrait` in this scope
16+
//~^ ERROR cannot find trait `UnknownBound`
17+
//~| ERROR cannot find trait `UnknownTrait`
1818
impl ValidTrait for UnknownType {}
19-
//~^ ERROR cannot find type `UnknownType` in this scope
19+
//~^ ERROR cannot find type `UnknownType`
2020
impl ValidTrait for ValidType where ValidTrait: UnknownBound {}
21-
//~^ ERROR cannot find trait `UnknownBound` in this scope
21+
//~^ ERROR cannot find trait `UnknownBound`
2222

2323
/// This impl has documentation
2424
impl NeedsBody for ValidType {
2525
type Item = UnknownType;
26-
//~^ ERROR cannot find type `UnknownType` in this scope
26+
//~^ ERROR cannot find type `UnknownType`
2727

2828
/// This function has documentation
2929
fn f() {
3030
<UnknownTypeShouldBeIgnored>::a();
3131
content::shouldnt::matter();
3232
unknown_macro!();
33-
//~^ ERROR cannot find macro `unknown_macro` in this scope
33+
//~^ ERROR cannot find macro `unknown_macro`
3434

3535
/// This is documentation for a macro
3636
macro_rules! can_define_macros_here_too {
@@ -42,7 +42,7 @@ pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
4242

4343
/// This also is documented.
4444
pub fn doubly_nested(c: UnknownType) {
45-
//~^ ERROR cannot find type `UnknownType` in this scope
45+
//~^ ERROR cannot find type `UnknownType`
4646
}
4747
}
4848
}

Diff for: tests/rustdoc-ui/impl-fn-nesting.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,55 @@ error: cannot find macro `unknown_macro` in this scope
44
LL | unknown_macro!();
55
| ^^^^^^^^^^^^^
66

7-
error[E0405]: cannot find trait `UnknownBound` in this scope
7+
error[E0405]: cannot find trait `UnknownBound`
88
--> $DIR/impl-fn-nesting.rs:11:13
99
|
1010
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
1111
| ^^^^^^^^^^^^ not found in this scope
1212

13-
error[E0412]: cannot find type `UnknownType` in this scope
13+
error[E0412]: cannot find type `UnknownType`
1414
--> $DIR/impl-fn-nesting.rs:11:30
1515
|
1616
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
1717
| ^^^^^^^^^^^ not found in this scope
1818

19-
error[E0405]: cannot find trait `UnknownTrait` in this scope
19+
error[E0405]: cannot find trait `UnknownTrait`
2020
--> $DIR/impl-fn-nesting.rs:14:10
2121
|
2222
LL | impl UnknownTrait for ValidType {}
2323
| ^^^^^^^^^^^^ not found in this scope
2424

25-
error[E0405]: cannot find trait `UnknownTrait` in this scope
25+
error[E0405]: cannot find trait `UnknownTrait`
2626
--> $DIR/impl-fn-nesting.rs:15:27
2727
|
2828
LL | impl<T: UnknownBound> UnknownTrait for T {}
2929
| ^^^^^^^^^^^^ not found in this scope
3030

31-
error[E0405]: cannot find trait `UnknownBound` in this scope
31+
error[E0405]: cannot find trait `UnknownBound`
3232
--> $DIR/impl-fn-nesting.rs:15:13
3333
|
3434
LL | impl<T: UnknownBound> UnknownTrait for T {}
3535
| ^^^^^^^^^^^^ not found in this scope
3636

37-
error[E0412]: cannot find type `UnknownType` in this scope
37+
error[E0412]: cannot find type `UnknownType`
3838
--> $DIR/impl-fn-nesting.rs:18:25
3939
|
4040
LL | impl ValidTrait for UnknownType {}
4141
| ^^^^^^^^^^^ not found in this scope
4242

43-
error[E0405]: cannot find trait `UnknownBound` in this scope
43+
error[E0405]: cannot find trait `UnknownBound`
4444
--> $DIR/impl-fn-nesting.rs:20:53
4545
|
4646
LL | impl ValidTrait for ValidType where ValidTrait: UnknownBound {}
4747
| ^^^^^^^^^^^^ not found in this scope
4848

49-
error[E0412]: cannot find type `UnknownType` in this scope
49+
error[E0412]: cannot find type `UnknownType`
5050
--> $DIR/impl-fn-nesting.rs:25:21
5151
|
5252
LL | type Item = UnknownType;
5353
| ^^^^^^^^^^^ not found in this scope
5454

55-
error[E0412]: cannot find type `UnknownType` in this scope
55+
error[E0412]: cannot find type `UnknownType`
5656
--> $DIR/impl-fn-nesting.rs:44:37
5757
|
5858
LL | pub fn doubly_nested(c: UnknownType) {

Diff for: tests/rustdoc-ui/issues/issue-81662-shortness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ compile-flags:--test --error-format=short
22
//@ check-stdout
3-
//@ error-pattern:cannot find function `foo` in this scope
3+
//@ error-pattern:cannot find function `foo`
44
//@ normalize-stdout-test: "tests/rustdoc-ui/issues" -> "$$DIR"
55
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
66
//@ failure-status: 101

Diff for: tests/rustdoc-ui/issues/issue-81662-shortness.stdout

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ test $DIR/issue-81662-shortness.rs - foo (line 8) ... FAILED
55
failures:
66

77
---- $DIR/issue-81662-shortness.rs - foo (line 8) stdout ----
8-
$DIR/issue-81662-shortness.rs:9:1: error[E0425]: cannot find function `foo` in this scope
8+
$DIR/issue-81662-shortness.rs:9:1: error[E0425]: cannot find function `foo`
99
error: aborting due to 1 previous error
1010
Couldn't compile the test.
1111

Diff for: tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct InvalidLitNestedAttr {}
7373

7474
#[derive(Diagnostic)]
7575
#[diag(nonsense, code = E0123)]
76-
//~^ ERROR cannot find value `nonsense` in module `crate::fluent_generated`
76+
//~^ ERROR cannot find value `nonsense`
7777
struct InvalidNestedStructAttr {}
7878

7979
#[derive(Diagnostic)]
@@ -805,7 +805,7 @@ struct SuggestionsInvalidItem {
805805
sub: Span,
806806
}
807807

808-
#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34` in this scope
808+
#[derive(Diagnostic)] //~ ERROR cannot find value `__code_34`
809809
#[diag(no_crate_example)]
810810
struct SuggestionsInvalidLiteral {
811811
#[suggestion(code = 3)]

Diff for: tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,13 @@ error: cannot find attribute `multipart_suggestion` in this scope
596596
LL | #[multipart_suggestion(no_crate_suggestion)]
597597
| ^^^^^^^^^^^^^^^^^^^^
598598

599-
error[E0425]: cannot find value `nonsense` in module `crate::fluent_generated`
599+
error[E0425]: cannot find value `nonsense`
600600
--> $DIR/diagnostic-derive.rs:75:8
601601
|
602602
LL | #[diag(nonsense, code = E0123)]
603-
| ^^^^^^^^ not found in `crate::fluent_generated`
603+
| ^^^^^^^^ not found in module `crate::fluent_generated`
604604

605-
error[E0425]: cannot find value `__code_34` in this scope
605+
error[E0425]: cannot find value `__code_34`
606606
--> $DIR/diagnostic-derive.rs:808:10
607607
|
608608
LL | #[derive(Diagnostic)]

Diff for: tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct D {
6666
#[derive(Subdiagnostic)]
6767
#[foo]
6868
//~^ ERROR `#[foo]` is not a valid attribute
69-
//~^^ ERROR cannot find attribute `foo` in this scope
69+
//~^^ ERROR cannot find attribute `foo`
7070
struct E {
7171
#[primary_span]
7272
span: Span,
@@ -124,8 +124,8 @@ struct K {
124124

125125
#[derive(Subdiagnostic)]
126126
#[label(slug)]
127-
//~^ ERROR cannot find value `slug` in module `crate::fluent_generated`
128-
//~^^ NOTE not found in `crate::fluent_generated`
127+
//~^ ERROR cannot find value `slug`
128+
//~^^ NOTE not found in module `crate::fluent_generated`
129129
struct L {
130130
#[primary_span]
131131
span: Span,
@@ -712,7 +712,7 @@ struct BP {
712712
}
713713

714714
#[derive(Subdiagnostic)]
715-
//~^ ERROR cannot find value `__code_29` in this scope
715+
//~^ ERROR cannot find value `__code_29`
716716
//~| NOTE in this expansion
717717
//~| NOTE not found in this scope
718718
#[multipart_suggestion(no_crate_example)]

Diff for: tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -553,13 +553,13 @@ error: cannot find attribute `bar` in this scope
553553
LL | #[bar("...")]
554554
| ^^^
555555

556-
error[E0425]: cannot find value `slug` in module `crate::fluent_generated`
556+
error[E0425]: cannot find value `slug`
557557
--> $DIR/subdiagnostic-derive.rs:126:9
558558
|
559559
LL | #[label(slug)]
560-
| ^^^^ not found in `crate::fluent_generated`
560+
| ^^^^ not found in module `crate::fluent_generated`
561561

562-
error[E0425]: cannot find value `__code_29` in this scope
562+
error[E0425]: cannot find value `__code_29`
563563
--> $DIR/subdiagnostic-derive.rs:714:10
564564
|
565565
LL | #[derive(Subdiagnostic)]

Diff for: tests/ui/annotate-snippet/missing-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ compile-flags: --error-format human-annotate-rs -Z unstable-options
2-
//@ error-pattern:cannot find type `Iter` in this scope
2+
//@ error-pattern:cannot find type `Iter`
33

44
pub fn main() {
55
let x: Iter;

Diff for: tests/ui/annotate-snippet/missing-type.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `Iter` in this scope
1+
error[E0412]: cannot find type `Iter`
22
--> $DIR/missing-type.rs:5:12
33
|
44
LL | let x: Iter;

Diff for: tests/ui/argument-suggestions/extern-fn-arg-names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extern "Rust" {
22
fn dstfn(src: i32, dst: err);
3-
//~^ ERROR cannot find type `err` in this scope
3+
//~^ ERROR cannot find type `err`
44
}
55

66
fn main() {

Diff for: tests/ui/argument-suggestions/extern-fn-arg-names.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `err` in this scope
1+
error[E0412]: cannot find type `err`
22
--> $DIR/extern-fn-arg-names.rs:2:29
33
|
44
LL | fn dstfn(src: i32, dst: err);

Diff for: tests/ui/argument-suggestions/issue-109831.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `C` in this scope
1+
error[E0412]: cannot find type `C`
22
--> $DIR/issue-109831.rs:4:24
33
|
44
LL | struct A;
@@ -16,7 +16,7 @@ help: you might be missing a type parameter
1616
LL | fn f<C>(b1: B, b2: B, a2: C) {}
1717
| +++
1818

19-
error[E0425]: cannot find value `C` in this scope
19+
error[E0425]: cannot find value `C`
2020
--> $DIR/issue-109831.rs:7:16
2121
|
2222
LL | struct A;

Diff for: tests/ui/array-slice-vec/slice-pat-type-mismatches.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ fn main() {
2424
};
2525

2626
match does_not_exist {
27-
//~^ ERROR cannot find value `does_not_exist` in this scope
28-
[] => {} // ERROR cannot find value `does_not_exist` in this scope
27+
//~^ ERROR cannot find value `does_not_exist`
28+
[] => {} // ERROR cannot find value `does_not_exist`
2929
};
3030
}
3131

Diff for: tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0425]: cannot find value `does_not_exist` in this scope
1+
error[E0425]: cannot find value `does_not_exist`
22
--> $DIR/slice-pat-type-mismatches.rs:26:11
33
|
44
LL | match does_not_exist {

Diff for: tests/ui/asm/issue-113788.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
//@ needs-asm-support
33
//@ only-x86_64
44
fn main() {
5-
let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0412]
5+
let peb: *const PEB; //~ ERROR cannot find type `PEB` [E0412]
66
unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); }
77
}

Diff for: tests/ui/asm/issue-113788.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `PEB` in this scope
1+
error[E0412]: cannot find type `PEB`
22
--> $DIR/issue-113788.rs:5:21
33
|
44
LL | let peb: *const PEB;

Diff for: tests/ui/associated-consts/issue-93835.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
fn e() {
44
type_ascribe!(p, a<p:p<e=6>>);
5-
//~^ ERROR cannot find type `a` in this scope
5+
//~^ ERROR cannot find type `a`
66
//~| ERROR cannot find value
77
//~| ERROR associated const equality
8-
//~| ERROR cannot find trait `p` in this scope
8+
//~| ERROR cannot find trait `p`
99
}
1010

1111
fn main() {}

Diff for: tests/ui/associated-consts/issue-93835.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
error[E0425]: cannot find value `p` in this scope
1+
error[E0425]: cannot find value `p`
22
--> $DIR/issue-93835.rs:4:19
33
|
44
LL | type_ascribe!(p, a<p:p<e=6>>);
55
| ^ not found in this scope
66

7-
error[E0412]: cannot find type `a` in this scope
7+
error[E0412]: cannot find type `a`
88
--> $DIR/issue-93835.rs:4:22
99
|
1010
LL | type_ascribe!(p, a<p:p<e=6>>);
1111
| ^ not found in this scope
1212

13-
error[E0405]: cannot find trait `p` in this scope
13+
error[E0405]: cannot find trait `p`
1414
--> $DIR/issue-93835.rs:4:26
1515
|
1616
LL | type_ascribe!(p, a<p:p<e=6>>);

Diff for: tests/ui/associated-item/issue-87638.fixed

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ impl Trait for S {
1414
}
1515

1616
fn main() {
17-
let _: <S as Trait>::Target; //~ ERROR cannot find associated type `Output` in trait `Trait`
17+
let _: <S as Trait>::Target; //~ ERROR cannot find associated type `Output`
1818
//~^ HELP maybe you meant this associated type
1919

20-
let _ = <S as Trait>::FOO; //~ ERROR cannot find method or associated constant `BAR` in trait `Trait`
20+
let _ = <S as Trait>::FOO; //~ ERROR cannot find method or associated constant `BAR`
2121
//~^ HELP maybe you meant this associated constant
2222
}

0 commit comments

Comments
 (0)