}
// Fall back to resolving to an external crate.
- if !(ns == TypeNS && self.extern_prelude.contains(&ident.name)) {
+ if !(
+ ns == TypeNS &&
+ !ident.is_path_segment_keyword() &&
+ self.extern_prelude.contains(&ident.name)
+ ) {
// ... unless the crate name is not in the `extern_prelude`.
return binding;
}
)
{
self.resolve_crate_root(ident)
- } else if ns == TypeNS && !ident.is_path_segment_keyword() {
+ } else if
+ ns == TypeNS &&
+ !ident.is_path_segment_keyword() &&
+ self.extern_prelude.contains(&ident.name)
+ {
let crate_id =
self.crate_loader.process_path_extern(ident.name, ident.span);
self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX })
-include ../tools.mk
all: extern_absolute_paths.rs extern_in_paths.rs krate2
- $(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018
+ $(RUSTC) extern_absolute_paths.rs -Zsave-analysis --edition=2018 \
+ -Z unstable-options --extern krate2
cat $(TMPDIR)/save-analysis/extern_absolute_paths.json | "$(PYTHON)" validate_json.py
- $(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018
+ $(RUSTC) extern_in_paths.rs -Zsave-analysis --edition=2018 \
+ -Z unstable-options --extern krate2
cat $(TMPDIR)/save-analysis/extern_in_paths.json | "$(PYTHON)" validate_json.py
krate2: krate2.rs
// edition:2018
// aux-build:issue-52489.rs
+// compile-flags:--extern issue_52489
use issue_52489;
//~^ ERROR use of unstable library feature 'issue_52489_unstable'
error[E0658]: use of unstable library feature 'issue_52489_unstable'
- --> $DIR/issue-52489.rs:14:5
+ --> $DIR/issue-52489.rs:15:5
|
LL | use issue_52489;
| ^^^^^^^^^^^
// edition:2018
-use xcrate::S; //~ ERROR can't find crate for `xcrate`
+use xcrate::S; //~ ERROR unresolved import `xcrate`
fn main() {}
-error[E0463]: can't find crate for `xcrate`
+error[E0432]: unresolved import `xcrate`
--> $DIR/non-existent-1.rs:13:5
|
-LL | use xcrate::S; //~ ERROR can't find crate for `xcrate`
- | ^^^^^^ can't find crate
+LL | use xcrate::S; //~ ERROR unresolved import `xcrate`
+ | ^^^^^^ Could not find `xcrate` in `{{root}}`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0463`.
+For more information about this error, try `rustc --explain E0432`.
// edition:2018
fn main() {
- let s = ::xcrate::S; //~ ERROR can't find crate for `xcrate`
+ let s = ::xcrate::S;
+ //~^ ERROR failed to resolve. Could not find `xcrate` in `{{root}}`
}
-error[E0463]: can't find crate for `xcrate`
+error[E0433]: failed to resolve. Could not find `xcrate` in `{{root}}`
--> $DIR/non-existent-2.rs:14:15
|
-LL | let s = ::xcrate::S; //~ ERROR can't find crate for `xcrate`
- | ^^^^^^ can't find crate
+LL | let s = ::xcrate::S;
+ | ^^^^^^ Could not find `xcrate` in `{{root}}`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0463`.
+For more information about this error, try `rustc --explain E0433`.
// edition:2018
-use ycrate; //~ ERROR can't find crate for `ycrate`
+use ycrate; //~ ERROR unresolved import `ycrate`
fn main() {}
-error[E0463]: can't find crate for `ycrate`
+error[E0432]: unresolved import `ycrate`
--> $DIR/non-existent-3.rs:13:5
|
-LL | use ycrate; //~ ERROR can't find crate for `ycrate`
- | ^^^^^^ can't find crate
+LL | use ycrate; //~ ERROR unresolved import `ycrate`
+ | ^^^^^^ no `ycrate` external crate
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0463`.
+For more information about this error, try `rustc --explain E0432`.
// except according to those terms.
// aux-build:xcrate.rs
+// compile-flags:--extern xcrate
// edition:2018
use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
error: crate root imports need to be explicitly named: `use crate as name;`
- --> $DIR/single-segment.rs:14:5
+ --> $DIR/single-segment.rs:15:5
|
LL | use crate; //~ ERROR crate root imports need to be explicitly named: `use crate as name;`
| ^^^^^
error: cannot glob-import all possible crates
- --> $DIR/single-segment.rs:15:5
+ --> $DIR/single-segment.rs:16:5
|
LL | use *; //~ ERROR cannot glob-import all possible crates
| ^
error[E0423]: expected value, found module `xcrate`
- --> $DIR/single-segment.rs:18:13
+ --> $DIR/single-segment.rs:19:13
|
LL | let s = ::xcrate; //~ ERROR expected value, found module `xcrate`
| ^^^^^^^^ not a value
#![feature(extern_in_paths)]
-use extern::xcrate::S; //~ ERROR can't find crate for `xcrate`
+use extern::xcrate::S; //~ ERROR unresolved import `extern::xcrate`
fn main() {}
-error[E0463]: can't find crate for `xcrate`
+error[E0432]: unresolved import `extern::xcrate`
--> $DIR/non-existent-1.rs:13:13
|
-LL | use extern::xcrate::S; //~ ERROR can't find crate for `xcrate`
- | ^^^^^^ can't find crate
+LL | use extern::xcrate::S; //~ ERROR unresolved import `extern::xcrate`
+ | ^^^^^^ Could not find `xcrate` in `extern`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0463`.
+For more information about this error, try `rustc --explain E0432`.
#![feature(extern_in_paths)]
fn main() {
- let s = extern::xcrate::S; //~ ERROR can't find crate for `xcrate`
+ let s = extern::xcrate::S;
+ //~^ ERROR failed to resolve. Could not find `xcrate` in `extern`
}
-error[E0463]: can't find crate for `xcrate`
+error[E0433]: failed to resolve. Could not find `xcrate` in `extern`
--> $DIR/non-existent-2.rs:14:21
|
-LL | let s = extern::xcrate::S; //~ ERROR can't find crate for `xcrate`
- | ^^^^^^ can't find crate
+LL | let s = extern::xcrate::S;
+ | ^^^^^^ Could not find `xcrate` in `extern`
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0463`.
+For more information about this error, try `rustc --explain E0433`.
#![feature(extern_in_paths)]
-use extern::ycrate; //~ ERROR can't find crate for `ycrate`
+use extern::ycrate; //~ ERROR unresolved import `extern::ycrate`
fn main() {}
-error[E0463]: can't find crate for `ycrate`
- --> $DIR/non-existent-3.rs:13:13
+error[E0432]: unresolved import `extern::ycrate`
+ --> $DIR/non-existent-3.rs:13:5
|
-LL | use extern::ycrate; //~ ERROR can't find crate for `ycrate`
- | ^^^^^^ can't find crate
+LL | use extern::ycrate; //~ ERROR unresolved import `extern::ycrate`
+ | ^^^^^^^^^^^^^^ no `ycrate` external crate
error: aborting due to previous error
-For more information about this error, try `rustc --explain E0463`.
+For more information about this error, try `rustc --explain E0432`.
// except according to those terms.
// aux-build:xcrate.rs
+// compile-flags:--extern xcrate
#![feature(extern_in_paths)]
error: cannot glob-import all possible crates
- --> $DIR/single-segment.rs:17:5
+ --> $DIR/single-segment.rs:18:5
|
LL | use extern::*; //~ ERROR cannot glob-import all possible crates
| ^^^^^^^^^
error[E0432]: unresolved import `extern`
- --> $DIR/single-segment.rs:15:5
+ --> $DIR/single-segment.rs:16:5
|
LL | use extern; //~ ERROR unresolved import `extern`
| ^^^^^^ no `extern` in the root
error[E0423]: expected value, found module `extern::xcrate`
- --> $DIR/single-segment.rs:20:13
+ --> $DIR/single-segment.rs:21:13
|
LL | let s = extern::xcrate; //~ ERROR expected value, found module `extern::xcrate`
| ^^^^^^^^^^^^^^ not a value
// run-pass
// aux-build:some_crate.rs
+// compile-flags:--extern some_crate
// edition:2018
mod foo {
// run-pass
// aux-build:some_crate.rs
+// compile-flags:--extern some_crate
// edition:2018
use some_crate as some_name;
// run-pass
// aux-build:png2.rs
+// compile-flags:--extern png2
// edition:2018
mod png {
// run-pass
// aux-build:xcrate.rs
+// compile-flags:--extern xcrate
// edition:2018
use xcrate::Z;
// run-pass
// aux-build:xcrate.rs
+// compile-flags:--extern xcrate
#![feature(extern_in_paths)]
// aux-build:edition-lint-paths.rs
// run-rustfix
+// compile-flags:--extern edition_lint_paths
// edition:2018
// The "normal case". Ideally we would remove the `extern crate` here,
// aux-build:edition-lint-paths.rs
// run-rustfix
+// compile-flags:--extern edition_lint_paths
// edition:2018
// The "normal case". Ideally we would remove the `extern crate` here,
error: unused extern crate
- --> $DIR/extern-crate-idiomatic-in-2018.rs:21:1
+ --> $DIR/extern-crate-idiomatic-in-2018.rs:22:1
|
LL | extern crate edition_lint_paths;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it
|
note: lint level defined here
- --> $DIR/extern-crate-idiomatic-in-2018.rs:18:9
+ --> $DIR/extern-crate-idiomatic-in-2018.rs:19:9
|
LL | #![deny(rust_2018_idioms)]
| ^^^^^^^^^^^^^^^^
= note: #[deny(unused_extern_crates)] implied by #[deny(rust_2018_idioms)]
error: `extern crate` is not idiomatic in the new edition
- --> $DIR/extern-crate-idiomatic-in-2018.rs:24:1
+ --> $DIR/extern-crate-idiomatic-in-2018.rs:25:1
|
LL | extern crate edition_lint_paths as bar;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
// run-pass
// aux-build:edition-lint-paths.rs
+// compile-flags:--extern edition_lint_paths
// run-rustfix
// The "normal case". Ideally we would remove the `extern crate` here,
// run-pass
// aux-build:edition-lint-paths.rs
+// compile-flags:--extern edition_lint_paths
// run-rustfix
// The "normal case". Ideally we would remove the `extern crate` here,
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// edition:2018
+
+#![no_std]
+#![crate_type = "lib"]
+
+use alloc::vec;
+//~^ ERROR unresolved import `alloc`
+
+pub fn foo() {
+ let mut xs = vec![];
+ //~^ ERROR cannot determine resolution for the macro `vec`
+ xs.push(0);
+}
--- /dev/null
+error[E0432]: unresolved import `alloc`
+ --> $DIR/issue-54006.rs:16:5
+ |
+LL | use alloc::vec;
+ | ^^^^^ Could not find `alloc` in `{{root}}`
+
+error: cannot determine resolution for the macro `vec`
+ --> $DIR/issue-54006.rs:20:18
+ |
+LL | let mut xs = vec![];
+ | ^^^
+ |
+ = note: import resolution is stuck, try simplifying macro imports
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0432`.
// edition:2018
// compile-pass
// aux-build:remove-extern-crate.rs
+// compile-flags:--extern remove_extern_crate --extern core
#![warn(rust_2018_idioms)]
// edition:2018
// compile-pass
// aux-build:remove-extern-crate.rs
+// compile-flags:--extern remove_extern_crate --extern core
#![warn(rust_2018_idioms)]
warning: unused extern crate
- --> $DIR/remove-extern-crate.rs:18:1
+ --> $DIR/remove-extern-crate.rs:19:1
|
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^ help: remove it
|
note: lint level defined here
- --> $DIR/remove-extern-crate.rs:16:9
+ --> $DIR/remove-extern-crate.rs:17:9
|
LL | #![warn(rust_2018_idioms)]
| ^^^^^^^^^^^^^^^^
= note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)]
warning: `extern crate` is not idiomatic in the new edition
- --> $DIR/remove-extern-crate.rs:19:1
+ --> $DIR/remove-extern-crate.rs:20:1
|
LL | extern crate core as another_name;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use`
warning: `extern crate` is not idiomatic in the new edition
- --> $DIR/remove-extern-crate.rs:32:5
+ --> $DIR/remove-extern-crate.rs:33:5
|
LL | extern crate core;
| ^^^^^^^^^^^^^^^^^^ help: convert it to a `use`