Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0412.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#### Note: this error code is no longer emitted by the compiler.

This error has been merged into E0425.

A used type name is not in scope.

Erroneous code examples:

```compile_fail,E0412
```compile_fail,E0425
impl Something {} // error: type name `Something` is not in scope

// or:
Expand Down Expand Up @@ -42,7 +46,7 @@ module. To fix this, you can follow the suggestion and use File directly or
`use super::File;` which will import the types from the parent namespace. An
example that causes this error is below:

```compile_fail,E0412
```compile_fail,E0425
use std::fs::File;

mod foo {
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0425.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ trait Foo {
// or:

let x = unknown_variable; // error: unresolved name `unknown_variable`

// or:

impl Something {} // error: type name `Something` is not in scope

// or:

fn foo(x: T) {} // error: type name `T` is not in scope
```

Please verify that the name wasn't misspelled and ensure that the
Expand Down Expand Up @@ -45,6 +53,18 @@ let unknown_variable = 12u32;
let x = unknown_variable; // ok!
```

Or for types:

```
struct Something;

impl Something {} // ok!

// or:

fn foo<T>(x: T) {} // ok!
```

If the item is not defined in the current module, it must be imported using a
`use` statement, like so:

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ E0805: 0805,
// E0246, // invalid recursive type
// E0247,
// E0248, // value used as a type, now reported earlier during resolution
// // as E0412
// // as E0425
// E0249,
// E0257,
// E0258,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ impl PathSource<'_, '_, '_> {
(PathSource::Trait(_), true) => E0404,
(PathSource::Trait(_), false) => E0405,
(PathSource::Type | PathSource::DefineOpaques, true) => E0573,
(PathSource::Type | PathSource::DefineOpaques, false) => E0412,
(PathSource::Type | PathSource::DefineOpaques, false) => E0425,
(PathSource::Struct(_), true) => E0574,
(PathSource::Struct(_), false) => E0422,
(PathSource::Expr(..), true) | (PathSource::Delegation, true) => E0423,
Expand Down Expand Up @@ -3161,7 +3161,7 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
result
}

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

// There are two different error messages user might receive at
// this point:
// - E0412 cannot find type `{}` in this scope
// - E0425 cannot find value `{}` in this scope
// - E0433 failed to resolve: use of undeclared type or module `{}`
//
// The first one is emitted for paths in type-position, and the
// latter one - for paths in expression-position.
// The first one is emitted for unresolved names, and the
// latter one - for paths in use statements.
//
// Thus (since we're in expression-position at this point), not to
// confuse the user, we want to keep the *message* from E0433 (so
// `parent_err`), but we want *hints* from E0412 (so `err`).
// `parent_err`), but we want *hints* from E0425 (so `err`).
//
// And that's what happens below - we're just mixing both messages
// into a single one.
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
if !enum_candidates.is_empty() {
enum_candidates.sort();

// Contextualize for E0412 "cannot find type", but don't belabor the point
// Contextualize for E0425 "cannot find value", but don't belabor the point
// (that it's a variant) for E0573 "expected type, found variant".
let preamble = if res.is_none() {
let others = match enum_candidates.len() {
Expand Down Expand Up @@ -1127,7 +1127,7 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
}

self.suggest_ident_hidden_by_hygiene(err, path, span);
} else if err_code == E0412 {
} else if err_code == E0425 {
if let Some(correct) = Self::likely_rust_type(path) {
err.span_suggestion(
span,
Expand Down
10 changes: 5 additions & 5 deletions tests/rustdoc-ui/impl-fn-nesting.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ error[E0405]: cannot find trait `UnknownBound` in this scope
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
| ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `UnknownType` in this scope
error[E0425]: cannot find type `UnknownType` in this scope
--> $DIR/impl-fn-nesting.rs:11:30
|
LL | pub fn f<B: UnknownBound>(a: UnknownType, b: B) {
Expand All @@ -34,7 +34,7 @@ error[E0405]: cannot find trait `UnknownBound` in this scope
LL | impl<T: UnknownBound> UnknownTrait for T {}
| ^^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `UnknownType` in this scope
error[E0425]: cannot find type `UnknownType` in this scope
--> $DIR/impl-fn-nesting.rs:18:25
|
LL | impl ValidTrait for UnknownType {}
Expand All @@ -46,19 +46,19 @@ error[E0405]: cannot find trait `UnknownBound` in this scope
LL | impl ValidTrait for ValidType where ValidTrait: UnknownBound {}
| ^^^^^^^^^^^^ not found in this scope

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

error[E0412]: cannot find type `UnknownType` in this scope
error[E0425]: cannot find type `UnknownType` in this scope
--> $DIR/impl-fn-nesting.rs:44:37
|
LL | pub fn doubly_nested(c: UnknownType) {
| ^^^^^^^^^^^ not found in this scope

error: aborting due to 10 previous errors

Some errors have detailed explanations: E0405, E0412.
Some errors have detailed explanations: E0405, E0425.
For more information about an error, try `rustc --explain E0405`.
4 changes: 2 additions & 2 deletions tests/ui/annotate-snippet/missing-type.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0412]: cannot find type `Iter` in this scope
error[E0425]: cannot find type `Iter` in this scope
--> $DIR/missing-type.rs:4:12
|
LL | let x: Iter;
Expand All @@ -18,4 +18,4 @@ LL + use std::collections::hash_map::Iter;

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/argument-suggestions/extern-fn-arg-names.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0412]: cannot find type `err` in this scope
error[E0425]: cannot find type `err` in this scope
--> $DIR/extern-fn-arg-names.rs:2:29
|
LL | fn dstfn(src: i32, dst: err);
Expand All @@ -22,5 +22,5 @@ LL | dstfn(1, /* dst */);

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0061, E0412.
Some errors have detailed explanations: E0061, E0425.
For more information about an error, try `rustc --explain E0061`.
2 changes: 1 addition & 1 deletion tests/ui/argument-suggestions/issue-109831.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
struct A;
struct B;

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

fn main() {
f(A, A, B, C); //~ ERROR E0425
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/argument-suggestions/issue-109831.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0412]: cannot find type `C` in this scope
error[E0425]: cannot find type `C` in this scope
--> $DIR/issue-109831.rs:4:24
|
LL | struct A;
Expand Down Expand Up @@ -48,5 +48,5 @@ LL + f(/* B */, /* B */, B);

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0061, E0412, E0425.
Some errors have detailed explanations: E0061, E0425, E0425.
For more information about an error, try `rustc --explain E0061`.
2 changes: 1 addition & 1 deletion tests/ui/asm/issue-113788.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
//@ needs-asm-support
//@ only-x86_64
fn main() {
let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0412]
let peb: *const PEB; //~ ERROR cannot find type `PEB` in this scope [E0425]
unsafe { std::arch::asm!("mov {0}, fs:[0x30]", out(reg) peb); }
}
4 changes: 2 additions & 2 deletions tests/ui/asm/issue-113788.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0412]: cannot find type `PEB` in this scope
error[E0425]: cannot find type `PEB` in this scope
--> $DIR/issue-113788.rs:5:21
|
LL | let peb: *const PEB;
| ^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/associated-consts/issue-93835.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0425]: cannot find value `p` in this scope
LL | type_ascribe!(p, a<p:p<e=6>>);
| ^ not found in this scope

error[E0412]: cannot find type `a` in this scope
error[E0425]: cannot find type `a` in this scope
--> $DIR/issue-93835.rs:4:22
|
LL | type_ascribe!(p, a<p:p<e=6>>);
Expand Down Expand Up @@ -39,5 +39,5 @@ LL | type_ascribe!(p, a<p:p<e=6>>);

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0405, E0412, E0425, E0658.
Some errors have detailed explanations: E0405, E0425, E0425, E0658.
For more information about an error, try `rustc --explain E0405`.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ error[E0576]: cannot find function `method` in this scope
LL | method(..): Send,
| ^^^^^^ not found in this scope

error[E0412]: cannot find type `method` in this scope
error[E0425]: cannot find type `method` in this scope
--> $DIR/not-a-method.rs:36:5
|
LL | method(): Send,
Expand All @@ -36,5 +36,5 @@ LL | method(..): Send,

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0412, E0573, E0575, E0576.
For more information about an error, try `rustc --explain E0412`.
Some errors have detailed explanations: E0425, E0573, E0575, E0576.
For more information about an error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/associated-types/associated-types-eq-1.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0412]: cannot find type `A` in this scope
error[E0425]: cannot find type `A` in this scope
--> $DIR/associated-types-eq-1.rs:10:12
|
LL | fn foo2<I: Foo>(x: I) {
Expand All @@ -18,4 +18,4 @@ LL | fn foo2<I: Foo, A>(x: I) {

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
2 changes: 1 addition & 1 deletion tests/ui/async-await/in-trait/return-not-existing-pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

trait MyTrait<'a, 'b, T> {
async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
//~^ ERROR: cannot find type `ConnImpl` in this scope [E0412]
//~^ ERROR: cannot find type `ConnImpl` in this scope [E0425]
}

impl<'a, 'b, T, U> MyTrait<T> for U {
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/async-await/in-trait/return-not-existing-pair.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ help: indicate the anonymous lifetimes
LL | impl<'a, 'b, T, U> MyTrait<'_, '_, T> for U {
| +++++++

error[E0412]: cannot find type `ConnImpl` in this scope
error[E0425]: cannot find type `ConnImpl` in this scope
--> $DIR/return-not-existing-pair.rs:5:48
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
Expand All @@ -26,5 +26,5 @@ LL | async fn foo(_: T) -> (&'a U, &'b T) {}

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0308, E0412, E0726.
Some errors have detailed explanations: E0308, E0425, E0726.
For more information about an error, try `rustc --explain E0308`.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Wrapper<T>(T);

trait Foo {
fn bar() -> Wrapper<Missing<impl Sized>>;
//~^ ERROR: cannot find type `Missing` in this scope [E0412]
//~^ ERROR: cannot find type `Missing` in this scope [E0425]
}

impl Foo for () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0412]: cannot find type `Missing` in this scope
error[E0425]: cannot find type `Missing` in this scope
--> $DIR/return-not-existing-type-wrapping-rpitit.rs:7:25
|
LL | fn bar() -> Wrapper<Missing<impl Sized>>;
| ^^^^^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
6 changes: 3 additions & 3 deletions tests/ui/async-await/issue-72590-type-error-sized.stderr
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
error[E0412]: cannot find type `Nonexistent` in this scope
error[E0425]: cannot find type `Nonexistent` in this scope
--> $DIR/issue-72590-type-error-sized.rs:6:10
|
LL | foo: Nonexistent,
| ^^^^^^^^^^^ not found in this scope

error[E0412]: cannot find type `Missing` in this scope
error[E0425]: cannot find type `Missing` in this scope
--> $DIR/issue-72590-type-error-sized.rs:11:11
|
LL | test: Missing
Expand All @@ -30,5 +30,5 @@ LL | async fn frob(&self) {}

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0412.
Some errors have detailed explanations: E0277, E0425.
For more information about an error, try `rustc --explain E0277`.
4 changes: 2 additions & 2 deletions tests/ui/async-await/unconstrained-lifetimes.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0412]: cannot find type `Missing` in this scope
error[E0425]: cannot find type `Missing` in this scope
--> $DIR/unconstrained-lifetimes.rs:6:17
|
LL | async fn foo(_: Missing<'_>) {}
| ^^^^^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/borrowck/bad-drop-side-effects.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0412]: cannot find type `Missing` in this scope
error[E0425]: cannot find type `Missing` in this scope
--> $DIR/bad-drop-side-effects.rs:7:16
|
LL | impl<U> B for &Missing {
| ^^^^^^^ not found in this scope

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/c-variadic/issue-86053-1.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize
|
= help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list

error[E0412]: cannot find type `F` in this scope
error[E0425]: cannot find type `F` in this scope
--> $DIR/issue-86053-1.rs:11:48
|
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
Expand All @@ -74,4 +74,4 @@ LL | fn ordering4 < 'a , 'b, F > ( a : , self , self , self ,

error: aborting due to 10 previous errors

For more information about this error, try `rustc --explain E0412`.
For more information about this error, try `rustc --explain E0425`.
4 changes: 2 additions & 2 deletions tests/ui/cast/casts-issue-46365.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
error[E0412]: cannot find type `Ipsum` in this scope
error[E0425]: cannot find type `Ipsum` in this scope
--> $DIR/casts-issue-46365.rs:2:12
|
LL | ipsum: Ipsum
| ^^^^^ not found in this scope

error: aborting due to 1 previous error

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