mirror of https://github.com/rust-lang/rust.git
Tweak output of import suggestions
When both `std::` and `core::` items are available, only suggest the `std::` ones. We ensure that in `no_std` crates we suggest `core::` items. Ensure that the list of items suggested to be imported are always in the order of local crate items, `std`/`core` items and finally foreign crate items. Tweak wording of import suggestion: if there are multiple items but they are all of the same kind, we use the kind name and not the generic "items". Fix #83564.
This commit is contained in:
parent
f1586001ac
commit
5de8e6edfc
|
@ -2783,33 +2783,65 @@ fn show_candidates(
|
||||||
// by iterating through a hash map, so make sure they are ordered:
|
// by iterating through a hash map, so make sure they are ordered:
|
||||||
for path_strings in [&mut accessible_path_strings, &mut inaccessible_path_strings] {
|
for path_strings in [&mut accessible_path_strings, &mut inaccessible_path_strings] {
|
||||||
path_strings.sort_by(|a, b| a.0.cmp(&b.0));
|
path_strings.sort_by(|a, b| a.0.cmp(&b.0));
|
||||||
|
path_strings.dedup_by(|a, b| a.0 == b.0);
|
||||||
let core_path_strings =
|
let core_path_strings =
|
||||||
path_strings.extract_if(|p| p.0.starts_with("core::")).collect::<Vec<_>>();
|
path_strings.extract_if(|p| p.0.starts_with("core::")).collect::<Vec<_>>();
|
||||||
path_strings.extend(core_path_strings);
|
let std_path_strings =
|
||||||
path_strings.dedup_by(|a, b| a.0 == b.0);
|
path_strings.extract_if(|p| p.0.starts_with("std::")).collect::<Vec<_>>();
|
||||||
|
let foreign_crate_path_strings =
|
||||||
|
path_strings.extract_if(|p| !p.0.starts_with("crate::")).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
// We list the `crate` local paths first.
|
||||||
|
// Then we list the `std`/`core` paths.
|
||||||
|
if std_path_strings.len() == core_path_strings.len() {
|
||||||
|
// Do not list `core::` paths if we are already listing the `std::` ones.
|
||||||
|
path_strings.extend(std_path_strings);
|
||||||
|
} else {
|
||||||
|
path_strings.extend(std_path_strings);
|
||||||
|
path_strings.extend(core_path_strings);
|
||||||
|
}
|
||||||
|
// List all paths from foreign crates last.
|
||||||
|
path_strings.extend(foreign_crate_path_strings);
|
||||||
}
|
}
|
||||||
accessible_path_strings.sort();
|
|
||||||
|
|
||||||
if !accessible_path_strings.is_empty() {
|
if !accessible_path_strings.is_empty() {
|
||||||
let (determiner, kind, name, through) =
|
let (determiner, kind, s, name, through) =
|
||||||
if let [(name, descr, _, _, via_import)] = &accessible_path_strings[..] {
|
if let [(name, descr, _, _, via_import)] = &accessible_path_strings[..] {
|
||||||
(
|
(
|
||||||
"this",
|
"this",
|
||||||
*descr,
|
*descr,
|
||||||
|
"",
|
||||||
format!(" `{name}`"),
|
format!(" `{name}`"),
|
||||||
if *via_import { " through its public re-export" } else { "" },
|
if *via_import { " through its public re-export" } else { "" },
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
("one of these", "items", String::new(), "")
|
// Get the unique item kinds and if there's only one, we use the right kind name
|
||||||
|
// instead of the more generic "items".
|
||||||
|
let mut kinds = accessible_path_strings
|
||||||
|
.iter()
|
||||||
|
.map(|(_, descr, _, _, _)| *descr)
|
||||||
|
.collect::<FxHashSet<&str>>()
|
||||||
|
.into_iter();
|
||||||
|
let kind = if let Some(kind) = kinds.next()
|
||||||
|
&& let None = kinds.next()
|
||||||
|
{
|
||||||
|
kind
|
||||||
|
} else {
|
||||||
|
"item"
|
||||||
|
};
|
||||||
|
let s = if kind.ends_with('s') { "es" } else { "s" };
|
||||||
|
|
||||||
|
("one of these", kind, s, String::new(), "")
|
||||||
};
|
};
|
||||||
|
|
||||||
let instead = if let Instead::Yes = instead { " instead" } else { "" };
|
let instead = if let Instead::Yes = instead { " instead" } else { "" };
|
||||||
let mut msg = if let DiagMode::Pattern = mode {
|
let mut msg = if let DiagMode::Pattern = mode {
|
||||||
format!(
|
format!(
|
||||||
"if you meant to match on {kind}{instead}{name}, use the full path in the pattern",
|
"if you meant to match on {kind}{s}{instead}{name}, use the full path in the \
|
||||||
|
pattern",
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!("consider importing {determiner} {kind}{through}{instead}")
|
format!("consider importing {determiner} {kind}{s}{through}{instead}")
|
||||||
};
|
};
|
||||||
|
|
||||||
for note in accessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) {
|
for note in accessible_path_strings.iter().flat_map(|cand| cand.3.as_ref()) {
|
||||||
|
|
|
@ -4,9 +4,7 @@ error[E0412]: cannot find type `PhantomData` in this scope
|
||||||
LL | _n: PhantomData,
|
LL | _n: PhantomData,
|
||||||
| ^^^^^^^^^^^ not found in this scope
|
| ^^^^^^^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing this struct
|
||||||
|
|
|
||||||
LL + use core::marker::PhantomData;
|
|
||||||
|
|
|
|
||||||
LL + use std::marker::PhantomData;
|
LL + use std::marker::PhantomData;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0433]: failed to resolve: use of undeclared type `IntoIter`
|
||||||
LL | let mut iter = IntoIter::new(self);
|
LL | let mut iter = IntoIter::new(self);
|
||||||
| ^^^^^^^^ use of undeclared type `IntoIter`
|
| ^^^^^^^^ use of undeclared type `IntoIter`
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these structs
|
||||||
|
|
|
|
||||||
LL + use std::array::IntoIter;
|
LL + use std::array::IntoIter;
|
||||||
|
|
|
|
||||||
|
|
|
@ -5,12 +5,16 @@
|
||||||
// ignore-tidy-linelength
|
// ignore-tidy-linelength
|
||||||
#![feature(const_refs_to_static)]
|
#![feature(const_refs_to_static)]
|
||||||
const REF_INTERIOR_MUT: &usize = {
|
const REF_INTERIOR_MUT: &usize = {
|
||||||
|
//~^ HELP consider importing this struct
|
||||||
static FOO: Sync = AtomicUsize::new(0);
|
static FOO: Sync = AtomicUsize::new(0);
|
||||||
//~^ ERROR failed to resolve: use of undeclared type `AtomicUsize`
|
//~^ ERROR failed to resolve: use of undeclared type `AtomicUsize`
|
||||||
//~| WARN trait objects without an explicit `dyn` are deprecated
|
//~| WARN trait objects without an explicit `dyn` are deprecated
|
||||||
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
//~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
//~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
|
||||||
|
//~| HELP if this is an object-safe trait, use `dyn`
|
||||||
|
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
|
//~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
unsafe { &*(&FOO as *const _ as *const usize) }
|
unsafe { &*(&FOO as *const _ as *const usize) }
|
||||||
};
|
};
|
||||||
pub fn main() {}
|
pub fn main() {}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0433]: failed to resolve: use of undeclared type `AtomicUsize`
|
error[E0433]: failed to resolve: use of undeclared type `AtomicUsize`
|
||||||
--> $DIR/const_refs_to_static-ice-121413.rs:8:24
|
--> $DIR/const_refs_to_static-ice-121413.rs:9:24
|
||||||
|
|
|
|
||||||
LL | static FOO: Sync = AtomicUsize::new(0);
|
LL | static FOO: Sync = AtomicUsize::new(0);
|
||||||
| ^^^^^^^^^^^ use of undeclared type `AtomicUsize`
|
| ^^^^^^^^^^^ use of undeclared type `AtomicUsize`
|
||||||
|
@ -10,7 +10,7 @@ LL + use std::sync::atomic::AtomicUsize;
|
||||||
|
|
|
|
||||||
|
|
||||||
warning: trait objects without an explicit `dyn` are deprecated
|
warning: trait objects without an explicit `dyn` are deprecated
|
||||||
--> $DIR/const_refs_to_static-ice-121413.rs:8:17
|
--> $DIR/const_refs_to_static-ice-121413.rs:9:17
|
||||||
|
|
|
|
||||||
LL | static FOO: Sync = AtomicUsize::new(0);
|
LL | static FOO: Sync = AtomicUsize::new(0);
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
@ -24,7 +24,7 @@ LL | static FOO: dyn Sync = AtomicUsize::new(0);
|
||||||
| +++
|
| +++
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/const_refs_to_static-ice-121413.rs:8:17
|
--> $DIR/const_refs_to_static-ice-121413.rs:9:17
|
||||||
|
|
|
|
||||||
LL | static FOO: Sync = AtomicUsize::new(0);
|
LL | static FOO: Sync = AtomicUsize::new(0);
|
||||||
| ^^^^ doesn't have a size known at compile-time
|
| ^^^^ doesn't have a size known at compile-time
|
||||||
|
@ -32,7 +32,7 @@ LL | static FOO: Sync = AtomicUsize::new(0);
|
||||||
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
= help: the trait `Sized` is not implemented for `(dyn Sync + 'static)`
|
||||||
|
|
||||||
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time
|
||||||
--> $DIR/const_refs_to_static-ice-121413.rs:8:24
|
--> $DIR/const_refs_to_static-ice-121413.rs:9:24
|
||||||
|
|
|
|
||||||
LL | static FOO: Sync = AtomicUsize::new(0);
|
LL | static FOO: Sync = AtomicUsize::new(0);
|
||||||
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
||||||
|
|
|
@ -22,7 +22,7 @@ error[E0425]: cannot find value `Set` in this scope
|
||||||
LL | fn setup() -> Set { Set }
|
LL | fn setup() -> Set { Set }
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these unit variants
|
||||||
|
|
|
|
||||||
LL + use AffixHeart::Set;
|
LL + use AffixHeart::Set;
|
||||||
|
|
|
|
||||||
|
|
|
@ -24,8 +24,7 @@ LL | fn f() { my_core::mem::drop(0); }
|
||||||
LL | a!();
|
LL | a!();
|
||||||
| ---- in this macro invocation
|
| ---- in this macro invocation
|
||||||
|
|
|
|
||||||
= help: consider importing one of these items:
|
= help: consider importing this module:
|
||||||
core::mem
|
|
||||||
std::mem
|
std::mem
|
||||||
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
|
= note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
|
@ -35,9 +34,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
|
||||||
LL | fn f() { my_core::mem::drop(0); }
|
LL | fn f() { my_core::mem::drop(0); }
|
||||||
| ^^^^^^^ use of undeclared crate or module `my_core`
|
| ^^^^^^^ use of undeclared crate or module `my_core`
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing this module
|
||||||
|
|
|
||||||
LL + use core::mem;
|
|
||||||
|
|
|
|
||||||
LL + use std::mem;
|
LL + use std::mem;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ error[E0432]: unresolved import `ops`
|
||||||
LL | use ops::{self as std};
|
LL | use ops::{self as std};
|
||||||
| ^^^^^^^^^^^ no external crate `ops`
|
| ^^^^^^^^^^^ no external crate `ops`
|
||||||
|
|
|
|
||||||
= help: consider importing one of these items instead:
|
= help: consider importing this module instead:
|
||||||
core::ops
|
|
||||||
std::ops
|
std::ops
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -4,8 +4,7 @@ error[E0432]: unresolved import `ops`
|
||||||
LL | use ops::{self as std};
|
LL | use ops::{self as std};
|
||||||
| ^^^^^^^^^^^ no external crate `ops`
|
| ^^^^^^^^^^^ no external crate `ops`
|
||||||
|
|
|
|
||||||
= help: consider importing one of these items instead:
|
= help: consider importing this module instead:
|
||||||
core::ops
|
|
||||||
std::ops
|
std::ops
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0412]: cannot find type `Foo` in this scope
|
||||||
LL | let _: Foo<i32> = todo!();
|
LL | let _: Foo<i32> = todo!();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these structs
|
||||||
|
|
|
|
||||||
LL + use crate::nice_crate_name::Foo;
|
LL + use crate::nice_crate_name::Foo;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0412]: cannot find type `Foo` in this scope
|
||||||
LL | let _: Foo<i32> = todo!();
|
LL | let _: Foo<i32> = todo!();
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these structs
|
||||||
|
|
|
|
||||||
LL + use crate::nice_crate_name::Foo;
|
LL + use crate::nice_crate_name::Foo;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,16 +4,16 @@ error[E0432]: unresolved import `empty::issue_56125`
|
||||||
LL | use empty::issue_56125;
|
LL | use empty::issue_56125;
|
||||||
| ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty`
|
| ^^^^^^^^^^^^^^^^^^ no `issue_56125` in `m3::empty`
|
||||||
|
|
|
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these modules instead
|
||||||
|
|
|
|
||||||
|
LL | use crate::m3::last_segment::issue_56125;
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
LL | use crate::m3::non_last_segment::non_last_segment::issue_56125;
|
||||||
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
LL | use ::issue_56125::issue_56125;
|
LL | use ::issue_56125::issue_56125;
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
LL | use ::issue_56125::last_segment::issue_56125;
|
LL | use ::issue_56125::last_segment::issue_56125;
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
LL | use ::issue_56125::non_last_segment::non_last_segment::issue_56125;
|
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
LL | use crate::m3::last_segment::issue_56125;
|
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
||||||
and 1 other candidate
|
and 1 other candidate
|
||||||
|
|
||||||
error[E0659]: `issue_56125` is ambiguous
|
error[E0659]: `issue_56125` is ambiguous
|
||||||
|
|
|
@ -95,7 +95,7 @@ mod foo {
|
||||||
],
|
],
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"message": "consider importing one of these items",
|
"message": "consider importing one of these structs",
|
||||||
"code": null,
|
"code": null,
|
||||||
"level": "help",
|
"level": "help",
|
||||||
"spans": [
|
"spans": [
|
||||||
|
@ -386,7 +386,7 @@ mod foo {
|
||||||
\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m let x: Iter;\u001b[0m
|
\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m let x: Iter;\u001b[0m
|
||||||
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in this scope\u001b[0m
|
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in this scope\u001b[0m
|
||||||
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
|
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
|
||||||
\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: consider importing one of these items\u001b[0m
|
\u001b[0m\u001b[1m\u001b[38;5;14mhelp\u001b[0m\u001b[0m: consider importing one of these structs\u001b[0m
|
||||||
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
|
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
|
||||||
\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ use std::collections::binary_heap::Iter;\u001b[0m
|
\u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[38;5;10m+ use std::collections::binary_heap::Iter;\u001b[0m
|
||||||
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
|
\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m
|
||||||
|
|
|
@ -12,7 +12,7 @@ help: a tuple struct with a similar name exists
|
||||||
|
|
|
|
||||||
LL | check(m1::TS);
|
LL | check(m1::TS);
|
||||||
| ~~
|
| ~~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use m2::S;
|
LL + use m2::S;
|
||||||
|
|
|
|
||||||
|
@ -40,7 +40,7 @@ help: a tuple struct with a similar name exists
|
||||||
|
|
|
|
||||||
LL | check(xm1::TS);
|
LL | check(xm1::TS);
|
||||||
| ~~
|
| ~~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use m2::S;
|
LL + use m2::S;
|
||||||
|
|
|
|
||||||
|
@ -66,7 +66,7 @@ help: a tuple variant with a similar name exists
|
||||||
|
|
|
|
||||||
LL | check(m7::TV);
|
LL | check(m7::TV);
|
||||||
| ~~
|
| ~~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use m8::V;
|
LL + use m8::V;
|
||||||
|
|
|
|
||||||
|
@ -94,7 +94,7 @@ help: a tuple variant with a similar name exists
|
||||||
|
|
|
|
||||||
LL | check(xm7::TV);
|
LL | check(xm7::TV);
|
||||||
| ~~
|
| ~~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use m8::V;
|
LL + use m8::V;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0574]: expected struct, variant or union type, found enum `Result`
|
||||||
LL | Result {
|
LL | Result {
|
||||||
| ^^^^^^ not a struct, variant or union type
|
| ^^^^^^ not a struct, variant or union type
|
||||||
|
|
|
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these type aliases instead
|
||||||
|
|
|
|
||||||
LL + use std::fmt::Result;
|
LL + use std::fmt::Result;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,14 +4,14 @@ error[E0405]: cannot find trait `Mul` in this scope
|
||||||
LL | impl Mul for Foo {
|
LL | impl Mul for Foo {
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these traits
|
||||||
|
|
|
||||||
|
LL + use std::ops::Mul;
|
||||||
|
|
|
|
||||||
LL + use mul1::Mul;
|
LL + use mul1::Mul;
|
||||||
|
|
|
|
||||||
LL + use mul2::Mul;
|
LL + use mul2::Mul;
|
||||||
|
|
|
|
||||||
LL + use std::ops::Mul;
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0412]: cannot find type `Mul` in this scope
|
error[E0412]: cannot find type `Mul` in this scope
|
||||||
--> $DIR/issue-21221-1.rs:58:16
|
--> $DIR/issue-21221-1.rs:58:16
|
||||||
|
@ -19,14 +19,14 @@ error[E0412]: cannot find type `Mul` in this scope
|
||||||
LL | fn getMul() -> Mul {
|
LL | fn getMul() -> Mul {
|
||||||
| ^^^ not found in this scope
|
| ^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these traits
|
||||||
|
|
|
||||||
|
LL + use std::ops::Mul;
|
||||||
|
|
|
|
||||||
LL + use mul1::Mul;
|
LL + use mul1::Mul;
|
||||||
|
|
|
|
||||||
LL + use mul2::Mul;
|
LL + use mul2::Mul;
|
||||||
|
|
|
|
||||||
LL + use std::ops::Mul;
|
|
||||||
|
|
|
||||||
|
|
||||||
error[E0405]: cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally` in this scope
|
error[E0405]: cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally` in this scope
|
||||||
--> $DIR/issue-21221-1.rs:63:6
|
--> $DIR/issue-21221-1.rs:63:6
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0405]: cannot find trait `T` in this scope
|
||||||
LL | impl T for Foo { }
|
LL | impl T for Foo { }
|
||||||
| ^ not found in this scope
|
| ^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these traits
|
||||||
|
|
|
|
||||||
LL + use baz::T;
|
LL + use baz::T;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0425]: cannot find value `LOG10_2` in module `std::f64`
|
||||||
LL | const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
|
LL | const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize;
|
||||||
| ^^^^^^^ not found in `std::f64`
|
| ^^^^^^^ not found in `std::f64`
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these constants
|
||||||
|
|
|
|
||||||
LL + use std::f128::consts::LOG10_2;
|
LL + use std::f128::consts::LOG10_2;
|
||||||
|
|
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ help: the following enum variant is available
|
||||||
|
|
|
|
||||||
LL | (E::TupleWithFields(/* fields */)).foo();
|
LL | (E::TupleWithFields(/* fields */)).foo();
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use std::f128::consts::E;
|
LL + use std::f128::consts::E;
|
||||||
|
|
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ help: a function with a similar name exists
|
||||||
|
|
|
|
||||||
LL | let _: E = m::f;
|
LL | let _: E = m::f;
|
||||||
| ~
|
| ~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use std::f128::consts::E;
|
LL + use std::f128::consts::E;
|
||||||
|
|
|
|
||||||
|
@ -123,7 +123,7 @@ help: alternatively, the following enum variant is available
|
||||||
|
|
|
|
||||||
LL | let _: E = (E::Fn(/* fields */));
|
LL | let _: E = (E::Fn(/* fields */));
|
||||||
| ~~~~~~~~~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~~~~~~~~~
|
||||||
help: consider importing one of these items instead
|
help: consider importing one of these constants instead
|
||||||
|
|
|
|
||||||
LL + use std::f128::consts::E;
|
LL + use std::f128::consts::E;
|
||||||
|
|
|
|
||||||
|
|
|
@ -4,10 +4,8 @@ error[E0432]: unresolved import `alloc`
|
||||||
LL | use alloc;
|
LL | use alloc;
|
||||||
| ^^^^^ no external crate `alloc`
|
| ^^^^^ no external crate `alloc`
|
||||||
|
|
|
|
||||||
help: consider importing one of these items instead
|
help: consider importing this module instead
|
||||||
|
|
|
|
||||||
LL | use core::alloc;
|
|
||||||
| ~~~~~~~~~~~
|
|
||||||
LL | use std::alloc;
|
LL | use std::alloc;
|
||||||
| ~~~~~~~~~~
|
| ~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ error[E0422]: cannot find struct, variant or union type `Drain` in this scope
|
||||||
LL | let _d = Drain {};
|
LL | let _d = Drain {};
|
||||||
| ^^^^^ not found in this scope
|
| ^^^^^ not found in this scope
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing one of these structs
|
||||||
|
|
|
|
||||||
LL + use crate::plumbing::Drain;
|
LL + use crate::plumbing::Drain;
|
||||||
|
|
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
//@ edition:2018
|
||||||
|
//
|
||||||
|
// This is a regression test for #83564.
|
||||||
|
// For some reason, Rust 2018 or higher is required to reproduce the bug.
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ revisions: no_std std
|
||||||
|
//@ [no_std]compile-flags: --cfg=no_std -C panic=abort
|
||||||
|
#![cfg_attr(no_std, no_std)]
|
||||||
|
|
||||||
|
use core::num::NonZero;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
//~^ HELP consider importing this struct
|
||||||
|
let _x = NonZero::new(5u32).unwrap();
|
||||||
|
//~^ ERROR failed to resolve: use of undeclared type `NonZero`
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[cfg_attr(no_std, panic_handler)]
|
||||||
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
|
@ -1,15 +1,13 @@
|
||||||
error[E0433]: failed to resolve: use of undeclared type `NonZero`
|
error[E0433]: failed to resolve: use of undeclared type `NonZero`
|
||||||
--> $DIR/core-std-import-order-issue-83564.rs:8:14
|
--> $DIR/core-std-import-order-issue-83564.rs:12:14
|
||||||
|
|
|
|
||||||
LL | let _x = NonZero::new(5u32).unwrap();
|
LL | let _x = NonZero::new(5u32).unwrap();
|
||||||
| ^^^^^^^ use of undeclared type `NonZero`
|
| ^^^^^^^ use of undeclared type `NonZero`
|
||||||
|
|
|
|
||||||
help: consider importing one of these items
|
help: consider importing this struct
|
||||||
|
|
|
|
||||||
LL + use core::num::NonZero;
|
LL + use core::num::NonZero;
|
||||||
|
|
|
|
||||||
LL + use std::num::NonZero;
|
|
||||||
|
|
|
||||||
|
|
||||||
error: aborting due to 1 previous error
|
error: aborting due to 1 previous error
|
||||||
|
|
|
@ -2,9 +2,19 @@
|
||||||
//
|
//
|
||||||
// This is a regression test for #83564.
|
// This is a regression test for #83564.
|
||||||
// For some reason, Rust 2018 or higher is required to reproduce the bug.
|
// For some reason, Rust 2018 or higher is required to reproduce the bug.
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ revisions: no_std std
|
||||||
|
//@ [no_std]compile-flags: --cfg=no_std -C panic=abort
|
||||||
|
#![cfg_attr(no_std, no_std)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
//~^ HELP consider importing one of these items
|
//~^ HELP consider importing this struct
|
||||||
let _x = NonZero::new(5u32).unwrap();
|
let _x = NonZero::new(5u32).unwrap();
|
||||||
//~^ ERROR failed to resolve: use of undeclared type `NonZero`
|
//~^ ERROR failed to resolve: use of undeclared type `NonZero`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[cfg_attr(no_std, panic_handler)]
|
||||||
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
//@ edition:2018
|
||||||
|
//
|
||||||
|
// This is a regression test for #83564.
|
||||||
|
// For some reason, Rust 2018 or higher is required to reproduce the bug.
|
||||||
|
//@ run-rustfix
|
||||||
|
//@ revisions: no_std std
|
||||||
|
//@ [no_std]compile-flags: --cfg=no_std -C panic=abort
|
||||||
|
#![cfg_attr(no_std, no_std)]
|
||||||
|
|
||||||
|
use std::num::NonZero;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
//~^ HELP consider importing this struct
|
||||||
|
let _x = NonZero::new(5u32).unwrap();
|
||||||
|
//~^ ERROR failed to resolve: use of undeclared type `NonZero`
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
#[cfg_attr(no_std, panic_handler)]
|
||||||
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
|
loop {}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
error[E0433]: failed to resolve: use of undeclared type `NonZero`
|
||||||
|
--> $DIR/core-std-import-order-issue-83564.rs:12:14
|
||||||
|
|
|
||||||
|
LL | let _x = NonZero::new(5u32).unwrap();
|
||||||
|
| ^^^^^^^ use of undeclared type `NonZero`
|
||||||
|
|
|
||||||
|
help: consider importing this struct
|
||||||
|
|
|
||||||
|
LL + use std::num::NonZero;
|
||||||
|
|
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0433`.
|
|
@ -30,9 +30,7 @@ help: there is a crate or module with a similar name
|
||||||
|
|
|
|
||||||
LL | bar: std::cell::Cell<bool>
|
LL | bar: std::cell::Cell<bool>
|
||||||
| ~~~
|
| ~~~
|
||||||
help: consider importing one of these items
|
help: consider importing this module
|
||||||
|
|
|
||||||
LL + use core::cell;
|
|
||||||
|
|
|
|
||||||
LL + use std::cell;
|
LL + use std::cell;
|
||||||
|
|
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Make sure that trying to access `TryInto`, `TryFrom`, `FromIterator` in pre-2021 mentions
|
// Make sure that trying to access `TryInto`, `TryFrom`, `FromIterator` in pre-2021 mentions
|
||||||
// Edition 2021 change
|
// Edition 2021 change.
|
||||||
//@ edition:2018
|
//@ edition:2018
|
||||||
|
|
||||||
fn test() {
|
fn test() {
|
||||||
|
@ -11,19 +11,16 @@ fn test() {
|
||||||
//~^ ERROR failed to resolve: use of undeclared type
|
//~^ ERROR failed to resolve: use of undeclared type
|
||||||
//~| NOTE use of undeclared type
|
//~| NOTE use of undeclared type
|
||||||
//~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
|
//~| NOTE 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
|
||||||
//~| NOTE 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
|
|
||||||
|
|
||||||
let _i: i16 = TryInto::try_into(0_i32).unwrap();
|
let _i: i16 = TryInto::try_into(0_i32).unwrap();
|
||||||
//~^ ERROR failed to resolve: use of undeclared type
|
//~^ ERROR failed to resolve: use of undeclared type
|
||||||
//~| NOTE use of undeclared type
|
//~| NOTE use of undeclared type
|
||||||
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
|
//~| NOTE 'std::convert::TryInto' is included in the prelude starting in Edition 2021
|
||||||
//~| NOTE 'core::convert::TryInto' is included in the prelude starting in Edition 2021
|
|
||||||
|
|
||||||
let _v: Vec<_> = FromIterator::from_iter(&[1]);
|
let _v: Vec<_> = FromIterator::from_iter(&[1]);
|
||||||
//~^ ERROR failed to resolve: use of undeclared type
|
//~^ ERROR failed to resolve: use of undeclared type
|
||||||
//~| NOTE use of undeclared type
|
//~| NOTE use of undeclared type
|
||||||
//~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
|
//~| NOTE 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
|
||||||
//~| NOTE 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -4,45 +4,36 @@ error[E0433]: failed to resolve: use of undeclared type `TryFrom`
|
||||||
LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap();
|
LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap();
|
||||||
| ^^^^^^^ use of undeclared type `TryFrom`
|
| ^^^^^^^ use of undeclared type `TryFrom`
|
||||||
|
|
|
|
||||||
= note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021
|
|
||||||
= note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
|
= note: 'std::convert::TryFrom' is included in the prelude starting in Edition 2021
|
||||||
help: consider importing one of these items
|
help: consider importing this trait
|
||||||
|
|
|
||||||
LL + use core::convert::TryFrom;
|
|
||||||
|
|
|
|
||||||
LL + use std::convert::TryFrom;
|
LL + use std::convert::TryFrom;
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0433]: failed to resolve: use of undeclared type `TryInto`
|
error[E0433]: failed to resolve: use of undeclared type `TryInto`
|
||||||
--> $DIR/suggest-tryinto-edition-change.rs:16:19
|
--> $DIR/suggest-tryinto-edition-change.rs:15:19
|
||||||
|
|
|
|
||||||
LL | let _i: i16 = TryInto::try_into(0_i32).unwrap();
|
LL | let _i: i16 = TryInto::try_into(0_i32).unwrap();
|
||||||
| ^^^^^^^ use of undeclared type `TryInto`
|
| ^^^^^^^ use of undeclared type `TryInto`
|
||||||
|
|
|
|
||||||
= note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021
|
|
||||||
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
|
= note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021
|
||||||
help: consider importing one of these items
|
help: consider importing this trait
|
||||||
|
|
|
||||||
LL + use core::convert::TryInto;
|
|
||||||
|
|
|
|
||||||
LL + use std::convert::TryInto;
|
LL + use std::convert::TryInto;
|
||||||
|
|
|
|
||||||
|
|
||||||
error[E0433]: failed to resolve: use of undeclared type `FromIterator`
|
error[E0433]: failed to resolve: use of undeclared type `FromIterator`
|
||||||
--> $DIR/suggest-tryinto-edition-change.rs:22:22
|
--> $DIR/suggest-tryinto-edition-change.rs:20:22
|
||||||
|
|
|
|
||||||
LL | let _v: Vec<_> = FromIterator::from_iter(&[1]);
|
LL | let _v: Vec<_> = FromIterator::from_iter(&[1]);
|
||||||
| ^^^^^^^^^^^^ use of undeclared type `FromIterator`
|
| ^^^^^^^^^^^^ use of undeclared type `FromIterator`
|
||||||
|
|
|
|
||||||
= note: 'core::iter::FromIterator' is included in the prelude starting in Edition 2021
|
|
||||||
= note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
|
= note: 'std::iter::FromIterator' is included in the prelude starting in Edition 2021
|
||||||
help: a trait with a similar name exists
|
help: a trait with a similar name exists
|
||||||
|
|
|
|
||||||
LL | let _v: Vec<_> = IntoIterator::from_iter(&[1]);
|
LL | let _v: Vec<_> = IntoIterator::from_iter(&[1]);
|
||||||
| ~~~~~~~~~~~~
|
| ~~~~~~~~~~~~
|
||||||
help: consider importing one of these items
|
help: consider importing this trait
|
||||||
|
|
|
||||||
LL + use core::iter::FromIterator;
|
|
||||||
|
|
|
|
||||||
LL + use std::iter::FromIterator;
|
LL + use std::iter::FromIterator;
|
||||||
|
|
|
|
||||||
|
|
Loading…
Reference in New Issue