diff --git a/compiler/rustc_builtin_macros/src/standard_library_imports.rs b/compiler/rustc_builtin_macros/src/standard_library_imports.rs index f446e6be84ca4..fbd8be22a9de2 100644 --- a/compiler/rustc_builtin_macros/src/standard_library_imports.rs +++ b/compiler/rustc_builtin_macros/src/standard_library_imports.rs @@ -2,7 +2,7 @@ use rustc_ast as ast; use rustc_expand::base::{ExtCtxt, ResolverExpand}; use rustc_expand::expand::ExpansionConfig; use rustc_session::Session; -use rustc_span::edition::Edition; +use rustc_span::edition::Edition::*; use rustc_span::hygiene::AstPass; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::DUMMY_SP; @@ -13,7 +13,7 @@ pub fn inject( sess: &Session, alt_std_name: Option, ) -> ast::Crate { - let rust_2018 = sess.parse_sess.edition >= Edition::Edition2018; + let edition = sess.parse_sess.edition; // the first name in this list is the crate name of the crate with the prelude let names: &[Symbol] = if sess.contains_name(&krate.attrs, sym::no_core) { @@ -42,7 +42,11 @@ pub fn inject( // .rev() to preserve ordering above in combination with insert(0, ...) for &name in names.iter().rev() { - let ident = if rust_2018 { Ident::new(name, span) } else { Ident::new(name, call_site) }; + let ident = if edition >= Edition2018 { + Ident::new(name, span) + } else { + Ident::new(name, call_site) + }; krate.items.insert( 0, cx.item( @@ -58,14 +62,18 @@ pub fn inject( // the one with the prelude. let name = names[0]; - let import_path = if rust_2018 { - [name, sym::prelude, sym::v1].iter().map(|symbol| Ident::new(*symbol, span)).collect() - } else { - [kw::PathRoot, name, sym::prelude, sym::v1] - .iter() - .map(|symbol| Ident::new(*symbol, span)) - .collect() - }; + let root = (edition == Edition2015).then(|| kw::PathRoot); + + let import_path = root + .iter() + .chain(&[name, sym::prelude]) + .chain(&[match edition { + Edition2015 => sym::rust_2015, + Edition2018 => sym::rust_2018, + Edition2021 => sym::rust_2021, + }]) + .map(|&symbol| Ident::new(symbol, span)) + .collect(); let use_item = cx.item( span, diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs index 315e5d63d2bb3..f21545447b204 100644 --- a/compiler/rustc_middle/src/ty/relate.rs +++ b/compiler/rustc_middle/src/ty/relate.rs @@ -421,12 +421,14 @@ pub fn super_relate_tys>( let t = relation.relate(a_t, b_t)?; match relation.relate(sz_a, sz_b) { Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))), - // FIXME(#72219) Implement improved diagnostics for mismatched array - // length? - Err(err) if relation.tcx().lazy_normalization() => Err(err), Err(err) => { // Check whether the lengths are both concrete/known values, // but are unequal, for better diagnostics. + // + // It might seem dubious to eagerly evaluate these constants here, + // we however cannot end up with errors in `Relate` during both + // `type_of` and `predicates_of`. This means that evaluating the + // constants should not cause cycle errors here. let sz_a = sz_a.try_eval_usize(tcx, relation.param_env()); let sz_b = sz_b.try_eval_usize(tcx, relation.param_env()); match (sz_a, sz_b) { diff --git a/compiler/rustc_mir/src/interpret/step.rs b/compiler/rustc_mir/src/interpret/step.rs index 2bed3b2c3adc7..6084f67abd78e 100644 --- a/compiler/rustc_mir/src/interpret/step.rs +++ b/compiler/rustc_mir/src/interpret/step.rs @@ -160,7 +160,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let layout = self.layout_of(src.layout.ty.builtin_deref(true).unwrap().ty)?; let (size, align) = (layout.size, layout.align.abi); let size = size.checked_mul(count, self).ok_or_else(|| { - err_ub_format!("overflow computing total size of `copy_nonoverlapping`") + err_ub_format!( + "overflow computing total size of `{}`", + if nonoverlapping { "copy_nonoverlapping" } else { "copy" } + ) })?; // Make sure we check both pointers for an access of the total size and aligment, diff --git a/compiler/rustc_mir/src/lib.rs b/compiler/rustc_mir/src/lib.rs index bbfcec5a76a43..93c17057590e6 100644 --- a/compiler/rustc_mir/src/lib.rs +++ b/compiler/rustc_mir/src/lib.rs @@ -25,7 +25,7 @@ Rust MIR: a lowered representation of Rust. #![feature(stmt_expr_attributes)] #![feature(trait_alias)] #![feature(option_expect_none)] -#![feature(option_get_or_default)] +#![feature(option_get_or_insert_default)] #![feature(or_patterns)] #![feature(once_cell)] #![feature(control_flow_enum)] diff --git a/compiler/rustc_mir/src/transform/coverage/graph.rs b/compiler/rustc_mir/src/transform/coverage/graph.rs index 8ad0d133b17e1..6f5fa858e2537 100644 --- a/compiler/rustc_mir/src/transform/coverage/graph.rs +++ b/compiler/rustc_mir/src/transform/coverage/graph.rs @@ -392,7 +392,8 @@ impl BasicCoverageBlockData { } } let operand = counter_kind.as_operand_id(); - if let Some(replaced) = self.edge_from_bcbs.get_or_default().insert(from_bcb, counter_kind) + if let Some(replaced) = + self.edge_from_bcbs.get_or_insert_default().insert(from_bcb, counter_kind) { Error::from_string(format!( "attempt to set an edge counter more than once; from_bcb: \ diff --git a/compiler/rustc_span/src/edition.rs b/compiler/rustc_span/src/edition.rs index a9200dd7dfd6e..8544acd6d05ee 100644 --- a/compiler/rustc_span/src/edition.rs +++ b/compiler/rustc_span/src/edition.rs @@ -20,7 +20,7 @@ pub enum Edition { Edition2015, /// The 2018 edition Edition2018, - /// The 2021 ediiton + /// The 2021 edition Edition2021, } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 90c5fd422cd51..79ca3c194cc82 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -959,8 +959,11 @@ symbols! { rt, rtm_target_feature, rust, + rust_2015, rust_2015_preview, + rust_2018, rust_2018_preview, + rust_2021, rust_2021_preview, rust_begin_unwind, rust_eh_catch_typeinfo, diff --git a/compiler/rustc_target/src/spec/crt_objects.rs b/compiler/rustc_target/src/spec/crt_objects.rs index 51a48147e6b62..2fc9ab29f92f4 100644 --- a/compiler/rustc_target/src/spec/crt_objects.rs +++ b/compiler/rustc_target/src/spec/crt_objects.rs @@ -108,11 +108,13 @@ pub(super) fn post_mingw() -> CrtObjects { } pub(super) fn pre_wasi_fallback() -> CrtObjects { + // Use crt1-command.o instead of crt1.o to enable support for new-style + // commands. See https://reviews.llvm.org/D81689 for more info. new(&[ - (LinkOutputKind::DynamicNoPicExe, &["crt1.o"]), - (LinkOutputKind::DynamicPicExe, &["crt1.o"]), - (LinkOutputKind::StaticNoPicExe, &["crt1.o"]), - (LinkOutputKind::StaticPicExe, &["crt1.o"]), + (LinkOutputKind::DynamicNoPicExe, &["crt1-command.o"]), + (LinkOutputKind::DynamicPicExe, &["crt1-command.o"]), + (LinkOutputKind::StaticNoPicExe, &["crt1-command.o"]), + (LinkOutputKind::StaticPicExe, &["crt1-command.o"]), (LinkOutputKind::WasiReactorExe, &["crt1-reactor.o"]), ]) } diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 9478e7f06bdf3..f1a0f455cd091 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -854,19 +854,17 @@ impl Option { // Entry-like operations to insert if None and return a reference ///////////////////////////////////////////////////////////////////////// - /// Inserts the default value into the option if it is [`None`], then + /// Inserts `value` into the option if it is [`None`], then /// returns a mutable reference to the contained value. /// /// # Examples /// /// ``` - /// #![feature(option_get_or_default)] - /// /// let mut x = None; /// /// { - /// let y: &mut u32 = x.get_or_default(); - /// assert_eq!(y, &0); + /// let y: &mut u32 = x.get_or_insert(5); + /// assert_eq!(y, &5); /// /// *y = 7; /// } @@ -874,25 +872,24 @@ impl Option { /// assert_eq!(x, Some(7)); /// ``` #[inline] - #[unstable(feature = "option_get_or_default", issue = "82901")] - pub fn get_or_default(&mut self) -> &mut T - where - T: Default, - { - self.get_or_insert_with(Default::default) + #[stable(feature = "option_entry", since = "1.20.0")] + pub fn get_or_insert(&mut self, value: T) -> &mut T { + self.get_or_insert_with(|| value) } - /// Inserts `value` into the option if it is [`None`], then + /// Inserts the default value into the option if it is [`None`], then /// returns a mutable reference to the contained value. /// /// # Examples /// /// ``` + /// #![feature(option_get_or_insert_default)] + /// /// let mut x = None; /// /// { - /// let y: &mut u32 = x.get_or_insert(5); - /// assert_eq!(y, &5); + /// let y: &mut u32 = x.get_or_insert_default(); + /// assert_eq!(y, &0); /// /// *y = 7; /// } @@ -900,9 +897,12 @@ impl Option { /// assert_eq!(x, Some(7)); /// ``` #[inline] - #[stable(feature = "option_entry", since = "1.20.0")] - pub fn get_or_insert(&mut self, value: T) -> &mut T { - self.get_or_insert_with(|| value) + #[unstable(feature = "option_get_or_insert_default", issue = "82901")] + pub fn get_or_insert_default(&mut self) -> &mut T + where + T: Default, + { + self.get_or_insert_with(Default::default) } /// Inserts a value computed from `f` into the option if it is [`None`], diff --git a/library/core/src/prelude/mod.rs b/library/core/src/prelude/mod.rs index 51f4acf068580..8f57db49496c3 100644 --- a/library/core/src/prelude/mod.rs +++ b/library/core/src/prelude/mod.rs @@ -1,5 +1,41 @@ //! The libcore prelude +//! +//! This module is intended for users of libcore which do not link to libstd as +//! well. This module is imported by default when `#![no_std]` is used in the +//! same manner as the standard library's prelude. #![stable(feature = "core_prelude", since = "1.4.0")] pub mod v1; + +/// The 2015 version of the core prelude. +/// +/// See the [module-level documentation](self) for more. +#[unstable(feature = "prelude_2015", issue = "none")] +pub mod rust_2015 { + #[unstable(feature = "prelude_2015", issue = "none")] + #[doc(no_inline)] + pub use super::v1::*; +} + +/// The 2018 version of the core prelude. +/// +/// See the [module-level documentation](self) for more. +#[unstable(feature = "prelude_2018", issue = "none")] +pub mod rust_2018 { + #[unstable(feature = "prelude_2018", issue = "none")] + #[doc(no_inline)] + pub use super::v1::*; +} + +/// The 2021 version of the core prelude. +/// +/// See the [module-level documentation](self) for more. +#[unstable(feature = "prelude_2021", issue = "none")] +pub mod rust_2021 { + #[unstable(feature = "prelude_2021", issue = "none")] + #[doc(no_inline)] + pub use super::v1::*; + + // FIXME: Add more things. +} diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index 5e8a8d252a238..c7cb2a69ff73c 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -1,8 +1,6 @@ -//! The core prelude +//! The first version of the core prelude. //! -//! This module is intended for users of libcore which do not link to libstd as -//! well. This module is imported by default when `#![no_std]` is used in the -//! same manner as the standard library's prelude. +//! See the [module-level documentation](super) for more. #![stable(feature = "core_prelude", since = "1.4.0")] diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 247d39743bef5..8149858e10338 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -302,6 +302,7 @@ #![feature(panic_internals)] #![feature(panic_unwind)] #![feature(pin_static_ref)] +#![feature(prelude_2021)] #![feature(prelude_import)] #![feature(ptr_internals)] #![feature(raw)] diff --git a/library/std/src/prelude/mod.rs b/library/std/src/prelude/mod.rs index eb2095b819657..505b5f3013b35 100644 --- a/library/std/src/prelude/mod.rs +++ b/library/std/src/prelude/mod.rs @@ -84,3 +84,37 @@ #![stable(feature = "rust1", since = "1.0.0")] pub mod v1; + +/// The 2015 version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[unstable(feature = "prelude_2015", issue = "none")] +pub mod rust_2015 { + #[unstable(feature = "prelude_2015", issue = "none")] + #[doc(no_inline)] + pub use super::v1::*; +} + +/// The 2018 version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[unstable(feature = "prelude_2018", issue = "none")] +pub mod rust_2018 { + #[unstable(feature = "prelude_2018", issue = "none")] + #[doc(no_inline)] + pub use super::v1::*; +} + +/// The 2021 version of the prelude of The Rust Standard Library. +/// +/// See the [module-level documentation](self) for more. +#[unstable(feature = "prelude_2021", issue = "none")] +pub mod rust_2021 { + #[unstable(feature = "prelude_2021", issue = "none")] + #[doc(no_inline)] + pub use super::v1::*; + + #[unstable(feature = "prelude_2021", issue = "none")] + #[doc(no_inline)] + pub use core::prelude::rust_2021::*; +} diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index 7181dc6e710e4..ec89bb6d2a48f 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -1,6 +1,6 @@ //! The first version of the prelude of The Rust Standard Library. //! -//! See the [module-level documentation](../index.html) for more. +//! See the [module-level documentation](super) for more. #![stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/sys/unix/ext/process.rs b/library/std/src/sys/unix/ext/process.rs index 4e170a8bb1cb3..1276edc6af6c8 100644 --- a/library/std/src/sys/unix/ext/process.rs +++ b/library/std/src/sys/unix/ext/process.rs @@ -62,9 +62,14 @@ pub trait CommandExt: Sealed { /// `fork`. This primarily means that any modifications made to memory on /// behalf of this closure will **not** be visible to the parent process. /// This is often a very constrained environment where normal operations - /// like `malloc` or acquiring a mutex are not guaranteed to work (due to + /// like `malloc`, accessing environment variables through [`std::env`] + /// or acquiring a mutex are not guaranteed to work (due to /// other threads perhaps still running when the `fork` was run). /// + /// For further details refer to the [POSIX fork() specification] + /// and the equivalent documentation for any targeted + /// platform, especially the requirements around *async-signal-safety*. + /// /// This also means that all resources such as file descriptors and /// memory-mapped regions got duplicated. It is your responsibility to make /// sure that the closure does not violate library invariants by making @@ -73,6 +78,10 @@ pub trait CommandExt: Sealed { /// When this closure is run, aspects such as the stdio file descriptors and /// working directory have successfully been changed, so output to these /// locations may not appear where intended. + /// + /// [POSIX fork() specification]: + /// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html + /// [`std::env`]: mod@crate::env #[stable(feature = "process_pre_exec", since = "1.34.0")] unsafe fn pre_exec(&mut self, f: F) -> &mut process::Command where diff --git a/library/std/src/sys/unix/process/process_unix.rs b/library/std/src/sys/unix/process/process_unix.rs index 2fdbabae2775f..2eb64a99e599a 100644 --- a/library/std/src/sys/unix/process/process_unix.rs +++ b/library/std/src/sys/unix/process/process_unix.rs @@ -1,6 +1,7 @@ use crate::convert::TryInto; use crate::fmt; use crate::io::{self, Error, ErrorKind}; +use crate::mem; use crate::ptr; use crate::sys; use crate::sys::cvt; @@ -45,15 +46,14 @@ impl Command { // // Note that as soon as we're done with the fork there's no need to hold // a lock any more because the parent won't do anything and the child is - // in its own process. - let result = unsafe { - let _env_lock = sys::os::env_lock(); - cvt(libc::fork())? - }; + // in its own process. Thus the parent drops the lock guard while the child + // forgets it to avoid unlocking it on a new thread, which would be invalid. + let (env_lock, result) = unsafe { (sys::os::env_lock(), cvt(libc::fork())?) }; let pid = unsafe { match result { 0 => { + mem::forget(env_lock); drop(input); let Err(err) = self.do_exec(theirs, envp.as_ref()); let errno = err.raw_os_error().unwrap_or(libc::EINVAL) as u32; @@ -74,7 +74,10 @@ impl Command { rtassert!(output.write(&bytes).is_ok()); libc::_exit(1) } - n => n, + n => { + drop(env_lock); + n + } } }; diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 24800b7886d94..9398f211721b8 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -210,7 +210,7 @@ fn copy_self_contained_objects( panic!("Target {:?} does not have a \"wasi-root\" key", target.triple) }) .join("lib/wasm32-wasi"); - for &obj in &["crt1.o", "crt1-reactor.o"] { + for &obj in &["crt1-command.o", "crt1-reactor.o"] { copy_and_stamp( builder, &libdir_self_contained, diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index ccc51c243ad8b..1505fe0369d86 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -1093,6 +1093,7 @@ fn markdown_summary_with_limit(md: &str, length_limit: usize) -> (String, bool) Tag::Emphasis => s.push_str(""), Tag::Strong => s.push_str(""), Tag::Paragraph => break, + Tag::Heading(..) => break, _ => {} }, Event::HardBreak | Event::SoftBreak => { diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs index e2ce9ad23f478..ac3ea4c8c5f6f 100644 --- a/src/librustdoc/html/markdown/tests.rs +++ b/src/librustdoc/html/markdown/tests.rs @@ -235,6 +235,7 @@ fn test_short_markdown_summary() { t("code `let x = i32;` ...", "code let x = i32; …"); t("type `Type<'static>` ...", "type Type<'static> …"); t("# top header", "top header"); + t("# top header\n\nfollowed by a paragraph", "top header"); t("## header", "header"); t("first paragraph\n\nsecond paragraph", "first paragraph"); t("```\nfn main() {}\n```", ""); diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 2331f4d20a84f..a4621fb8ed555 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -286,11 +286,7 @@ impl Serialize for TypeWithKind { where S: Serializer, { - let mut seq = serializer.serialize_seq(None)?; - seq.serialize_element(&self.ty.name)?; - let x: ItemType = self.kind.into(); - seq.serialize_element(&x)?; - seq.end() + (&self.ty.name, ItemType::from(self.kind)).serialize(serializer) } } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index d5071cec0c83d..42519d596225b 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2188,7 +2188,7 @@ function defocusSearchBar() { return "+"; } // button will collapse the section - // note that this text is also set in the HTML template in render.rs + // note that this text is also set in the HTML template in ../render/mod.rs return "\u2212"; // "\u2212" is "−" minus sign } @@ -2831,17 +2831,10 @@ function defocusSearchBar() { }); } - function enableSearchInput() { - if (search_input) { - search_input.removeAttribute('disabled'); - } - } - function addSearchOptions(crates) { var elem = document.getElementById("crate-search"); if (!elem) { - enableSearchInput(); return; } var savedCrate = getSettingValue("saved-filter-crate"); @@ -2860,7 +2853,6 @@ function defocusSearchBar() { elem.value = savedCrate; } } - enableSearchInput(); }; function buildHelperPopup() { @@ -2952,7 +2944,7 @@ function defocusSearchBar() { search_input.addEventListener("blur", function() { search_input.placeholder = search_input.origPlaceholder; }); - enableSearchInput(); + search_input.removeAttribute('disabled'); var crateSearchDropDown = document.getElementById("crate-search"); crateSearchDropDown.addEventListener("focus", loadSearch); diff --git a/src/test/pretty/asm.pp b/src/test/pretty/asm.pp index b3d188dd70881..c86d8a1197188 100644 --- a/src/test/pretty/asm.pp +++ b/src/test/pretty/asm.pp @@ -2,7 +2,7 @@ #![no_std] #![feature(asm)] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; diff --git a/src/test/pretty/cast-lt.pp b/src/test/pretty/cast-lt.pp index 47a7dac95b9c5..4f6a924909029 100644 --- a/src/test/pretty/cast-lt.pp +++ b/src/test/pretty/cast-lt.pp @@ -1,7 +1,7 @@ #![feature(prelude_import)] #![no_std] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; // pretty-compare-only diff --git a/src/test/pretty/dollar-crate.pp b/src/test/pretty/dollar-crate.pp index 131cd0a67c669..f4be3c1c63a84 100644 --- a/src/test/pretty/dollar-crate.pp +++ b/src/test/pretty/dollar-crate.pp @@ -1,7 +1,7 @@ #![feature(prelude_import)] #![no_std] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; // pretty-compare-only diff --git a/src/test/pretty/expanded-and-path-remap-80832.pp b/src/test/pretty/expanded-and-path-remap-80832.pp index 6dbc19e9d9c6c..1579ea41cfdf1 100644 --- a/src/test/pretty/expanded-and-path-remap-80832.pp +++ b/src/test/pretty/expanded-and-path-remap-80832.pp @@ -1,7 +1,7 @@ #![feature(prelude_import)] #![no_std] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; // Test for issue 80832 diff --git a/src/test/pretty/issue-12590-c.pp b/src/test/pretty/issue-12590-c.pp index 1761c0653ce86..dd0b8899b2d9d 100644 --- a/src/test/pretty/issue-12590-c.pp +++ b/src/test/pretty/issue-12590-c.pp @@ -1,7 +1,7 @@ #![feature(prelude_import)] #![no_std] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; // pretty-compare-only diff --git a/src/test/pretty/issue-4264.pp b/src/test/pretty/issue-4264.pp index 7b0a00282fbb0..199aee05622be 100644 --- a/src/test/pretty/issue-4264.pp +++ b/src/test/pretty/issue-4264.pp @@ -1,5 +1,5 @@ #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; // pretty-compare-only diff --git a/src/test/ui/ast-json/ast-json-output.stdout b/src/test/ui/ast-json/ast-json-output.stdout index d26530efe3ecd..535f57bf6af85 100644 --- a/src/test/ui/ast-json/ast-json-output.stdout +++ b/src/test/ui/ast-json/ast-json-output.stdout @@ -1 +1 @@ -{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"kind":{"variant":"Interpolated","fields":[{"variant":"NtExpr","fields":[{"id":0,"kind":{"variant":"Lit","fields":[{"token":{"kind":"Str","symbol":"lib","suffix":null},"kind":{"variant":"Str","fields":["lib","Cooked"]},"span":{"lo":0,"hi":0}}]},"span":{"lo":0,"hi":0},"attrs":{"0":null},"tokens":{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}}]}]},"span":{"lo":0,"hi":0}}]},"tokens":null},{"0":[[{"variant":"Token","fields":[{"kind":"Pound","span":{"lo":0,"hi":0}}]},"Joint"],[{"variant":"Token","fields":[{"kind":"Not","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Delimited","fields":[{"open":{"lo":0,"hi":0},"close":{"lo":0,"hi":0}},"Bracket",{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate_type",false]},"span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":"Eq","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"Alone"]]}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null},null]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null},null]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"span":{"lo":0,"hi":0},"proc_macros":[]} +{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"kind":{"variant":"Interpolated","fields":[{"variant":"NtExpr","fields":[{"id":0,"kind":{"variant":"Lit","fields":[{"token":{"kind":"Str","symbol":"lib","suffix":null},"kind":{"variant":"Str","fields":["lib","Cooked"]},"span":{"lo":0,"hi":0}}]},"span":{"lo":0,"hi":0},"attrs":{"0":null},"tokens":{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}}]}]},"span":{"lo":0,"hi":0}}]},"tokens":null},{"0":[[{"variant":"Token","fields":[{"kind":"Pound","span":{"lo":0,"hi":0}}]},"Joint"],[{"variant":"Token","fields":[{"kind":"Not","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Delimited","fields":[{"open":{"lo":0,"hi":0},"close":{"lo":0,"hi":0}},"Bracket",{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Ident","fields":["crate_type",false]},"span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":"Eq","span":{"lo":0,"hi":0}}]},"Alone"],[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"Alone"]]}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null},null]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"rust_2015","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null},null]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"span":{"lo":0,"hi":0},"proc_macros":[]} diff --git a/src/test/ui/command/command-pre-exec.rs b/src/test/ui/command/command-pre-exec.rs index 8fc6a220331f0..819ed0b2ddef7 100644 --- a/src/test/ui/command/command-pre-exec.rs +++ b/src/test/ui/command/command-pre-exec.rs @@ -43,20 +43,6 @@ fn main() { assert!(output.stderr.is_empty()); assert_eq!(output.stdout, b"hello\nhello2\n"); - let output = unsafe { - Command::new(&me) - .arg("test2") - .pre_exec(|| { - env::set_var("FOO", "BAR"); - Ok(()) - }) - .output() - .unwrap() - }; - assert!(output.status.success()); - assert!(output.stderr.is_empty()); - assert!(output.stdout.is_empty()); - let output = unsafe { Command::new(&me) .arg("test3") diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr index a35c3abc113b9..6ef698bd6a04f 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr +++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:7:67 + --> $DIR/const-argument-cross-crate-mismatch.rs:9:67 | LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8])); | ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:9:65 + --> $DIR/const-argument-cross-crate-mismatch.rs:11:65 | LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]); | ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr index a35c3abc113b9..6ef698bd6a04f 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr +++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:7:67 + --> $DIR/const-argument-cross-crate-mismatch.rs:9:67 | LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8])); | ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements error[E0308]: mismatched types - --> $DIR/const-argument-cross-crate-mismatch.rs:9:65 + --> $DIR/const-argument-cross-crate-mismatch.rs:11:65 | LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]); | ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs index 9ae2ae50ba0ab..a8f533eceaa6d 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs +++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs @@ -1,5 +1,7 @@ // aux-build:const_generic_lib.rs // revisions: full min +#![cfg_attr(full, feature(const_generics))] +#![cfg_attr(full, allow(incomplete_features))] extern crate const_generic_lib; diff --git a/src/test/ui/consts/copy-intrinsic.rs b/src/test/ui/consts/copy-intrinsic.rs index 6b46b9317d0a1..9dc595f37faae 100644 --- a/src/test/ui/consts/copy-intrinsic.rs +++ b/src/test/ui/consts/copy-intrinsic.rs @@ -1,6 +1,6 @@ // ignore-tidy-linelength #![feature(const_mut_refs, const_intrinsic_copy, const_ptr_offset)] -use std::ptr; +use std::{ptr, mem}; const COPY_ZERO: () = unsafe { // Since we are not copying anything, this should be allowed. @@ -26,6 +26,20 @@ const COPY_OOB_2: () = unsafe { //~| previously accepted }; +const COPY_SIZE_OVERFLOW: () = unsafe { + let x = 0; + let mut y = 0; + ptr::copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); //~ ERROR any use of this value will cause an error + //~| overflow computing total size of `copy` + //~| previously accepted +}; +const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe { + let x = 0; + let mut y = 0; + ptr::copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); //~ ERROR any use of this value will cause an error + //~| overflow computing total size of `copy_nonoverlapping` + //~| previously accepted +}; fn main() { } diff --git a/src/test/ui/consts/copy-intrinsic.stderr b/src/test/ui/consts/copy-intrinsic.stderr index 9157ba50ddeeb..2736cdeac690e 100644 --- a/src/test/ui/consts/copy-intrinsic.stderr +++ b/src/test/ui/consts/copy-intrinsic.stderr @@ -33,5 +33,37 @@ LL | | }; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 -error: aborting due to 2 previous errors +error: any use of this value will cause an error + --> $DIR/copy-intrinsic.rs:32:5 + | +LL | / const COPY_SIZE_OVERFLOW: () = unsafe { +LL | | let x = 0; +LL | | let mut y = 0; +LL | | ptr::copy(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy` +LL | | +LL | | +LL | | }; + | |__- + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 + +error: any use of this value will cause an error + --> $DIR/copy-intrinsic.rs:39:5 + | +LL | / const COPY_NONOVERLAPPING_SIZE_OVERFLOW: () = unsafe { +LL | | let x = 0; +LL | | let mut y = 0; +LL | | ptr::copy_nonoverlapping(&x, &mut y, 1usize << (mem::size_of::() * 8 - 1)); + | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow computing total size of `copy_nonoverlapping` +LL | | +LL | | +LL | | }; + | |__- + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 + +error: aborting due to 4 previous errors diff --git a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr index 016c48118b3ce..4cda07758527a 100644 --- a/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr +++ b/src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr @@ -24,10 +24,10 @@ LL | extern crate std as Vec; LL | define_vec!(); | -------------- in this macro invocation note: `Vec` could also refer to the struct defined here - --> $SRC_DIR/std/src/prelude/v1.rs:LL:COL + --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | -LL | pub use crate::vec::Vec; - | ^^^^^^^^^^^^^^^ +LL | pub use super::v1::*; + | ^^^^^^^^^^^^ = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-27033.stderr b/src/test/ui/issues/issue-27033.stderr index ad48fc23a386b..fa42611d0b32e 100644 --- a/src/test/ui/issues/issue-27033.stderr +++ b/src/test/ui/issues/issue-27033.stderr @@ -4,10 +4,10 @@ error[E0530]: match bindings cannot shadow unit variants LL | None @ _ => {} | ^^^^ cannot be named the same as a unit variant | - ::: $SRC_DIR/std/src/prelude/v1.rs:LL:COL + ::: $SRC_DIR/std/src/prelude/mod.rs:LL:COL | -LL | pub use crate::option::Option::{self, None, Some}; - | ---- the unit variant `None` is defined here +LL | pub use super::v1::*; + | ------------ the unit variant `None` is defined here error[E0530]: match bindings cannot shadow constants --> $DIR/issue-27033.rs:7:9 diff --git a/src/test/ui/issues/issue-60662.stdout b/src/test/ui/issues/issue-60662.stdout index cebe834824a61..14a49f20e6b22 100644 --- a/src/test/ui/issues/issue-60662.stdout +++ b/src/test/ui/issues/issue-60662.stdout @@ -3,7 +3,7 @@ #![feature(type_alias_impl_trait)] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; diff --git a/src/test/ui/proc-macro/meta-macro-hygiene.stdout b/src/test/ui/proc-macro/meta-macro-hygiene.stdout index a067b7b5411dd..aa51fc8240d63 100644 --- a/src/test/ui/proc-macro/meta-macro-hygiene.stdout +++ b/src/test/ui/proc-macro/meta-macro-hygiene.stdout @@ -15,7 +15,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro #![no_std /* 0#0 */] #[prelude_import /* 0#1 */] -use core /* 0#1 */::prelude /* 0#1 */::v1 /* 0#1 */::*; +use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*; #[macro_use /* 0#1 */] extern crate core /* 0#1 */; #[macro_use /* 0#1 */] diff --git a/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout b/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout index 1623d67772639..ba3b3ee782784 100644 --- a/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -35,7 +35,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ #![no_std /* 0#0 */] #[prelude_import /* 0#1 */] -use ::core /* 0#1 */::prelude /* 0#1 */::v1 /* 0#1 */::*; +use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*; #[macro_use /* 0#1 */] extern crate core /* 0#2 */; #[macro_use /* 0#1 */] diff --git a/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout b/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout index c88f50c6813ec..aeee43b01cc02 100644 --- a/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout +++ b/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout @@ -1,7 +1,7 @@ #![feature(prelude_import)] #![no_std] #[prelude_import] -use ::std::prelude::v1::*; +use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; // build-pass (FIXME(62277): could be check-pass?)