-
Notifications
You must be signed in to change notification settings - Fork 14k
Merge E0412 into E0425 #148678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Merge E0412 into E0425 #148678
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,64 +1,6 @@ | ||
| A used type name is not in scope. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Retain all original content, no need to edit it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
| #### Note: this error code is no longer emitted by the compiler. | ||
|
|
||
| Erroneous code examples: | ||
| Unresolved types are now reported under the unified error code E0425 | ||
| ("cannot find ... in this scope"). | ||
|
|
||
| ```compile_fail,E0412 | ||
| impl Something {} // error: type name `Something` is not in scope | ||
| // or: | ||
| trait Foo { | ||
| fn bar(N); // error: type name `N` is not in scope | ||
| } | ||
| // or: | ||
| fn foo(x: T) {} // type name `T` is not in scope | ||
| ``` | ||
|
|
||
| To fix this error, please verify you didn't misspell the type name, you did | ||
| declare it or imported it into the scope. Examples: | ||
|
|
||
| ``` | ||
| struct Something; | ||
| impl Something {} // ok! | ||
| // or: | ||
| trait Foo { | ||
| type N; | ||
| fn bar(_: Self::N); // ok! | ||
| } | ||
| // or: | ||
| fn foo<T>(x: T) {} // ok! | ||
| ``` | ||
|
|
||
| Another case that causes this error is when a type is imported into a parent | ||
| 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 | ||
| use std::fs::File; | ||
| mod foo { | ||
| fn some_function(f: File) {} | ||
| } | ||
| ``` | ||
|
|
||
| ``` | ||
| use std::fs::File; | ||
| mod foo { | ||
| // either | ||
| use super::File; | ||
| // or | ||
| // use std::fs::File; | ||
| fn foo(f: File) {} | ||
| } | ||
| # fn main() {} // don't insert it for us; that'll break imports | ||
| ``` | ||
| See the explanation for E0425 for guidance on common causes and fixes. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
|
|
@@ -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)); | ||
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why "type" was removed here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a mistake will fix this. |
||
| // - E0425 cannot find `{}` 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. | ||
| // | ||
| // 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. | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For some reasons this get into commit, so you need to manage to remove it somehow
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
| 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`. |
| 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`. |
| 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`. |
| 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`. |
Uh oh!
There was an error while loading. Please reload this page.