diff --git a/src/Cargo.lock b/src/Cargo.lock index fe0069dac233e..63a6b3c66a6a9 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -198,7 +198,7 @@ dependencies = [ "hex 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "home 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ignore 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazycell 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", @@ -944,11 +944,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "jobserver" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1349,19 +1350,18 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "parking_lot_core" -version = "0.2.9" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1469,16 +1469,6 @@ dependencies = [ "nibble_vec 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rand" -version = "0.3.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rand" version = "0.4.2" @@ -1692,7 +1682,7 @@ dependencies = [ "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "fmt_macros 0.0.0", "graphviz 0.0.0", - "jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "proc_macro 0.0.0", @@ -1723,7 +1713,7 @@ dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1824,7 +1814,7 @@ name = "rustc_back" version = "0.0.0" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", "syntax 0.0.0", ] @@ -1867,7 +1857,7 @@ dependencies = [ "ena 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", "serialize 0.0.0", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1923,7 +1913,7 @@ version = "0.0.0" dependencies = [ "graphviz 0.0.0", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc_data_structures 0.0.0", "serialize 0.0.0", @@ -2102,7 +2092,7 @@ dependencies = [ "cc 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2948,7 +2938,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21" "checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" -"checksum jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "565f6106bd87b394398f813bea4e5ecad6d6b0f6aa077592d088f882a506481d" +"checksum jobserver 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2abd9fd3242accb0e2e30986f2cf30cda3e19eec5cc6d584b218ce2b1c0e3c" "checksum json 0.11.12 (registry+https://github.com/rust-lang/crates.io-index)" = "39ebf0fac977ee3a4a3242b6446004ff64514889e3e2730bbd4f764a67a2e483" "checksum jsonrpc-core 8.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ddf83704f4e79979a424d1082dd2c1e52683058056c9280efa19ac5f6bc9033c" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" @@ -2990,7 +2980,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum os_pipe 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "998bfbb3042e715190fe2a41abfa047d7e8cb81374d2977d7f100eacd8619cb1" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" "checksum parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e7f7c9857874e54afeb950eebeae662b1e51a2493666d2ea4c0a5d91dcf0412" -"checksum parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6bf05dc61189828dfd7a59fd6e66d538e88d6b30390da1124a291e09fd3098b3" +"checksum parking_lot_core 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "538ef00b7317875071d5e00f603f24d16f0b474c1a5fc0ccb8b454ca72eafa79" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" @@ -3003,7 +2993,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum quote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408" "checksum racer 2.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "034f1c4528581c40a60e96875467c03315868084e08ff4ceb46a00f7be3b16b4" "checksum radix_trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "211c49b6a9995cac0fd1dd9ca60b42cf3a51e151a12eb954b3a9e75513426ee8" -"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "485541959c8ecc49865526fe6c4de9653dd6e60d829d6edf0be228167b60372d" "checksum rayon-core 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d24ad214285a7729b174ed6d3bcfcb80177807f959d95fafd5bfc5c4f201ac8" diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 40e2ef41144f3..4be16475590f4 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -175,9 +175,6 @@ fn main() { if let Ok(s) = env::var("RUSTC_CODEGEN_UNITS") { cmd.arg("-C").arg(format!("codegen-units={}", s)); } - if env::var("RUSTC_THINLTO").is_ok() { - cmd.arg("-Ccodegen-units=16").arg("-Zthinlto"); - } // Emit save-analysis info. if env::var("RUSTC_SAVE_ANALYSIS") == Ok("api".to_string()) { diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 1b74e7c41e7a7..fab7a2b3fcc5c 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -778,17 +778,6 @@ impl<'a> Builder<'a> { if cmd != "bench" { cargo.arg("--release"); } - - if self.config.rust_codegen_units.is_none() && - self.build.is_rust_llvm(compiler.host) && - self.config.rust_thinlto { - cargo.env("RUSTC_THINLTO", "1"); - } else if self.config.rust_codegen_units.is_none() { - // Generally, if ThinLTO has been disabled for some reason, we - // want to set the codegen units to 1. However, we shouldn't do - // this if the option was specifically set by the user. - cargo.env("RUSTC_CODEGEN_UNITS", "1"); - } } if self.config.locked_deps { diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 259910eca301b..920a8ffc2fc86 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -86,7 +86,6 @@ pub struct Config { // rust codegen options pub rust_optimize: bool, pub rust_codegen_units: Option, - pub rust_thinlto: bool, pub rust_debug_assertions: bool, pub rust_debuginfo: bool, pub rust_debuginfo_lines: bool, @@ -270,7 +269,6 @@ impl Default for StringOrBool { struct Rust { optimize: Option, codegen_units: Option, - thinlto: Option, debug_assertions: Option, debuginfo: Option, debuginfo_lines: Option, @@ -429,7 +427,6 @@ impl Config { // Store off these values as options because if they're not provided // we'll infer default values for them later - let mut thinlto = None; let mut llvm_assertions = None; let mut debuginfo_lines = None; let mut debuginfo_only_std = None; @@ -473,7 +470,6 @@ impl Config { optimize = rust.optimize; ignore_git = rust.ignore_git; debug_jemalloc = rust.debug_jemalloc; - thinlto = rust.thinlto; set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.codegen_tests, rust.codegen_tests); @@ -561,7 +557,6 @@ impl Config { "stable" | "beta" | "nightly" => true, _ => false, }; - config.rust_thinlto = thinlto.unwrap_or(true); config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default); config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index e9b4a233d0af5..97da7cae07f7c 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -71,7 +71,6 @@ def v(*args): # Optimization and debugging options. These may be overridden by the release # channel, etc. o("optimize", "rust.optimize", "build optimized rust code") -o("thinlto", "rust.thinlto", "build Rust with ThinLTO enabled") o("optimize-llvm", "llvm.optimize", "build optimized LLVM") o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") diff --git a/src/ci/run.sh b/src/ci/run.sh index 7ce50d5c2000b..e3f38e4834a92 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -46,7 +46,6 @@ export RUST_RELEASE_CHANNEL=nightly if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-thinlto" if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md index cc7b15812ec34..fea8685a605d6 100644 --- a/src/doc/rustdoc/src/documentation-tests.md +++ b/src/doc/rustdoc/src/documentation-tests.md @@ -35,6 +35,22 @@ let x = 5; There's some subtlety though! Read on for more details. +## Passing or failing a doctest + +Like regular unit tests, regular doctests are considered to "pass" +if they compile and run without panicking. +So if you want to demonstrate that some computation gives a certain result, +the `assert!` family of macros works the same as other Rust code: + +```rust +let foo = "foo"; + +assert_eq!(foo, "foo"); +``` + +This way, if the computation ever returns something different, +the code panics and the doctest fails. + ## Pre-processing examples In the example above, you'll note something strange: there's no `main` diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index 9bbba4e22b03d..d1e746ea43b45 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -9,11 +9,8 @@ // except according to those terms. use std::borrow::Cow; -#[cfg(not(target_arch = "asmjs"))] use std::collections::CollectionAllocErr::*; -#[cfg(not(target_arch = "asmjs"))] use std::mem::size_of; -#[cfg(not(target_arch = "asmjs"))] use std::{usize, isize}; pub trait IntoCow<'a, B: ?Sized> where B: ToOwned { @@ -535,7 +532,6 @@ fn test_reserve_exact() { assert!(s.capacity() >= 33) } -#[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve() { @@ -613,7 +609,6 @@ fn test_try_reserve() { } -#[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve_exact() { diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 85e11d8b8ee6e..3c17a401bbaf5 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -10,11 +10,8 @@ use std::borrow::Cow; use std::mem::size_of; -use std::{usize, panic}; -#[cfg(not(target_arch = "asmjs"))] -use std::isize; +use std::{usize, isize, panic}; use std::vec::{Drain, IntoIter}; -#[cfg(not(target_arch = "asmjs"))] use std::collections::CollectionAllocErr::*; struct DropCounter<'a> { @@ -994,7 +991,6 @@ fn test_reserve_exact() { assert!(v.capacity() >= 33) } -#[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve() { @@ -1097,7 +1093,6 @@ fn test_try_reserve() { } -#[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve_exact() { diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index 9fd38ed6f6f49..fc1a0b624a555 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -11,13 +11,9 @@ use std::collections::VecDeque; use std::fmt::Debug; use std::collections::vec_deque::{Drain}; -#[cfg(not(target_arch = "asmjs"))] use std::collections::CollectionAllocErr::*; -#[cfg(not(target_arch = "asmjs"))] use std::mem::size_of; -use std::isize; -#[cfg(not(target_arch = "asmjs"))] -use std::usize; +use std::{usize, isize}; use self::Taggy::*; use self::Taggypar::*; @@ -1053,7 +1049,6 @@ fn test_reserve_exact_2() { assert!(v.capacity() >= 48) } -#[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve() { @@ -1155,7 +1150,6 @@ fn test_try_reserve() { } -#[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve_exact() { diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index a6802d606ca8c..b1b783b47c72b 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -2605,7 +2605,7 @@ impl DoubleEndedIterator for Flatten } } -#[stable(feature = "fused", since = "1.26.0")] +#[unstable(feature = "iterator_flatten", issue = "48213")] impl FusedIterator for Flatten where I: FusedIterator, U: Iterator, I::Item: IntoIterator {} diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 8b4b9aaeac848..37d79f408f3f0 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -55,7 +55,9 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> { } } -pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) { +pub fn find_entry_point(session: &Session, + hir_map: &hir_map::Map, + crate_name: &str) { let any_exe = session.crate_types.borrow().iter().any(|ty| { *ty == config::CrateTypeExecutable }); @@ -81,7 +83,7 @@ pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) { hir_map.krate().visit_all_item_likes(&mut ctxt); - configure_main(&mut ctxt); + configure_main(&mut ctxt, crate_name); } // Beware, this is duplicated in libsyntax/entry.rs, make sure to keep @@ -150,7 +152,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) { } } -fn configure_main(this: &mut EntryContext) { +fn configure_main(this: &mut EntryContext, crate_name: &str) { if this.start_fn.is_some() { *this.session.entry_fn.borrow_mut() = this.start_fn; this.session.entry_type.set(Some(config::EntryStart)); @@ -162,7 +164,8 @@ fn configure_main(this: &mut EntryContext) { this.session.entry_type.set(Some(config::EntryMain)); } else { // No main function - let mut err = struct_err!(this.session, E0601, "main function not found"); + let mut err = struct_err!(this.session, E0601, + "`main` function not found in crate `{}`", crate_name); if !this.non_main_fns.is_empty() { // There were some functions named 'main' though. Try to give the user a hint. err.note("the main function must be defined at the crate level \ @@ -175,6 +178,9 @@ fn configure_main(this: &mut EntryContext) { err.emit(); this.session.abort_if_errors(); } else { + if let Some(ref filename) = this.session.local_crate_source_file { + err.note(&format!("consider adding a `main` function to `{}`", filename.display())); + } if this.session.teach(&err.get_code().unwrap()) { err.note("If you don't know the basics of Rust, you can go look to the Rust Book \ to get started: https://doc.rust-lang.org/book/"); diff --git a/src/librustc_back/Cargo.toml b/src/librustc_back/Cargo.toml index d864c5bc61054..4c5b1417a2f67 100644 --- a/src/librustc_back/Cargo.toml +++ b/src/librustc_back/Cargo.toml @@ -12,7 +12,7 @@ crate-type = ["dylib"] syntax = { path = "../libsyntax" } serialize = { path = "../libserialize" } log = "0.4" -rand = "0.3" +rand = "0.4" [features] jemalloc = [] diff --git a/src/librustc_back/target/asmjs_unknown_emscripten.rs b/src/librustc_back/target/asmjs_unknown_emscripten.rs index f114926740a5e..ab7df4ba1c543 100644 --- a/src/librustc_back/target/asmjs_unknown_emscripten.rs +++ b/src/librustc_back/target/asmjs_unknown_emscripten.rs @@ -15,7 +15,9 @@ pub fn target() -> Result { let mut args = LinkArgs::new(); args.insert(LinkerFlavor::Em, vec!["-s".to_string(), - "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string()]); + "ERROR_ON_UNDEFINED_SYMBOLS=1".to_string(), + "-s".to_string(), + "ABORTING_MALLOC=0".to_string()]); let opts = TargetOptions { dynamic_linking: false, diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 542f818c3818a..e52575f02b2ff 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -979,7 +979,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(trans: &TransCrate, time(sess, "looking for entry point", - || middle::entry::find_entry_point(sess, &hir_map)); + || middle::entry::find_entry_point(sess, &hir_map, name)); sess.plugin_registrar_fn.set(time(sess, "looking for plugin registrar", || { plugin::build::find_plugin_registrar(sess.diagnostic(), &hir_map) diff --git a/src/librustc_incremental/Cargo.toml b/src/librustc_incremental/Cargo.toml index eabc3ab03b194..dd05679589e7e 100644 --- a/src/librustc_incremental/Cargo.toml +++ b/src/librustc_incremental/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["dylib"] [dependencies] graphviz = { path = "../libgraphviz" } log = "0.4" -rand = "0.3" +rand = "0.4" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } serialize = { path = "../libserialize" } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a6b776125ae97..c84caee13e82a 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -41,7 +41,7 @@ use rustc::ty; use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap}; -use syntax::codemap::{dummy_spanned, respan, CodeMap}; +use syntax::codemap::{dummy_spanned, respan, BytePos, CodeMap}; use syntax::ext::hygiene::{Mark, MarkKind, SyntaxContext}; use syntax::ast::{self, Name, NodeId, Ident, SpannedIdent, FloatTy, IntTy, UintTy}; use syntax::ext::base::SyntaxExtension; @@ -179,11 +179,12 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, E0401, "can't use type parameters from outer function"); err.span_label(span, "use of type variable from outer function"); + + let cm = resolver.session.codemap(); match outer_def { Def::SelfTy(_, maybe_impl_defid) => { if let Some(impl_span) = maybe_impl_defid.map_or(None, |def_id| resolver.definitions.opt_span(def_id)) { - let cm = resolver.session.codemap(); err.span_label(reduce_impl_span_to_impl_keyword(cm, impl_span), "`Self` type implicitely declared here, on the `impl`"); } @@ -206,12 +207,13 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, // Try to retrieve the span of the function signature and generate a new message with // a local type parameter let sugg_msg = "try using a local type parameter instead"; - if let Some((sugg_span, new_snippet)) = generate_local_type_param_snippet( - resolver.session.codemap(), span) { + if let Some((sugg_span, new_snippet)) = generate_local_type_param_snippet(cm, span) { // Suggest the modification to the user err.span_suggestion(sugg_span, sugg_msg, new_snippet); + } else if let Some(sp) = generate_fn_name_span(cm, span) { + err.span_label(sp, "try adding a local type parameter in this method instead"); } else { err.help("try using a local type parameter instead"); } @@ -407,6 +409,15 @@ fn reduce_impl_span_to_impl_keyword(cm: &CodeMap, impl_span: Span) -> Span { impl_span } +fn generate_fn_name_span(cm: &CodeMap, span: Span) -> Option { + let prev_span = cm.span_extend_to_prev_str(span, "fn", true); + cm.span_to_snippet(prev_span).map(|snippet| { + let len = snippet.find(|c: char| !c.is_alphanumeric() && c != '_') + .expect("no label after fn"); + prev_span.with_hi(BytePos(prev_span.lo().0 + len as u32)) + }).ok() +} + /// Take the span of a type parameter in a function signature and try to generate a span for the /// function name (with generics) and a new snippet for this span with the pointed type parameter as /// a new local type parameter. @@ -428,17 +439,12 @@ fn reduce_impl_span_to_impl_keyword(cm: &CodeMap, impl_span: Span) -> Span { fn generate_local_type_param_snippet(cm: &CodeMap, span: Span) -> Option<(Span, String)> { // Try to extend the span to the previous "fn" keyword to retrieve the function // signature - let sugg_span = cm.span_extend_to_prev_str(span, "fn"); + let sugg_span = cm.span_extend_to_prev_str(span, "fn", false); if sugg_span != span { if let Ok(snippet) = cm.span_to_snippet(sugg_span) { - use syntax::codemap::BytePos; - // Consume the function name - let mut offset = 0; - for c in snippet.chars().take_while(|c| c.is_ascii_alphanumeric() || - *c == '_') { - offset += c.len_utf8(); - } + let mut offset = snippet.find(|c: char| !c.is_alphanumeric() && c != '_') + .expect("no label after fn"); // Consume the generics part of the function signature let mut bracket_counter = 0; diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index 4a98fff6af76d..44c18c371a40f 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -30,6 +30,7 @@ use cabi_sparc64; use cabi_nvptx; use cabi_nvptx64; use cabi_hexagon; +use cabi_wasm32; use mir::place::PlaceRef; use mir::operand::OperandValue; use type_::Type; @@ -948,7 +949,13 @@ impl<'a, 'tcx> FnType<'tcx> { "powerpc64" => cabi_powerpc64::compute_abi_info(cx, self), "s390x" => cabi_s390x::compute_abi_info(cx, self), "asmjs" => cabi_asmjs::compute_abi_info(cx, self), - "wasm32" => cabi_asmjs::compute_abi_info(cx, self), + "wasm32" => { + if cx.sess().opts.target_triple.contains("emscripten") { + cabi_asmjs::compute_abi_info(cx, self) + } else { + cabi_wasm32::compute_abi_info(cx, self) + } + } "msp430" => cabi_msp430::compute_abi_info(self), "sparc" => cabi_sparc::compute_abi_info(cx, self), "sparc64" => cabi_sparc64::compute_abi_info(cx, self), diff --git a/src/librustc_trans/cabi_mips64.rs b/src/librustc_trans/cabi_mips64.rs index 94bf53cee1edb..231fe4c6edb67 100644 --- a/src/librustc_trans/cabi_mips64.rs +++ b/src/librustc_trans/cabi_mips64.rs @@ -28,18 +28,6 @@ fn extend_integer_width_mips(arg: &mut ArgType, bits: u64) { arg.extend_integer_width_to(bits); } -fn bits_to_int_reg(bits: u64) -> Reg { - if bits <= 8 { - Reg::i8() - } else if bits <= 16 { - Reg::i16() - } else if bits <= 32 { - Reg::i32() - } else { - Reg::i64() - } -} - fn float_reg<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ret: &ArgType<'tcx>, i: usize) -> Option { match ret.layout.field(cx, i).abi { layout::Abi::Scalar(ref scalar) => match scalar.value { @@ -82,7 +70,7 @@ fn classify_ret_ty<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) // Cast to a uniform int structure ret.cast_to(Uniform { - unit: bits_to_int_reg(bits), + unit: Reg::i64(), total: size }); } else { diff --git a/src/librustc_trans/cabi_wasm32.rs b/src/librustc_trans/cabi_wasm32.rs new file mode 100644 index 0000000000000..5530a03d65dda --- /dev/null +++ b/src/librustc_trans/cabi_wasm32.rs @@ -0,0 +1,31 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use abi::{FnType, ArgType}; +use context::CodegenCx; + +fn classify_ret_ty<'a, 'tcx>(_cx: &CodegenCx<'a, 'tcx>, ret: &mut ArgType<'tcx>) { + ret.extend_integer_width_to(32); +} + +fn classify_arg_ty(arg: &mut ArgType) { + arg.extend_integer_width_to(32); +} + +pub fn compute_abi_info<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, fty: &mut FnType<'tcx>) { + if !fty.ret.is_ignore() { + classify_ret_ty(cx, &mut fty.ret); + } + + for arg in &mut fty.args { + if arg.is_ignore() { continue; } + classify_arg_ty(arg); + } +} diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 9b09dbf52761a..0a98f74212d69 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -123,6 +123,7 @@ mod cabi_sparc64; mod cabi_x86; mod cabi_x86_64; mod cabi_x86_win64; +mod cabi_wasm32; mod callee; mod common; mod consts; diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index afe32f3f66933..dd8b44c96b90c 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -92,6 +92,7 @@ const X86_WHITELIST: &'static [&'static str] = &["aes", "avx", "avx2", "avx512bw "bmi1", "bmi2", "fma", "fxsr", "lzcnt", "mmx", "pclmulqdq", "popcnt", "rdrand", "rdseed", + "sha", "sse", "sse2", "sse3", "sse4.1", "sse4.2", "sse4a", "ssse3", "tbm", "xsave", "xsavec", diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index d10ee358e0728..b94af0a1e0081 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -525,7 +525,7 @@ impl<'a, 'gcx> CheckTypeWellFormedVisitor<'a, 'gcx> { } else { fcx.tcx.sess.diagnostic().mut_span_err( span, &format!("invalid `self` type: {:?}", self_arg_ty)) - .note(&format!("type must be `{:?}` or a type that dereferences to it`", self_ty)) + .note(&format!("type must be `{:?}` or a type that dereferences to it", self_ty)) .help("consider changing to `self`, `&self`, `&mut self`, or `self: Box`") .code(DiagnosticId::Error("E0307".into())) .emit(); diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index d3de31d630a97..07b7c600b9f30 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -52,10 +52,10 @@ fn check_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeId) { fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_def_id: DefId) { let did = Some(trait_def_id); let li = tcx.lang_items(); + let span = tcx.sess.codemap().def_span(tcx.span_of_impl(impl_def_id).unwrap()); // Disallow *all* explicit impls of `Sized` and `Unsize` for now. if did == li.sized_trait() { - let span = tcx.span_of_impl(impl_def_id).unwrap(); struct_span_err!(tcx.sess, span, E0322, @@ -66,11 +66,12 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d } if did == li.unsize_trait() { - let span = tcx.span_of_impl(impl_def_id).unwrap(); - span_err!(tcx.sess, - span, - E0328, - "explicit impls for the `Unsize` trait are not permitted"); + struct_span_err!(tcx.sess, + span, + E0328, + "explicit impls for the `Unsize` trait are not permitted") + .span_label(span, "impl of `Unsize` not allowed") + .emit(); return; } @@ -88,14 +89,14 @@ fn enforce_trait_manually_implementable(tcx: TyCtxt, impl_def_id: DefId, trait_d } else { return; // everything OK }; - let mut err = struct_span_err!(tcx.sess, - tcx.span_of_impl(impl_def_id).unwrap(), - E0183, - "manual implementations of `{}` are experimental", - trait_name); - help!(&mut err, - "add `#![feature(unboxed_closures)]` to the crate attributes to enable"); - err.emit(); + struct_span_err!(tcx.sess, + span, + E0183, + "manual implementations of `{}` are experimental", + trait_name) + .span_label(span, format!("manual implementations of `{}` are experimental", trait_name)) + .help("add `#![feature(unboxed_closures)]` to the crate attributes to enable") + .emit(); } pub fn provide(providers: &mut Providers) { @@ -168,13 +169,17 @@ fn check_impl_overlap<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, node_id: ast::NodeI traits::supertrait_def_ids(tcx, data.principal().unwrap().def_id()); if supertrait_def_ids.any(|d| d == trait_def_id) { - span_err!(tcx.sess, - tcx.span_of_impl(impl_def_id).unwrap(), - E0371, - "the object type `{}` automatically \ - implements the trait `{}`", - trait_ref.self_ty(), - tcx.item_path_str(trait_def_id)); + let sp = tcx.sess.codemap().def_span(tcx.span_of_impl(impl_def_id).unwrap()); + struct_span_err!(tcx.sess, + sp, + E0371, + "the object type `{}` automatically implements the trait `{}`", + trait_ref.self_ty(), + tcx.item_path_str(trait_def_id)) + .span_label(sp, format!("`{}` automatically implements trait `{}`", + trait_ref.self_ty(), + tcx.item_path_str(trait_def_id))) + .emit(); } } } diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index c2dfd798a3c4a..6d6594e55437d 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -40,29 +40,36 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { self.tcx.hir.node_to_string(item.id)); let trait_ref = self.tcx.impl_trait_ref(def_id).unwrap(); let trait_def_id = trait_ref.def_id; + let cm = self.tcx.sess.codemap(); + let sp = cm.def_span(item.span); match traits::orphan_check(self.tcx, def_id) { Ok(()) => {} Err(traits::OrphanCheckErr::NoLocalInputType) => { struct_span_err!(self.tcx.sess, - item.span, + sp, E0117, "only traits defined in the current crate can be \ implemented for arbitrary types") - .span_label(item.span, "impl doesn't use types inside crate") - .note(&format!("the impl does not reference any types defined in \ - this crate")) + .span_label(sp, "impl doesn't use types inside crate") + .note("the impl does not reference any types defined in this crate") .note("define and implement a trait or new type instead") .emit(); return; } Err(traits::OrphanCheckErr::UncoveredTy(param_ty)) => { - span_err!(self.tcx.sess, - item.span, - E0210, - "type parameter `{}` must be used as the type parameter for \ - some local type (e.g. `MyStruct`); only traits defined in \ - the current crate can be implemented for a type parameter", - param_ty); + struct_span_err!(self.tcx.sess, + sp, + E0210, + "type parameter `{}` must be used as the type parameter \ + for some local type (e.g. `MyStruct<{}>`)", + param_ty, + param_ty) + .span_label(sp, + format!("type parameter `{}` must be used as the type \ + parameter for some local type", param_ty)) + .note("only traits defined in the current crate can be implemented \ + for a type parameter") + .emit(); return; } } @@ -121,22 +128,29 @@ impl<'cx, 'tcx, 'v> ItemLikeVisitor<'v> for OrphanChecker<'cx, 'tcx> { if self_def_id.is_local() { None } else { - Some(format!("cross-crate traits with a default impl, like `{}`, \ - can only be implemented for a struct/enum type \ - defined in the current crate", - self.tcx.item_path_str(trait_def_id))) + Some(( + format!("cross-crate traits with a default impl, like `{}`, \ + can only be implemented for a struct/enum type \ + defined in the current crate", + self.tcx.item_path_str(trait_def_id)), + "can't implement cross-crate trait for type in another crate" + )) } } _ => { - Some(format!("cross-crate traits with a default impl, like `{}`, can \ - only be implemented for a struct/enum type, not `{}`", - self.tcx.item_path_str(trait_def_id), - self_ty)) + Some((format!("cross-crate traits with a default impl, like `{}`, can \ + only be implemented for a struct/enum type, not `{}`", + self.tcx.item_path_str(trait_def_id), + self_ty), + "can't implement cross-crate trait with a default impl for \ + non-struct/enum type")) } }; - if let Some(msg) = msg { - span_err!(self.tcx.sess, item.span, E0321, "{}", msg); + if let Some((msg, label)) = msg { + struct_span_err!(self.tcx.sess, sp, E0321, "{}", msg) + .span_label(sp, label) + .emit(); return; } } diff --git a/src/librustdoc/README.md b/src/librustdoc/README.md index b0a5ae3718df3..2cfe43a8389bb 100644 --- a/src/librustdoc/README.md +++ b/src/librustdoc/README.md @@ -1,172 +1,3 @@ -# The walking tour of rustdoc +For more information about how `librustdoc` works, see the [rustc guide]. -Rustdoc is implemented entirely within the crate `librustdoc`. After partially compiling a crate to -get its AST (technically the HIR map) from rustc, librustdoc performs two major steps past that to -render a set of documentation: - -* "Clean" the AST into a form that's more suited to creating documentation (and slightly more - resistant to churn in the compiler). -* Use this cleaned AST to render a crate's documentation, one page at a time. - -Naturally, there's more than just this, and those descriptions simplify out lots of details, but -that's the high-level overview. - -(Side note: this is a library crate! The `rustdoc` binary is crated using the project in -`src/tools/rustdoc`. Note that literally all that does is call the `main()` that's in this crate's -`lib.rs`, though.) - -## Cheat sheet - -* Use `x.py build --stage 1 src/libstd src/tools/rustdoc` to make a useable rustdoc you can run on - other projects. - * Add `src/libtest` to be able to use `rustdoc --test`. - * If you've used `rustup toolchain link local /path/to/build/$TARGET/stage1` previously, then - after the previous build command, `cargo +local doc` will Just Work. -* Use `x.py doc --stage 1 src/libstd` to use this rustdoc to generate the standard library docs. - * The completed docs will be available in `build/$TARGET/doc/std`, though the bundle is meant to - be used as though you would copy out the `doc` folder to a web server, since that's where the - CSS/JS and landing page are. -* Most of the HTML printing code is in `html/format.rs` and `html/render.rs`. It's in a bunch of - `fmt::Display` implementations and supplementary functions. -* The types that got `Display` impls above are defined in `clean/mod.rs`, right next to the custom - `Clean` trait used to process them out of the rustc HIR. -* The bits specific to using rustdoc as a test harness are in `test.rs`. -* The Markdown renderer is loaded up in `html/markdown.rs`, including functions for extracting - doctests from a given block of Markdown. -* The tests on rustdoc *output* are located in `src/test/rustdoc`, where they're handled by the test - runner of rustbuild and the supplementary script `src/etc/htmldocck.py`. -* Tests on search index generation are located in `src/test/rustdoc-js`, as a series of JavaScript - files that encode queries on the standard library search index and expected results. - -## From crate to clean - -In `core.rs` are two central items: the `DocContext` struct, and the `run_core` function. The latter -is where rustdoc calls out to rustc to compile a crate to the point where rustdoc can take over. The -former is a state container used when crawling through a crate to gather its documentation. - -The main process of crate crawling is done in `clean/mod.rs` through several implementations of the -`Clean` trait defined within. This is a conversion trait, which defines one method: - -```rust -pub trait Clean { - fn clean(&self, cx: &DocContext) -> T; -} -``` - -`clean/mod.rs` also defines the types for the "cleaned" AST used later on to render documentation -pages. Each usually accompanies an implementation of `Clean` that takes some AST or HIR type from -rustc and converts it into the appropriate "cleaned" type. "Big" items like modules or associated -items may have some extra processing in its `Clean` implementation, but for the most part these -impls are straightforward conversions. The "entry point" to this module is the `impl Clean -for visit_ast::RustdocVisitor`, which is called by `run_core` above. - -You see, I actually lied a little earlier: There's another AST transformation that happens before -the events in `clean/mod.rs`. In `visit_ast.rs` is the type `RustdocVisitor`, which *actually* -crawls a `hir::Crate` to get the first intermediate representation, defined in `doctree.rs`. This -pass is mainly to get a few intermediate wrappers around the HIR types and to process visibility -and inlining. This is where `#[doc(inline)]`, `#[doc(no_inline)]`, and `#[doc(hidden)]` are -processed, as well as the logic for whether a `pub use` should get the full page or a "Reexport" -line in the module page. - -The other major thing that happens in `clean/mod.rs` is the collection of doc comments and -`#[doc=""]` attributes into a separate field of the Attributes struct, present on anything that gets -hand-written documentation. This makes it easier to collect this documentation later in the process. - -The primary output of this process is a clean::Crate with a tree of Items which describe the -publicly-documentable items in the target crate. - -### Hot potato - -Before moving on to the next major step, a few important "passes" occur over the documentation. -These do things like combine the separate "attributes" into a single string and strip leading -whitespace to make the document easier on the markdown parser, or drop items that are not public or -deliberately hidden with `#[doc(hidden)]`. These are all implemented in the `passes/` directory, one -file per pass. By default, all of these passes are run on a crate, but the ones regarding dropping -private/hidden items can be bypassed by passing `--document-private-items` to rustdoc. - -(Strictly speaking, you can fine-tune the passes run and even add your own, but [we're trying to -deprecate that][44136]. If you need finer-grain control over these passes, please let us know!) - -[44136]: https://github.com/rust-lang/rust/issues/44136 - -## From clean to crate - -This is where the "second phase" in rustdoc begins. This phase primarily lives in the `html/` -folder, and it all starts with `run()` in `html/render.rs`. This code is responsible for setting up -the `Context`, `SharedContext`, and `Cache` which are used during rendering, copying out the static -files which live in every rendered set of documentation (things like the fonts, CSS, and JavaScript -that live in `html/static/`), creating the search index, and printing out the source code rendering, -before beginning the process of rendering all the documentation for the crate. - -Several functions implemented directly on `Context` take the `clean::Crate` and set up some state -between rendering items or recursing on a module's child items. From here the "page rendering" -begins, via an enormous `write!()` call in `html/layout.rs`. The parts that actually generate HTML -from the items and documentation occurs within a series of `std::fmt::Display` implementations and -functions that pass around a `&mut std::fmt::Formatter`. The top-level implementation that writes -out the page body is the `impl<'a> fmt::Display for Item<'a>` in `html/render.rs`, which switches -out to one of several `item_*` functions based on the kind of `Item` being rendered. - -Depending on what kind of rendering code you're looking for, you'll probably find it either in -`html/render.rs` for major items like "what sections should I print for a struct page" or -`html/format.rs` for smaller component pieces like "how should I print a where clause as part of -some other item". - -Whenever rustdoc comes across an item that should print hand-written documentation alongside, it -calls out to `html/markdown.rs` which interfaces with the Markdown parser. This is exposed as a -series of types that wrap a string of Markdown, and implement `fmt::Display` to emit HTML text. It -takes special care to enable certain features like footnotes and tables and add syntax highlighting -to Rust code blocks (via `html/highlight.rs`) before running the Markdown parser. There's also a -function in here (`find_testable_code`) that specifically scans for Rust code blocks so the -test-runner code can find all the doctests in the crate. - -### From soup to nuts - -(alternate title: ["An unbroken thread that stretches from those first `Cell`s to us"][video]) - -[video]: https://www.youtube.com/watch?v=hOLAGYmUQV0 - -It's important to note that the AST cleaning can ask the compiler for information (crucially, -`DocContext` contains a `TyCtxt`), but page rendering cannot. The `clean::Crate` created within -`run_core` is passed outside the compiler context before being handed to `html::render::run`. This -means that a lot of the "supplementary data" that isn't immediately available inside an item's -definition, like which trait is the `Deref` trait used by the language, needs to be collected during -cleaning, stored in the `DocContext`, and passed along to the `SharedContext` during HTML rendering. -This manifests as a bunch of shared state, context variables, and `RefCell`s. - -Also of note is that some items that come from "asking the compiler" don't go directly into the -`DocContext` - for example, when loading items from a foreign crate, rustdoc will ask about trait -implementations and generate new `Item`s for the impls based on that information. This goes directly -into the returned `Crate` rather than roundabout through the `DocContext`. This way, these -implementations can be collected alongside the others, right before rendering the HTML. - -## Other tricks up its sleeve - -All this describes the process for generating HTML documentation from a Rust crate, but there are -couple other major modes that rustdoc runs in. It can also be run on a standalone Markdown file, or -it can run doctests on Rust code or standalone Markdown files. For the former, it shortcuts straight -to `html/markdown.rs`, optionally including a mode which inserts a Table of Contents to the output -HTML. - -For the latter, rustdoc runs a similar partial-compilation to get relevant documentation in -`test.rs`, but instead of going through the full clean and render process, it runs a much simpler -crate walk to grab *just* the hand-written documentation. Combined with the aforementioned -"`find_testable_code`" in `html/markdown.rs`, it builds up a collection of tests to run before -handing them off to the libtest test runner. One notable location in `test.rs` is the function -`make_test`, which is where hand-written doctests get transformed into something that can be -executed. - -## Dotting i's and crossing t's - -So that's rustdoc's code in a nutshell, but there's more things in the repo that deal with it. Since -we have the full `compiletest` suite at hand, there's a set of tests in `src/test/rustdoc` that make -sure the final HTML is what we expect in various situations. These tests also use a supplementary -script, `src/etc/htmldocck.py`, that allows it to look through the final HTML using XPath notation -to get a precise look at the output. The full description of all the commands available to rustdoc -tests is in `htmldocck.py`. - -In addition, there are separate tests for the search index and rustdoc's ability to query it. The -files in `src/test/rustdoc-js` each contain a different search query and the expected results, -broken out by search tab. These files are processed by a script in `src/tools/rustdoc-js` and the -Node.js runtime. These tests don't have as thorough of a writeup, but a broad example that features -results in all tabs can be found in `basic.js`. The basic idea is that you match a given `QUERY` -with a set of `EXPECTED` results, complete with the full item path of each item. +[rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/rustdoc.html diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 5f5dec2dd4ff1..b18b38ec30246 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -2755,11 +2755,8 @@ mod test_map { use cell::RefCell; use rand::{thread_rng, Rng}; use panic; - #[cfg(not(target_arch = "asmjs"))] use realstd::collections::CollectionAllocErr::*; - #[cfg(not(target_arch = "asmjs"))] use realstd::mem::size_of; - #[cfg(not(target_arch = "asmjs"))] use realstd::usize; #[test] @@ -3696,7 +3693,6 @@ mod test_map { assert_eq!(hm.len(), 0); } - #[cfg(not(target_arch = "asmjs"))] #[test] fn test_try_reserve() { diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 261d44eebaa27..ae5037cc44e80 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -372,6 +372,25 @@ impl FromStr for SocketAddr { /// [`IpAddr`], [`Ipv4Addr`], [`Ipv6Addr`], [`SocketAddr`], [`SocketAddrV4`], and /// [`SocketAddrV6`]. /// +/// # Potential causes +/// +/// `AddrParseError` may be thrown because the provided string does not parse as the given type, +/// often because it includes information only handled by a different address type. +/// +/// ```should_panic +/// use std::net::IpAddr; +/// let _foo: IpAddr = "127.0.0.1:8080".parse().expect("Cannot handle the socket port"); +/// ``` +/// +/// [`IpAddr`] doesn't handle the port. Use [`SocketAddr`] instead. +/// +/// ``` +/// use std::net::SocketAddr; +/// +/// // No problem, the `panic!` message has disappeared. +/// let _foo: SocketAddr = "127.0.0.1:8080".parse().expect("unreachable panic"); +/// ``` +/// /// [`FromStr`]: ../../std/str/trait.FromStr.html /// [`IpAddr`]: ../../std/net/enum.IpAddr.html /// [`Ipv4Addr`]: ../../std/net/struct.Ipv4Addr.html diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index c340f1b8c8ab3..951f8a871ca66 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -622,13 +622,21 @@ impl CodeMap { sp } - /// Extend the given `Span` to just after the previous occurrence of `pat`. Return the same span - /// if no character could be found or if an error occurred while retrieving the code snippet. - pub fn span_extend_to_prev_str(&self, sp: Span, pat: &str) -> Span { - if let Ok(prev_source) = self.span_to_prev_source(sp) { - let prev_source = prev_source.rsplit(pat).nth(0).unwrap_or("").trim_left(); - if !prev_source.is_empty() && !prev_source.contains('\n') { - return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32)); + /// Extend the given `Span` to just after the previous occurrence of `pat` when surrounded by + /// whitespace. Return the same span if no character could be found or if an error occurred + /// while retrieving the code snippet. + pub fn span_extend_to_prev_str(&self, sp: Span, pat: &str, accept_newlines: bool) -> Span { + // assure that the pattern is delimited, to avoid the following + // fn my_fn() + // ^^^^ returned span without the check + // ---------- correct span + for ws in &[" ", "\t", "\n"] { + let pat = pat.to_owned() + ws; + if let Ok(prev_source) = self.span_to_prev_source(sp) { + let prev_source = prev_source.rsplit(&pat).nth(0).unwrap_or("").trim_left(); + if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) { + return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32)); + } } } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 377f47a3ea5a1..3e75afcee1cf3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -484,13 +484,15 @@ impl<'a, 'b> MacroExpander<'a, 'b> { match *ext { MultiModifier(ref mac) => { - let meta = attr.parse_meta(self.cx.parse_sess).ok()?; + let meta = attr.parse_meta(self.cx.parse_sess) + .map_err(|mut e| { e.emit(); }).ok()?; let item = mac.expand(self.cx, attr.span, &meta, item); Some(kind.expect_from_annotatables(item)) } MultiDecorator(ref mac) => { let mut items = Vec::new(); - let meta = attr.parse_meta(self.cx.parse_sess).ok()?; + let meta = attr.parse_meta(self.cx.parse_sess) + .expect("derive meta should already have been parsed"); mac.expand(self.cx, attr.span, &meta, &item, &mut |item| items.push(item)); items.push(item); Some(kind.expect_from_annotatables(items)) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 51fa14895993d..f42cb8a258314 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -449,6 +449,9 @@ declare_features! ( // Parentheses in patterns (active, pattern_parentheses, "1.26.0", None, None), + + // `use path as _;` and `extern crate c as _;` + (active, underscore_imports, "1.26.0", Some(48216), None), ); declare_features! ( @@ -1434,9 +1437,24 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } + fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, _nested: bool) { + if let ast::UseTreeKind::Simple(ident) = use_tree.kind { + if ident.name == "_" { + gate_feature_post!(&self, underscore_imports, use_tree.span, + "renaming imports with `_` is unstable"); + } + } + + visit::walk_use_tree(self, use_tree, id); + } + fn visit_item(&mut self, i: &'a ast::Item) { match i.node { ast::ItemKind::ExternCrate(_) => { + if i.ident.name == "_" { + gate_feature_post!(&self, underscore_imports, i.span, + "renaming extern crates with `_` is unstable"); + } if let Some(attr) = attr::find_by_name(&i.attrs[..], "macro_reexport") { gate_feature_post!(&self, macro_reexport, attr.span, "macros re-exports are experimental \ diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index e3812ce159a9a..a3a6489fe8b14 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -7065,7 +7065,11 @@ impl<'a> Parser<'a> { fn parse_rename(&mut self) -> PResult<'a, Option> { if self.eat_keyword(keywords::As) { - self.parse_ident().map(Some) + if self.eat(&token::Underscore) { + Ok(Some(Ident::with_empty_ctxt(Symbol::gensym("_")))) + } else { + self.parse_ident().map(Some) + } } else { Ok(None) } diff --git a/src/test/codegen/abi-main-signature-16bit-c-int.rs b/src/test/codegen/abi-main-signature-16bit-c-int.rs index 1e02fe4befdf5..707531bf376a7 100644 --- a/src/test/codegen/abi-main-signature-16bit-c-int.rs +++ b/src/test/codegen/abi-main-signature-16bit-c-int.rs @@ -17,6 +17,7 @@ // ignore-asmjs // ignore-hexagon // ignore-mips +// ignore-mips64 // ignore-powerpc // ignore-s390x // ignore-sparc diff --git a/src/test/codegen/fastcall-inreg.rs b/src/test/codegen/fastcall-inreg.rs index b24899cc363a0..9bfe47d0a1f28 100644 --- a/src/test/codegen/fastcall-inreg.rs +++ b/src/test/codegen/fastcall-inreg.rs @@ -21,9 +21,7 @@ // ignore-bpfeb // ignore-hexagon // ignore-mips -// ignore-mipsel // ignore-mips64 -// ignore-mips64el // ignore-msp430 // ignore-powerpc // ignore-r600 diff --git a/src/test/codegen/global_asm.rs b/src/test/codegen/global_asm.rs index 5661592d0c7b2..94b69a6cab583 100644 --- a/src/test/codegen/global_asm.rs +++ b/src/test/codegen/global_asm.rs @@ -17,9 +17,7 @@ // ignore-bpfeb // ignore-hexagon // ignore-mips -// ignore-mipsel // ignore-mips64 -// ignore-mips64el // ignore-msp430 // ignore-powerpc // ignore-r600 diff --git a/src/test/codegen/global_asm_include.rs b/src/test/codegen/global_asm_include.rs index d8b5db12404ac..c3688077f221b 100644 --- a/src/test/codegen/global_asm_include.rs +++ b/src/test/codegen/global_asm_include.rs @@ -17,9 +17,7 @@ // ignore-bpfeb // ignore-hexagon // ignore-mips -// ignore-mipsel // ignore-mips64 -// ignore-mips64el // ignore-msp430 // ignore-powerpc // ignore-r600 diff --git a/src/test/codegen/global_asm_x2.rs b/src/test/codegen/global_asm_x2.rs index caa0506550dde..3b8fe43fa048a 100644 --- a/src/test/codegen/global_asm_x2.rs +++ b/src/test/codegen/global_asm_x2.rs @@ -17,9 +17,7 @@ // ignore-bpfeb // ignore-hexagon // ignore-mips -// ignore-mipsel // ignore-mips64 -// ignore-mips64el // ignore-msp430 // ignore-powerpc // ignore-r600 diff --git a/src/test/codegen/repr-transparent-aggregates-2.rs b/src/test/codegen/repr-transparent-aggregates-2.rs index e6374928a5cbf..9605ded569ef6 100644 --- a/src/test/codegen/repr-transparent-aggregates-2.rs +++ b/src/test/codegen/repr-transparent-aggregates-2.rs @@ -12,6 +12,7 @@ // ignore-aarch64 // ignore-asmjs +// ignore-mips64 // ignore-s390x // ignore-wasm // ignore-x86 diff --git a/src/test/codegen/repr-transparent-aggregates-3.rs b/src/test/codegen/repr-transparent-aggregates-3.rs new file mode 100644 index 0000000000000..0c90239c9de8f --- /dev/null +++ b/src/test/codegen/repr-transparent-aggregates-3.rs @@ -0,0 +1,49 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -C no-prepopulate-passes + +// only-mips64 +// See repr-transparent.rs + +#![crate_type="lib"] +#![feature(repr_transparent)] + + +#[repr(C)] +pub struct Big([u32; 16]); + +#[repr(transparent)] +pub struct BigW(Big); + +// CHECK: define void @test_Big(%Big* [[BIG_RET_ATTRS:.*]], [8 x i64] +#[no_mangle] +pub extern fn test_Big(_: Big) -> Big { loop {} } + +// CHECK: define void @test_BigW(%BigW* [[BIG_RET_ATTRS]], [8 x i64] +#[no_mangle] +pub extern fn test_BigW(_: BigW) -> BigW { loop {} } + + +#[repr(C)] +pub union BigU { + foo: [u32; 16], +} + +#[repr(transparent)] +pub struct BigUw(BigU); + +// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], [8 x i64] +#[no_mangle] +pub extern fn test_BigU(_: BigU) -> BigU { loop {} } + +// CHECK: define void @test_BigUw(%BigUw* [[BIGU_RET_ATTRS]], [8 x i64] +#[no_mangle] +pub extern fn test_BigUw(_: BigUw) -> BigUw { loop {} } diff --git a/src/test/codegen/stack-probes.rs b/src/test/codegen/stack-probes.rs index 4a489f1edb3b8..af400ff3bcbd0 100644 --- a/src/test/codegen/stack-probes.rs +++ b/src/test/codegen/stack-probes.rs @@ -10,8 +10,9 @@ // ignore-arm // ignore-aarch64 +// ignore-mips +// ignore-mips64 // ignore-powerpc -// ignore-aarch64 // ignore-wasm // ignore-emscripten // ignore-windows diff --git a/src/test/codegen/x86_mmx.rs b/src/test/codegen/x86_mmx.rs index dc9f63c35db2e..30777c6214ec9 100644 --- a/src/test/codegen/x86_mmx.rs +++ b/src/test/codegen/x86_mmx.rs @@ -11,6 +11,8 @@ // ignore-arm // ignore-aarch64 // ignore-emscripten +// ignore-mips +// ignore-mips64 // compile-flags: -O #![feature(repr_simd)] diff --git a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs index 61b1a0a0b4d25..48be4ac6c37bc 100644 --- a/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs +++ b/src/test/compile-fail-fulldeps/auxiliary/macro_crate_test.rs @@ -37,6 +37,9 @@ pub fn plugin_registrar(reg: &mut Registry) { reg.register_syntax_extension( Symbol::intern("into_multi_foo"), MultiModifier(Box::new(expand_into_foo_multi))); + reg.register_syntax_extension( + Symbol::intern("noop_attribute"), + MultiModifier(Box::new(expand_noop_attribute))); reg.register_syntax_extension( Symbol::intern("duplicate"), MultiDecorator(Box::new(expand_duplicate))); @@ -93,6 +96,13 @@ fn expand_into_foo_multi(cx: &mut ExtCtxt, } } +fn expand_noop_attribute(_cx: &mut ExtCtxt, + _sp: Span, + _attr: &MetaItem, + it: Annotatable) -> Annotatable { + it +} + // Create a duplicate of the annotatable, based on the MetaItem fn expand_duplicate(cx: &mut ExtCtxt, _sp: Span, diff --git a/src/test/compile-fail-fulldeps/issue-48941.rs b/src/test/compile-fail-fulldeps/issue-48941.rs new file mode 100644 index 0000000000000..4be2874ed4ff6 --- /dev/null +++ b/src/test/compile-fail-fulldeps/issue-48941.rs @@ -0,0 +1,29 @@ +// Copyright 2013-2014 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This is a regression test against an ICE that used to occur +// on malformed attributes for a custom MultiModifier. + +// aux-build:macro_crate_test.rs +// ignore-stage1 + +#![feature(plugin)] +#![plugin(macro_crate_test)] + +#[noop_attribute"x"] //~ ERROR expected one of +fn night() { } + +#[noop_attribute("hi"), rank = 2] //~ ERROR unexpected token +fn knight() { } + +#[noop_attribute("/user", data= = " $DIR/empty_span.rs:17:5 | LL | unsafe impl Send for &'static Foo { } //~ ERROR cross-crate traits with a default impl - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't implement cross-crate trait with a default impl for non-struct/enum type error: aborting due to previous error diff --git a/src/test/ui/coherence-impls-copy.stderr b/src/test/ui/coherence-impls-copy.stderr index d98492876e8c5..5f9b0c62df2b8 100644 --- a/src/test/ui/coherence-impls-copy.stderr +++ b/src/test/ui/coherence-impls-copy.stderr @@ -32,7 +32,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-copy.rs:33:1 | LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead @@ -41,7 +41,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-copy.rs:40:1 | LL | impl Copy for [MyType] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead @@ -50,7 +50,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/coherence-impls-copy.rs:44:1 | LL | impl Copy for &'static [NotSync] {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead diff --git a/src/test/ui/e0119/complex-impl.stderr b/src/test/ui/e0119/complex-impl.stderr index 0c331cf5e75b6..1fc4c28d67c5d 100644 --- a/src/test/ui/e0119/complex-impl.stderr +++ b/src/test/ui/e0119/complex-impl.stderr @@ -8,11 +8,13 @@ LL | impl External for (Q, R) {} //~ ERROR must be used - impl<'a, 'b, 'c, T, U, V, W> complex_impl_support::External for (T, complex_impl_support::M<'a, 'b, 'c, std::boxed::Box, V, W>) where >::Output == V, ::Item == T, 'b : 'a, T : 'a, U: std::ops::FnOnce<(T,)>, U : 'static, V: std::iter::Iterator, V: std::clone::Clone, W: std::ops::Add, ::Output: std::marker::Copy; -error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g. `MyStruct`); only traits defined in the current crate can be implemented for a type parameter +error[E0210]: type parameter `R` must be used as the type parameter for some local type (e.g. `MyStruct`) --> $DIR/complex-impl.rs:19:1 | LL | impl External for (Q, R) {} //~ ERROR must be used - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ type parameter `R` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter error: aborting due to 2 previous errors diff --git a/src/test/ui/e0119/issue-28981.stderr b/src/test/ui/e0119/issue-28981.stderr index 16da24550bc1b..afcbab4a5c6c0 100644 --- a/src/test/ui/e0119/issue-28981.stderr +++ b/src/test/ui/e0119/issue-28981.stderr @@ -8,11 +8,13 @@ LL | impl Deref for Foo { } //~ ERROR must be used - impl<'a, T> std::ops::Deref for &'a T where T: ?Sized; -error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct`); only traits defined in the current crate can be implemented for a type parameter +error[E0210]: type parameter `Foo` must be used as the type parameter for some local type (e.g. `MyStruct`) --> $DIR/issue-28981.rs:15:1 | LL | impl Deref for Foo { } //~ ERROR must be used - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ type parameter `Foo` must be used as the type parameter for some local type + | + = note: only traits defined in the current crate can be implemented for a type parameter error: aborting due to 2 previous errors diff --git a/src/test/ui/error-codes/E0117.stderr b/src/test/ui/error-codes/E0117.stderr index 16c1a1fae7f5e..045ae700955d4 100644 --- a/src/test/ui/error-codes/E0117.stderr +++ b/src/test/ui/error-codes/E0117.stderr @@ -8,7 +8,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/E0117.rs:11:1 | LL | impl Drop for u32 {} //~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr index d28bb876d4d63..bbc0da2248f6e 100644 --- a/src/test/ui/error-codes/E0206.stderr +++ b/src/test/ui/error-codes/E0206.stderr @@ -14,7 +14,7 @@ error[E0117]: only traits defined in the current crate can be implemented for ar --> $DIR/E0206.rs:13:1 | LL | impl Copy for Foo { } - | ^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | ^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate | = note: the impl does not reference any types defined in this crate = note: define and implement a trait or new type instead diff --git a/src/test/ui/error-codes/E0328.rs b/src/test/ui/error-codes/E0328.rs new file mode 100644 index 0000000000000..e08532b02491f --- /dev/null +++ b/src/test/ui/error-codes/E0328.rs @@ -0,0 +1,20 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unsize)] + +use std::marker::Unsize; + +pub struct MyType; + +impl Unsize for MyType {} +//~^ ERROR explicit impls for the `Unsize` trait are not permitted [E0328] + +fn main() {} diff --git a/src/test/ui/error-codes/E0328.stderr b/src/test/ui/error-codes/E0328.stderr new file mode 100644 index 0000000000000..ad3a224279ce5 --- /dev/null +++ b/src/test/ui/error-codes/E0328.stderr @@ -0,0 +1,9 @@ +error[E0328]: explicit impls for the `Unsize` trait are not permitted + --> $DIR/E0328.rs:17:1 + | +LL | impl Unsize for MyType {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `Unsize` not allowed + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0328`. diff --git a/src/test/ui/error-codes/E0401.rs b/src/test/ui/error-codes/E0401.rs index 15b946625778c..4fc74f5ef2219 100644 --- a/src/test/ui/error-codes/E0401.rs +++ b/src/test/ui/error-codes/E0401.rs @@ -11,14 +11,14 @@ trait Baz {} fn foo(x: T) { - fn bar, W: Fn()>(y: T) { //~ ERROR E0401 + fn bfnr, W: Fn()>(y: T) { //~ ERROR E0401 } fn baz, W: Fn()> (y: T) { //~ ERROR E0401 } - bar(x); + bfnr(x); } diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr index 42c79602cf3a7..5b66d1093408e 100644 --- a/src/test/ui/error-codes/E0401.stderr +++ b/src/test/ui/error-codes/E0401.stderr @@ -1,12 +1,12 @@ error[E0401]: can't use type parameters from outer function - --> $DIR/E0401.rs:14:38 + --> $DIR/E0401.rs:14:39 | LL | fn foo(x: T) { | - type variable from outer function -LL | fn bar, W: Fn()>(y: T) { //~ ERROR E0401 - | -------------------------- ^ use of type variable from outer function +LL | fn bfnr, W: Fn()>(y: T) { //~ ERROR E0401 + | --------------------------- ^ use of type variable from outer function | | - | help: try using a local type parameter instead: `bar, W: Fn(), T>` + | help: try using a local type parameter instead: `bfnr, W: Fn(), T>` error[E0401]: can't use type parameters from outer function --> $DIR/E0401.rs:19:16 @@ -14,10 +14,11 @@ error[E0401]: can't use type parameters from outer function LL | fn foo(x: T) { | - type variable from outer function ... +LL | fn baz $DIR/E0401.rs:32:25 diff --git a/src/test/ui/error-codes/E0522.rs b/src/test/ui/error-codes/E0522.rs index 3d4377853464b..c50cb759e05c2 100644 --- a/src/test/ui/error-codes/E0522.rs +++ b/src/test/ui/error-codes/E0522.rs @@ -15,3 +15,5 @@ fn cookie() -> ! { //~^^ ERROR definition of an unknown language item: `cookie` [E0522] loop {} } + +fn main() {} diff --git a/src/test/ui/error-codes/E0522.stderr b/src/test/ui/error-codes/E0522.stderr index 5a6331bca0bde..9f3f8968d734e 100644 --- a/src/test/ui/error-codes/E0522.stderr +++ b/src/test/ui/error-codes/E0522.stderr @@ -1,12 +1,9 @@ -error[E0601]: main function not found - error[E0522]: definition of an unknown language item: `cookie` --> $DIR/E0522.rs:13:1 | LL | #[lang = "cookie"] | ^^^^^^^^^^^^^^^^^^ definition of unknown language item `cookie` -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0522, E0601. -For more information about an error, try `rustc --explain E0522`. +For more information about this error, try `rustc --explain E0522`. diff --git a/src/test/ui/error-codes/E0601.rs b/src/test/ui/error-codes/E0601.rs new file mode 100644 index 0000000000000..37b3f523475fc --- /dev/null +++ b/src/test/ui/error-codes/E0601.rs @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test for main function not found. diff --git a/src/test/ui/error-codes/E0601.stderr b/src/test/ui/error-codes/E0601.stderr new file mode 100644 index 0000000000000..cbc20db35da77 --- /dev/null +++ b/src/test/ui/error-codes/E0601.stderr @@ -0,0 +1,7 @@ +error[E0601]: `main` function not found in crate `E0601` + | + = note: consider adding a `main` function to `$DIR/E0601.rs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/feature-gate-i128_type2.rs b/src/test/ui/feature-gate-i128_type2.rs index d3bd810ceb2b4..8a7d316ed8384 100644 --- a/src/test/ui/feature-gate-i128_type2.rs +++ b/src/test/ui/feature-gate-i128_type2.rs @@ -30,3 +30,5 @@ fn test3_2() { enum A { //~ ERROR 128-bit type is unstable A(u64) } + +fn main() {} diff --git a/src/test/ui/feature-gate-i128_type2.stderr b/src/test/ui/feature-gate-i128_type2.stderr index 2348e7fe2c5b3..23d4d6c98d90a 100644 --- a/src/test/ui/feature-gate-i128_type2.stderr +++ b/src/test/ui/feature-gate-i128_type2.stderr @@ -30,8 +30,6 @@ LL | let x: u128 = 0; //~ ERROR 128-bit type is unstable | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0601]: main function not found - error[E0658]: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:30:1 | @@ -42,7 +40,6 @@ LL | | } | = help: add #![feature(repr128)] to the crate attributes to enable -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors -Some errors occurred: E0601, E0658. -For more information about an error, try `rustc --explain E0601`. +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate-underscore-imports.rs b/src/test/ui/feature-gate-underscore-imports.rs new file mode 100644 index 0000000000000..ceb8afe124a8c --- /dev/null +++ b/src/test/ui/feature-gate-underscore-imports.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate std as _; //~ ERROR renaming extern crates with `_` is unstable +use std::vec as _; //~ ERROR renaming imports with `_` is unstable + +fn main() {} diff --git a/src/test/ui/feature-gate-underscore-imports.stderr b/src/test/ui/feature-gate-underscore-imports.stderr new file mode 100644 index 0000000000000..2eea95260d5e5 --- /dev/null +++ b/src/test/ui/feature-gate-underscore-imports.stderr @@ -0,0 +1,19 @@ +error[E0658]: renaming extern crates with `_` is unstable (see issue #48216) + --> $DIR/feature-gate-underscore-imports.rs:11:1 + | +LL | extern crate std as _; //~ ERROR renaming extern crates with `_` is unstable + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add #![feature(underscore_imports)] to the crate attributes to enable + +error[E0658]: renaming imports with `_` is unstable (see issue #48216) + --> $DIR/feature-gate-underscore-imports.rs:12:5 + | +LL | use std::vec as _; //~ ERROR renaming imports with `_` is unstable + | ^^^^^^^^^^^^^ + | + = help: add #![feature(underscore_imports)] to the crate attributes to enable + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-bench.rs b/src/test/ui/feature-gate/issue-43106-gating-of-bench.rs index a34f98f03559f..6c22679933874 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-bench.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-bench.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: main function not found +// error-pattern: `main` function not found // At time of authorship, a crate-level #![bench] with no `--test` // will cause compilation to error unconditionally with "main function diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr index f9f1cce91f1c7..503ef020d9604 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-bench.stderr @@ -1,4 +1,6 @@ -error[E0601]: main function not found +error[E0601]: `main` function not found in crate `issue_43106_gating_of_bench` + | + = note: consider adding a `main` function to `$DIR/issue-43106-gating-of-bench.rs` error: aborting due to previous error diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs b/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs index 24e77bf60a8d1..410f960e655fb 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-inline.rs @@ -35,3 +35,5 @@ mod inline { #[inline = "2100"] impl S { } //~^ ERROR attribute should be applied to function } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr index 36320be1dc81f..d67d78e31a9d5 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-inline.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error[E0518]: attribute should be applied to function --> $DIR/issue-43106-gating-of-inline.rs:21:1 | @@ -39,7 +37,6 @@ error[E0518]: attribute should be applied to function LL | #[inline = "2100"] impl S { } | ^^^^^^^^^^^^^^^^^^ ---------- not a function -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors -Some errors occurred: E0518, E0601. -For more information about an error, try `rustc --explain E0518`. +For more information about this error, try `rustc --explain E0518`. diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs index 3b2dbdefebad8..ec3c97beab0f3 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.rs @@ -13,5 +13,9 @@ // `#![macro_escape]` is incompatible with crate-level `#![macro_use]` // already present in issue-43106-gating-of-builtin-attrs. +// must-compile-successfully + #![macro_escape] //~^ WARN macro_escape is a deprecated synonym for macro_use + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr index d1d37720a55db..d19720397e66d 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-macro_escape.stderr @@ -1,13 +1,8 @@ warning: macro_escape is a deprecated synonym for macro_use - --> $DIR/issue-43106-gating-of-macro_escape.rs:16:1 + --> $DIR/issue-43106-gating-of-macro_escape.rs:18:1 | LL | #![macro_escape] | ^^^^^^^^^^^^^^^^ | = help: consider an outer attribute, #[macro_use] mod ... -error[E0601]: main function not found - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.rs b/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.rs index 133f70e0f3b19..5bb8bb024ed51 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.rs @@ -40,3 +40,5 @@ mod proc_macro_derive2 { #[proc_macro_derive = "2500"] impl S { } //~^ ERROR the `#[proc_macro_derive]` attribute may only be used on bare functions } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.stderr index c7654a3f258c9..419efb6825a97 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-proc_macro_derive.stderr @@ -34,8 +34,5 @@ error: the `#[proc_macro_derive]` attribute may only be used on bare functions LL | #[proc_macro_derive = "2500"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0601]: main function not found +error: aborting due to 6 previous errors -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.rs b/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.rs index 10c1398634923..0c6cfb5da565c 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.rs @@ -36,3 +36,4 @@ mod rustc_deprecated { //~^ ERROR stability attributes may not be used outside of the standard library } +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr index 5a1dd706ff3c9..35c15cb6b1ea8 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-rustc_deprecated.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error: stability attributes may not be used outside of the standard library --> $DIR/issue-43106-gating-of-rustc_deprecated.rs:17:1 | @@ -42,6 +40,5 @@ error: stability attributes may not be used outside of the standard library LL | #[rustc_deprecated = "1500"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-stable.rs b/src/test/ui/feature-gate/issue-43106-gating-of-stable.rs index a6eaabf7a383e..6415243d0873e 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-stable.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-stable.rs @@ -35,3 +35,5 @@ mod stable { #[stable = "1300"] impl S { } //~^ ERROR stability attributes may not be used outside of the standard library } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr index bee9b8e968200..21543d1b20afc 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-stable.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error: stability attributes may not be used outside of the standard library --> $DIR/issue-43106-gating-of-stable.rs:17:1 | @@ -42,6 +40,5 @@ error: stability attributes may not be used outside of the standard library LL | #[stable = "1300"] impl S { } | ^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-test.rs b/src/test/ui/feature-gate/issue-43106-gating-of-test.rs index adcbfe77280b7..06632396249a5 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-test.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-test.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: main function not found +// error-pattern: `main` function not found // At time of authorship, crate-level #[test] attribute with no // `--test` signals unconditional error complaining of missing main diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr index f9f1cce91f1c7..2ab35be43c576 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-test.stderr @@ -1,4 +1,6 @@ -error[E0601]: main function not found +error[E0601]: `main` function not found in crate `issue_43106_gating_of_test` + | + = note: consider adding a `main` function to `$DIR/issue-43106-gating-of-test.rs` error: aborting due to previous error diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs b/src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs index ff0600deb1936..140474d82c88d 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs +++ b/src/test/ui/feature-gate/issue-43106-gating-of-unstable.rs @@ -35,3 +35,5 @@ mod unstable { #[unstable = "1200"] impl S { } //~^ ERROR stability attributes may not be used outside of the standard library } + +fn main() {} diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr b/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr index 970cc2f2a349d..6124e16f41804 100644 --- a/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr +++ b/src/test/ui/feature-gate/issue-43106-gating-of-unstable.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error: stability attributes may not be used outside of the standard library --> $DIR/issue-43106-gating-of-unstable.rs:17:1 | @@ -42,6 +40,5 @@ error: stability attributes may not be used outside of the standard library LL | #[unstable = "1200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/generator/yield-in-const.rs b/src/test/ui/generator/yield-in-const.rs index e166d26515975..8636a66ae00ae 100644 --- a/src/test/ui/generator/yield-in-const.rs +++ b/src/test/ui/generator/yield-in-const.rs @@ -12,3 +12,5 @@ const A: u8 = { yield 3u8; 3u8}; //~^ ERROR yield statement outside + +fn main() {} diff --git a/src/test/ui/generator/yield-in-const.stderr b/src/test/ui/generator/yield-in-const.stderr index 41a20893f5c46..874edce593168 100644 --- a/src/test/ui/generator/yield-in-const.stderr +++ b/src/test/ui/generator/yield-in-const.stderr @@ -1,12 +1,9 @@ -error[E0601]: main function not found - error[E0627]: yield statement outside of generator literal --> $DIR/yield-in-const.rs:13:17 | LL | const A: u8 = { yield 3u8; 3u8}; | ^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0601, E0627. -For more information about an error, try `rustc --explain E0601`. +For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/generator/yield-in-static.rs b/src/test/ui/generator/yield-in-static.rs index 823a2aa425e2c..21601f47f677d 100644 --- a/src/test/ui/generator/yield-in-static.rs +++ b/src/test/ui/generator/yield-in-static.rs @@ -12,3 +12,5 @@ static B: u8 = { yield 3u8; 3u8}; //~^ ERROR yield statement outside + +fn main() {} diff --git a/src/test/ui/generator/yield-in-static.stderr b/src/test/ui/generator/yield-in-static.stderr index 71ebc189035a5..35d1ebaabdc1c 100644 --- a/src/test/ui/generator/yield-in-static.stderr +++ b/src/test/ui/generator/yield-in-static.stderr @@ -1,12 +1,9 @@ -error[E0601]: main function not found - error[E0627]: yield statement outside of generator literal --> $DIR/yield-in-static.rs:13:18 | LL | static B: u8 = { yield 3u8; 3u8}; | ^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0601, E0627. -For more information about an error, try `rustc --explain E0601`. +For more information about this error, try `rustc --explain E0627`. diff --git a/src/test/ui/imports/macro-paths.rs b/src/test/ui/imports/macro-paths.rs index 88a6e1c0d92e6..e709eeee14a84 100644 --- a/src/test/ui/imports/macro-paths.rs +++ b/src/test/ui/imports/macro-paths.rs @@ -36,3 +36,5 @@ fn g() { mod baz { pub use two_macros::m; } } } + +fn main() {} diff --git a/src/test/ui/imports/macro-paths.stderr b/src/test/ui/imports/macro-paths.stderr index 1422fb0904d0c..799e7f972464b 100644 --- a/src/test/ui/imports/macro-paths.stderr +++ b/src/test/ui/imports/macro-paths.stderr @@ -36,9 +36,6 @@ LL | | } | |_^ = note: macro-expanded items do not shadow when used in a macro invocation path -error[E0601]: main function not found +error: aborting due to 2 previous errors -error: aborting due to 3 previous errors - -Some errors occurred: E0601, E0659. -For more information about an error, try `rustc --explain E0601`. +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/imports/macros.rs b/src/test/ui/imports/macros.rs index 98577d73ee0f6..5d6a11913849a 100644 --- a/src/test/ui/imports/macros.rs +++ b/src/test/ui/imports/macros.rs @@ -49,3 +49,5 @@ mod m4 { use two_macros::m; m!(); //~ ERROR ambiguous } + +fn main() {} diff --git a/src/test/ui/imports/macros.stderr b/src/test/ui/imports/macros.stderr index d74020ecab298..f91987cd9f340 100644 --- a/src/test/ui/imports/macros.stderr +++ b/src/test/ui/imports/macros.stderr @@ -51,9 +51,6 @@ LL | use two_macros::m; | ^^^^^^^^^^^^^ = note: macro-expanded macro imports do not shadow -error[E0601]: main function not found +error: aborting due to 3 previous errors -error: aborting due to 4 previous errors - -Some errors occurred: E0601, E0659. -For more information about an error, try `rustc --explain E0601`. +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs index f845762cefd8b..ff04cfe99c0bc 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs @@ -20,3 +20,5 @@ impl Deref for Struct { } } //~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter + +fn main() {} diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr index a3d05e72ed9f5..37b586e1e3bd0 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements --> $DIR/mismatched_trait_impl-2.rs:18:5 | @@ -18,7 +16,6 @@ LL | | } expected fn(&Struct) -> &Trait + 'static found fn(&Struct) -> &Trait -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0495, E0601. -For more information about an error, try `rustc --explain E0495`. +For more information about this error, try `rustc --explain E0495`. diff --git a/src/test/ui/issue-47706-trait.rs b/src/test/ui/issue-47706-trait.rs index 86a9da49a054a..4ce653547da03 100644 --- a/src/test/ui/issue-47706-trait.rs +++ b/src/test/ui/issue-47706-trait.rs @@ -14,3 +14,5 @@ trait T { } //~^^ ERROR function is expected to take a single 0-tuple as argument } + +fn main() {} diff --git a/src/test/ui/issue-47706-trait.stderr b/src/test/ui/issue-47706-trait.stderr index 542ba50178067..717b3eb0b5625 100644 --- a/src/test/ui/issue-47706-trait.stderr +++ b/src/test/ui/issue-47706-trait.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error[E0593]: function is expected to take a single 0-tuple as argument, but it takes 2 distinct arguments --> $DIR/issue-47706-trait.rs:13:20 | @@ -8,7 +6,6 @@ LL | fn f(&self, _: ()) { LL | None::<()>.map(Self::f); | ^^^ expected function that takes a single 0-tuple as argument -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0593, E0601. -For more information about an error, try `rustc --explain E0593`. +For more information about this error, try `rustc --explain E0593`. diff --git a/src/test/ui/main-wrong-location.stderr b/src/test/ui/main-wrong-location.stderr index aad68de9ec794..a5ef92f14bbc5 100644 --- a/src/test/ui/main-wrong-location.stderr +++ b/src/test/ui/main-wrong-location.stderr @@ -1,4 +1,4 @@ -error[E0601]: main function not found +error[E0601]: `main` function not found in crate `main_wrong_location` | = note: the main function must be defined at the crate level but you have one or more functions named 'main' that are not defined at the crate level. Either move the definition or attach the `#[main]` attribute to override this behavior. note: here is a function named 'main' diff --git a/src/test/ui/missing-items/m2.rs b/src/test/ui/missing-items/m2.rs index 9f1954526916f..f655047f6f5ac 100644 --- a/src/test/ui/missing-items/m2.rs +++ b/src/test/ui/missing-items/m2.rs @@ -18,3 +18,5 @@ struct X { impl m1::X for X { //~ ERROR not all trait items implemented } + +fn main() {} diff --git a/src/test/ui/missing-items/m2.stderr b/src/test/ui/missing-items/m2.stderr index 1e4b47b44fabd..3f7a4039eb76b 100644 --- a/src/test/ui/missing-items/m2.stderr +++ b/src/test/ui/missing-items/m2.stderr @@ -1,5 +1,3 @@ -error[E0601]: main function not found - error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method` --> $DIR/m2.rs:19:1 | @@ -10,7 +8,6 @@ LL | impl m1::X for X { //~ ERROR not all trait items implemented = note: `Type` from trait: `type Type;` = note: `method` from trait: `fn(&Self, std::string::String) -> ::Type` -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors occurred: E0046, E0601. -For more information about an error, try `rustc --explain E0046`. +For more information about this error, try `rustc --explain E0046`. diff --git a/src/test/ui/resolve/issue-14254.rs b/src/test/ui/resolve/issue-14254.rs index 896085329ab94..eab500de25569 100644 --- a/src/test/ui/resolve/issue-14254.rs +++ b/src/test/ui/resolve/issue-14254.rs @@ -111,3 +111,5 @@ impl Foo for Box { //~^ ERROR cannot find value `bah` } } + +fn main() {} diff --git a/src/test/ui/resolve/issue-14254.stderr b/src/test/ui/resolve/issue-14254.stderr index 325e885084529..055cbb2d57916 100644 --- a/src/test/ui/resolve/issue-14254.stderr +++ b/src/test/ui/resolve/issue-14254.stderr @@ -142,9 +142,6 @@ error[E0425]: cannot find value `bah` in this scope LL | bah; | ^^^ help: try: `Self::bah` -error[E0601]: main function not found +error: aborting due to 24 previous errors -error: aborting due to 25 previous errors - -Some errors occurred: E0425, E0601. -For more information about an error, try `rustc --explain E0425`. +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/resolve/issue-21221-2.rs b/src/test/ui/resolve/issue-21221-2.rs index 4ddb4d669fcd2..361e8caf7442e 100644 --- a/src/test/ui/resolve/issue-21221-2.rs +++ b/src/test/ui/resolve/issue-21221-2.rs @@ -27,3 +27,5 @@ pub mod baz { struct Foo; impl T for Foo { } //~^ ERROR cannot find trait `T` + +fn main() {} diff --git a/src/test/ui/resolve/issue-21221-2.stderr b/src/test/ui/resolve/issue-21221-2.stderr index 50781d4379272..c61ffe3b33e8a 100644 --- a/src/test/ui/resolve/issue-21221-2.stderr +++ b/src/test/ui/resolve/issue-21221-2.stderr @@ -8,7 +8,5 @@ help: possible candidate is found in another module, you can import it into scop LL | use foo::bar::T; | -error[E0601]: main function not found - error: cannot continue compilation due to previous error diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs index 981a853a04056..d24fced5d313f 100644 --- a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs +++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.rs @@ -65,3 +65,5 @@ fn h8() -> i32 { a::b() //~^ ERROR expected function, found module `a::b` } + +fn main() {} diff --git a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr index 263319f2ffa9e..9216c0b321929 100644 --- a/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr +++ b/src/test/ui/resolve/suggest-path-instead-of-mod-dot-item.stderr @@ -72,9 +72,6 @@ LL | a::b() | | | did you mean `I`? -error[E0601]: main function not found +error: aborting due to 9 previous errors -error: aborting due to 10 previous errors - -Some errors occurred: E0423, E0601. -For more information about an error, try `rustc --explain E0423`. +For more information about this error, try `rustc --explain E0423`. diff --git a/src/test/ui/rfc-2166-underscore-imports/basic.rs b/src/test/ui/rfc-2166-underscore-imports/basic.rs new file mode 100644 index 0000000000000..06651a71d0c00 --- /dev/null +++ b/src/test/ui/rfc-2166-underscore-imports/basic.rs @@ -0,0 +1,67 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + +#![feature(underscore_imports)] +#![warn(unused_imports, unused_extern_crates)] + +struct S; + +mod m { + pub trait Tr1 { + fn tr1_is_in_scope(&self) {} + } + pub trait Tr2 { + fn tr2_is_in_scope(&self) {} + } + + impl Tr1 for ::S {} + impl Tr2 for ::S {} +} + +mod unused { + use m::Tr1 as _; //~ WARN unused import + use S as _; //~ WARN unused import + extern crate core as _; //~ WARN unused extern crate +} + +mod outer { + mod middle { + pub use m::Tr1 as _; + pub use m::Tr2 as _; // OK, no name conflict + struct Tr1; // OK, no name conflict + fn check() { + // Both traits are in scope + ::S.tr1_is_in_scope(); + ::S.tr2_is_in_scope(); + } + + mod inner { + // `_` imports are fetched by glob imports + use super::*; + fn check() { + // Both traits are in scope + ::S.tr1_is_in_scope(); + ::S.tr2_is_in_scope(); + } + } + } + + // `_` imports are fetched by glob imports + use self::middle::*; + fn check() { + // Both traits are in scope + ::S.tr1_is_in_scope(); + ::S.tr2_is_in_scope(); + } +} + +fn main() {} diff --git a/src/test/ui/rfc-2166-underscore-imports/basic.stderr b/src/test/ui/rfc-2166-underscore-imports/basic.stderr new file mode 100644 index 0000000000000..4530d0fa604aa --- /dev/null +++ b/src/test/ui/rfc-2166-underscore-imports/basic.stderr @@ -0,0 +1,30 @@ +warning: unused import: `m::Tr1 as _` + --> $DIR/basic.rs:31:9 + | +LL | use m::Tr1 as _; //~ WARN unused import + | ^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/basic.rs:14:9 + | +LL | #![warn(unused_imports, unused_extern_crates)] + | ^^^^^^^^^^^^^^ + +warning: unused import: `S as _` + --> $DIR/basic.rs:32:9 + | +LL | use S as _; //~ WARN unused import + | ^^^^^^ + +warning: unused extern crate + --> $DIR/basic.rs:33:5 + | +LL | extern crate core as _; //~ WARN unused extern crate + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/basic.rs:14:25 + | +LL | #![warn(unused_imports, unused_extern_crates)] + | ^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/ui/span/issue-27522.stderr b/src/test/ui/span/issue-27522.stderr index d0611bd580fe2..9b61ecae6512e 100644 --- a/src/test/ui/span/issue-27522.stderr +++ b/src/test/ui/span/issue-27522.stderr @@ -4,7 +4,7 @@ error[E0307]: invalid `self` type: &SomeType LL | fn handler(self: &SomeType); //~ ERROR invalid `self` type | ^^^^^^^^^ | - = note: type must be `Self` or a type that dereferences to it` + = note: type must be `Self` or a type that dereferences to it = help: consider changing to `self`, `&self`, `&mut self`, or `self: Box` error: aborting due to previous error diff --git a/src/test/ui/span/issue-35987.rs b/src/test/ui/span/issue-35987.rs index fa0410686c26c..19e05f33825f7 100644 --- a/src/test/ui/span/issue-35987.rs +++ b/src/test/ui/span/issue-35987.rs @@ -20,3 +20,5 @@ impl Add for Foo { unimplemented!(); } } + +fn main() {} diff --git a/src/test/ui/span/issue-35987.stderr b/src/test/ui/span/issue-35987.stderr index d3267d0cc1579..2d4a7cc72f5f6 100644 --- a/src/test/ui/span/issue-35987.stderr +++ b/src/test/ui/span/issue-35987.stderr @@ -8,7 +8,5 @@ help: possible better candidate is found in another module, you can import it in LL | use std::ops::Add; | -error[E0601]: main function not found - error: cannot continue compilation due to previous error diff --git a/src/test/ui/token/issue-10636-2.rs b/src/test/ui/token/issue-10636-2.rs index 4aa4127019378..711803754408f 100644 --- a/src/test/ui/token/issue-10636-2.rs +++ b/src/test/ui/token/issue-10636-2.rs @@ -17,3 +17,5 @@ pub fn trace_option(option: Option) { } //~ ERROR: incorrect close delimiter //~^ ERROR: expected expression, found `)` + +fn main() {} diff --git a/src/test/ui/token/issue-10636-2.stderr b/src/test/ui/token/issue-10636-2.stderr index 4b672f31d3851..56a30423171da 100644 --- a/src/test/ui/token/issue-10636-2.stderr +++ b/src/test/ui/token/issue-10636-2.stderr @@ -22,8 +22,5 @@ error: expected expression, found `)` LL | } //~ ERROR: incorrect close delimiter | ^ expected expression -error[E0601]: main function not found +error: aborting due to 3 previous errors -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0601`. diff --git a/src/test/ui/token/issue-41155.rs b/src/test/ui/token/issue-41155.rs index 550a90fc6af26..7bd8506af90b9 100644 --- a/src/test/ui/token/issue-41155.rs +++ b/src/test/ui/token/issue-41155.rs @@ -11,3 +11,5 @@ impl S { //~ ERROR cannot find type pub } //~ ERROR expected one of + +fn main() {} diff --git a/src/test/ui/token/issue-41155.stderr b/src/test/ui/token/issue-41155.stderr index 00155cc28734a..b56b95a8aafd7 100644 --- a/src/test/ui/token/issue-41155.stderr +++ b/src/test/ui/token/issue-41155.stderr @@ -12,9 +12,6 @@ error[E0412]: cannot find type `S` in this scope LL | impl S { //~ ERROR cannot find type | ^ not found in this scope -error[E0601]: main function not found +error: aborting due to 2 previous errors -error: aborting due to 3 previous errors - -Some errors occurred: E0412, E0601. -For more information about an error, try `rustc --explain E0412`. +For more information about this error, try `rustc --explain E0412`. diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index cf63cb2e5d901..0e3fa25b13ce9 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -40,6 +40,7 @@ const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[ ("i386", "x86"), ("i586", "x86"), ("i686", "x86"), + ("mips64", "mips64"), ("mips", "mips"), ("msp430", "msp430"), ("powerpc", "powerpc"),