-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=3868d05aad2cfb9e962511b364e05077
use std::mem::MaybeUninit;
pub fn next_unsafe(x: &mut (usize, MaybeUninit<[u16; 8]>)) -> Option<[u16; 8]> {
if x.0 > 0 {
x.0 -= 1;
Some(if x.0 > 0 {
x.1.assume_init_ref().clone()
} else {
std::mem::replace(&mut x.1, MaybeUnint::uninit()).assume_init()
})
} else {
None
}
}The current output is:
error[E0433]: failed to resolve: use of undeclared type `MaybeUnint`
--> src/lib.rs:9:41
|
9 | std::mem::replace(&mut x.1, MaybeUnint::uninit()).assume_init()
| ^^^^^^^^^^ use of undeclared type `MaybeUnint`
For more information about this error, try `rustc --explain E0433`.
Ideally the output should look something like:
error[E0433]: failed to resolve: use of undeclared type `MaybeUnint`
--> src/lib.rs:9:41
|
9 | std::mem::replace(&mut x.1, MaybeUnint::uninit()).assume_init()
| ^^^^^^^^^^ use of undeclared type `MaybeUnint`
| help: there is an in-scope type with a similar name: `MaybeUninit`
For more information about this error, try `rustc --explain E0433`.
Similar to how there's a suggestion when I typo the method name instead:
error[E0599]: no function or associated item named `unint` found for union `MaybeUninit` in the current scope
--> src/lib.rs:9:54
|
9 | std::mem::replace(&mut x.1, MaybeUninit::unint()).assume_init()
| ^^^^^
| |
| function or associated item not found in `MaybeUninit<_>`
| help: there is an associated function with a similar name: `uninit`
For more information about this error, try `rustc --explain E0599`.
I can understand that searching the entire universe of paths on resolution might not be worth doing, but hopefully things that are used could be done reasonably, or something similar.
(That said, once it's already used it's also true that I'm in much less need of the help.)
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.