rustc_resolve: always include core, std and meta in the extern prelude.

This commit is contained in:
Eduard-Mihai Burtescu 2018-09-10 19:41:30 +03:00
parent 9eb7a3c76f
commit 38c82a2180
9 changed files with 181 additions and 45 deletions

View file

@ -0,0 +1,17 @@
// 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
// Tests that `meta` is whitelisted, even if the crate doesn't exist
// yet (i.e. it causes a different error than `not-whitelisted.rs`).
use meta; //~ ERROR can't find crate for `meta`
fn main() {}

View file

@ -0,0 +1,9 @@
error[E0463]: can't find crate for `meta`
--> $DIR/meta.rs:15:5
|
LL | use meta; //~ ERROR can't find crate for `meta`
| ^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.

View file

@ -0,0 +1,19 @@
// 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
// Tests that arbitrary crates (other than `core`, `std` and `meta`)
// aren't allowed without `--extern`, even if they're in the sysroot.
use alloc; //~ ERROR unresolved import `alloc`
use test; //~ ERROR unresolved import `test`
use proc_macro; //~ ERROR unresolved import `proc_macro`
fn main() {}

View file

@ -0,0 +1,21 @@
error[E0432]: unresolved import `alloc`
--> $DIR/not-whitelisted.rs:15:5
|
LL | use alloc; //~ ERROR unresolved import `alloc`
| ^^^^^ no `alloc` external crate
error[E0432]: unresolved import `test`
--> $DIR/not-whitelisted.rs:16:5
|
LL | use test; //~ ERROR unresolved import `test`
| ^^^^ no `test` external crate
error[E0432]: unresolved import `proc_macro`
--> $DIR/not-whitelisted.rs:17:5
|
LL | use proc_macro; //~ ERROR unresolved import `proc_macro`
| ^^^^^^^^^^ no `proc_macro` external crate
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0432`.

View file

@ -0,0 +1,24 @@
// 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.
// run-pass
// edition:2018
// Tests that `core` and `std` are always available.
use core::iter;
use std::io;
// FIXME(eddyb) Add a `meta` crate to the distribution.
// use meta;
fn main() {
for _ in iter::once(()) {
io::stdout();
}
}

View file

@ -12,7 +12,7 @@
// edition:2018
// compile-pass
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate --extern core
// compile-flags:--extern remove_extern_crate
#![warn(rust_2018_idioms)]

View file

@ -12,7 +12,7 @@
// edition:2018
// compile-pass
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate --extern core
// compile-flags:--extern remove_extern_crate
#![warn(rust_2018_idioms)]