diff --git a/README.md b/README.md index da6788824b034..a2acfe8b478e2 100644 --- a/README.md +++ b/README.md @@ -225,13 +225,16 @@ variety of channels on Mozilla's IRC network, irc.mozilla.org. The most popular channel is [#rust], a venue for general discussion about Rust. And a good place to ask for help would be [#rust-beginners]. -Also, the [rustc guide] might be a good place to start if you want to -find out how various parts of the compiler work. +The [rustc guide] might be a good place to start if you want to find out how +various parts of the compiler work. + +Also, you may find the [rustdocs for the compiler itself][rustdocs] useful. [IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat [#rust]: irc://irc.mozilla.org/rust [#rust-beginners]: irc://irc.mozilla.org/rust-beginners [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/about-this-guide.html +[rustdocs]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc/ ## License [license]: #license diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index c885c842e40e4..168cbde7e0d13 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -115,6 +115,7 @@ #![deny(warnings)] #![feature(core_intrinsics)] +#![feature(drain_filter)] #[macro_use] extern crate build_helper; diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 7dcdbe9c931cf..93b8880a900ef 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -631,6 +631,7 @@ impl Step for Openssl { "powerpc-unknown-netbsd" => "BSD-generic32", "powerpc64-unknown-linux-gnu" => "linux-ppc64", "powerpc64le-unknown-linux-gnu" => "linux-ppc64le", + "powerpc64le-unknown-linux-musl" => "linux-ppc64le", "s390x-unknown-linux-gnu" => "linux64-s390x", "sparc-unknown-linux-gnu" => "linux-sparcv9", "sparc64-unknown-linux-gnu" => "linux64-sparcv9", diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 32d1e428e7607..b3d7b9a91ecfe 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -13,6 +13,7 @@ use std::env; use std::iter; use std::path::PathBuf; use std::process::{Command, exit}; +use std::collections::HashSet; use Mode; use Compiler; @@ -122,8 +123,13 @@ impl Step for ToolBuild { let mut duplicates = Vec::new(); let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| { // Only care about big things like the RLS/Cargo for now - if tool != "rls" && tool != "cargo" && tool != "clippy-driver" { - return + match tool { + | "rls" + | "cargo" + | "clippy-driver" + => {} + + _ => return, } let (id, features, filenames) = match msg { compile::CargoMessage::CompilerArtifact { @@ -182,12 +188,22 @@ impl Step for ToolBuild { typically means that something was recompiled because \ a transitive dependency has different features activated \ than in a previous build:\n"); + println!("the following dependencies are duplicated although they \ + have the same features enabled:"); + for (id, cur, prev) in duplicates.drain_filter(|(_, cur, prev)| cur.2 == prev.2) { + println!(" {}", id); + // same features + println!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1); + } + println!("the following dependencies have different features:"); for (id, cur, prev) in duplicates { println!(" {}", id); - println!(" `{}` enabled features {:?} at {:?}", - cur.0, cur.2, cur.1); - println!(" `{}` enabled features {:?} at {:?}", - prev.0, prev.2, prev.1); + let cur_features: HashSet<_> = cur.2.into_iter().collect(); + let prev_features: HashSet<_> = prev.2.into_iter().collect(); + println!(" `{}` additionally enabled features {:?} at {:?}", + cur.0, &cur_features - &prev_features, cur.1); + println!(" `{}` additionally enabled features {:?} at {:?}", + prev.0, &prev_features - &cur_features, prev.1); } println!(""); panic!("tools should not compile multiple copies of the same crate"); diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 2abd9c85c5754..4244b09b18f9c 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -886,13 +886,14 @@ impl Arc { // holder. // // The acquire label here ensures a happens-before relationship with any - // writes to `strong` prior to decrements of the `weak` count (via drop, - // which uses Release). + // writes to `strong` (in particular in `Weak::upgrade`) prior to decrements + // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded + // weak ref was never dropped, the CAS here will fail so we do not care to synchronize. if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() { - // Due to the previous acquire read, this will observe any writes to - // `strong` that were due to upgrading weak pointers; only strong - // clones remain, which require that the strong count is > 1 anyway. - let unique = self.inner().strong.load(Relaxed) == 1; + // This needs to be an `Acquire` to synchronize with the decrement of the `strong` + // counter in `drop` -- the only access that happens when any but the last reference + // is being dropped. + let unique = self.inner().strong.load(Acquire) == 1; // The release write here synchronizes with a read in `downgrade`, // effectively preventing the above read of `strong` from happening diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 4437c36c15a5b..94f23db1ccc36 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -431,7 +431,7 @@ impl Any+Send+Sync { /// /// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth /// noting that the hashes and ordering will vary between Rust releases. Beware -/// of relying on them outside of your code! +/// of relying on them inside of your code! #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] #[stable(feature = "rust1", since = "1.0.0")] pub struct TypeId { diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 24595c9328208..ffd138c9c4815 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -7,7 +7,7 @@ use hir::def_id::DefId; use super::{EvalResult, Pointer, PointerArithmetic, Allocation}; -/// Represents a constant value in Rust. ByVal and ScalarPair are optimizations which +/// Represents a constant value in Rust. Scalar and ScalarPair are optimizations which /// matches Value's optimizations for easy conversions between these two types #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)] pub enum ConstValue<'tcx> { @@ -72,7 +72,7 @@ impl<'tcx> ConstValue<'tcx> { /// A `Value` represents a single self-contained Rust value. /// /// A `Value` can either refer to a block of memory inside an allocation (`ByRef`) or to a primitve -/// value held directly, outside of any allocation (`ByVal`). For `ByRef`-values, we remember +/// value held directly, outside of any allocation (`Scalar`). For `ByRef`-values, we remember /// whether the pointer is supposed to be aligned or not (also see Place). /// /// For optimization of a few very common cases, there is also a representation for a pair of diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 074cab3b5d251..b188f850575a6 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -98,6 +98,7 @@ pub enum Lto { #[derive(Clone, PartialEq, Hash)] pub enum CrossLangLto { LinkerPlugin(PathBuf), + LinkerPluginAuto, NoLink, Disabled } @@ -106,6 +107,7 @@ impl CrossLangLto { pub fn embed_bitcode(&self) -> bool { match *self { CrossLangLto::LinkerPlugin(_) | + CrossLangLto::LinkerPluginAuto | CrossLangLto::NoLink => true, CrossLangLto::Disabled => false, } @@ -1020,7 +1022,7 @@ macro_rules! options { let mut bool_arg = None; if parse_opt_bool(&mut bool_arg, v) { *slot = if bool_arg.unwrap() { - CrossLangLto::NoLink + CrossLangLto::LinkerPluginAuto } else { CrossLangLto::Disabled }; diff --git a/src/librustc_codegen_llvm/back/link.rs b/src/librustc_codegen_llvm/back/link.rs index 7e24e1114a0c2..70053cb7e9d80 100644 --- a/src/librustc_codegen_llvm/back/link.rs +++ b/src/librustc_codegen_llvm/back/link.rs @@ -816,8 +816,8 @@ fn link_natively(sess: &Session, if sess.target.target.options.is_like_msvc && linker_not_found { sess.note_without_error("the msvc targets depend on the msvc linker \ but `link.exe` was not found"); - sess.note_without_error("please ensure that VS 2013 or VS 2015 was installed \ - with the Visual C++ option"); + sess.note_without_error("please ensure that VS 2013, VS 2015 or VS 2017 \ + was installed with the Visual C++ option"); } sess.abort_if_errors(); } diff --git a/src/librustc_codegen_llvm/back/linker.rs b/src/librustc_codegen_llvm/back/linker.rs index dd1983bdc1723..fffde30d5f60c 100644 --- a/src/librustc_codegen_llvm/back/linker.rs +++ b/src/librustc_codegen_llvm/back/linker.rs @@ -182,6 +182,38 @@ impl<'a> GccLinker<'a> { self.hinted_static = false; } } + + fn push_cross_lang_lto_args(&mut self, plugin_path: Option<&OsStr>) { + if let Some(plugin_path) = plugin_path { + let mut arg = OsString::from("-plugin="); + arg.push(plugin_path); + self.linker_arg(&arg); + } + + let opt_level = match self.sess.opts.optimize { + config::OptLevel::No => "O0", + config::OptLevel::Less => "O1", + config::OptLevel::Default => "O2", + config::OptLevel::Aggressive => "O3", + config::OptLevel::Size => "Os", + config::OptLevel::SizeMin => "Oz", + }; + + self.linker_arg(&format!("-plugin-opt={}", opt_level)); + self.linker_arg(&format!("-plugin-opt=mcpu={}", self.sess.target_cpu())); + + match self.sess.opts.cg.lto { + config::Lto::Thin | + config::Lto::ThinLocal => { + self.linker_arg(&format!("-plugin-opt=thin")); + } + config::Lto::Fat | + config::Lto::Yes | + config::Lto::No => { + // default to regular LTO + } + } + } } impl<'a> Linker for GccLinker<'a> { @@ -443,32 +475,11 @@ impl<'a> Linker for GccLinker<'a> { CrossLangLto::NoLink => { // Nothing to do } + CrossLangLto::LinkerPluginAuto => { + self.push_cross_lang_lto_args(None); + } CrossLangLto::LinkerPlugin(ref path) => { - self.linker_arg(&format!("-plugin={}", path.display())); - - let opt_level = match self.sess.opts.optimize { - config::OptLevel::No => "O0", - config::OptLevel::Less => "O1", - config::OptLevel::Default => "O2", - config::OptLevel::Aggressive => "O3", - config::OptLevel::Size => "Os", - config::OptLevel::SizeMin => "Oz", - }; - - self.linker_arg(&format!("-plugin-opt={}", opt_level)); - self.linker_arg(&format!("-plugin-opt=mcpu={}", self.sess.target_cpu())); - - match self.sess.opts.cg.lto { - config::Lto::Thin | - config::Lto::ThinLocal => { - self.linker_arg(&format!("-plugin-opt=thin")); - } - config::Lto::Fat | - config::Lto::Yes | - config::Lto::No => { - // default to regular LTO - } - } + self.push_cross_lang_lto_args(Some(path.as_os_str())); } } } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 3a046cd800a3e..09c5df0005260 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -395,15 +395,8 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; let param_env = ty::ParamEnv::reveal_all(); - match tcx.const_eval(param_env.and(cid)) { - Ok(val) => collect_const(tcx, val, instance.substs, &mut neighbors), - Err(err) => { - let span = tcx.def_span(def_id); - err.report_as_error( - tcx.at(span), - "could not evaluate static initializer", - ); - } + if let Ok(val) = tcx.const_eval(param_env.and(cid)) { + collect_const(tcx, val, instance.substs, &mut neighbors); } } MonoItem::Fn(instance) => { diff --git a/src/librustc_target/spec/mod.rs b/src/librustc_target/spec/mod.rs index e54cd773123c8..49639915ee115 100644 --- a/src/librustc_target/spec/mod.rs +++ b/src/librustc_target/spec/mod.rs @@ -274,6 +274,7 @@ supported_targets! { ("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe), ("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu), ("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu), + ("powerpc64le-unknown-linux-musl", powerpc64le_unknown_linux_musl), ("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu), ("sparc-unknown-linux-gnu", sparc_unknown_linux_gnu), ("sparc64-unknown-linux-gnu", sparc64_unknown_linux_gnu), diff --git a/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs b/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs new file mode 100644 index 0000000000000..34ec82412289d --- /dev/null +++ b/src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs @@ -0,0 +1,35 @@ +// 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 spec::{LinkerFlavor, Target, TargetResult}; + +pub fn target() -> TargetResult { + let mut base = super::linux_musl_base::opts(); + base.cpu = "ppc64le".to_string(); + base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); + base.max_atomic_width = Some(64); + + // see #36994 + base.exe_allocation_crate = None; + + Ok(Target { + llvm_target: "powerpc64le-unknown-linux-musl".to_string(), + target_endian: "little".to_string(), + target_pointer_width: "64".to_string(), + target_c_int_width: "32".to_string(), + data_layout: "e-m:e-i64:64-n32:64".to_string(), + arch: "powerpc64".to_string(), + target_os: "linux".to_string(), + target_env: "musl".to_string(), + target_vendor: "unknown".to_string(), + linker_flavor: LinkerFlavor::Gcc, + options: base, + }) +} diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 7add0e21f548c..649ee0b781e48 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -108,7 +108,7 @@ pre { .content .highlighted { color: #eee !important; - background-color: #333; + background-color: #616161; } .content .highlighted a, .content .highlighted span { color: #eee !important; } .content .highlighted.trait { background-color: #013191; } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2ae0e669fd031..4c88325378793 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -421,7 +421,7 @@ declare_features! ( (active, wasm_custom_section, "1.26.0", Some(51088), None), // The #![wasm_import_module] attribute - (active, wasm_import_module, "1.26.0", Some(51088), None), + (active, wasm_import_module, "1.26.0", Some(52090), None), // Allows keywords to be escaped for use as identifiers (active, raw_identifiers, "1.26.0", Some(48589), None), diff --git a/src/llvm b/src/llvm index 1c817c7a0c828..509f29ac17874 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 1c817c7a0c828b8fc8e8e462afbe5db41c7052d1 +Subproject commit 509f29ac17874394acf4d49d6bae3cd93c652aa1 diff --git a/src/test/compile-fail/issue-14227.rs b/src/test/compile-fail/issue-14227.rs index 95f017061a257..250e78ce24640 100644 --- a/src/test/compile-fail/issue-14227.rs +++ b/src/test/compile-fail/issue-14227.rs @@ -16,7 +16,5 @@ extern { static CRASH: () = symbol; //~^ ERROR could not evaluate static initializer //~| tried to read from foreign (extern) static -//~^^^ ERROR could not evaluate static initializer -//~| tried to read from foreign (extern) static fn main() {} diff --git a/src/test/compile-fail/issue-28324.rs b/src/test/compile-fail/issue-28324.rs index 8512238dd31ca..af73db2b4d211 100644 --- a/src/test/compile-fail/issue-28324.rs +++ b/src/test/compile-fail/issue-28324.rs @@ -17,7 +17,5 @@ extern { pub static BAZ: u32 = *&error_message_count; //~^ ERROR could not evaluate static initializer //~| tried to read from foreign (extern) static -//~^^^ ERROR could not evaluate static initializer -//~| tried to read from foreign (extern) static fn main() {} diff --git a/src/test/run-pass/weird-exprs.rs b/src/test/run-pass/weird-exprs.rs index a15fbf377ecf6..35120e428a7bd 100644 --- a/src/test/run-pass/weird-exprs.rs +++ b/src/test/run-pass/weird-exprs.rs @@ -10,6 +10,8 @@ // compile-flags: -Z borrowck=compare +#![recursion_limit = "128"] + use std::cell::Cell; use std::mem::swap; @@ -121,6 +123,16 @@ fn special_characters() { assert!(!val); } +fn punch_card() -> impl std::fmt::Debug { + ..=..=.. .. .. .. .. .. .. .. .. .. .. ..=.. .. + ..=.. ..=.. .. .. .. .. .. .. .. .. ..=..=..=.. + ..=.. ..=.. ..=.. ..=.. .. ..=..=.. .. ..=.. .. + ..=..=.. .. ..=.. ..=.. ..=.. .. .. .. ..=.. .. + ..=.. ..=.. ..=.. ..=.. .. ..=.. .. .. ..=.. .. + ..=.. ..=.. ..=.. ..=.. .. .. ..=.. .. ..=.. .. + ..=.. ..=.. .. ..=..=.. ..=..=.. .. .. ..=.. .. +} + pub fn main() { strange(); funny(); @@ -135,4 +147,5 @@ pub fn main() { fishy(); union(); special_characters(); + punch_card(); } diff --git a/src/test/ui/const-eval/index_out_of_bounds.rs b/src/test/ui/const-eval/index_out_of_bounds.rs index 55c64d2b04e45..f3578bcef6e41 100644 --- a/src/test/ui/const-eval/index_out_of_bounds.rs +++ b/src/test/ui/const-eval/index_out_of_bounds.rs @@ -10,7 +10,6 @@ static FOO: i32 = [][0]; //~^ ERROR E0080 -//~| ERROR E0080 fn main() { let array = [std::env::args().len()]; diff --git a/src/test/ui/const-eval/index_out_of_bounds.stderr b/src/test/ui/const-eval/index_out_of_bounds.stderr index 828fba55a3afe..464ba8ff92723 100644 --- a/src/test/ui/const-eval/index_out_of_bounds.stderr +++ b/src/test/ui/const-eval/index_out_of_bounds.stderr @@ -4,22 +4,14 @@ error[E0080]: could not evaluate static initializer LL | static FOO: i32 = [][0]; | ^^^^^ index out of bounds: the len is 0 but the index is 0 -error[E0080]: could not evaluate static initializer - --> $DIR/index_out_of_bounds.rs:11:1 - | -LL | static FOO: i32 = [][0]; - | ^^^^^^^^^^^^^^^^^^-----^ - | | - | index out of bounds: the len is 0 but the index is 0 - error: index out of bounds: the len is 1 but the index is 1 - --> $DIR/index_out_of_bounds.rs:17:5 + --> $DIR/index_out_of_bounds.rs:16:5 | LL | array[1]; //~ ERROR index out of bounds | ^^^^^^^^ | = note: #[deny(const_err)] on by default -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/feature-gate-wasm_import_module.stderr b/src/test/ui/feature-gate-wasm_import_module.stderr index 02830a49f530f..5430f6b5825eb 100644 --- a/src/test/ui/feature-gate-wasm_import_module.stderr +++ b/src/test/ui/feature-gate-wasm_import_module.stderr @@ -1,4 +1,4 @@ -error[E0658]: experimental attribute (see issue #51088) +error[E0658]: experimental attribute (see issue #52090) --> $DIR/feature-gate-wasm_import_module.rs:11:1 | LL | #[wasm_import_module = "test"] //~ ERROR: experimental diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 4a1ba1736c2ed..b2aa5cfb444d9 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -88,6 +88,7 @@ static TARGETS: &'static [&'static str] = &[ "powerpc-unknown-linux-gnuspe", "powerpc64-unknown-linux-gnu", "powerpc64le-unknown-linux-gnu", + "powerpc64le-unknown-linux-musl", "s390x-unknown-linux-gnu", "sparc-unknown-linux-gnu", "sparc64-unknown-linux-gnu",