Skip to content

Commit 15ddd4c

Browse files
committed
EO412_replacement_with_EO425
1 parent ab67c37 commit 15ddd4c

File tree

202 files changed

+532
-591
lines changed

Some content is hidden

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

202 files changed

+532
-591
lines changed
Lines changed: 3 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,5 @@
1-
A used type name is not in scope.
1+
This error code is no longer emitted by the compiler.
22

3-
Erroneous code examples:
3+
Unresolved types are now reported under the unified error code E0425 ("cannot find ... in this scope").
44

5-
```compile_fail,E0412
6-
impl Something {} // error: type name `Something` is not in scope
7-
8-
// or:
9-
10-
trait Foo {
11-
fn bar(N); // error: type name `N` is not in scope
12-
}
13-
14-
// or:
15-
16-
fn foo(x: T) {} // type name `T` is not in scope
17-
```
18-
19-
To fix this error, please verify you didn't misspell the type name, you did
20-
declare it or imported it into the scope. Examples:
21-
22-
```
23-
struct Something;
24-
25-
impl Something {} // ok!
26-
27-
// or:
28-
29-
trait Foo {
30-
type N;
31-
32-
fn bar(_: Self::N); // ok!
33-
}
34-
35-
// or:
36-
37-
fn foo<T>(x: T) {} // ok!
38-
```
39-
40-
Another case that causes this error is when a type is imported into a parent
41-
module. To fix this, you can follow the suggestion and use File directly or
42-
`use super::File;` which will import the types from the parent namespace. An
43-
example that causes this error is below:
44-
45-
```compile_fail,E0412
46-
use std::fs::File;
47-
48-
mod foo {
49-
fn some_function(f: File) {}
50-
}
51-
```
52-
53-
```
54-
use std::fs::File;
55-
56-
mod foo {
57-
// either
58-
use super::File;
59-
// or
60-
// use std::fs::File;
61-
fn foo(f: File) {}
62-
}
63-
# fn main() {} // don't insert it for us; that'll break imports
64-
```
5+
See the explanation for E0425 for guidance on common causes and fixes.

compiler/rustc_resolve/src/late.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ impl PathSource<'_, '_, '_> {
622622
(PathSource::Trait(_), true) => E0404,
623623
(PathSource::Trait(_), false) => E0405,
624624
(PathSource::Type | PathSource::DefineOpaques, true) => E0573,
625-
(PathSource::Type | PathSource::DefineOpaques, false) => E0412,
625+
(PathSource::Type | PathSource::DefineOpaques, false) => E0425,
626626
(PathSource::Struct(_), true) => E0574,
627627
(PathSource::Struct(_), false) => E0422,
628628
(PathSource::Expr(..), true) | (PathSource::Delegation, true) => E0423,
@@ -3161,7 +3161,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
31613161
result
31623162
}
31633163

3164-
/// When evaluating a `trait` use its associated types' idents for suggestions in E0412.
3164+
/// When evaluating a `trait` use its associated types' idents for suggestions in EO425.
31653165
fn resolve_trait_items(&mut self, trait_items: &'ast [Box<AssocItem>]) {
31663166
let trait_assoc_items =
31673167
replace(&mut self.diag_metadata.current_trait_assoc_items, Some(trait_items));
@@ -4362,15 +4362,15 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
43624362

43634363
// There are two different error messages user might receive at
43644364
// this point:
4365-
// - E0412 cannot find type `{}` in this scope
4365+
// - E0425 cannot find `{}` in this scope
43664366
// - E0433 failed to resolve: use of undeclared type or module `{}`
43674367
//
43684368
// The first one is emitted for paths in type-position, and the
43694369
// latter one - for paths in expression-position.
43704370
//
43714371
// Thus (since we're in expression-position at this point), not to
43724372
// confuse the user, we want to keep the *message* from E0433 (so
4373-
// `parent_err`), but we want *hints* from E0412 (so `err`).
4373+
// `parent_err`), but we want *hints* from the unified E0425 (so `err`).
43744374
//
43754375
// And that's what happens below - we're just mixing both messages
43764376
// into a single one.

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
11271127
}
11281128

11291129
self.suggest_ident_hidden_by_hygiene(err, path, span);
1130-
} else if err_code == E0412 {
1130+
// cannot find type in this scope
11311131
if let Some(correct) = Self::likely_rust_type(path) {
11321132
err.span_suggestion(
11331133
span,

src/tools/cargo

Submodule cargo updated 73 files

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `PhantomData` in this scope
1+
error[E0425]: cannot find type `PhantomData` in this scope
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[E0425]: cannot find type `VAL` in this scope
1313
--> tests/ui/crashes/ice-6252.rs:12:63
1414
|
1515
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
@@ -31,5 +31,5 @@ LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
3131

3232
error: aborting due to 3 previous errors
3333

34-
Some errors have detailed explanations: E0046, E0412.
34+
Some errors have detailed explanations: E0046, E0425.
3535
For more information about an error, try `rustc --explain E0046`.

tests/rustdoc-ui/impl-fn-nesting.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ error[E0405]: cannot find trait `UnknownBound` in this scope
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[E0425]: cannot find type `UnknownType` in this scope
1414
--> $DIR/impl-fn-nesting.rs:11:30
1515
|
1616
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
@@ -34,7 +34,7 @@ error[E0405]: cannot find trait `UnknownBound` in this scope
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[E0425]: cannot find type `UnknownType` in this scope
3838
--> $DIR/impl-fn-nesting.rs:18:25
3939
|
4040
LL | impl ValidTrait for UnknownType {}
@@ -46,19 +46,19 @@ error[E0405]: cannot find trait `UnknownBound` in this scope
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[E0425]: cannot find type `UnknownType` in this scope
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[E0425]: cannot find type `UnknownType` in this scope
5656
--> $DIR/impl-fn-nesting.rs:44:37
5757
|
5858
LL | pub fn doubly_nested(c: UnknownType) {
5959
| ^^^^^^^^^^^ not found in this scope
6060

6161
error: aborting due to 10 previous errors
6262

63-
Some errors have detailed explanations: E0405, E0412.
63+
Some errors have detailed explanations: E0405, E0425.
6464
For more information about an error, try `rustc --explain E0405`.

tests/ui/annotate-snippet/missing-type.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `Iter` in this scope
1+
error[E0425]: cannot find type `Iter` in this scope
22
--> $DIR/missing-type.rs:4:12
33
|
44
LL | let x: Iter;
@@ -18,4 +18,4 @@ LL + use std::collections::hash_map::Iter;
1818

1919
error: aborting due to 1 previous error
2020

21-
For more information about this error, try `rustc --explain E0412`.
21+
For more information about this error, try `rustc --explain E0425`.

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

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

2323
error: aborting due to 2 previous errors
2424

25-
Some errors have detailed explanations: E0061, E0412.
25+
Some errors have detailed explanations: E0061, E0425.
2626
For more information about an error, try `rustc --explain E0061`.

tests/ui/argument-suggestions/issue-109831.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
struct A;
22
struct B;
33

4-
fn f(b1: B, b2: B, a2: C) {} //~ ERROR E0412
4+
fn f(b1: B, b2: B, a2: C) {} //~ ERROR E0425
55

66
fn main() {
77
f(A, A, B, C); //~ ERROR E0425

tests/ui/argument-suggestions/issue-109831.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0412]: cannot find type `C` in this scope
1+
error[E0425]: cannot find type `C` in this scope
22
--> $DIR/issue-109831.rs:4:24
33
|
44
LL | struct A;
@@ -48,5 +48,5 @@ LL + f(/* B */, /* B */, B);
4848

4949
error: aborting due to 3 previous errors
5050

51-
Some errors have detailed explanations: E0061, E0412, E0425.
51+
Some errors have detailed explanations: E0061, E0425, E0425.
5252
For more information about an error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)