diff --git a/README.md b/README.md index 7eb5e8067eda2..cb1f06257ed15 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ Read ["Installation"] from [The Book]. 3. Build and install: ```sh - $ git submodule update --init --recursive --progress $ ./x.py build && sudo ./x.py install ``` diff --git a/RELEASES.md b/RELEASES.md index aae25ab9988e9..83c44774da283 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -121,6 +121,12 @@ Stabilized APIs - [`i64::from_be_bytes`] - [`i64::from_le_bytes`] - [`i64::from_ne_bytes`] +- [`i128::to_be_bytes`] +- [`i128::to_le_bytes`] +- [`i128::to_ne_bytes`] +- [`i128::from_be_bytes`] +- [`i128::from_le_bytes`] +- [`i128::from_ne_bytes`] - [`isize::to_be_bytes`] - [`isize::to_le_bytes`] - [`isize::to_ne_bytes`] @@ -151,6 +157,12 @@ Stabilized APIs - [`u64::from_be_bytes`] - [`u64::from_le_bytes`] - [`u64::from_ne_bytes`] +- [`u128::to_be_bytes`] +- [`u128::to_le_bytes`] +- [`u128::to_ne_bytes`] +- [`u128::from_be_bytes`] +- [`u128::from_le_bytes`] +- [`u128::from_ne_bytes`] - [`usize::to_be_bytes`] - [`usize::to_le_bytes`] - [`usize::to_ne_bytes`] @@ -208,6 +220,12 @@ Compatibility Notes [`UnsafeCell::get`]: https://doc.rust-lang.org/std/cell/struct.UnsafeCell.html#method.get [`slice::as_ptr`]: https://doc.rust-lang.org/std/primitive.slice.html#method.as_ptr [`char::is_ascii`]: https://doc.rust-lang.org/std/primitive.char.html#method.is_ascii +[`i128::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.from_be_bytes +[`i128::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.from_le_bytes +[`i128::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.from_ne_bytes +[`i128::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.to_be_bytes +[`i128::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.to_le_bytes +[`i128::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i128.html#method.to_ne_bytes [`i16::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_be_bytes [`i16::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_le_bytes [`i16::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.i16.html#method.from_ne_bytes @@ -240,6 +258,12 @@ Compatibility Notes [`isize::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.isize.html#method.to_ne_bytes [`iter::empty`]: https://doc.rust-lang.org/std/iter/fn.empty.html [`str::as_ptr`]: https://doc.rust-lang.org/std/primitive.str.html#method.as_ptr +[`u128::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.from_be_bytes +[`u128::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.from_le_bytes +[`u128::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.from_ne_bytes +[`u128::to_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.to_be_bytes +[`u128::to_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.to_le_bytes +[`u128::to_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u128.html#method.to_ne_bytes [`u16::from_be_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.from_be_bytes [`u16::from_le_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.from_le_bytes [`u16::from_ne_bytes`]: https://doc.rust-lang.org/stable/std/primitive.u16.html#method.from_ne_bytes diff --git a/config.toml.example b/config.toml.example index c68d358b6a67e..23943d34b7ca8 100644 --- a/config.toml.example +++ b/config.toml.example @@ -288,7 +288,7 @@ #codegen-units-std = 1 # Whether or not debug assertions are enabled for the compiler and standard -# library. Also enables compilation of debug! and trace! logging macros. +# library. #debug-assertions = false # Whether or not debuginfo is emitted diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 7ddfc385fc0fe..cb9c86df55080 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -346,15 +346,13 @@ fn configure_cmake(builder: &Builder, if builder.config.llvm_clang_cl.is_some() && target.contains("i686") { cfg.env("SCCACHE_EXTRA_ARGS", "-m32"); } - - // If ccache is configured we inform the build a little differently how - // to invoke ccache while also invoking our compilers. - } else if let Some(ref ccache) = builder.config.ccache { - cfg.define("CMAKE_C_COMPILER", ccache) - .define("CMAKE_C_COMPILER_ARG1", sanitize_cc(cc)) - .define("CMAKE_CXX_COMPILER", ccache) - .define("CMAKE_CXX_COMPILER_ARG1", sanitize_cc(cxx)); } else { + // If ccache is configured we inform the build a little differently how + // to invoke ccache while also invoking our compilers. + if let Some(ref ccache) = builder.config.ccache { + cfg.define("CMAKE_C_COMPILER_LAUNCHER", ccache) + .define("CMAKE_CXX_COMPILER_LAUNCHER", ccache); + } cfg.define("CMAKE_C_COMPILER", sanitize_cc(cc)) .define("CMAKE_CXX_COMPILER", sanitize_cc(cxx)); } diff --git a/src/doc/unstable-book/src/language-features/irrefutable-let-patterns.md b/src/doc/unstable-book/src/language-features/irrefutable-let-patterns.md deleted file mode 100644 index 46b843778e810..0000000000000 --- a/src/doc/unstable-book/src/language-features/irrefutable-let-patterns.md +++ /dev/null @@ -1,28 +0,0 @@ -# `irrefutable_let_patterns` - -The tracking issue for this feature is: [#44495] - -[#44495]: https://github.com/rust-lang/rust/issues/44495 - ------------------------- - -This feature changes the way that "irrefutable patterns" are handled -in the `if let` and `while let` forms. An *irrefutable pattern* is one -that cannot fail to match -- for example, the `_` pattern matches any -value, and hence it is "irrefutable". Without this feature, using an -irrefutable pattern in an `if let` gives a hard error (since often -this indicates programmer error). But when the feature is enabled, the -error becomes a lint (since in some cases irrefutable patterns are -expected). This means you can use `#[allow]` to silence the lint: - -```rust -#![feature(irrefutable_let_patterns)] - -#[allow(irrefutable_let_patterns)] -fn main() { - // These two examples used to be errors, but now they - // trigger a lint (that is allowed): - if let _ = 5 {} - while let _ = 5 { break; } -} -``` diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index b69c114ed4594..e1c5ab15bb5ce 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -738,53 +738,88 @@ impl Vec { self } - /// Sets the length of a vector. + /// Forces the length of the vector to `new_len`. /// - /// This will explicitly set the size of the vector, without actually - /// modifying its buffers, so it is up to the caller to ensure that the - /// vector is actually the specified size. + /// This is a low-level operation that maintains none of the normal + /// invariants of the type. Normally changing the length of a vector + /// is done using one of the safe operations instead, such as + /// [`truncate`], [`resize`], [`extend`], or [`clear`]. /// - /// # Examples + /// [`truncate`]: #method.truncate + /// [`resize`]: #method.resize + /// [`extend`]: #method.extend-1 + /// [`clear`]: #method.clear /// - /// ``` - /// use std::ptr; + /// # Safety /// - /// let mut vec = vec!['r', 'u', 's', 't']; + /// - `new_len` must be less than or equal to [`capacity()`]. + /// - The elements at `old_len..new_len` must be initialized. /// - /// unsafe { - /// ptr::drop_in_place(&mut vec[3]); - /// vec.set_len(3); + /// [`capacity()`]: #method.capacity + /// + /// # Examples + /// + /// This method can be useful for situations in which the vector + /// is serving as a buffer for other code, particularly over FFI: + /// + /// ```no_run + /// # #![allow(dead_code)] + /// # // This is just a minimal skeleton for the doc example; + /// # // don't use this as a starting point for a real library. + /// # pub struct StreamWrapper { strm: *mut std::ffi::c_void } + /// # const Z_OK: i32 = 0; + /// # extern "C" { + /// # fn deflateGetDictionary( + /// # strm: *mut std::ffi::c_void, + /// # dictionary: *mut u8, + /// # dictLength: *mut usize, + /// # ) -> i32; + /// # } + /// # impl StreamWrapper { + /// pub fn get_dictionary(&self) -> Option> { + /// // Per the FFI method's docs, "32768 bytes is always enough". + /// let mut dict = Vec::with_capacity(32_768); + /// let mut dict_length = 0; + /// // SAFETY: When `deflateGetDictionary` returns `Z_OK`, it holds that: + /// // 1. `dict_length` elements were initialized. + /// // 2. `dict_length` <= the capacity (32_768) + /// // which makes `set_len` safe to call. + /// unsafe { + /// // Make the FFI call... + /// let r = deflateGetDictionary(self.strm, dict.as_mut_ptr(), &mut dict_length); + /// if r == Z_OK { + /// // ...and update the length to what was initialized. + /// dict.set_len(dict_length); + /// Some(dict) + /// } else { + /// None + /// } + /// } /// } - /// assert_eq!(vec, ['r', 'u', 's']); + /// # } /// ``` /// - /// In this example, there is a memory leak since the memory locations - /// owned by the inner vectors were not freed prior to the `set_len` call: + /// While the following example is sound, there is a memory leak since + /// the inner vectors were not freed prior to the `set_len` call: /// /// ``` /// let mut vec = vec![vec![1, 0, 0], /// vec![0, 1, 0], /// vec![0, 0, 1]]; + /// // SAFETY: + /// // 1. `old_len..0` is empty so no elements need to be initialized. + /// // 2. `0 <= capacity` always holds whatever `capacity` is. /// unsafe { /// vec.set_len(0); /// } /// ``` /// - /// In this example, the vector gets expanded from zero to four items - /// without any memory allocations occurring, resulting in vector - /// values of unallocated memory: - /// - /// ``` - /// let mut vec: Vec = Vec::new(); - /// - /// unsafe { - /// vec.set_len(4); - /// } - /// ``` + /// Normally, here, one would use [`clear`] instead to correctly drop + /// the contents and thus not leak memory. #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub unsafe fn set_len(&mut self, len: usize) { - self.len = len; + pub unsafe fn set_len(&mut self, new_len: usize) { + self.len = new_len; } /// Removes an element from the vector and returns it. diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 55a72d7a9a94d..02eef07afd7ab 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -849,6 +849,7 @@ pub unsafe fn write_unaligned(dst: *mut T, src: T) { /// [valid]: ../ptr/index.html#safety /// [`Copy`]: ../marker/trait.Copy.html /// [`read`]: ./fn.read.html +/// [read-ownership]: ./fn.read.html#ownership-of-the-returned-value /// /// Just like in C, whether an operation is volatile has no bearing whatsoever /// on questions involving concurrent access from multiple threads. Volatile diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 689d456d41246..bdde187d931cc 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -20,8 +20,7 @@ pub mod pattern; #[allow(missing_docs)] pub mod lossy; -/// A trait to abstract the idea of creating a new instance of a type from a -/// string. +/// Parse a value from a string /// /// `FromStr`'s [`from_str`] method is often used implicitly, through /// [`str`]'s [`parse`] method. See [`parse`]'s documentation for examples. @@ -30,6 +29,11 @@ pub mod lossy; /// [`str`]: ../../std/primitive.str.html /// [`parse`]: ../../std/primitive.str.html#method.parse /// +/// `FromStr` does not have a lifetime parameter, and so you can only parse types +/// that do not contain a lifetime parameter themselves. In other words, you can +/// parse an `i32` with `FromStr`, but not a `&i32`. You can parse a struct that +/// contains an `i32`, but not one that contains an `&i32`. +/// /// # Examples /// /// Basic implementation of `FromStr` on an example `Point` type: diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index fb2c873d740ca..0a8c72a0ad8ec 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -17,8 +17,6 @@ pub enum CrateNum { // FIXME(jseyfried): this is also used for custom derives until proc-macro crates get // `CrateNum`s. BuiltinMacros, - /// A CrateNum value that indicates that something is wrong. - Invalid, /// A special CrateNum that we use for the tcx.rcache when decoding from /// the incr. comp. cache. ReservedForIncrCompCache, @@ -29,7 +27,6 @@ impl ::std::fmt::Debug for CrateNum { fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { match self { CrateNum::Index(id) => write!(fmt, "crate{}", id.private), - CrateNum::Invalid => write!(fmt, "invalid crate"), CrateNum::BuiltinMacros => write!(fmt, "builtin macros crate"), CrateNum::ReservedForIncrCompCache => write!(fmt, "crate for decoding incr comp cache"), } @@ -90,7 +87,6 @@ impl fmt::Display for CrateNum { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { CrateNum::Index(id) => fmt::Display::fmt(&id.private, f), - CrateNum::Invalid => write!(f, "invalid crate"), CrateNum::BuiltinMacros => write!(f, "builtin macros crate"), CrateNum::ReservedForIncrCompCache => write!(f, "crate for decoding incr comp cache"), } diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 22854382df15c..c428ff1bd1b37 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -286,7 +286,7 @@ declare_lint! { declare_lint! { pub IRREFUTABLE_LET_PATTERNS, - Deny, + Warn, "detects irrefutable patterns in if-let and while-let statements" } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index c0ba4329ae05c..8d4b8aae8b176 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -417,6 +417,12 @@ pub struct TypeckTables<'tcx> { /// All the existential types that are restricted to concrete types /// by this function pub concrete_existential_types: FxHashMap>, + + /// Given the closure ID this map provides the list of UpvarIDs used by it. + /// The upvarID contains the HIR node ID and it also contains the full path + /// leading to the member of the struct or tuple that is used instead of the + /// entire variable. + pub upvar_list: ty::UpvarListMap, } impl<'tcx> TypeckTables<'tcx> { @@ -441,6 +447,7 @@ impl<'tcx> TypeckTables<'tcx> { tainted_by_errors: false, free_region_map: Default::default(), concrete_existential_types: Default::default(), + upvar_list: Default::default(), } } @@ -741,6 +748,8 @@ impl<'a, 'gcx> HashStable> for TypeckTables<'gcx> { tainted_by_errors, ref free_region_map, ref concrete_existential_types, + ref upvar_list, + } = *self; hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { @@ -783,6 +792,7 @@ impl<'a, 'gcx> HashStable> for TypeckTables<'gcx> { tainted_by_errors.hash_stable(hcx, hasher); free_region_map.hash_stable(hcx, hasher); concrete_existential_types.hash_stable(hcx, hasher); + upvar_list.hash_stable(hcx, hasher); }) } } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 171c53b7b20ba..1162bff852cbb 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1842,7 +1842,11 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { return Ok(None); } } - if let FieldPlacement::Array { .. } = layout.fields { + if let FieldPlacement::Array { count: original_64_bit_count, .. } = layout.fields { + // rust-lang/rust#57038: avoid ICE within FieldPlacement::count when count too big + if original_64_bit_count > usize::max_value() as u64 { + return Err(LayoutError::SizeOverflow(layout.ty)); + } if layout.fields.count() > 0 { return self.find_niche(layout.field(self, 0)?); } else { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index a2c96e7cf9f66..cfd99948e4370 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -808,6 +808,7 @@ pub struct UpvarBorrow<'tcx> { pub region: ty::Region<'tcx>, } +pub type UpvarListMap = FxHashMap>; pub type UpvarCaptureMap<'tcx> = FxHashMap>; #[derive(Copy, Clone)] diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 727b769cf4d44..65ae111fbc0fc 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -4,7 +4,7 @@ use hair::cx::Cx; use hair::{LintLevel, BindingMode, PatternKind}; use rustc::hir; use rustc::hir::Node; -use rustc::hir::def_id::{DefId, LocalDefId}; +use rustc::hir::def_id::DefId; use rustc::middle::region; use rustc::mir::*; use rustc::mir::visit::{MutVisitor, TyContext}; @@ -640,21 +640,29 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, let arguments: Vec<_> = arguments.collect(); let tcx = hir.tcx(); - let span = tcx.hir().span(fn_id); + let tcx_hir = tcx.hir(); + let span = tcx_hir.span(fn_id); + + let hir_tables = hir.tables(); + let fn_def_id = tcx_hir.local_def_id(fn_id); // Gather the upvars of a closure, if any. - let upvar_decls: Vec<_> = tcx.with_freevars(fn_id, |freevars| { - freevars.iter().map(|fv| { - let var_id = fv.var_id(); - let var_hir_id = tcx.hir().node_to_hir_id(var_id); - let closure_expr_id = tcx.hir().local_def_id(fn_id); - let capture = hir.tables().upvar_capture(ty::UpvarId { - var_path: ty::UpvarPath {hir_id: var_hir_id}, - closure_expr_id: LocalDefId::from_def_id(closure_expr_id), - }); + // In analyze_closure() in upvar.rs we gathered a list of upvars used by a + // closure and we stored in a map called upvar_list in TypeckTables indexed + // with the closure's DefId. Here, we run through that vec of UpvarIds for + // the given closure and use the necessary information to create UpvarDecl. + let upvar_decls: Vec<_> = hir_tables + .upvar_list + .get(&fn_def_id) + .into_iter() + .flatten() + .map(|upvar_id| { + let var_hir_id = upvar_id.var_path.hir_id; + let var_node_id = tcx_hir.hir_to_node_id(var_hir_id); + let capture = hir_tables.upvar_capture(*upvar_id); let by_ref = match capture { ty::UpvarCapture::ByValue => false, - ty::UpvarCapture::ByRef(..) => true + ty::UpvarCapture::ByRef(..) => true, }; let mut decl = UpvarDecl { debug_name: keywords::Invalid.name(), @@ -662,10 +670,9 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, by_ref, mutability: Mutability::Not, }; - if let Some(Node::Binding(pat)) = tcx.hir().find(var_id) { + if let Some(Node::Binding(pat)) = tcx_hir.find(var_node_id) { if let hir::PatKind::Binding(_, _, ident, _) = pat.node { decl.debug_name = ident.name; - if let Some(&bm) = hir.tables.pat_binding_modes().get(pat.hir_id) { if bm == ty::BindByValue(hir::MutMutable) { decl.mutability = Mutability::Mut; @@ -678,8 +685,8 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, } } decl - }).collect() - }); + }) + .collect(); let mut builder = Builder::new(hir, span, @@ -689,7 +696,6 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, return_ty_span, upvar_decls); - let fn_def_id = tcx.hir().local_def_id(fn_id); let call_site_scope = region::Scope { id: body.value.hir_id.local_id, data: region::ScopeData::CallSite @@ -732,7 +738,7 @@ fn construct_fn<'a, 'gcx, 'tcx, A>(hir: Cx<'a, 'gcx, 'tcx>, // RustCall pseudo-ABI untuples the last argument. spread_arg = Some(Local::new(arguments.len())); } - let closure_expr_id = tcx.hir().local_def_id(fn_id); + let closure_expr_id = tcx_hir.local_def_id(fn_id); info!("fn_id {:?} has attrs {:?}", closure_expr_id, tcx.get_attrs(closure_expr_id)); diff --git a/src/librustc_mir/diagnostics.rs b/src/librustc_mir/diagnostics.rs index 7e8ac3fb72006..a324761f06ab5 100644 --- a/src/librustc_mir/diagnostics.rs +++ b/src/librustc_mir/diagnostics.rs @@ -325,11 +325,13 @@ match Some(42) { "##, E0162: r##" +#### Note: this error code is no longer emitted by the compiler. + An if-let pattern attempts to match the pattern, and enters the body if the match was successful. If the match is irrefutable (when it cannot fail to match), use a regular `let`-binding instead. For instance: -```compile_fail,E0162 +```compile_pass struct Irrefutable(i32); let irr = Irrefutable(0); @@ -352,11 +354,13 @@ println!("{}", x); "##, E0165: r##" +#### Note: this error code is no longer emitted by the compiler. + A while-let pattern attempts to match the pattern, and enters the body if the match was successful. If the match is irrefutable (when it cannot fail to match), use a regular `let`-binding inside a `loop` instead. For instance: -```compile_fail,E0165 +```compile_pass,no_run struct Irrefutable(i32); let irr = Irrefutable(0); @@ -2334,7 +2338,7 @@ local variable that already exists, and hence no temporary is created. Temporaries are not always dropped at the end of the enclosing statement. In simple cases where the `&` expression is immediately stored into a variable, the compiler will automatically extend -the lifetime of the temporary until the end of the enclosinb +the lifetime of the temporary until the end of the enclosing block. Therefore, an alternative way to fix the original program is to write `let tmp = &foo()` and not `let tmp = foo()`: diff --git a/src/librustc_mir/hair/pattern/check_match.rs b/src/librustc_mir/hair/pattern/check_match.rs index c104af7a7d81b..10213beba2a6d 100644 --- a/src/librustc_mir/hair/pattern/check_match.rs +++ b/src/librustc_mir/hair/pattern/check_match.rs @@ -350,7 +350,6 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, { let mut seen = Matrix::empty(); let mut catchall = None; - let mut printed_if_let_err = false; for (arm_index, &(ref pats, guard)) in arms.iter().enumerate() { for &(pat, hir_pat) in pats { let v = smallvec![pat]; @@ -359,27 +358,12 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, NotUseful => { match source { hir::MatchSource::IfLetDesugar { .. } => { - if cx.tcx.features().irrefutable_let_patterns { - cx.tcx.lint_node( - lint::builtin::IRREFUTABLE_LET_PATTERNS, - hir_pat.id, pat.span, - "irrefutable if-let pattern"); - } else { - if printed_if_let_err { - // we already printed an irrefutable if-let pattern error. - // We don't want two, that's just confusing. - } else { - // find the first arm pattern so we can use its span - let &(ref first_arm_pats, _) = &arms[0]; - let first_pat = &first_arm_pats[0]; - let span = first_pat.0.span; - struct_span_err!(cx.tcx.sess, span, E0162, - "irrefutable if-let pattern") - .span_label(span, "irrefutable pattern") - .emit(); - printed_if_let_err = true; - } - } + cx.tcx.lint_node( + lint::builtin::IRREFUTABLE_LET_PATTERNS, + hir_pat.id, + pat.span, + "irrefutable if-let pattern", + ); } hir::MatchSource::WhileLetDesugar => { @@ -394,21 +378,12 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>, }, // The arm with the wildcard pattern. 1 => { - if cx.tcx.features().irrefutable_let_patterns { - cx.tcx.lint_node( - lint::builtin::IRREFUTABLE_LET_PATTERNS, - hir_pat.id, pat.span, - "irrefutable while-let pattern"); - } else { - // find the first arm pattern so we can use its span - let &(ref first_arm_pats, _) = &arms[0]; - let first_pat = &first_arm_pats[0]; - let span = first_pat.0.span; - struct_span_err!(cx.tcx.sess, span, E0165, - "irrefutable while-let pattern") - .span_label(span, "irrefutable pattern") - .emit(); - } + cx.tcx.lint_node( + lint::builtin::IRREFUTABLE_LET_PATTERNS, + hir_pat.id, + pat.span, + "irrefutable while-let pattern", + ); }, _ => bug!(), } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index a04dd5bb5970f..193b0fe05f002 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -21,7 +21,7 @@ use rustc::mir::visit::{PlaceContext, Visitor, MutatingUseContext, NonMutatingUs use rustc::middle::lang_items; use rustc::session::config::nightly_options; use syntax::ast::LitKind; -use syntax::feature_gate::{UnstableFeatures, feature_err, emit_feature_err, GateIssue}; +use syntax::feature_gate::{UnstableFeatures, emit_feature_err, GateIssue}; use syntax_pos::{Span, DUMMY_SP}; use std::fmt; @@ -104,7 +104,6 @@ struct Qualifier<'a, 'gcx: 'a+'tcx, 'tcx: 'a> { param_env: ty::ParamEnv<'tcx>, local_qualif: IndexVec>, qualif: Qualif, - const_fn_arg_vars: BitSet, temp_promotion_state: IndexVec, promotion_candidates: Vec } @@ -139,7 +138,6 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { param_env, local_qualif, qualif: Qualif::empty(), - const_fn_arg_vars: BitSet::new_empty(mir.local_decls.len()), temp_promotion_state: temps, promotion_candidates: vec![] } @@ -168,26 +166,6 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { } } - /// Error about extra statements in a constant. - fn statement_like(&mut self) { - self.add(Qualif::NOT_CONST); - if self.mode != Mode::Fn { - let mut err = feature_err( - &self.tcx.sess.parse_sess, - "const_let", - self.span, - GateIssue::Language, - &format!("statements in {}s are unstable", self.mode), - ); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("Blocks in constants may only contain items (such as constant, function \ - definition, etc...) and a tail expression."); - err.help("To avoid it, you have to replace the non-item object."); - } - err.emit(); - } - } - /// Add the given qualification to self.qualif. fn add(&mut self, qualif: Qualif) { self.qualif = self.qualif | qualif; @@ -233,80 +211,46 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { return; } - if self.tcx.features().const_let { - let mut dest = dest; - let index = loop { - match dest { - // with `const_let` active, we treat all locals equal - Place::Local(index) => break *index, - // projections are transparent for assignments - // we qualify the entire destination at once, even if just a field would have - // stricter qualification - Place::Projection(proj) => { - // Catch more errors in the destination. `visit_place` also checks various - // projection rules like union field access and raw pointer deref - self.visit_place( - dest, - PlaceContext::MutatingUse(MutatingUseContext::Store), - location - ); - dest = &proj.base; - }, - Place::Promoted(..) => bug!("promoteds don't exist yet during promotion"), - Place::Static(..) => { - // Catch more errors in the destination. `visit_place` also checks that we - // do not try to access statics from constants or try to mutate statics - self.visit_place( - dest, - PlaceContext::MutatingUse(MutatingUseContext::Store), - location - ); - return; - } + let mut dest = dest; + let index = loop { + match dest { + // We treat all locals equal in constants + Place::Local(index) => break *index, + // projections are transparent for assignments + // we qualify the entire destination at once, even if just a field would have + // stricter qualification + Place::Projection(proj) => { + // Catch more errors in the destination. `visit_place` also checks various + // projection rules like union field access and raw pointer deref + self.visit_place( + dest, + PlaceContext::MutatingUse(MutatingUseContext::Store), + location + ); + dest = &proj.base; + }, + Place::Promoted(..) => bug!("promoteds don't exist yet during promotion"), + Place::Static(..) => { + // Catch more errors in the destination. `visit_place` also checks that we + // do not try to access statics from constants or try to mutate statics + self.visit_place( + dest, + PlaceContext::MutatingUse(MutatingUseContext::Store), + location + ); + return; } - }; - debug!("store to var {:?}", index); - match &mut self.local_qualif[index] { - // this is overly restrictive, because even full assignments do not clear the qualif - // While we could special case full assignments, this would be inconsistent with - // aggregates where we overwrite all fields via assignments, which would not get - // that feature. - Some(ref mut qualif) => *qualif = *qualif | self.qualif, - // insert new qualification - qualif @ None => *qualif = Some(self.qualif), - } - return; - } - - match *dest { - Place::Local(index) if self.mir.local_kind(index) == LocalKind::Temp || - self.mir.local_kind(index) == LocalKind::ReturnPointer => { - debug!("store to {:?} (temp or return pointer)", index); - store(&mut self.local_qualif[index]) - } - - Place::Projection(box Projection { - base: Place::Local(index), - elem: ProjectionElem::Deref - }) if self.mir.local_kind(index) == LocalKind::Temp - && self.mir.local_decls[index].ty.is_box() - && self.local_qualif[index].map_or(false, |qualif| { - qualif.contains(Qualif::NOT_CONST) - }) => { - // Part of `box expr`, we should've errored - // already for the Box allocation Rvalue. - } - - // This must be an explicit assignment. - _ => { - // Catch more errors in the destination. - self.visit_place( - dest, - PlaceContext::MutatingUse(MutatingUseContext::Store), - location - ); - self.statement_like(); } + }; + debug!("store to var {:?}", index); + match &mut self.local_qualif[index] { + // this is overly restrictive, because even full assignments do not clear the qualif + // While we could special case full assignments, this would be inconsistent with + // aggregates where we overwrite all fields via assignments, which would not get + // that feature. + Some(ref mut qualif) => *qualif = *qualif | self.qualif, + // insert new qualification + qualif @ None => *qualif = Some(self.qualif), } } @@ -347,45 +291,6 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { TerminatorKind::FalseUnwind { .. } => None, TerminatorKind::Return => { - if !self.tcx.features().const_let { - // Check for unused values. This usually means - // there are extra statements in the AST. - for temp in mir.temps_iter() { - if self.local_qualif[temp].is_none() { - continue; - } - - let state = self.temp_promotion_state[temp]; - if let TempState::Defined { location, uses: 0 } = state { - let data = &mir[location.block]; - let stmt_idx = location.statement_index; - - // Get the span for the initialization. - let source_info = if stmt_idx < data.statements.len() { - data.statements[stmt_idx].source_info - } else { - data.terminator().source_info - }; - self.span = source_info.span; - - // Treat this as a statement in the AST. - self.statement_like(); - } - } - - // Make sure there are no extra unassigned variables. - self.qualif = Qualif::NOT_CONST; - for index in mir.vars_iter() { - if !self.const_fn_arg_vars.contains(index) { - debug!("unassigned variable {:?}", index); - self.assign(&Place::Local(index), Location { - block: bb, - statement_index: usize::MAX, - }); - } - } - } - break; } }; @@ -454,12 +359,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { LocalKind::ReturnPointer => { self.not_const(); } - LocalKind::Var if !self.tcx.features().const_let => { - if self.mode != Mode::Fn { - emit_feature_err(&self.tcx.sess.parse_sess, "const_let", - self.span, GateIssue::Language, - &format!("let bindings in {}s are unstable",self.mode)); - } + LocalKind::Var if self.mode == Mode::Fn => { self.add(Qualif::NOT_CONST); } LocalKind::Var | @@ -569,6 +469,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } } + ProjectionElem::ConstantIndex {..} | + ProjectionElem::Subslice {..} | ProjectionElem::Field(..) | ProjectionElem::Index(_) => { let base_ty = proj.base.ty(this.mir, this.tcx).to_ty(this.tcx); @@ -598,8 +500,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { this.qualif.restrict(ty, this.tcx, this.param_env); } - ProjectionElem::ConstantIndex {..} | - ProjectionElem::Subslice {..} | ProjectionElem::Downcast(..) => { this.not_const() } @@ -1168,46 +1068,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { debug!("visit_assign: dest={:?} rvalue={:?} location={:?}", dest, rvalue, location); self.visit_rvalue(rvalue, location); - // Check the allowed const fn argument forms. - if let (Mode::ConstFn, &Place::Local(index)) = (self.mode, dest) { - if self.mir.local_kind(index) == LocalKind::Var && - self.const_fn_arg_vars.insert(index) && - !self.tcx.features().const_let { - // Direct use of an argument is permitted. - match *rvalue { - Rvalue::Use(Operand::Copy(Place::Local(local))) | - Rvalue::Use(Operand::Move(Place::Local(local))) => { - if self.mir.local_kind(local) == LocalKind::Arg { - return; - } - } - _ => {} - } - // Avoid a generic error for other uses of arguments. - if self.qualif.contains(Qualif::FN_ARGUMENT) { - let decl = &self.mir.local_decls[index]; - let mut err = feature_err( - &self.tcx.sess.parse_sess, - "const_let", - decl.source_info.span, - GateIssue::Language, - "arguments of constant functions can only be immutable by-value bindings" - ); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("Constant functions are not allowed to mutate anything. Thus, \ - binding to an argument with a mutable pattern is not allowed."); - err.note("Remove any mutable bindings from the argument list to fix this \ - error. In case you need to mutate the argument, try lazily \ - initializing a global variable instead of using a const fn, or \ - refactoring the code to a functional style to avoid mutation if \ - possible."); - } - err.emit(); - return; - } - } - } - self.assign(dest, location); } diff --git a/src/librustc_mir/transform/qualify_min_const_fn.rs b/src/librustc_mir/transform/qualify_min_const_fn.rs index 33f309c995702..41a042ebcb643 100644 --- a/src/librustc_mir/transform/qualify_min_const_fn.rs +++ b/src/librustc_mir/transform/qualify_min_const_fn.rs @@ -65,12 +65,6 @@ pub fn is_min_const_fn( } } - for local in mir.vars_iter() { - return Err(( - mir.local_decls[local].source_info.span, - "local variables in const fn are unstable".into(), - )); - } for local in &mir.local_decls { check_ty(tcx, local.ty, local.source_info.span)?; } @@ -147,7 +141,7 @@ fn check_rvalue( check_operand(tcx, mir, operand, span) } Rvalue::Len(place) | Rvalue::Discriminant(place) | Rvalue::Ref(_, _, place) => { - check_place(tcx, mir, place, span, PlaceMode::Read) + check_place(tcx, mir, place, span) } Rvalue::Cast(CastKind::Misc, operand, cast_ty) => { use rustc::ty::cast::CastTy; @@ -213,11 +207,6 @@ fn check_rvalue( } } -enum PlaceMode { - Assign, - Read, -} - fn check_statement( tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &'a Mir<'tcx>, @@ -226,11 +215,11 @@ fn check_statement( let span = statement.source_info.span; match &statement.kind { StatementKind::Assign(place, rval) => { - check_place(tcx, mir, place, span, PlaceMode::Assign)?; + check_place(tcx, mir, place, span)?; check_rvalue(tcx, mir, rval, span) } - StatementKind::FakeRead(_, place) => check_place(tcx, mir, place, span, PlaceMode::Read), + StatementKind::FakeRead(_, place) => check_place(tcx, mir, place, span), // just an assignment StatementKind::SetDiscriminant { .. } => Ok(()), @@ -256,7 +245,7 @@ fn check_operand( ) -> McfResult { match operand { Operand::Move(place) | Operand::Copy(place) => { - check_place(tcx, mir, place, span, PlaceMode::Read) + check_place(tcx, mir, place, span) } Operand::Constant(_) => Ok(()), } @@ -267,29 +256,17 @@ fn check_place( mir: &'a Mir<'tcx>, place: &Place<'tcx>, span: Span, - mode: PlaceMode, ) -> McfResult { match place { - Place::Local(l) => match mode { - PlaceMode::Assign => match mir.local_kind(*l) { - LocalKind::Temp | LocalKind::ReturnPointer => Ok(()), - LocalKind::Arg | LocalKind::Var => { - Err((span, "assignments in const fn are unstable".into())) - } - }, - PlaceMode::Read => Ok(()), - }, + Place::Local(_) => Ok(()), // promoteds are always fine, they are essentially constants Place::Promoted(_) => Ok(()), Place::Static(_) => Err((span, "cannot access `static` items in const fn".into())), Place::Projection(proj) => { match proj.elem { + | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } | ProjectionElem::Deref | ProjectionElem::Field(..) | ProjectionElem::Index(_) => { - check_place(tcx, mir, &proj.base, span, mode) - } - // slice patterns are unstable - | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => { - return Err((span, "slice patterns in const fn are unstable".into())) + check_place(tcx, mir, &proj.base, span) } | ProjectionElem::Downcast(..) => { Err((span, "`match` or `if let` in `const fn` is unstable".into())) @@ -311,10 +288,10 @@ fn check_terminator( | TerminatorKind::Resume => Ok(()), TerminatorKind::Drop { location, .. } => { - check_place(tcx, mir, location, span, PlaceMode::Read) + check_place(tcx, mir, location, span) } TerminatorKind::DropAndReplace { location, value, .. } => { - check_place(tcx, mir, location, span, PlaceMode::Read)?; + check_place(tcx, mir, location, span)?; check_operand(tcx, mir, value, span) }, diff --git a/src/librustc_passes/ast_validation.rs b/src/librustc_passes/ast_validation.rs index 584f0ba0449e1..3d0e46d998622 100644 --- a/src/librustc_passes/ast_validation.rs +++ b/src/librustc_passes/ast_validation.rs @@ -438,8 +438,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } for predicate in &generics.where_clause.predicates { if let WherePredicate::EqPredicate(ref predicate) = *predicate { - self.err_handler().span_err(predicate.span, "equality constraints are not yet \ - supported in where clauses (#20041)"); + self.err_handler() + .span_err(predicate.span, "equality constraints are not yet \ + supported in where clauses (see #20041)"); } } visit::walk_generics(self, generics) diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 38f9adee0a48f..fbba89164e6db 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -213,8 +213,14 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> { fcx.ty_to_string(self.expr_ty), cast_ty)); if let Ok(snippet) = fcx.sess().source_map().span_to_snippet(self.expr.span) { - err.span_help(self.expr.span, - &format!("did you mean `*{}`?", snippet)); + err.span_suggestion_with_applicability( + self.expr.span, + "dereference the expression", + format!("*{}", snippet), + Applicability::MaybeIncorrect, + ); + } else { + err.span_help(self.expr.span, "dereference the expression with `*`"); } err.emit(); } diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 86165d50b27e4..ffd7c2114e5ab 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -122,14 +122,18 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }; self.tcx.with_freevars(closure_node_id, |freevars| { + let mut freevar_list: Vec = Vec::with_capacity(freevars.len()); for freevar in freevars { let upvar_id = ty::UpvarId { var_path: ty::UpvarPath { - hir_id : self.tcx.hir().node_to_hir_id(freevar.var_id()), + hir_id: self.tcx.hir().node_to_hir_id(freevar.var_id()), }, closure_expr_id: LocalDefId::from_def_id(closure_def_id), }; debug!("seed upvar_id {:?}", upvar_id); + // Adding the upvar Id to the list of Upvars, which will be added + // to the map for the closure at the end of the for loop. + freevar_list.push(upvar_id); let capture_kind = match capture_clause { hir::CaptureByValue => ty::UpvarCapture::ByValue, @@ -149,6 +153,15 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .upvar_capture_map .insert(upvar_id, capture_kind); } + // Add the vector of freevars to the map keyed with the closure id. + // This gives us an easier access to them without having to call + // with_freevars again.. + if !freevar_list.is_empty() { + self.tables + .borrow_mut() + .upvar_list + .insert(closure_def_id, freevar_list); + } }); let body_owner_def_id = self.tcx.hir().body_owner_def_id(body.id()); @@ -166,7 +179,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.param_env, region_scope_tree, &self.tables.borrow(), - ).consume_body(body); + ) + .consume_body(body); if let Some(closure_substs) = infer_kind { // Unify the (as yet unbound) type variable in the closure @@ -240,9 +254,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let var_hir_id = tcx.hir().node_to_hir_id(var_node_id); let freevar_ty = self.node_ty(var_hir_id); let upvar_id = ty::UpvarId { - var_path: ty::UpvarPath { - hir_id: var_hir_id, - }, + var_path: ty::UpvarPath { hir_id: var_hir_id }, closure_expr_id: LocalDefId::from_def_id(closure_def_index), }; let capture = self.tables.borrow().upvar_capture(upvar_id); @@ -262,7 +274,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { }, ), } - }).collect() + }) + .collect() }) } } diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 38de936a027ff..c61159eb49481 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -21,6 +21,15 @@ use syntax_pos::Span; /////////////////////////////////////////////////////////////////////////// // Entry point +// During type inference, partially inferred types are +// represented using Type variables (ty::Infer). These don't appear in +// the final TypeckTables since all of the types should have been +// inferred once typeck_tables_of is done. +// When type inference is running however, having to update the typeck +// tables every time a new type is inferred would be unreasonably slow, +// so instead all of the replacement happens at the end in +// resolve_type_vars_in_body, which creates a new TypeTables which +// doesn't contain any inference types. impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { pub fn resolve_type_vars_in_body(&self, body: &'gcx hir::Body) -> &'gcx ty::TypeckTables<'gcx> { let item_id = self.tcx.hir().body_owner(body.id()); @@ -35,7 +44,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { wbcx.visit_node_id(arg.pat.span, arg.hir_id); } wbcx.visit_body(body); - wbcx.visit_upvar_borrow_map(); + wbcx.visit_upvar_capture_map(); + wbcx.visit_upvar_list_map(); wbcx.visit_closures(); wbcx.visit_liberated_fn_sigs(); wbcx.visit_fru_field_types(); @@ -291,7 +301,7 @@ impl<'cx, 'gcx, 'tcx> Visitor<'gcx> for WritebackCx<'cx, 'gcx, 'tcx> { } impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { - fn visit_upvar_borrow_map(&mut self) { + fn visit_upvar_capture_map(&mut self) { for (upvar_id, upvar_capture) in self.fcx.tables.borrow().upvar_capture_map.iter() { let new_upvar_capture = match *upvar_capture { ty::UpvarCapture::ByValue => ty::UpvarCapture::ByValue, @@ -314,6 +324,21 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { } } + /// Runs through the function context's upvar list map and adds the same to + /// the TypeckTables. upvarlist is a hashmap of the list of upvars referred + /// to in a closure.. + fn visit_upvar_list_map(&mut self) { + for (closure_def_id, upvar_list) in self.fcx.tables.borrow().upvar_list.iter() { + debug!( + "UpvarIDs captured by closure {:?} are: {:?}", + closure_def_id, upvar_list + ); + self.tables + .upvar_list + .insert(*closure_def_id, upvar_list.to_vec()); + } + } + fn visit_closures(&mut self) { let fcx_tables = self.fcx.tables.borrow(); debug_assert_eq!(fcx_tables.local_id_root, self.tables.local_id_root); diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 2ac52bcda76f7..be5f398e31f05 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1108,7 +1108,7 @@ fn report_assoc_ty_on_inherent_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: tcx.sess, span, E0202, - "associated types are not allowed in inherent impls" + "associated types are not yet supported in inherent impls (see #8995)" ); } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 184d5b24d6e12..b48951d7593b6 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -893,14 +893,12 @@ themePicker.onblur = handleThemeButtonsBlur; static_files::fira_sans::MEDIUM)?; write(cx.dst.join("FiraSans-LICENSE.txt"), static_files::fira_sans::LICENSE)?; - write(cx.dst.join("Heuristica-Italic.woff"), - static_files::heuristica::ITALIC)?; - write(cx.dst.join("Heuristica-LICENSE.txt"), - static_files::heuristica::LICENSE)?; - write(cx.dst.join("SourceSerifPro-Regular.woff"), + write(cx.dst.join("SourceSerifPro-Regular.ttf.woff"), static_files::source_serif_pro::REGULAR)?; - write(cx.dst.join("SourceSerifPro-Bold.woff"), + write(cx.dst.join("SourceSerifPro-Bold.ttf.woff"), static_files::source_serif_pro::BOLD)?; + write(cx.dst.join("SourceSerifPro-It.ttf.woff"), + static_files::source_serif_pro::ITALIC)?; write(cx.dst.join("SourceSerifPro-LICENSE.txt"), static_files::source_serif_pro::LICENSE)?; write(cx.dst.join("SourceCodePro-Regular.woff"), diff --git a/src/librustdoc/html/static/COPYRIGHT.txt b/src/librustdoc/html/static/COPYRIGHT.txt index c69861aa70a23..af77776cca431 100644 --- a/src/librustdoc/html/static/COPYRIGHT.txt +++ b/src/librustdoc/html/static/COPYRIGHT.txt @@ -12,21 +12,6 @@ included, and carry their own copyright notices and license terms: Licensed under the SIL Open Font License, Version 1.1. See FiraSans-LICENSE.txt. -* Heuristica (Heuristica-Italic.woff): - - Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved. - Utopia is either a registered trademark or trademark of Adobe Systems - Incorporated in the United States and/or other countries. Used under - license. - - Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net - - Copyright (c) 2008-2012, Andrey V. Panov (panov@canopus.iacp.dvo.ru), - with Reserved Font Name Heuristica. - - Licensed under the SIL Open Font License, Version 1.1. - See Heuristica-LICENSE.txt. - * rustdoc.css, main.js, and playpen.js: Copyright 2015 The Rust Developers. @@ -47,7 +32,8 @@ included, and carry their own copyright notices and license terms: Licensed under the SIL Open Font License, Version 1.1. See SourceCodePro-LICENSE.txt. -* Source Serif Pro (SourceSerifPro-Regular.woff, SourceSerifPro-Bold.woff): +* Source Serif Pro (SourceSerifPro-Regular.ttf.woff, + SourceSerifPro-Bold.ttf.woff, SourceSerifPro-It.ttf.woff): Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of diff --git a/src/librustdoc/html/static/Heuristica-Italic.woff b/src/librustdoc/html/static/Heuristica-Italic.woff deleted file mode 100644 index b0cebf01de49b..0000000000000 Binary files a/src/librustdoc/html/static/Heuristica-Italic.woff and /dev/null differ diff --git a/src/librustdoc/html/static/Heuristica-LICENSE.txt b/src/librustdoc/html/static/Heuristica-LICENSE.txt deleted file mode 100644 index dd85e40e64548..0000000000000 --- a/src/librustdoc/html/static/Heuristica-LICENSE.txt +++ /dev/null @@ -1,101 +0,0 @@ -Copyright 1989, 1991 Adobe Systems Incorporated. All rights reserved. -Utopia is either a registered trademark or trademark of Adobe Systems -Incorporated in the United States and/or other countries. Used under -license. - -Copyright 2006 Han The Thanh, Vntopia font family, http://vntex.sf.net - -Copyright (c) 2008-2012, Andrey V. Panov (panov@canopus.iacp.dvo.ru), -with Reserved Font Name Heuristica. - -This Font Software is licensed under the SIL Open Font License, Version 1.1. -This license is copied below, and is also available with a FAQ at: -http://scripts.sil.org/OFL - - ------------------------------------------------------------ -SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 ------------------------------------------------------------ - -PREAMBLE -The goals of the Open Font License (OFL) are to stimulate worldwide -development of collaborative font projects, to support the font creation -efforts of academic and linguistic communities, and to provide a free and -open framework in which fonts may be shared and improved in partnership -with others. - -The OFL allows the licensed fonts to be used, studied, modified and -redistributed freely as long as they are not sold by themselves. The -fonts, including any derivative works, can be bundled, embedded, -redistributed and/or sold with any software provided that any reserved -names are not used by derivative works. The fonts and derivatives, -however, cannot be released under any other type of license. The -requirement for fonts to remain under this license does not apply -to any document created using the fonts or their derivatives. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this license and clearly marked as such. This may -include source files, build scripts and documentation. - -"Reserved Font Name" refers to any names specified as such after the -copyright statement(s). - -"Original Version" refers to the collection of Font Software components as -distributed by the Copyright Holder(s). - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to a -new environment. - -"Author" refers to any designer, engineer, programmer, technical -writer or other person who contributed to the Font Software. - -PERMISSION & CONDITIONS -Permission is hereby granted, free of charge, to any person obtaining -a copy of the Font Software, to use, study, copy, merge, embed, modify, -redistribute, and sell modified and unmodified copies of the Font -Software, subject to the following conditions: - -1) Neither the Font Software nor any of its individual components, -in Original or Modified Versions, may be sold by itself. - -2) Original or Modified Versions of the Font Software may be bundled, -redistributed and/or sold with any software, provided that each copy -contains the above copyright notice and this license. These can be -included either as stand-alone text files, human-readable headers or -in the appropriate machine-readable metadata fields within text or -binary files as long as those fields can be easily viewed by the user. - -3) No Modified Version of the Font Software may use the Reserved Font -Name(s) unless explicit written permission is granted by the corresponding -Copyright Holder. This restriction only applies to the primary font name as -presented to the users. - -4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font -Software shall not be used to promote, endorse or advertise any -Modified Version, except to acknowledge the contribution(s) of the -Copyright Holder(s) and the Author(s) or with their explicit written -permission. - -5) The Font Software, modified or unmodified, in part or in whole, -must be distributed entirely under this license, and must not be -distributed under any other license. The requirement for fonts to -remain under this license does not apply to any document created -using the Font Software. - -TERMINATION -This license becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT -OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM -OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff b/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff new file mode 100644 index 0000000000000..e283dae58de6b Binary files /dev/null and b/src/librustdoc/html/static/SourceSerifPro-Bold.ttf.woff differ diff --git a/src/librustdoc/html/static/SourceSerifPro-Bold.woff b/src/librustdoc/html/static/SourceSerifPro-Bold.woff deleted file mode 100644 index ac1b1b3a0bb7a..0000000000000 Binary files a/src/librustdoc/html/static/SourceSerifPro-Bold.woff and /dev/null differ diff --git a/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff b/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff new file mode 100644 index 0000000000000..4bd621c9bd0ba Binary files /dev/null and b/src/librustdoc/html/static/SourceSerifPro-It.ttf.woff differ diff --git a/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff b/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff new file mode 100644 index 0000000000000..96b36a0ed2366 Binary files /dev/null and b/src/librustdoc/html/static/SourceSerifPro-Regular.ttf.woff differ diff --git a/src/librustdoc/html/static/SourceSerifPro-Regular.woff b/src/librustdoc/html/static/SourceSerifPro-Regular.woff deleted file mode 100644 index e8c43b852e10e..0000000000000 Binary files a/src/librustdoc/html/static/SourceSerifPro-Regular.woff and /dev/null differ diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 2cc0b5e30b893..14273c6b1db33 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -12,25 +12,24 @@ src: local('Fira Sans Medium'), url("FiraSans-Medium.woff") format('woff'); } -/* See SourceSerifPro-LICENSE.txt for the Source Serif Pro license and - * Heuristica-LICENSE.txt for the Heuristica license. */ +/* See SourceSerifPro-LICENSE.txt for the Source Serif Pro license. */ @font-face { font-family: 'Source Serif Pro'; font-style: normal; font-weight: 400; - src: local('Source Serif Pro'), url("SourceSerifPro-Regular.woff") format('woff'); + src: local('Source Serif Pro'), url("SourceSerifPro-Regular.ttf.woff") format('woff'); } @font-face { font-family: 'Source Serif Pro'; font-style: italic; font-weight: 400; - src: url("Heuristica-Italic.woff") format('woff'); + src: local('Source Serif Pro Italic'), url("SourceSerifPro-It.ttf.woff") format('woff'); } @font-face { font-family: 'Source Serif Pro'; font-style: normal; font-weight: 700; - src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.woff") format('woff'); + src: local('Source Serif Pro Bold'), url("SourceSerifPro-Bold.ttf.woff") format('woff'); } /* See SourceCodePro-LICENSE.txt for the Source Code Pro license. */ diff --git a/src/librustdoc/html/static_files.rs b/src/librustdoc/html/static_files.rs index 47629d058e31a..f340590e5fe33 100644 --- a/src/librustdoc/html/static_files.rs +++ b/src/librustdoc/html/static_files.rs @@ -73,22 +73,17 @@ pub mod fira_sans { pub static LICENSE: &'static [u8] = include_bytes!("static/FiraSans-LICENSE.txt"); } -/// Files related to the Heuristica font. -pub mod heuristica { - /// The file `Heuristica-Italic.woff`, the Italic variant of the Heuristica font. - pub static ITALIC: &'static [u8] = include_bytes!("static/Heuristica-Italic.woff"); - - /// The file `Heuristica-LICENSE.txt`, the license text for the Heuristica font. - pub static LICENSE: &'static [u8] = include_bytes!("static/Heuristica-LICENSE.txt"); -} - /// Files related to the Source Serif Pro font. pub mod source_serif_pro { - /// The file `SourceSerifPro-Regular.woff`, the Regular variant of the Source Serif Pro font. - pub static REGULAR: &'static [u8] = include_bytes!("static/SourceSerifPro-Regular.woff"); + /// The file `SourceSerifPro-Regular.ttf.woff`, the Regular variant of the Source Serif Pro + /// font. + pub static REGULAR: &'static [u8] = include_bytes!("static/SourceSerifPro-Regular.ttf.woff"); + + /// The file `SourceSerifPro-Bold.ttf.woff`, the Bold variant of the Source Serif Pro font. + pub static BOLD: &'static [u8] = include_bytes!("static/SourceSerifPro-Bold.ttf.woff"); - /// The file `SourceSerifPro-Bold.woff`, the Bold variant of the Source Serif Pro font. - pub static BOLD: &'static [u8] = include_bytes!("static/SourceSerifPro-Bold.woff"); + /// The file `SourceSerifPro-It.ttf.woff`, the Italic variant of the Source Serif Pro font. + pub static ITALIC: &'static [u8] = include_bytes!("static/SourceSerifPro-It.ttf.woff"); /// The file `SourceSerifPro-LICENSE.txt`, the license text for the Source Serif Pro font. pub static LICENSE: &'static [u8] = include_bytes!("static/SourceSerifPro-LICENSE.txt"); diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 2170054b532b9..1f19fa2e7f598 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -394,7 +394,7 @@ pub fn make_test(s: &str, // Uses libsyntax to parse the doctest and find if there's a main fn and the extern // crate already is included. - let (already_has_main, already_has_extern_crate) = crate::syntax::with_globals(|| { + let (already_has_main, already_has_extern_crate, found_macro) = crate::syntax::with_globals(|| { use crate::syntax::{ast, parse::{self, ParseSess}, source_map::FilePathMapping}; use crate::syntax_pos::FileName; use errors::emitter::EmitterWriter; @@ -412,6 +412,7 @@ pub fn make_test(s: &str, let mut found_main = false; let mut found_extern_crate = cratename.is_none(); + let mut found_macro = false; let mut parser = match parse::maybe_new_parser_from_source_str(&sess, filename, source) { Ok(p) => p, @@ -420,7 +421,7 @@ pub fn make_test(s: &str, err.cancel(); } - return (found_main, found_extern_crate); + return (found_main, found_extern_crate, found_macro); } }; @@ -448,6 +449,12 @@ pub fn make_test(s: &str, } } + if !found_macro { + if let ast::ItemKind::Mac(..) = item.node { + found_macro = true; + } + } + if found_main && found_extern_crate { break; } @@ -460,9 +467,28 @@ pub fn make_test(s: &str, } } - (found_main, found_extern_crate) + (found_main, found_extern_crate, found_macro) }); + // If a doctest's `fn main` is being masked by a wrapper macro, the parsing loop above won't + // see it. In that case, run the old text-based scan to see if they at least have a main + // function written inside a macro invocation. See + // https://github.com/rust-lang/rust/issues/56898 + let already_has_main = if found_macro && !already_has_main { + s.lines() + .map(|line| { + let comment = line.find("//"); + if let Some(comment_begins) = comment { + &line[0..comment_begins] + } else { + line + } + }) + .any(|code| code.contains("fn main")) + } else { + already_has_main + }; + // Don't inject `extern crate std` because it's already injected by the // compiler. if !already_has_extern_crate && !opts.no_crate_inject && cratename != Some("std") { @@ -1143,4 +1169,23 @@ assert_eq!(asdf::foo, 4); let output = make_test(input, Some("asdf"), false, &opts); assert_eq!(output, (expected, 3)); } + + #[test] + fn make_test_main_in_macro() { + let opts = TestOptions::default(); + let input = +"#[macro_use] extern crate my_crate; +test_wrapper! { + fn main() {} +}"; + let expected = +"#![allow(unused)] +#[macro_use] extern crate my_crate; +test_wrapper! { + fn main() {} +}".to_string(); + + let output = make_test(input, Some("my_crate"), false, &opts); + assert_eq!(output, (expected, 1)); + } } diff --git a/src/libstd/error.rs b/src/libstd/error.rs index f026cadd639c3..2f9efb3f0fb57 100644 --- a/src/libstd/error.rs +++ b/src/libstd/error.rs @@ -30,17 +30,17 @@ use string; /// themselves through the [`Display`] and [`Debug`] traits, and may provide /// cause chain information: /// -/// The [`cause`] method is generally used when errors cross "abstraction -/// boundaries", i.e., when a one module must report an error that is "caused" -/// by an error from a lower-level module. This setup makes it possible for the -/// high-level module to provide its own errors that do not commit to any -/// particular implementation, but also reveal some of its implementation for -/// debugging via [`cause`] chains. +/// The [`source`] method is generally used when errors cross "abstraction +/// boundaries". If one module must report an error that is caused by an error +/// from a lower-level module, it can allow access to that error via the +/// [`source`] method. This makes it possible for the high-level module to +/// provide its own errors while also revealing some of the implementation for +/// debugging via [`source`] chains. /// /// [`Result`]: ../result/enum.Result.html /// [`Display`]: ../fmt/trait.Display.html /// [`Debug`]: ../fmt/trait.Debug.html -/// [`cause`]: trait.Error.html#method.cause +/// [`source`]: trait.Error.html#method.source #[stable(feature = "rust1", since = "1.0.0")] pub trait Error: Debug + Display { /// **This method is soft-deprecated.** diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 0991957fa7fd5..28a6fbd48cf09 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -252,7 +252,7 @@ //! [`println!`]: ../macro.println.html //! [`Lines`]: struct.Lines.html //! [`io::Result`]: type.Result.html -//! [`?` operator]: ../../book/first-edition/syntax-index.html +//! [`?` operator]: ../../book/appendix-02-operators.html //! [`Read::read`]: trait.Read.html#tymethod.read //! [`Result`]: ../result/enum.Result.html //! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 701565191b960..e220080844946 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -305,7 +305,7 @@ #![feature(maybe_uninit)] #![cfg_attr(all(target_vendor = "fortanix", target_env = "sgx"), feature(global_asm, range_contains, slice_index_methods, - decl_macro, coerce_unsized, sgx_platform))] + decl_macro, coerce_unsized, sgx_platform, ptr_wrapping_offset_from))] #![default_lib_allocator] diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 317a7d817db43..5c7bff70a0dcd 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -2203,6 +2203,8 @@ impl Path { /// `a/b` all have `a` and `b` as components, but `./a/b` starts with /// an additional [`CurDir`] component. /// + /// * A trailing slash is normalized away, `/a/b` and `/a/b/` are equivalent. + /// /// Note that no other normalization takes place; in particular, `a/c` /// and `a/b/../c` are distinct, to account for the possibility that `b` /// is a symbolic link (so its parent isn't `a`). diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 475c9b4aeaa4e..c2751508ce094 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -550,7 +550,6 @@ mod prim_array { } #[doc(alias = "[")] #[doc(alias = "]")] #[doc(alias = "[]")] -// /// A dynamically-sized view into a contiguous sequence, `[T]`. /// /// *[See also the `std::slice` module](slice/index.html).* @@ -572,11 +571,11 @@ mod prim_array { } /// points to: /// /// ``` -/// let x = &mut [1, 2, 3]; +/// let mut x = [1, 2, 3]; +/// let x = &mut x[..]; // Take a full slice of `x`. /// x[1] = 7; /// assert_eq!(x, &[1, 7, 3]); /// ``` -/// #[stable(feature = "rust1", since = "1.0.0")] mod prim_slice { } diff --git a/src/libstd/sys/sgx/abi/mem.rs b/src/libstd/sys/sgx/abi/mem.rs index 09552d5b4af29..808f1ce3ff2c7 100644 --- a/src/libstd/sys/sgx/abi/mem.rs +++ b/src/libstd/sys/sgx/abi/mem.rs @@ -17,8 +17,10 @@ extern { // Do not remove inline: will result in relocation failure // For the same reason we use inline ASM here instead of an extern static to // locate the base +/// Returns address at which current enclave is loaded. #[inline(always)] -fn image_base() -> u64 { +#[unstable(feature = "sgx_platform", issue = "56975")] +pub fn image_base() -> u64 { let base; unsafe { asm!("lea IMAGE_BASE(%rip),$0":"=r"(base)) }; base diff --git a/src/libstd/sys/sgx/backtrace.rs b/src/libstd/sys/sgx/backtrace.rs index 52d4a63bb6384..2b8e1da05791d 100644 --- a/src/libstd/sys/sgx/backtrace.rs +++ b/src/libstd/sys/sgx/backtrace.rs @@ -1,21 +1,90 @@ use io; -use sys::unsupported; +use error::Error; +use libc; use sys_common::backtrace::Frame; +use unwind as uw; +use sys::sgx::abi::mem::image_base; pub struct BacktraceContext; -pub fn unwind_backtrace(_frames: &mut [Frame]) - -> io::Result<(usize, BacktraceContext)> -{ - unsupported() +struct Context<'a> { + idx: usize, + frames: &'a mut [Frame], +} + +#[derive(Debug)] +struct UnwindError(uw::_Unwind_Reason_Code); + +impl Error for UnwindError { + fn description(&self) -> &'static str { + "unexpected return value while unwinding" + } +} + +impl ::fmt::Display for UnwindError { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + write!(f, "{}: {:?}", self.description(), self.0) + } +} + +#[inline(never)] // this function call can be skipped it when tracing. +pub fn unwind_backtrace(frames: &mut [Frame]) -> io::Result<(usize, BacktraceContext)> { + let mut cx = Context { idx: 0, frames }; + let result_unwind = + unsafe { uw::_Unwind_Backtrace(trace_fn, &mut cx as *mut Context as *mut libc::c_void) }; + // See libunwind:src/unwind/Backtrace.c for the return values. + // No, there is no doc. + let res = match result_unwind { + // These return codes seem to be benign and need to be ignored for backtraces + // to show up properly on all tested platforms. + uw::_URC_END_OF_STACK | uw::_URC_FATAL_PHASE1_ERROR | uw::_URC_FAILURE => { + Ok((cx.idx, BacktraceContext)) + } + _ => Err(io::Error::new( + io::ErrorKind::Other, + UnwindError(result_unwind), + )), + }; + res +} + +extern "C" fn trace_fn( + ctx: *mut uw::_Unwind_Context, + arg: *mut libc::c_void, +) -> uw::_Unwind_Reason_Code { + let cx = unsafe { &mut *(arg as *mut Context) }; + if cx.idx >= cx.frames.len() { + return uw::_URC_NORMAL_STOP; + } + + let mut ip_before_insn = 0; + let mut ip = unsafe { uw::_Unwind_GetIPInfo(ctx, &mut ip_before_insn) as *mut libc::c_void }; + if !ip.is_null() && ip_before_insn == 0 { + // this is a non-signaling frame, so `ip` refers to the address + // after the calling instruction. account for that. + ip = (ip as usize - 1) as *mut _; + } + + let symaddr = unsafe { uw::_Unwind_FindEnclosingFunction(ip) }; + cx.frames[cx.idx] = Frame { + symbol_addr: symaddr as *mut u8, + exact_position: ip as *mut u8, + inline_context: 0, + }; + cx.idx += 1; + + uw::_URC_NO_REASON } -pub fn resolve_symname(_frame: Frame, - _callback: F, +// To reduce TCB size in Sgx enclave, we do not want to implement resolve_symname functionality. +// Rather, we print the offset of the address here, which could be later mapped to correct function. +pub fn resolve_symname(frame: Frame, + callback: F, _: &BacktraceContext) -> io::Result<()> where F: FnOnce(Option<&str>) -> io::Result<()> { - unsupported() + callback(Some(&format!("0x{:x}", + (frame.symbol_addr.wrapping_offset_from(image_base() as _))))) } pub fn foreach_symbol_fileline(_: Frame, @@ -23,5 +92,5 @@ pub fn foreach_symbol_fileline(_: Frame, _: &BacktraceContext) -> io::Result where F: FnMut(&[u8], u32) -> io::Result<()> { - unsupported() + Ok(false) } diff --git a/src/libstd/sys/sgx/ext/arch.rs b/src/libstd/sys/sgx/ext/arch.rs index ba6f9e622ad35..3bd87b5d26574 100644 --- a/src/libstd/sys/sgx/ext/arch.rs +++ b/src/libstd/sys/sgx/ext/arch.rs @@ -36,7 +36,7 @@ pub fn egetkey(request: &Align512<[u8; 512]>) -> Result, u32> : "={eax}"(error) : "{eax}"(ENCLU_EGETKEY), "{rbx}"(request), - "{rcx}"(out.get_mut()) + "{rcx}"(out.as_mut_ptr()) : "flags" ); @@ -66,7 +66,7 @@ pub fn ereport( : "{eax}"(ENCLU_EREPORT), "{rbx}"(targetinfo), "{rcx}"(reportdata), - "{rdx}"(report.get_mut()) + "{rdx}"(report.as_mut_ptr()) ); report.into_inner() diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 45b3ba604c62f..9d1f91875e5d8 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -193,9 +193,6 @@ declare_features! ( // Allows the definition of `const` functions with some advanced features. (active, const_fn, "1.2.0", Some(24111), None), - // Allows let bindings and destructuring in `const` functions and constants. - (active, const_let, "1.22.1", Some(48821), None), - // Allows accessing fields of unions inside `const` functions. (active, const_fn_union, "1.27.0", Some(51909), None), @@ -411,9 +408,6 @@ declare_features! ( // `#[doc(alias = "...")]` (active, doc_alias, "1.27.0", Some(50146), None), - // Allows irrefutable patterns in `if let` and `while let` statements (RFC 2086). - (active, irrefutable_let_patterns, "1.27.0", Some(44495), None), - // inconsistent bounds in where clauses (active, trivial_bounds, "1.28.0", Some(48214), None), @@ -681,8 +675,14 @@ declare_features! ( (accepted, underscore_imports, "1.33.0", Some(48216), None), // Allows `#[repr(packed(N))]` attribute on structs. (accepted, repr_packed, "1.33.0", Some(33158), None), + // Allows irrefutable patterns in `if let` and `while let` statements (RFC 2086). + (accepted, irrefutable_let_patterns, "1.33.0", Some(44495), None), // Allows calling `const unsafe fn` inside `unsafe` blocks in `const fn` functions. (accepted, min_const_unsafe_fn, "1.33.0", Some(55607), None), + // Allows let bindings, assignments and destructuring in `const` functions and constants. + // As long as control flow is not implemented in const eval, `&&` and `||` may not be used + // at the same time as let bindings. + (accepted, const_let, "1.33.0", Some(48821), None), // `#[cfg_attr(predicate, multiple, attributes, here)]` (accepted, cfg_attr_multi, "1.33.0", Some(54881), None), // Top level or-patterns (`p | q`) in `if let` and `while let`. diff --git a/src/libsyntax_ext/format.rs b/src/libsyntax_ext/format.rs index 61722ba551653..3e3bca7080fb6 100644 --- a/src/libsyntax_ext/format.rs +++ b/src/libsyntax_ext/format.rs @@ -159,7 +159,7 @@ fn parse_args<'a>( }; let name: &str = &ident.as_str(); - p.expect(&token::Eq).unwrap(); + p.expect(&token::Eq)?; let e = p.parse_expr()?; if let Some(prev) = names.get(name) { ecx.struct_span_err(e.span, &format!("duplicate argument named `{}`", name)) diff --git a/src/test/compile-fail/const-fn-error.rs b/src/test/compile-fail/const-fn-error.rs index 9913138693c94..da6036a04a549 100644 --- a/src/test/compile-fail/const-fn-error.rs +++ b/src/test/compile-fail/const-fn-error.rs @@ -1,4 +1,4 @@ -#![feature(const_fn, const_let)] +#![feature(const_fn)] const X : usize = 2; diff --git a/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs b/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs deleted file mode 100644 index d9a42a2963998..0000000000000 --- a/src/test/run-pass/binding/allow_irrefutable_let_patterns.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -#![feature(irrefutable_let_patterns)] - -// must-compile-successfully-irrefutable_let_patterns_with_gate -#[allow(irrefutable_let_patterns)] -fn main() { - if let _ = 5 {} - - while let _ = 5 { - break; - } -} diff --git a/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs b/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs index 90295414d3efc..10a4c31f24ed4 100644 --- a/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs +++ b/src/test/run-pass/ctfe/const-block-non-item-statement-3.rs @@ -1,8 +1,8 @@ // run-pass #![allow(dead_code)] -#![feature(const_let)] - type Array = [u32; { let x = 2; 5 }]; -pub fn main() {} +pub fn main() { + let _: Array = [0; 5]; +} diff --git a/src/test/run-pass/ctfe/const-block-non-item-statement.rs b/src/test/run-pass/ctfe/const-block-non-item-statement.rs index 21ce08ab69c73..a1b9b586ad038 100644 --- a/src/test/run-pass/ctfe/const-block-non-item-statement.rs +++ b/src/test/run-pass/ctfe/const-block-non-item-statement.rs @@ -1,10 +1,11 @@ // run-pass #![allow(dead_code)] -#![feature(const_let)] - +#[repr(u8)] enum Foo { Bar = { let x = 1; 3 } } -pub fn main() {} +pub fn main() { + assert_eq!(3, Foo::Bar as u8); +} diff --git a/src/test/run-pass/ctfe/issue-37550.rs b/src/test/run-pass/ctfe/issue-37550.rs index 732c34dff5a80..04865830df2eb 100644 --- a/src/test/run-pass/ctfe/issue-37550.rs +++ b/src/test/run-pass/ctfe/issue-37550.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(unused_variables)] -#![feature(const_fn, const_let)] +#![feature(const_fn)] const fn x() { let t = true; diff --git a/src/test/run-pass/ctfe/locals-in-const-fn.rs b/src/test/run-pass/ctfe/locals-in-const-fn.rs index e527e1e88c8da..95d50171a847b 100644 --- a/src/test/run-pass/ctfe/locals-in-const-fn.rs +++ b/src/test/run-pass/ctfe/locals-in-const-fn.rs @@ -2,8 +2,6 @@ // https://github.com/rust-lang/rust/issues/48821 -#![feature(const_fn, const_let)] - const fn foo(i: usize) -> usize { let x = i; x diff --git a/src/test/ui/assoc-inherent.rs b/src/test/ui/assoc-inherent.rs index fe34be3731736..05329a2714257 100644 --- a/src/test/ui/assoc-inherent.rs +++ b/src/test/ui/assoc-inherent.rs @@ -1,9 +1,9 @@ -// Test associated types are forbidden in inherent impls. +// Test associated types are, until #8995 is implemented, forbidden in inherent impls. struct Foo; impl Foo { - type Bar = isize; //~ERROR associated types are not allowed in inherent impls + type Bar = isize; //~ERROR associated types are not yet supported in inherent impls (see #8995) } fn main() {} diff --git a/src/test/ui/assoc-inherent.stderr b/src/test/ui/assoc-inherent.stderr index 1a555bd53ac83..f438ac8df4a09 100644 --- a/src/test/ui/assoc-inherent.stderr +++ b/src/test/ui/assoc-inherent.stderr @@ -1,7 +1,7 @@ -error[E0202]: associated types are not allowed in inherent impls +error[E0202]: associated types are not yet supported in inherent impls (see #8995) --> $DIR/assoc-inherent.rs:6:5 | -LL | type Bar = isize; //~ERROR associated types are not allowed in inherent impls +LL | type Bar = isize; //~ERROR associated types are not yet supported in inherent impls (see #8995) | ^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/check-static-values-constraints.nll.stderr b/src/test/ui/check-static-values-constraints.nll.stderr index d2f6c7510a91d..f1a2312490813 100644 --- a/src/test/ui/check-static-values-constraints.nll.stderr +++ b/src/test/ui/check-static-values-constraints.nll.stderr @@ -13,44 +13,80 @@ error[E0010]: allocations are not allowed in statics LL | static STATIC11: Box = box MyOwned; | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:79:37 + | +LL | static STATIC11: Box = box MyOwned; + | ^^^^^^^ + error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/check-static-values-constraints.rs:89:32 + --> $DIR/check-static-values-constraints.rs:90:32 | LL | field2: SafeEnum::Variant4("str".to_string()) | ^^^^^^^^^^^^^^^^^ error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:94:5 + --> $DIR/check-static-values-constraints.rs:95:5 | LL | box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:95:9 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:95:5 + --> $DIR/check-static-values-constraints.rs:97:5 | LL | box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:97:9 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:99:6 + --> $DIR/check-static-values-constraints.rs:102:6 | LL | &box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:102:10 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:100:6 + --> $DIR/check-static-values-constraints.rs:104:6 | LL | &box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:104:10 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:106:5 + --> $DIR/check-static-values-constraints.rs:111:5 | LL | box 3; | ^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:111:9 + | +LL | box 3; + | ^ + error[E0507]: cannot move out of static item - --> $DIR/check-static-values-constraints.rs:110:45 + --> $DIR/check-static-values-constraints.rs:116:45 | LL | let y = { static x: Box = box 3; x }; | ^ @@ -59,12 +95,18 @@ LL | let y = { static x: Box = box 3; x }; | help: consider borrowing here: `&x` error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:110:38 + --> $DIR/check-static-values-constraints.rs:116:38 | LL | let y = { static x: Box = box 3; x }; | ^^^^^ allocation not allowed in statics -error: aborting due to 10 previous errors +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:116:42 + | +LL | let y = { static x: Box = box 3; x }; + | ^ + +error: aborting due to 17 previous errors -Some errors occurred: E0010, E0015, E0493, E0507. +Some errors occurred: E0010, E0015, E0019, E0493, E0507. For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/check-static-values-constraints.rs b/src/test/ui/check-static-values-constraints.rs index eb0fc39e1bf15..acfb3b5e44bab 100644 --- a/src/test/ui/check-static-values-constraints.rs +++ b/src/test/ui/check-static-values-constraints.rs @@ -78,6 +78,7 @@ struct MyOwned; static STATIC11: Box = box MyOwned; //~^ ERROR allocations are not allowed in statics +//~| ERROR static contains unimplemented expression type static mut STATIC12: UnsafeStruct = UnsafeStruct; @@ -92,12 +93,16 @@ static mut STATIC14: SafeStruct = SafeStruct { static STATIC15: &'static [Box] = &[ box MyOwned, //~ ERROR allocations are not allowed in statics + //~| ERROR contains unimplemented expression box MyOwned, //~ ERROR allocations are not allowed in statics + //~| ERROR contains unimplemented expression ]; static STATIC16: (&'static Box, &'static Box) = ( &box MyOwned, //~ ERROR allocations are not allowed in statics + //~| ERROR contains unimplemented expression &box MyOwned, //~ ERROR allocations are not allowed in statics + //~| ERROR contains unimplemented expression ); static mut STATIC17: SafeEnum = SafeEnum::Variant1; @@ -105,9 +110,11 @@ static mut STATIC17: SafeEnum = SafeEnum::Variant1; static STATIC19: Box = box 3; //~^ ERROR allocations are not allowed in statics + //~| ERROR contains unimplemented expression pub fn main() { let y = { static x: Box = box 3; x }; //~^ ERROR allocations are not allowed in statics - //~^^ ERROR cannot move out of static item + //~| ERROR cannot move out of static item + //~| ERROR contains unimplemented expression } diff --git a/src/test/ui/check-static-values-constraints.stderr b/src/test/ui/check-static-values-constraints.stderr index 450a9ba0c0d11..5b1f265c34aef 100644 --- a/src/test/ui/check-static-values-constraints.stderr +++ b/src/test/ui/check-static-values-constraints.stderr @@ -13,55 +13,97 @@ error[E0010]: allocations are not allowed in statics LL | static STATIC11: Box = box MyOwned; | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:79:37 + | +LL | static STATIC11: Box = box MyOwned; + | ^^^^^^^ + error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/check-static-values-constraints.rs:89:32 + --> $DIR/check-static-values-constraints.rs:90:32 | LL | field2: SafeEnum::Variant4("str".to_string()) | ^^^^^^^^^^^^^^^^^ error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:94:5 + --> $DIR/check-static-values-constraints.rs:95:5 | LL | box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:95:9 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:95:5 + --> $DIR/check-static-values-constraints.rs:97:5 | LL | box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:97:9 + | +LL | box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:99:6 + --> $DIR/check-static-values-constraints.rs:102:6 | LL | &box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:102:10 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:100:6 + --> $DIR/check-static-values-constraints.rs:104:6 | LL | &box MyOwned, //~ ERROR allocations are not allowed in statics | ^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:104:10 + | +LL | &box MyOwned, //~ ERROR allocations are not allowed in statics + | ^^^^^^^ + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:106:5 + --> $DIR/check-static-values-constraints.rs:111:5 | LL | box 3; | ^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:111:9 + | +LL | box 3; + | ^ + error[E0507]: cannot move out of static item - --> $DIR/check-static-values-constraints.rs:110:45 + --> $DIR/check-static-values-constraints.rs:116:45 | LL | let y = { static x: Box = box 3; x }; | ^ cannot move out of static item error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:110:38 + --> $DIR/check-static-values-constraints.rs:116:38 | LL | let y = { static x: Box = box 3; x }; | ^^^^^ allocation not allowed in statics -error: aborting due to 10 previous errors +error[E0019]: static contains unimplemented expression type + --> $DIR/check-static-values-constraints.rs:116:42 + | +LL | let y = { static x: Box = box 3; x }; + | ^ + +error: aborting due to 17 previous errors -Some errors occurred: E0010, E0015, E0493, E0507. +Some errors occurred: E0010, E0015, E0019, E0493, E0507. For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/consts/const-block-non-item-statement-2.rs b/src/test/ui/consts/const-block-non-item-statement-2.rs deleted file mode 100644 index 58a6cf6dcfdeb..0000000000000 --- a/src/test/ui/consts/const-block-non-item-statement-2.rs +++ /dev/null @@ -1,18 +0,0 @@ -const A: usize = { 1; 2 }; -//~^ ERROR statements in constants are unstable - -const B: usize = { { } 2 }; -//~^ ERROR statements in constants are unstable - -macro_rules! foo { - () => (()) //~ ERROR statements in constants are unstable -} -const C: usize = { foo!(); 2 }; - -const D: usize = { let x = 4; 2 }; -//~^ ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable -//~| ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable - -pub fn main() {} diff --git a/src/test/ui/consts/const-block-non-item-statement-2.stderr b/src/test/ui/consts/const-block-non-item-statement-2.stderr deleted file mode 100644 index e0c61a953f50b..0000000000000 --- a/src/test/ui/consts/const-block-non-item-statement-2.stderr +++ /dev/null @@ -1,62 +0,0 @@ -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:1:20 - | -LL | const A: usize = { 1; 2 }; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:4:20 - | -LL | const B: usize = { { } 2 }; - | ^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:8:12 - | -LL | () => (()) //~ ERROR statements in constants are unstable - | ^^ -LL | } -LL | const C: usize = { foo!(); 2 }; - | ------- in this macro invocation - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:12:28 - | -LL | const D: usize = { let x = 4; 2 }; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:12:28 - | -LL | const D: usize = { let x = 4; 2 }; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:12:1 - | -LL | const D: usize = { let x = 4; 2 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-2.rs:12:1 - | -LL | const D: usize = { let x = 4; 2 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-block-non-item-statement-3.rs b/src/test/ui/consts/const-block-non-item-statement-3.rs deleted file mode 100644 index 867840925b2d5..0000000000000 --- a/src/test/ui/consts/const-block-non-item-statement-3.rs +++ /dev/null @@ -1,7 +0,0 @@ -type Array = [u32; { let x = 2; 5 }]; -//~^ ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable -//~| ERROR let bindings in constants are unstable -//~| ERROR statements in constants are unstable - -pub fn main() {} diff --git a/src/test/ui/consts/const-block-non-item-statement-3.stderr b/src/test/ui/consts/const-block-non-item-statement-3.stderr deleted file mode 100644 index 0a549bc0c8ded..0000000000000 --- a/src/test/ui/consts/const-block-non-item-statement-3.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-3.rs:1:31 - | -LL | type Array = [u32; { let x = 2; 5 }]; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-3.rs:1:31 - | -LL | type Array = [u32; { let x = 2; 5 }]; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-3.rs:1:20 - | -LL | type Array = [u32; { let x = 2; 5 }]; - | ^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement-3.rs:1:20 - | -LL | type Array = [u32; { let x = 2; 5 }]; - | ^^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-block-non-item-statement.rs b/src/test/ui/consts/const-block-non-item-statement.rs index 2db9e2413e5b5..5ecf9a049842d 100644 --- a/src/test/ui/consts/const-block-non-item-statement.rs +++ b/src/test/ui/consts/const-block-non-item-statement.rs @@ -1,9 +1,23 @@ +// compile-pass + enum Foo { Bar = { let x = 1; 3 } - //~^ ERROR let bindings in constants are unstable - //~| ERROR statements in constants are unstable - //~| ERROR let bindings in constants are unstable - //~| ERROR statements in constants are unstable } + +const A: usize = { 1; 2 }; + +const B: usize = { { } 2 }; + +macro_rules! foo { + () => (()) +} + +const C: usize = { foo!(); 2 }; + +const D: usize = { let x = 4; 2 }; + +type Array = [u32; { let x = 2; 5 }]; +type Array2 = [u32; { let mut x = 2; x = 3; x}]; + pub fn main() {} diff --git a/src/test/ui/consts/const-block-non-item-statement.stderr b/src/test/ui/consts/const-block-non-item-statement.stderr deleted file mode 100644 index f0d751e07561c..0000000000000 --- a/src/test/ui/consts/const-block-non-item-statement.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement.rs:2:21 - | -LL | Bar = { let x = 1; 3 } - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement.rs:2:21 - | -LL | Bar = { let x = 1; 3 } - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement.rs:2:11 - | -LL | Bar = { let x = 1; 3 } - | ^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/const-block-non-item-statement.rs:2:11 - | -LL | Bar = { let x = 1; 3 } - | ^^^^^^^^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs index ba8d032367ef8..4d3c714481a29 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.rs @@ -2,7 +2,6 @@ // The test should never compile successfully #![feature(const_raw_ptr_deref)] -#![feature(const_let)] use std::cell::UnsafeCell; diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr index 6ca9d688bd062..be1be6c060071 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static-2.stderr @@ -1,5 +1,5 @@ error[E0019]: static contains unimplemented expression type - --> $DIR/assign-to-static-within-other-static-2.rs:17:5 + --> $DIR/assign-to-static-within-other-static-2.rs:16:5 | LL | *FOO.0.get() = 5; //~ ERROR contains unimplemented expression type | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs index 9fe17bfc6a06e..b4c416b1c55f0 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.rs @@ -2,7 +2,6 @@ // The test should never compile successfully #![feature(const_raw_ptr_deref)] -#![feature(const_let)] use std::cell::UnsafeCell; diff --git a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr index 2ab9765305f47..31e49dc10ca60 100644 --- a/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr +++ b/src/test/ui/consts/const-eval/assign-to-static-within-other-static.stderr @@ -1,5 +1,5 @@ error: cannot mutate statics in the initializer of another static - --> $DIR/assign-to-static-within-other-static.rs:11:5 + --> $DIR/assign-to-static-within-other-static.rs:10:5 | LL | FOO = 5; //~ ERROR cannot mutate statics in the initializer of another static | ^^^^^^^ diff --git a/src/test/ui/consts/const-eval/const_let.rs b/src/test/ui/consts/const-eval/const_let.rs index 9e6952733bb0b..63321b9120076 100644 --- a/src/test/ui/consts/const-eval/const_let.rs +++ b/src/test/ui/consts/const-eval/const_let.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - fn main() {} struct FakeNeedsDrop; diff --git a/src/test/ui/consts/const-eval/const_let.stderr b/src/test/ui/consts/const-eval/const_let.stderr index e128ca07d8659..00de97e6fb3a0 100644 --- a/src/test/ui/consts/const-eval/const_let.stderr +++ b/src/test/ui/consts/const-eval/const_let.stderr @@ -1,11 +1,11 @@ error[E0019]: constant contains unimplemented expression type - --> $DIR/const_let.rs:15:55 + --> $DIR/const_let.rs:13:55 | LL | const Y: FakeNeedsDrop = { let mut x = FakeNeedsDrop; x = FakeNeedsDrop; x }; | ^ error[E0019]: constant contains unimplemented expression type - --> $DIR/const_let.rs:19:35 + --> $DIR/const_let.rs:17:35 | LL | const Z: () = { let mut x = None; x = Some(FakeNeedsDrop); }; | ^ diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs index 0d5530acc9582..a2a45af7cb086 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.rs +++ b/src/test/ui/consts/const-eval/infinite_loop.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - fn main() { // Tests the Collatz conjecture with an incorrect base case (0 instead of 1). // The value of `n` will loop indefinitely (4 - 2 - 1 - 4). diff --git a/src/test/ui/consts/const-eval/infinite_loop.stderr b/src/test/ui/consts/const-eval/infinite_loop.stderr index 90d2159d7b551..422c2bab6ea90 100644 --- a/src/test/ui/consts/const-eval/infinite_loop.stderr +++ b/src/test/ui/consts/const-eval/infinite_loop.stderr @@ -1,5 +1,5 @@ error[E0019]: constant contains unimplemented expression type - --> $DIR/infinite_loop.rs:9:9 + --> $DIR/infinite_loop.rs:7:9 | LL | / while n != 0 { //~ ERROR constant contains unimplemented expression type LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; @@ -8,7 +8,7 @@ LL | | } | |_________^ warning: Constant evaluating a complex constant, this might take some time - --> $DIR/infinite_loop.rs:6:18 + --> $DIR/infinite_loop.rs:4:18 | LL | let _ = [(); { | __________________^ @@ -21,7 +21,7 @@ LL | | }]; | |_____^ error[E0080]: evaluation of constant value failed - --> $DIR/infinite_loop.rs:10:20 + --> $DIR/infinite_loop.rs:8:20 | LL | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; | ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate diff --git a/src/test/ui/consts/const-eval/issue-52475.rs b/src/test/ui/consts/const-eval/issue-52475.rs index 2e3d6fb9e84be..aafdd5fe61782 100644 --- a/src/test/ui/consts/const-eval/issue-52475.rs +++ b/src/test/ui/consts/const-eval/issue-52475.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - fn main() { let _ = [(); { //~^ WARNING Constant evaluating a complex constant, this might take some time diff --git a/src/test/ui/consts/const-eval/issue-52475.stderr b/src/test/ui/consts/const-eval/issue-52475.stderr index 329ea8a21f989..4f1b2ab4c8f46 100644 --- a/src/test/ui/consts/const-eval/issue-52475.stderr +++ b/src/test/ui/consts/const-eval/issue-52475.stderr @@ -1,5 +1,5 @@ error[E0019]: constant contains unimplemented expression type - --> $DIR/issue-52475.rs:8:9 + --> $DIR/issue-52475.rs:6:9 | LL | / while n < 5 { //~ ERROR constant contains unimplemented expression type LL | | n = (n + 1) % 5; //~ ERROR evaluation of constant value failed @@ -8,7 +8,7 @@ LL | | } | |_________^ warning: Constant evaluating a complex constant, this might take some time - --> $DIR/issue-52475.rs:4:18 + --> $DIR/issue-52475.rs:2:18 | LL | let _ = [(); { | __________________^ @@ -21,7 +21,7 @@ LL | | }]; | |_____^ error[E0080]: evaluation of constant value failed - --> $DIR/issue-52475.rs:9:17 + --> $DIR/issue-52475.rs:7:17 | LL | n = (n + 1) % 5; //~ ERROR evaluation of constant value failed | ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate diff --git a/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs b/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs index 62090f4180d36..32f0062168b3d 100644 --- a/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs +++ b/src/test/ui/consts/const-eval/mod-static-with-const-fn.rs @@ -2,7 +2,6 @@ // The test should never compile successfully #![feature(const_raw_ptr_deref)] -#![feature(const_let)] use std::cell::UnsafeCell; diff --git a/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr b/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr index 12d6e3be40a99..9fad6868d2038 100644 --- a/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr +++ b/src/test/ui/consts/const-eval/mod-static-with-const-fn.stderr @@ -1,11 +1,11 @@ error[E0019]: static contains unimplemented expression type - --> $DIR/mod-static-with-const-fn.rs:19:5 + --> $DIR/mod-static-with-const-fn.rs:18:5 | LL | *FOO.0.get() = 5; | ^^^^^^^^^^^^^^^^ error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/mod-static-with-const-fn.rs:22:5 + --> $DIR/mod-static-with-const-fn.rs:21:5 | LL | foo(); | ^^^^^ diff --git a/src/test/ui/consts/const-eval/ub-upvars.rs b/src/test/ui/consts/const-eval/ub-upvars.rs index 16df0c1b0cc0e..9b7bca6b72d61 100644 --- a/src/test/ui/consts/const-eval/ub-upvars.rs +++ b/src/test/ui/consts/const-eval/ub-upvars.rs @@ -1,4 +1,4 @@ -#![feature(const_transmute,const_let)] +#![feature(const_transmute)] #![allow(const_err)] // make sure we cannot allow away the errors tested here use std::mem; diff --git a/src/test/ui/consts/const-fn-destructuring-arg.rs b/src/test/ui/consts/const-fn-destructuring-arg.rs index 7f818079a19d1..dcf89f90e31da 100644 --- a/src/test/ui/consts/const-fn-destructuring-arg.rs +++ b/src/test/ui/consts/const-fn-destructuring-arg.rs @@ -1,17 +1,7 @@ -// test that certain things are disallowed in constant functions +// compile-pass -#![feature(const_fn)] - -// no destructuring -const fn i(( - a, - //~^ ERROR arguments of constant functions can only be immutable by-value bindings - b - //~^ ERROR arguments of constant functions can only be immutable by-value bindings - ): (u32, u32)) -> u32 { +const fn i((a, b): (u32, u32)) -> u32 { a + b - //~^ ERROR let bindings in constant functions are unstable - //~| ERROR let bindings in constant functions are unstable } fn main() {} diff --git a/src/test/ui/consts/const-fn-destructuring-arg.stderr b/src/test/ui/consts/const-fn-destructuring-arg.stderr deleted file mode 100644 index db63e8308045a..0000000000000 --- a/src/test/ui/consts/const-fn-destructuring-arg.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821) - --> $DIR/const-fn-destructuring-arg.rs:7:13 - | -LL | a, - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: arguments of constant functions can only be immutable by-value bindings (see issue #48821) - --> $DIR/const-fn-destructuring-arg.rs:9:13 - | -LL | b - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-destructuring-arg.rs:12:5 - | -LL | a + b - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-destructuring-arg.rs:12:9 - | -LL | a + b - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/consts/const-fn-not-safe-for-const.rs b/src/test/ui/consts/const-fn-not-safe-for-const.rs index fe672e7b3e6da..085ff5c58e60c 100644 --- a/src/test/ui/consts/const-fn-not-safe-for-const.rs +++ b/src/test/ui/consts/const-fn-not-safe-for-const.rs @@ -27,13 +27,9 @@ const fn get_Y_addr() -> &'static u32 { } const fn get() -> u32 { - let x = 22; //~ ERROR let bindings in constant functions are unstable -//~^ ERROR statements in constant functions - let y = 44; //~ ERROR let bindings in constant functions are unstable -//~^ ERROR statements in constant functions + let x = 22; + let y = 44; x + y -//~^ ERROR let bindings in constant functions are unstable -//~| ERROR let bindings in constant functions are unstable } fn main() {} diff --git a/src/test/ui/consts/const-fn-not-safe-for-const.stderr b/src/test/ui/consts/const-fn-not-safe-for-const.stderr index 8cc4c38526238..2003b137c272b 100644 --- a/src/test/ui/consts/const-fn-not-safe-for-const.stderr +++ b/src/test/ui/consts/const-fn-not-safe-for-const.stderr @@ -16,55 +16,7 @@ error[E0013]: constant functions cannot refer to statics, use a constant instead LL | &Y | ^^ -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-not-safe-for-const.rs:30:13 - | -LL | let x = 22; //~ ERROR let bindings in constant functions are unstable - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-not-safe-for-const.rs:30:13 - | -LL | let x = 22; //~ ERROR let bindings in constant functions are unstable - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-not-safe-for-const.rs:32:13 - | -LL | let y = 44; //~ ERROR let bindings in constant functions are unstable - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-not-safe-for-const.rs:32:13 - | -LL | let y = 44; //~ ERROR let bindings in constant functions are unstable - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-not-safe-for-const.rs:34:5 - | -LL | x + y - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constant functions are unstable (see issue #48821) - --> $DIR/const-fn-not-safe-for-const.rs:34:9 - | -LL | x + y - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 9 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0013, E0015, E0658. +Some errors occurred: E0013, E0015. For more information about an error, try `rustc --explain E0013`. diff --git a/src/test/ui/consts/const_let_assign.rs b/src/test/ui/consts/const_let_assign.rs index a3c53a451e106..0b09b8469fd75 100644 --- a/src/test/ui/consts/const_let_assign.rs +++ b/src/test/ui/consts/const_let_assign.rs @@ -1,7 +1,5 @@ // compile-pass -#![feature(const_let)] - struct S(i32); const A: () = { diff --git a/src/test/ui/consts/const_let_assign2.rs b/src/test/ui/consts/const_let_assign2.rs index 0de7396501adc..1c44237e49b7a 100644 --- a/src/test/ui/consts/const_let_assign2.rs +++ b/src/test/ui/consts/const_let_assign2.rs @@ -1,8 +1,5 @@ // compile-pass -#![feature(const_let)] -#![feature(const_fn)] - pub struct AA { pub data: [u8; 10], } diff --git a/src/test/ui/consts/const_let_assign3.rs b/src/test/ui/consts/const_let_assign3.rs index c2ed6cd85ab5c..cbe73923e9c42 100644 --- a/src/test/ui/consts/const_let_assign3.rs +++ b/src/test/ui/consts/const_let_assign3.rs @@ -1,4 +1,3 @@ -#![feature(const_let)] #![feature(const_fn)] struct S { @@ -18,6 +17,15 @@ const FOO: S = { s }; +type Array = [u32; { + let mut x = 2; + let y = &mut x; +//~^ ERROR references in constants may only refer to immutable values + *y = 42; +//~^ ERROR constant contains unimplemented expression type + *y +}]; + fn main() { assert_eq!(FOO.state, 3); } diff --git a/src/test/ui/consts/const_let_assign3.stderr b/src/test/ui/consts/const_let_assign3.stderr index 0f294616d255c..6649fb997cce4 100644 --- a/src/test/ui/consts/const_let_assign3.stderr +++ b/src/test/ui/consts/const_let_assign3.stderr @@ -1,16 +1,28 @@ error[E0019]: constant function contains unimplemented expression type - --> $DIR/const_let_assign3.rs:10:9 + --> $DIR/const_let_assign3.rs:9:9 | LL | self.state = x; | ^^^^^^^^^^^^^^ error[E0017]: references in constants may only refer to immutable values - --> $DIR/const_let_assign3.rs:17:5 + --> $DIR/const_let_assign3.rs:16:5 | LL | s.foo(3); //~ ERROR references in constants may only refer to immutable values | ^ constants require immutable values -error: aborting due to 2 previous errors +error[E0017]: references in constants may only refer to immutable values + --> $DIR/const_let_assign3.rs:22:13 + | +LL | let y = &mut x; + | ^^^^^^ constants require immutable values + +error[E0019]: constant contains unimplemented expression type + --> $DIR/const_let_assign3.rs:24:5 + | +LL | *y = 42; + | ^^^^^^^ + +error: aborting due to 4 previous errors Some errors occurred: E0017, E0019. For more information about an error, try `rustc --explain E0017`. diff --git a/src/test/ui/consts/const_let_eq.rs b/src/test/ui/consts/const_let_eq.rs index 8739cb80e9403..a2364c392f26b 100644 --- a/src/test/ui/consts/const_let_eq.rs +++ b/src/test/ui/consts/const_let_eq.rs @@ -1,5 +1,3 @@ -#![feature(const_let, const_fn)] - // run-pass struct Foo(T); diff --git a/src/test/ui/consts/const_let_eq_float.rs b/src/test/ui/consts/const_let_eq_float.rs index 2c7262df367a3..c48f54e567b2c 100644 --- a/src/test/ui/consts/const_let_eq_float.rs +++ b/src/test/ui/consts/const_let_eq_float.rs @@ -1,6 +1,6 @@ // compile-pass -#![feature(const_let, const_fn)] +#![feature(const_fn)] struct Foo(T); struct Bar { x: T } diff --git a/src/test/ui/consts/const_let_irrefutable.rs b/src/test/ui/consts/const_let_irrefutable.rs new file mode 100644 index 0000000000000..424a16f7ed39b --- /dev/null +++ b/src/test/ui/consts/const_let_irrefutable.rs @@ -0,0 +1,11 @@ +// compile-pass + +fn main() {} + +const fn tup((a, b): (i32, i32)) -> i32 { + a + b +} + +const fn array([a, b]: [i32; 2]) -> i32 { + a + b +} diff --git a/src/test/ui/consts/const_let_refutable.rs b/src/test/ui/consts/const_let_refutable.rs new file mode 100644 index 0000000000000..345f682868fbc --- /dev/null +++ b/src/test/ui/consts/const_let_refutable.rs @@ -0,0 +1,5 @@ +fn main() {} + +const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument + a + b +} diff --git a/src/test/ui/consts/const_let_refutable.stderr b/src/test/ui/consts/const_let_refutable.stderr new file mode 100644 index 0000000000000..c5d2ba02a70c6 --- /dev/null +++ b/src/test/ui/consts/const_let_refutable.stderr @@ -0,0 +1,9 @@ +error[E0005]: refutable pattern in function argument: `&[]` not covered + --> $DIR/const_let_refutable.rs:3:16 + | +LL | const fn slice([a, b]: &[i32]) -> i32 { //~ ERROR refutable pattern in function argument + | ^^^^^^ pattern `&[]` not covered + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0005`. diff --git a/src/test/ui/consts/const_short_circuit.rs b/src/test/ui/consts/const_short_circuit.rs index cc49e4696e58f..1e7b7ed319355 100644 --- a/src/test/ui/consts/const_short_circuit.rs +++ b/src/test/ui/consts/const_short_circuit.rs @@ -1,4 +1,4 @@ -#![feature(underscore_const_names, const_let)] +#![feature(underscore_const_names)] const _: bool = false && false; const _: bool = true && false; diff --git a/src/test/ui/consts/dangling-alloc-id-ice.rs b/src/test/ui/consts/dangling-alloc-id-ice.rs index 695d33b690898..dbc50f1fbd4b4 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.rs +++ b/src/test/ui/consts/dangling-alloc-id-ice.rs @@ -1,7 +1,5 @@ // https://github.com/rust-lang/rust/issues/55223 -#![feature(const_let)] - union Foo<'a> { y: &'a (), long_live_the_unit: &'static (), diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index a5fa88e5e6832..2cd8711f03d31 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,5 +1,5 @@ error: any use of this value will cause an error - --> $DIR/dangling-alloc-id-ice.rs:10:1 + --> $DIR/dangling-alloc-id-ice.rs:8:1 | LL | / const FOO: &() = { //~ ERROR any use of this value will cause an error LL | | let y = (); diff --git a/src/test/ui/consts/dangling_raw_ptr.rs b/src/test/ui/consts/dangling_raw_ptr.rs index 7fc773412f2f8..c2d8e6d421a28 100644 --- a/src/test/ui/consts/dangling_raw_ptr.rs +++ b/src/test/ui/consts/dangling_raw_ptr.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - const FOO: *const u32 = { //~ ERROR any use of this value will cause an error let x = 42; &x diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr index 3b20936f8ae97..091f1f785cb02 100644 --- a/src/test/ui/consts/dangling_raw_ptr.stderr +++ b/src/test/ui/consts/dangling_raw_ptr.stderr @@ -1,5 +1,5 @@ error: any use of this value will cause an error - --> $DIR/dangling_raw_ptr.rs:3:1 + --> $DIR/dangling_raw_ptr.rs:1:1 | LL | / const FOO: *const u32 = { //~ ERROR any use of this value will cause an error LL | | let x = 42; diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr index 551bc57e5ae7d..91b076097b018 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.nll.stderr @@ -112,12 +112,6 @@ error: `if`, `match`, `&&` and `||` are not stable in const fn LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn | ^^^^^^^^^^^ -error: local variables in const fn are unstable - --> $DIR/min_const_fn.rs:99:34 - | -LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn - | ^ - error: `if`, `match`, `&&` and `||` are not stable in const fn --> $DIR/min_const_fn.rs:100:44 | @@ -220,7 +214,7 @@ error: function pointers in const fn are unstable LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } | ^^^^ -error: aborting due to 35 previous errors +error: aborting due to 34 previous errors Some errors occurred: E0493, E0515. For more information about an error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.rs b/src/test/ui/consts/min_const_fn/min_const_fn.rs index 238b5f7e31003..05cf3d5f1f173 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.rs +++ b/src/test/ui/consts/min_const_fn/min_const_fn.rs @@ -96,7 +96,7 @@ const fn foo30_2(x: *mut u32) -> usize { x as usize } const fn foo30_4(b: bool) -> usize { if b { 1 } else { 42 } } //~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn -const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn +const fn foo30_6() -> bool { let x = true; x } const fn foo36(a: bool, b: bool) -> bool { a && b } //~^ ERROR `if`, `match`, `&&` and `||` are not stable in const fn const fn foo37(a: bool, b: bool) -> bool { a || b } diff --git a/src/test/ui/consts/min_const_fn/min_const_fn.stderr b/src/test/ui/consts/min_const_fn/min_const_fn.stderr index 1c68df513b697..2cae714fbf727 100644 --- a/src/test/ui/consts/min_const_fn/min_const_fn.stderr +++ b/src/test/ui/consts/min_const_fn/min_const_fn.stderr @@ -112,12 +112,6 @@ error: `if`, `match`, `&&` and `||` are not stable in const fn LL | const fn foo30_5(b: bool) { while b { } } //~ ERROR not stable in const fn | ^^^^^^^^^^^ -error: local variables in const fn are unstable - --> $DIR/min_const_fn.rs:99:34 - | -LL | const fn foo30_6() -> bool { let x = true; x } //~ ERROR local variables in const fn - | ^ - error: `if`, `match`, `&&` and `||` are not stable in const fn --> $DIR/min_const_fn.rs:100:44 | @@ -208,6 +202,6 @@ error: function pointers in const fn are unstable LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo } | ^^^^ -error: aborting due to 35 previous errors +error: aborting due to 34 previous errors For more information about this error, try `rustc --explain E0493`. diff --git a/src/test/ui/consts/min_const_fn/mutable_borrow.rs b/src/test/ui/consts/min_const_fn/mutable_borrow.rs index 3dd76b630a883..89acfea6ed8ff 100644 --- a/src/test/ui/consts/min_const_fn/mutable_borrow.rs +++ b/src/test/ui/consts/min_const_fn/mutable_borrow.rs @@ -1,6 +1,6 @@ const fn mutable_ref_in_const() -> u8 { - let mut a = 0; //~ ERROR local variables in const fn - let b = &mut a; + let mut a = 0; + let b = &mut a; //~ ERROR mutable references in const fn *b } @@ -8,8 +8,8 @@ struct X; impl X { const fn inherent_mutable_ref_in_const() -> u8 { - let mut a = 0; //~ ERROR local variables in const fn - let b = &mut a; + let mut a = 0; + let b = &mut a; //~ ERROR mutable references in const fn *b } } diff --git a/src/test/ui/consts/min_const_fn/mutable_borrow.stderr b/src/test/ui/consts/min_const_fn/mutable_borrow.stderr index fa46f5c804fe0..5ce0f30dc6e1f 100644 --- a/src/test/ui/consts/min_const_fn/mutable_borrow.stderr +++ b/src/test/ui/consts/min_const_fn/mutable_borrow.stderr @@ -1,14 +1,14 @@ -error: local variables in const fn are unstable - --> $DIR/mutable_borrow.rs:2:9 +error: mutable references in const fn are unstable + --> $DIR/mutable_borrow.rs:3:9 | -LL | let mut a = 0; //~ ERROR local variables in const fn - | ^^^^^ +LL | let b = &mut a; //~ ERROR mutable references in const fn + | ^ -error: local variables in const fn are unstable - --> $DIR/mutable_borrow.rs:11:13 +error: mutable references in const fn are unstable + --> $DIR/mutable_borrow.rs:12:13 | -LL | let mut a = 0; //~ ERROR local variables in const fn - | ^^^^^ +LL | let b = &mut a; //~ ERROR mutable references in const fn + | ^ error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/partial_qualif.rs b/src/test/ui/consts/partial_qualif.rs index 4ce41f80f82c8..32c68e69f4bed 100644 --- a/src/test/ui/consts/partial_qualif.rs +++ b/src/test/ui/consts/partial_qualif.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - use std::cell::Cell; const FOO: &(Cell, bool) = { diff --git a/src/test/ui/consts/partial_qualif.stderr b/src/test/ui/consts/partial_qualif.stderr index d695f64e2c3b5..967fb83b78b08 100644 --- a/src/test/ui/consts/partial_qualif.stderr +++ b/src/test/ui/consts/partial_qualif.stderr @@ -1,5 +1,5 @@ error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/partial_qualif.rs:8:5 + --> $DIR/partial_qualif.rs:6:5 | LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability | ^^^^ diff --git a/src/test/ui/consts/projection_qualif.rs b/src/test/ui/consts/projection_qualif.rs index 5863429a2f2c5..dedb7db592089 100644 --- a/src/test/ui/consts/projection_qualif.rs +++ b/src/test/ui/consts/projection_qualif.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - use std::cell::Cell; const FOO: &u32 = { diff --git a/src/test/ui/consts/projection_qualif.stderr b/src/test/ui/consts/projection_qualif.stderr index cc3635a979b37..410c51c4b54e1 100644 --- a/src/test/ui/consts/projection_qualif.stderr +++ b/src/test/ui/consts/projection_qualif.stderr @@ -1,17 +1,17 @@ error[E0017]: references in constants may only refer to immutable values - --> $DIR/projection_qualif.rs:8:27 + --> $DIR/projection_qualif.rs:6:27 | LL | let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values | ^^^^^^ constants require immutable values error[E0019]: constant contains unimplemented expression type - --> $DIR/projection_qualif.rs:9:18 + --> $DIR/projection_qualif.rs:7:18 | LL | unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants | ^^^^^^ error[E0658]: dereferencing raw pointers in constants is unstable (see issue #51911) - --> $DIR/projection_qualif.rs:9:18 + --> $DIR/projection_qualif.rs:7:18 | LL | unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants | ^^^^^^ diff --git a/src/test/ui/consts/promote_const_let.nll.stderr b/src/test/ui/consts/promote_const_let.nll.stderr index d8749bb5fd90b..e6ee1523a3b28 100644 --- a/src/test/ui/consts/promote_const_let.nll.stderr +++ b/src/test/ui/consts/promote_const_let.nll.stderr @@ -1,5 +1,5 @@ error[E0597]: `y` does not live long enough - --> $DIR/promote_const_let.rs:6:9 + --> $DIR/promote_const_let.rs:4:9 | LL | let x: &'static u32 = { | ------------ type annotation requires that `y` is borrowed for `'static` @@ -9,6 +9,21 @@ LL | &y //~ ERROR does not live long enough LL | }; | - `y` dropped here while still borrowed -error: aborting due to previous error +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote_const_let.rs:6:28 + | +LL | let x: &'static u32 = &{ //~ ERROR does not live long enough + | ____________------------____^ + | | | + | | type annotation requires that borrow lasts for `'static` +LL | | let y = 42; +LL | | y +LL | | }; + | |_____^ creates a temporary which is freed while still in use +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0597`. +Some errors occurred: E0597, E0716. +For more information about an error, try `rustc --explain E0597`. diff --git a/src/test/ui/consts/promote_const_let.rs b/src/test/ui/consts/promote_const_let.rs index 8de9b00eb111d..a8a6d4d99c6ff 100644 --- a/src/test/ui/consts/promote_const_let.rs +++ b/src/test/ui/consts/promote_const_let.rs @@ -1,8 +1,10 @@ -#![feature(const_let)] - fn main() { let x: &'static u32 = { let y = 42; &y //~ ERROR does not live long enough }; + let x: &'static u32 = &{ //~ ERROR does not live long enough + let y = 42; + y + }; } diff --git a/src/test/ui/consts/promote_const_let.stderr b/src/test/ui/consts/promote_const_let.stderr index 6bbb7495fb0dc..d37bd49186032 100644 --- a/src/test/ui/consts/promote_const_let.stderr +++ b/src/test/ui/consts/promote_const_let.stderr @@ -1,5 +1,5 @@ error[E0597]: `y` does not live long enough - --> $DIR/promote_const_let.rs:6:10 + --> $DIR/promote_const_let.rs:4:10 | LL | &y //~ ERROR does not live long enough | ^ borrowed value does not live long enough @@ -8,6 +8,20 @@ LL | }; | = note: borrowed value must be valid for the static lifetime... -error: aborting due to previous error +error[E0597]: borrowed value does not live long enough + --> $DIR/promote_const_let.rs:6:28 + | +LL | let x: &'static u32 = &{ //~ ERROR does not live long enough + | ____________________________^ +LL | | let y = 42; +LL | | y +LL | | }; + | |_____^ temporary value does not live long enough +LL | } + | - temporary value only lives until here + | + = note: borrowed value must be valid for the static lifetime... + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/consts/qualif_overwrite.rs b/src/test/ui/consts/qualif_overwrite.rs index 806a74ee4530b..430eea37de73c 100644 --- a/src/test/ui/consts/qualif_overwrite.rs +++ b/src/test/ui/consts/qualif_overwrite.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - use std::cell::Cell; // this is overly conservative. The reset to `None` should clear `a` of all qualifications diff --git a/src/test/ui/consts/qualif_overwrite.stderr b/src/test/ui/consts/qualif_overwrite.stderr index 4fac64bf8063f..30479139e314c 100644 --- a/src/test/ui/consts/qualif_overwrite.stderr +++ b/src/test/ui/consts/qualif_overwrite.stderr @@ -1,5 +1,5 @@ error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/qualif_overwrite.rs:12:5 + --> $DIR/qualif_overwrite.rs:10:5 | LL | &{a} //~ ERROR cannot borrow a constant which may contain interior mutability | ^^^^ diff --git a/src/test/ui/consts/qualif_overwrite_2.rs b/src/test/ui/consts/qualif_overwrite_2.rs index 29557a3da4781..fa79b5c14a736 100644 --- a/src/test/ui/consts/qualif_overwrite_2.rs +++ b/src/test/ui/consts/qualif_overwrite_2.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - use std::cell::Cell; // const qualification is not smart enough to know about fields and always assumes that there might diff --git a/src/test/ui/consts/qualif_overwrite_2.stderr b/src/test/ui/consts/qualif_overwrite_2.stderr index 181b728c7b76f..8276db99a12c0 100644 --- a/src/test/ui/consts/qualif_overwrite_2.stderr +++ b/src/test/ui/consts/qualif_overwrite_2.stderr @@ -1,5 +1,5 @@ error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/qualif_overwrite_2.rs:10:5 + --> $DIR/qualif_overwrite_2.rs:8:5 | LL | &{a.0} //~ ERROR cannot borrow a constant which may contain interior mutability | ^^^^^^ diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.rs b/src/test/ui/consts/static_mut_containing_mut_ref2.rs index 4180b1e295ab0..ef378fa84518e 100644 --- a/src/test/ui/consts/static_mut_containing_mut_ref2.rs +++ b/src/test/ui/consts/static_mut_containing_mut_ref2.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - static mut STDERR_BUFFER_SPACE: u8 = 0; pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.stderr b/src/test/ui/consts/static_mut_containing_mut_ref2.stderr index f0ae1545056b7..72186571d697e 100644 --- a/src/test/ui/consts/static_mut_containing_mut_ref2.stderr +++ b/src/test/ui/consts/static_mut_containing_mut_ref2.stderr @@ -1,11 +1,11 @@ error[E0017]: references in statics may only refer to immutable values - --> $DIR/static_mut_containing_mut_ref2.rs:5:46 + --> $DIR/static_mut_containing_mut_ref2.rs:3:46 | LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values error[E0019]: static contains unimplemented expression type - --> $DIR/static_mut_containing_mut_ref2.rs:5:45 + --> $DIR/static_mut_containing_mut_ref2.rs:3:45 | LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/static_mut_containing_mut_ref3.rs b/src/test/ui/consts/static_mut_containing_mut_ref3.rs index 0bc7faa9afdec..c24c7e2792079 100644 --- a/src/test/ui/consts/static_mut_containing_mut_ref3.rs +++ b/src/test/ui/consts/static_mut_containing_mut_ref3.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - static mut FOO: (u8, u8) = (42, 43); static mut BAR: () = unsafe { FOO.0 = 99; }; diff --git a/src/test/ui/consts/static_mut_containing_mut_ref3.stderr b/src/test/ui/consts/static_mut_containing_mut_ref3.stderr index cae53c6fee9dd..e88e49b097af2 100644 --- a/src/test/ui/consts/static_mut_containing_mut_ref3.stderr +++ b/src/test/ui/consts/static_mut_containing_mut_ref3.stderr @@ -1,5 +1,5 @@ error[E0080]: could not evaluate static initializer - --> $DIR/static_mut_containing_mut_ref3.rs:5:31 + --> $DIR/static_mut_containing_mut_ref3.rs:3:31 | LL | static mut BAR: () = unsafe { FOO.0 = 99; }; | ^^^^^^^^^^ tried to modify a static's initial value from another static's initializer diff --git a/src/test/ui/error-codes/E0010-teach.rs b/src/test/ui/error-codes/E0010-teach.rs index fc5dffb37cfe7..da51035ab5550 100644 --- a/src/test/ui/error-codes/E0010-teach.rs +++ b/src/test/ui/error-codes/E0010-teach.rs @@ -4,5 +4,6 @@ #![allow(warnings)] const CON : Box = box 0; //~ ERROR E0010 +//~^ ERROR constant contains unimplemented expression type fn main() {} diff --git a/src/test/ui/error-codes/E0010-teach.stderr b/src/test/ui/error-codes/E0010-teach.stderr index da0aadfded5f8..77e7b5ec0e860 100644 --- a/src/test/ui/error-codes/E0010-teach.stderr +++ b/src/test/ui/error-codes/E0010-teach.stderr @@ -6,6 +6,16 @@ LL | const CON : Box = box 0; //~ ERROR E0010 | = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time. -error: aborting due to previous error +error[E0019]: constant contains unimplemented expression type + --> $DIR/E0010-teach.rs:6:28 + | +LL | const CON : Box = box 0; //~ ERROR E0010 + | ^ + | + = note: A function call isn't allowed in the const's initialization expression because the expression's value must be known at compile-time. + = note: Remember: you can't use a function call inside a const's initialization expression! However, you can use it anywhere else. + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0010`. +Some errors occurred: E0010, E0019. +For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/error-codes/E0010.rs b/src/test/ui/error-codes/E0010.rs index e62997640f473..3398e2c28ba6b 100644 --- a/src/test/ui/error-codes/E0010.rs +++ b/src/test/ui/error-codes/E0010.rs @@ -2,5 +2,6 @@ #![allow(warnings)] const CON : Box = box 0; //~ ERROR E0010 +//~^ ERROR constant contains unimplemented expression type fn main() {} diff --git a/src/test/ui/error-codes/E0010.stderr b/src/test/ui/error-codes/E0010.stderr index b4b490922c45f..1364693109e08 100644 --- a/src/test/ui/error-codes/E0010.stderr +++ b/src/test/ui/error-codes/E0010.stderr @@ -4,6 +4,13 @@ error[E0010]: allocations are not allowed in constants LL | const CON : Box = box 0; //~ ERROR E0010 | ^^^^^ allocation not allowed in constants -error: aborting due to previous error +error[E0019]: constant contains unimplemented expression type + --> $DIR/E0010.rs:4:28 + | +LL | const CON : Box = box 0; //~ ERROR E0010 + | ^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0010`. +Some errors occurred: E0010, E0019. +For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/error-codes/E0162.rs b/src/test/ui/error-codes/E0162.rs deleted file mode 100644 index d3221f8e1769a..0000000000000 --- a/src/test/ui/error-codes/E0162.rs +++ /dev/null @@ -1,8 +0,0 @@ -struct Irrefutable(i32); - -fn main() { - let irr = Irrefutable(0); - if let Irrefutable(x) = irr { //~ ERROR E0162 - println!("{}", x); - } -} diff --git a/src/test/ui/error-codes/E0162.stderr b/src/test/ui/error-codes/E0162.stderr deleted file mode 100644 index ca5c56cd59d31..0000000000000 --- a/src/test/ui/error-codes/E0162.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0162]: irrefutable if-let pattern - --> $DIR/E0162.rs:5:12 - | -LL | if let Irrefutable(x) = irr { //~ ERROR E0162 - | ^^^^^^^^^^^^^^ irrefutable pattern - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/error-codes/E0165.rs b/src/test/ui/error-codes/E0165.rs deleted file mode 100644 index 952071c8b9e77..0000000000000 --- a/src/test/ui/error-codes/E0165.rs +++ /dev/null @@ -1,9 +0,0 @@ -struct Irrefutable(i32); - -fn main() { - let irr = Irrefutable(0); - while let Irrefutable(x) = irr { //~ ERROR E0165 - //~| irrefutable pattern - // ... - } -} diff --git a/src/test/ui/error-codes/E0165.stderr b/src/test/ui/error-codes/E0165.stderr deleted file mode 100644 index e0d192ea15290..0000000000000 --- a/src/test/ui/error-codes/E0165.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0165]: irrefutable while-let pattern - --> $DIR/E0165.rs:5:15 - | -LL | while let Irrefutable(x) = irr { //~ ERROR E0165 - | ^^^^^^^^^^^^^^ irrefutable pattern - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0165`. diff --git a/src/test/ui/error-codes/E0606.stderr b/src/test/ui/error-codes/E0606.stderr index bc872b3b79cce..89ec4896a2b43 100644 --- a/src/test/ui/error-codes/E0606.stderr +++ b/src/test/ui/error-codes/E0606.stderr @@ -2,13 +2,10 @@ error[E0606]: casting `&u8` as `u8` is invalid --> $DIR/E0606.rs:2:5 | LL | &0u8 as u8; //~ ERROR E0606 - | ^^^^^^^^^^ cannot cast `&u8` as `u8` - | -help: did you mean `*&0u8`? - --> $DIR/E0606.rs:2:5 - | -LL | &0u8 as u8; //~ ERROR E0606 - | ^^^^ + | ----^^^^^^ + | | + | cannot cast `&u8` as `u8` + | help: dereference the expression: `*&0u8` error: aborting due to previous error diff --git a/src/test/ui/error-festival.stderr b/src/test/ui/error-festival.stderr index 2a48272216919..ef7b49399bf3a 100644 --- a/src/test/ui/error-festival.stderr +++ b/src/test/ui/error-festival.stderr @@ -60,13 +60,10 @@ error[E0606]: casting `&u8` as `u32` is invalid --> $DIR/error-festival.rs:37:18 | LL | let y: u32 = x as u32; - | ^^^^^^^^ cannot cast `&u8` as `u32` - | -help: did you mean `*x`? - --> $DIR/error-festival.rs:37:18 - | -LL | let y: u32 = x as u32; - | ^ + | -^^^^^^^ + | | + | cannot cast `&u8` as `u32` + | help: dereference the expression: `*x` error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]` --> $DIR/error-festival.rs:41:5 diff --git a/src/test/ui/feature-gates/feature-gate-const_let.rs b/src/test/ui/feature-gates/feature-gate-const_let.rs deleted file mode 100644 index 74cefd7c0670d..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-const_let.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Test use of const let without feature gate. - -const FOO: usize = { - //~^ ERROR statements in constants are unstable - //~| ERROR: let bindings in constants are unstable - let x = 42; - //~^ ERROR statements in constants are unstable - //~| ERROR: let bindings in constants are unstable - 42 -}; - -static BAR: usize = { - //~^ ERROR statements in statics are unstable - //~| ERROR: let bindings in statics are unstable - let x = 42; - //~^ ERROR statements in statics are unstable - //~| ERROR: let bindings in statics are unstable - 42 -}; - -fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-const_let.stderr b/src/test/ui/feature-gates/feature-gate-const_let.stderr deleted file mode 100644 index 56312999a5fd8..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-const_let.stderr +++ /dev/null @@ -1,91 +0,0 @@ -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:6:13 - | -LL | let x = 42; - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:6:13 - | -LL | let x = 42; - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:3:1 - | -LL | / const FOO: usize = { -LL | | //~^ ERROR statements in constants are unstable -LL | | //~| ERROR: let bindings in constants are unstable -LL | | let x = 42; -... | -LL | | 42 -LL | | }; - | |__^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:3:1 - | -LL | / const FOO: usize = { -LL | | //~^ ERROR statements in constants are unstable -LL | | //~| ERROR: let bindings in constants are unstable -LL | | let x = 42; -... | -LL | | 42 -LL | | }; - | |__^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in statics are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:15:13 - | -LL | let x = 42; - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:15:13 - | -LL | let x = 42; - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in statics are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:12:1 - | -LL | / static BAR: usize = { -LL | | //~^ ERROR statements in statics are unstable -LL | | //~| ERROR: let bindings in statics are unstable -LL | | let x = 42; -... | -LL | | 42 -LL | | }; - | |__^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/feature-gate-const_let.rs:12:1 - | -LL | / static BAR: usize = { -LL | | //~^ ERROR statements in statics are unstable -LL | | //~| ERROR: let bindings in statics are unstable -LL | | let x = 42; -... | -LL | | 42 -LL | | }; - | |__^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/feature-gates/feature-gate-underscore_const_names.rs b/src/test/ui/feature-gates/feature-gate-underscore_const_names.rs index a82b356c75216..6b97c24a47ed2 100644 --- a/src/test/ui/feature-gates/feature-gate-underscore_const_names.rs +++ b/src/test/ui/feature-gates/feature-gate-underscore_const_names.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - trait Trt {} struct Str {} diff --git a/src/test/ui/feature-gates/feature-gate-underscore_const_names.stderr b/src/test/ui/feature-gates/feature-gate-underscore_const_names.stderr index b3658208828e9..d608f3d37cf2a 100644 --- a/src/test/ui/feature-gates/feature-gate-underscore_const_names.stderr +++ b/src/test/ui/feature-gates/feature-gate-underscore_const_names.stderr @@ -1,5 +1,5 @@ error[E0658]: naming constants with `_` is unstable (see issue #54912) - --> $DIR/feature-gate-underscore_const_names.rs:8:1 + --> $DIR/feature-gate-underscore_const_names.rs:6:1 | LL | / const _ : () = { LL | | //~^ ERROR is unstable diff --git a/src/test/ui/feature-gates/feature-gate-without_gate_irrefutable_pattern.rs b/src/test/ui/feature-gates/feature-gate-without_gate_irrefutable_pattern.rs deleted file mode 100644 index cae2f1d2793df..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-without_gate_irrefutable_pattern.rs +++ /dev/null @@ -1,8 +0,0 @@ -// gate-test-irrefutable_let_patterns - - -#[allow(irrefutable_let_patterns)] -fn main() { - if let _ = 5 {} - //~^ ERROR irrefutable if-let pattern [E0162] -} diff --git a/src/test/ui/feature-gates/feature-gate-without_gate_irrefutable_pattern.stderr b/src/test/ui/feature-gates/feature-gate-without_gate_irrefutable_pattern.stderr deleted file mode 100644 index fa8b74ffecf3a..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-without_gate_irrefutable_pattern.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0162]: irrefutable if-let pattern - --> $DIR/feature-gate-without_gate_irrefutable_pattern.rs:6:12 - | -LL | if let _ = 5 {} - | ^ irrefutable pattern - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/if/if-let.rs b/src/test/ui/if/if-let.rs index 304de457059f3..741685fe9b649 100644 --- a/src/test/ui/if/if-let.rs +++ b/src/test/ui/if/if-let.rs @@ -1,3 +1,5 @@ +// compile-pass + fn macros() { macro_rules! foo{ ($p:pat, $e:expr, $b:block) => {{ @@ -10,20 +12,20 @@ fn macros() { }} } - foo!(a, 1, { //~ ERROR irrefutable if-let + foo!(a, 1, { //~ WARN irrefutable if-let println!("irrefutable pattern"); }); - bar!(a, 1, { //~ ERROR irrefutable if-let + bar!(a, 1, { //~ WARN irrefutable if-let println!("irrefutable pattern"); }); } pub fn main() { - if let a = 1 { //~ ERROR irrefutable if-let + if let a = 1 { //~ WARN irrefutable if-let println!("irrefutable pattern"); } - if let a = 1 { //~ ERROR irrefutable if-let + if let a = 1 { //~ WARN irrefutable if-let println!("irrefutable pattern"); } else if true { println!("else-if in irrefutable if-let"); @@ -33,13 +35,13 @@ pub fn main() { if let 1 = 2 { println!("refutable pattern"); - } else if let a = 1 { //~ ERROR irrefutable if-let + } else if let a = 1 { //~ WARN irrefutable if-let println!("irrefutable pattern"); } if true { println!("if"); - } else if let a = 1 { //~ ERROR irrefutable if-let + } else if let a = 1 { //~ WARN irrefutable if-let println!("irrefutable pattern"); } } diff --git a/src/test/ui/if/if-let.stderr b/src/test/ui/if/if-let.stderr index 3802d7828ae7d..b2a104bfacffc 100644 --- a/src/test/ui/if/if-let.stderr +++ b/src/test/ui/if/if-let.stderr @@ -1,39 +1,62 @@ -error[E0162]: irrefutable if-let pattern - --> $DIR/if-let.rs:13:10 +warning: irrefutable if-let pattern + --> $DIR/if-let.rs:6:13 | -LL | foo!(a, 1, { //~ ERROR irrefutable if-let - | ^ irrefutable pattern - -error[E0162]: irrefutable if-let pattern - --> $DIR/if-let.rs:16:10 +LL | if let $p = $e $b + | ^^ +... +LL | / foo!(a, 1, { //~ WARN irrefutable if-let +LL | | println!("irrefutable pattern"); +LL | | }); + | |_______- in this macro invocation | -LL | bar!(a, 1, { //~ ERROR irrefutable if-let - | ^ irrefutable pattern + = note: #[warn(irrefutable_let_patterns)] on by default -error[E0162]: irrefutable if-let pattern - --> $DIR/if-let.rs:22:12 +warning: irrefutable if-let pattern + --> $DIR/if-let.rs:6:13 | -LL | if let a = 1 { //~ ERROR irrefutable if-let - | ^ irrefutable pattern +LL | if let $p = $e $b + | ^^ +... +LL | / bar!(a, 1, { //~ WARN irrefutable if-let +LL | | println!("irrefutable pattern"); +LL | | }); + | |_______- in this macro invocation -error[E0162]: irrefutable if-let pattern - --> $DIR/if-let.rs:26:12 +warning: irrefutable if-let pattern + --> $DIR/if-let.rs:24:5 | -LL | if let a = 1 { //~ ERROR irrefutable if-let - | ^ irrefutable pattern +LL | / if let a = 1 { //~ WARN irrefutable if-let +LL | | println!("irrefutable pattern"); +LL | | } + | |_____^ -error[E0162]: irrefutable if-let pattern - --> $DIR/if-let.rs:36:19 +warning: irrefutable if-let pattern + --> $DIR/if-let.rs:28:5 | -LL | } else if let a = 1 { //~ ERROR irrefutable if-let - | ^ irrefutable pattern +LL | / if let a = 1 { //~ WARN irrefutable if-let +LL | | println!("irrefutable pattern"); +LL | | } else if true { +LL | | println!("else-if in irrefutable if-let"); +LL | | } else { +LL | | println!("else in irrefutable if-let"); +LL | | } + | |_____^ -error[E0162]: irrefutable if-let pattern - --> $DIR/if-let.rs:42:19 +warning: irrefutable if-let pattern + --> $DIR/if-let.rs:38:12 | -LL | } else if let a = 1 { //~ ERROR irrefutable if-let - | ^ irrefutable pattern +LL | } else if let a = 1 { //~ WARN irrefutable if-let + | ____________^ +LL | | println!("irrefutable pattern"); +LL | | } + | |_____^ -error: aborting due to 6 previous errors +warning: irrefutable if-let pattern + --> $DIR/if-let.rs:44:12 + | +LL | } else if let a = 1 { //~ WARN irrefutable if-let + | ____________^ +LL | | println!("irrefutable pattern"); +LL | | } + | |_____^ -For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/issues/issue-18118.nll.stderr b/src/test/ui/issues/issue-18118.nll.stderr index d3084b0616776..1920e1637d149 100644 --- a/src/test/ui/issues/issue-18118.nll.stderr +++ b/src/test/ui/issues/issue-18118.nll.stderr @@ -1,68 +1,14 @@ -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:5:17 - | -LL | let p = 3; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:5:17 - | -LL | let p = 3; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:8:9 - | -LL | &p //~ ERROR `p` does not live long enough - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:2:5 - | -LL | / const z: &'static isize = { -LL | | //~^ ERROR let bindings in constants are unstable -LL | | //~| ERROR statements in constants are unstable -LL | | let p = 3; -... | -LL | | //~^ ERROR let bindings in constants are unstable -LL | | }; - | |______^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:2:5 - | -LL | / const z: &'static isize = { -LL | | //~^ ERROR let bindings in constants are unstable -LL | | //~| ERROR statements in constants are unstable -LL | | let p = 3; -... | -LL | | //~^ ERROR let bindings in constants are unstable -LL | | }; - | |______^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - error[E0597]: `p` does not live long enough - --> $DIR/issue-18118.rs:8:9 + --> $DIR/issue-18118.rs:4:9 | LL | &p //~ ERROR `p` does not live long enough | ^^ | | | borrowed value does not live long enough | using this value as a constant requires that `p` is borrowed for `'static` -LL | //~^ ERROR let bindings in constants are unstable LL | }; | - `p` dropped here while still borrowed -error: aborting due to 6 previous errors +error: aborting due to previous error -Some errors occurred: E0597, E0658. -For more information about an error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-18118.rs b/src/test/ui/issues/issue-18118.rs index 7bbea191cd167..f58a3de281f1a 100644 --- a/src/test/ui/issues/issue-18118.rs +++ b/src/test/ui/issues/issue-18118.rs @@ -1,11 +1,6 @@ pub fn main() { const z: &'static isize = { - //~^ ERROR let bindings in constants are unstable - //~| ERROR statements in constants are unstable let p = 3; - //~^ ERROR let bindings in constants are unstable - //~| ERROR statements in constants are unstable &p //~ ERROR `p` does not live long enough - //~^ ERROR let bindings in constants are unstable }; } diff --git a/src/test/ui/issues/issue-18118.stderr b/src/test/ui/issues/issue-18118.stderr index 1383cdb4438c9..9b21ece341a9f 100644 --- a/src/test/ui/issues/issue-18118.stderr +++ b/src/test/ui/issues/issue-18118.stderr @@ -1,67 +1,13 @@ -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:5:17 - | -LL | let p = 3; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:5:17 - | -LL | let p = 3; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:8:9 - | -LL | &p //~ ERROR `p` does not live long enough - | ^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: let bindings in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:2:5 - | -LL | / const z: &'static isize = { -LL | | //~^ ERROR let bindings in constants are unstable -LL | | //~| ERROR statements in constants are unstable -LL | | let p = 3; -... | -LL | | //~^ ERROR let bindings in constants are unstable -LL | | }; - | |______^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-18118.rs:2:5 - | -LL | / const z: &'static isize = { -LL | | //~^ ERROR let bindings in constants are unstable -LL | | //~| ERROR statements in constants are unstable -LL | | let p = 3; -... | -LL | | //~^ ERROR let bindings in constants are unstable -LL | | }; - | |______^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - error[E0597]: `p` does not live long enough - --> $DIR/issue-18118.rs:8:10 + --> $DIR/issue-18118.rs:4:10 | LL | &p //~ ERROR `p` does not live long enough | ^ borrowed value does not live long enough -LL | //~^ ERROR let bindings in constants are unstable LL | }; | - borrowed value only lives until here | = note: borrowed value must be valid for the static lifetime... -error: aborting due to 6 previous errors +error: aborting due to previous error -Some errors occurred: E0597, E0658. -For more information about an error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/issues/issue-32829-2.rs b/src/test/ui/issues/issue-32829-2.rs index 9db9d30411d6f..c93c84b5fb773 100644 --- a/src/test/ui/issues/issue-32829-2.rs +++ b/src/test/ui/issues/issue-32829-2.rs @@ -1,11 +1,8 @@ // ignore-tidy-linelength -#![feature(const_fn)] - const bad : u32 = { { 5; - //~^ ERROR statements in constants are unstable 0 } }; @@ -13,8 +10,7 @@ const bad : u32 = { const bad_two : u32 = { { invalid(); - //~^ ERROR statements in constants are unstable - //~^^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants + //~^ ERROR: calls in constants are limited to constant functions, tuple structs and tuple variants 0 } }; @@ -22,7 +18,6 @@ const bad_two : u32 = { const bad_three : u32 = { { valid(); - //~^ ERROR statements in constants are unstable 0 } }; @@ -30,7 +25,6 @@ const bad_three : u32 = { static bad_four : u32 = { { 5; - //~^ ERROR statements in statics are unstable 0 } }; @@ -39,7 +33,6 @@ static bad_five : u32 = { { invalid(); //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants - //~| ERROR statements in statics are unstable 0 } }; @@ -47,7 +40,6 @@ static bad_five : u32 = { static bad_six : u32 = { { valid(); - //~^ ERROR statements in statics are unstable 0 } }; @@ -55,7 +47,6 @@ static bad_six : u32 = { static mut bad_seven : u32 = { { 5; - //~^ ERROR statements in statics are unstable 0 } }; @@ -63,8 +54,7 @@ static mut bad_seven : u32 = { static mut bad_eight : u32 = { { invalid(); - //~^ ERROR statements in statics are unstable - //~| ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants + //~^ ERROR: calls in statics are limited to constant functions, tuple structs and tuple variants 0 } }; @@ -72,7 +62,6 @@ static mut bad_eight : u32 = { static mut bad_nine : u32 = { { valid(); - //~^ ERROR statements in statics are unstable 0 } }; diff --git a/src/test/ui/issues/issue-32829-2.stderr b/src/test/ui/issues/issue-32829-2.stderr index 7fe0261281830..8d7423f29ae97 100644 --- a/src/test/ui/issues/issue-32829-2.stderr +++ b/src/test/ui/issues/issue-32829-2.stderr @@ -1,94 +1,21 @@ -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:7:9 - | -LL | 5; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-32829-2.rs:15:9 + --> $DIR/issue-32829-2.rs:12:9 | LL | invalid(); | ^^^^^^^^^ -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:15:9 - | -LL | invalid(); - | ^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in constants are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:24:9 - | -LL | valid(); - | ^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:32:9 - | -LL | 5; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-32829-2.rs:40:9 + --> $DIR/issue-32829-2.rs:34:9 | LL | invalid(); | ^^^^^^^^^ -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:40:9 - | -LL | invalid(); - | ^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:49:9 - | -LL | valid(); - | ^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:57:9 - | -LL | 5; - | ^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants - --> $DIR/issue-32829-2.rs:65:9 + --> $DIR/issue-32829-2.rs:56:9 | LL | invalid(); | ^^^^^^^^^ -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:65:9 - | -LL | invalid(); - | ^^^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error[E0658]: statements in statics are unstable (see issue #48821) - --> $DIR/issue-32829-2.rs:74:9 - | -LL | valid(); - | ^^^^^^^ - | - = help: add #![feature(const_let)] to the crate attributes to enable - -error: aborting due to 12 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0015, E0658. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/issues/issue-37550.rs b/src/test/ui/issues/issue-37550.rs index 12282f3e54887..505c030b96712 100644 --- a/src/test/ui/issues/issue-37550.rs +++ b/src/test/ui/issues/issue-37550.rs @@ -1,6 +1,6 @@ const fn x() { - let t = true; //~ ERROR local variables in const fn - let x = || t; + let t = true; + let x = || t; //~ ERROR function pointers in const fn are unstable } fn main() {} diff --git a/src/test/ui/issues/issue-37550.stderr b/src/test/ui/issues/issue-37550.stderr index d42f72ad3fac8..d2b03416cb73c 100644 --- a/src/test/ui/issues/issue-37550.stderr +++ b/src/test/ui/issues/issue-37550.stderr @@ -1,7 +1,7 @@ -error: local variables in const fn are unstable - --> $DIR/issue-37550.rs:2:9 +error: function pointers in const fn are unstable + --> $DIR/issue-37550.rs:3:9 | -LL | let t = true; //~ ERROR local variables in const fn +LL | let x = || t; //~ ERROR function pointers in const fn are unstable | ^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-51714.rs b/src/test/ui/issues/issue-51714.rs index b52e3ac6abd84..4885e4a2db7d5 100644 --- a/src/test/ui/issues/issue-51714.rs +++ b/src/test/ui/issues/issue-51714.rs @@ -10,5 +10,5 @@ fn main() { [(); return while let Some(n) = Some(0) {}]; //~^ ERROR return statement outside of function body - //~^^ ERROR irrefutable while-let pattern + //~^^ WARN irrefutable while-let pattern } diff --git a/src/test/ui/issues/issue-51714.stderr b/src/test/ui/issues/issue-51714.stderr index 47a8b415b0cf0..df11f6b7f5a53 100644 --- a/src/test/ui/issues/issue-51714.stderr +++ b/src/test/ui/issues/issue-51714.stderr @@ -22,13 +22,14 @@ error[E0572]: return statement outside of function body LL | [(); return while let Some(n) = Some(0) {}]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0165]: irrefutable while-let pattern - --> $DIR/issue-51714.rs:11:27 +warning: irrefutable while-let pattern + --> $DIR/issue-51714.rs:11:17 | LL | [(); return while let Some(n) = Some(0) {}]; - | ^^^^^^^ irrefutable pattern + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(irrefutable_let_patterns)] on by default -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors -Some errors occurred: E0165, E0572. -For more information about an error, try `rustc --explain E0165`. +For more information about this error, try `rustc --explain E0572`. diff --git a/src/test/ui/issues/issue-7364.rs b/src/test/ui/issues/issue-7364.rs index 3f9c2ef48a7af..52ec9e42be782 100644 --- a/src/test/ui/issues/issue-7364.rs +++ b/src/test/ui/issues/issue-7364.rs @@ -6,5 +6,6 @@ use std::cell::RefCell; static boxed: Box> = box RefCell::new(0); //~^ ERROR allocations are not allowed in statics //~| ERROR `std::cell::RefCell` cannot be shared between threads safely [E0277] +//~| ERROR static contains unimplemented expression type fn main() { } diff --git a/src/test/ui/issues/issue-7364.stderr b/src/test/ui/issues/issue-7364.stderr index 0e4d6ff1d71fa..52a99ce36b870 100644 --- a/src/test/ui/issues/issue-7364.stderr +++ b/src/test/ui/issues/issue-7364.stderr @@ -4,6 +4,12 @@ error[E0010]: allocations are not allowed in statics LL | static boxed: Box> = box RefCell::new(0); | ^^^^^^^^^^^^^^^^^^^ allocation not allowed in statics +error[E0019]: static contains unimplemented expression type + --> $DIR/issue-7364.rs:6:41 + | +LL | static boxed: Box> = box RefCell::new(0); + | ^^^^^^^^^^^^^^^ + error[E0277]: `std::cell::RefCell` cannot be shared between threads safely --> $DIR/issue-7364.rs:6:1 | @@ -15,7 +21,7 @@ LL | static boxed: Box> = box RefCell::new(0); = note: required because it appears within the type `std::boxed::Box>` = note: shared static variables must have a type that implements `Sync` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors occurred: E0010, E0277. +Some errors occurred: E0010, E0019, E0277. For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/macros/format-parse-errors.rs b/src/test/ui/macros/format-parse-errors.rs index ba1e441fe339f..96aee5e6aeed5 100644 --- a/src/test/ui/macros/format-parse-errors.rs +++ b/src/test/ui/macros/format-parse-errors.rs @@ -2,6 +2,7 @@ fn main() { format!(); //~ ERROR requires at least a format string argument format!(struct); //~ ERROR expected expression format!("s", name =); //~ ERROR expected expression + format!("s", foo = foo, bar); //~ ERROR expected `=` format!("s", foo = struct); //~ ERROR expected expression format!("s", struct); //~ ERROR expected expression diff --git a/src/test/ui/macros/format-parse-errors.stderr b/src/test/ui/macros/format-parse-errors.stderr index 0463c54890177..a3d2786bce111 100644 --- a/src/test/ui/macros/format-parse-errors.stderr +++ b/src/test/ui/macros/format-parse-errors.stderr @@ -18,20 +18,26 @@ error: expected expression, found `` LL | format!("s", name =); //~ ERROR expected expression | ^ expected expression +error: expected `=`, found `` + --> $DIR/format-parse-errors.rs:5:29 + | +LL | format!("s", foo = foo, bar); //~ ERROR expected `=` + | ^^^ expected `=` + error: expected expression, found keyword `struct` - --> $DIR/format-parse-errors.rs:5:24 + --> $DIR/format-parse-errors.rs:6:24 | LL | format!("s", foo = struct); //~ ERROR expected expression | ^^^^^^ expected expression error: expected expression, found keyword `struct` - --> $DIR/format-parse-errors.rs:6:18 + --> $DIR/format-parse-errors.rs:7:18 | LL | format!("s", struct); //~ ERROR expected expression | ^^^^^^ expected expression error: format argument must be a string literal - --> $DIR/format-parse-errors.rs:9:13 + --> $DIR/format-parse-errors.rs:10:13 | LL | format!(123); //~ ERROR format argument must be a string literal | ^^^ @@ -40,5 +46,5 @@ help: you might be missing a string literal to format with LL | format!("{}", 123); //~ ERROR format argument must be a string literal | ^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors diff --git a/src/test/ui/mismatched_types/cast-rfc0401.stderr b/src/test/ui/mismatched_types/cast-rfc0401.stderr index 158d114616979..fbe5e6d409934 100644 --- a/src/test/ui/mismatched_types/cast-rfc0401.stderr +++ b/src/test/ui/mismatched_types/cast-rfc0401.stderr @@ -240,13 +240,10 @@ error[E0606]: casting `&{float}` as `f32` is invalid --> $DIR/cast-rfc0401.rs:71:30 | LL | vec![0.0].iter().map(|s| s as f32).collect::>(); //~ ERROR is invalid - | ^^^^^^^^ cannot cast `&{float}` as `f32` - | -help: did you mean `*s`? - --> $DIR/cast-rfc0401.rs:71:30 - | -LL | vec![0.0].iter().map(|s| s as f32).collect::>(); //~ ERROR is invalid - | ^ + | -^^^^^^^ + | | + | cannot cast `&{float}` as `f32` + | help: dereference the expression: `*s` error: aborting due to 34 previous errors diff --git a/src/test/ui/pattern/deny-irrefutable-let-patterns.rs b/src/test/ui/pattern/deny-irrefutable-let-patterns.rs new file mode 100644 index 0000000000000..14040c8ada67d --- /dev/null +++ b/src/test/ui/pattern/deny-irrefutable-let-patterns.rs @@ -0,0 +1,9 @@ +#![deny(irrefutable_let_patterns)] + +fn main() { + if let _ = 5 {} //~ ERROR irrefutable if-let pattern + + while let _ = 5 { //~ ERROR irrefutable while-let pattern + break; + } +} diff --git a/src/test/ui/pattern/deny-irrefutable-let-patterns.stderr b/src/test/ui/pattern/deny-irrefutable-let-patterns.stderr new file mode 100644 index 0000000000000..ad8cc2ef8973b --- /dev/null +++ b/src/test/ui/pattern/deny-irrefutable-let-patterns.stderr @@ -0,0 +1,22 @@ +error: irrefutable if-let pattern + --> $DIR/deny-irrefutable-let-patterns.rs:4:5 + | +LL | if let _ = 5 {} //~ ERROR irrefutable if-let pattern + | ^^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/deny-irrefutable-let-patterns.rs:1:9 + | +LL | #![deny(irrefutable_let_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: irrefutable while-let pattern + --> $DIR/deny-irrefutable-let-patterns.rs:6:5 + | +LL | / while let _ = 5 { //~ ERROR irrefutable while-let pattern +LL | | break; +LL | | } + | |_____^ + +error: aborting due to 2 previous errors + diff --git a/src/test/run-pass/enum-variant-generic-args.rs b/src/test/ui/pattern/enum-variant-generic-args.rs similarity index 97% rename from src/test/run-pass/enum-variant-generic-args.rs rename to src/test/ui/pattern/enum-variant-generic-args.rs index 0743f99897922..85599530ea6a4 100644 --- a/src/test/run-pass/enum-variant-generic-args.rs +++ b/src/test/ui/pattern/enum-variant-generic-args.rs @@ -1,4 +1,5 @@ -#![feature(irrefutable_let_patterns)] +// run-pass + #![feature(type_alias_enum_variants)] #![allow(irrefutable_let_patterns)] diff --git a/src/test/ui/pattern/irrefutable-let-patterns.rs b/src/test/ui/pattern/irrefutable-let-patterns.rs new file mode 100644 index 0000000000000..d400ef0bbd64c --- /dev/null +++ b/src/test/ui/pattern/irrefutable-let-patterns.rs @@ -0,0 +1,11 @@ +// run-pass + +#![allow(irrefutable_let_patterns)] + +fn main() { + if let _ = 5 {} + + while let _ = 5 { + break; + } +} diff --git a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs index 3814fc02745a7..d79798d57e820 100644 --- a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs +++ b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.rs @@ -2,7 +2,6 @@ // Enabling `ireffutable_let_patterns` isn't necessary for what this tests, but it makes coming up // with examples easier. -#![feature(irrefutable_let_patterns)] #[allow(irrefutable_let_patterns)] fn main() { diff --git a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr index 1d518215c2c36..2cd59fe56cf2d 100644 --- a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2015.stderr @@ -1,5 +1,5 @@ error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2015.rs:11:47 + --> $DIR/syntax-ambiguity-2015.rs:10:47 | LL | if let Range { start: _, end: _ } = true..true && false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` @@ -8,7 +8,7 @@ LL | if let Range { start: _, end: _ } = true..true && false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `||` - --> $DIR/syntax-ambiguity-2015.rs:14:47 + --> $DIR/syntax-ambiguity-2015.rs:13:47 | LL | if let Range { start: _, end: _ } = true..true || false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` @@ -17,7 +17,7 @@ LL | if let Range { start: _, end: _ } = true..true || false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2015.rs:17:50 + --> $DIR/syntax-ambiguity-2015.rs:16:50 | LL | while let Range { start: _, end: _ } = true..true && false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` @@ -26,7 +26,7 @@ LL | while let Range { start: _, end: _ } = true..true && false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `||` - --> $DIR/syntax-ambiguity-2015.rs:20:50 + --> $DIR/syntax-ambiguity-2015.rs:19:50 | LL | while let Range { start: _, end: _ } = true..true || false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` @@ -35,7 +35,7 @@ LL | while let Range { start: _, end: _ } = true..true || false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2015.rs:23:19 + --> $DIR/syntax-ambiguity-2015.rs:22:19 | LL | if let true = false && false { } | ^^^^^^^^^^^^^^ help: consider adding parentheses: `(false && false)` @@ -44,7 +44,7 @@ LL | if let true = false && false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2015.rs:26:22 + --> $DIR/syntax-ambiguity-2015.rs:25:22 | LL | while let true = (1 == 2) && false { } | ^^^^^^^^^^^^^^^^^ help: consider adding parentheses: `((1 == 2) && false)` diff --git a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs index 311953a283e37..687bf659416ab 100644 --- a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs +++ b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.rs @@ -2,7 +2,6 @@ // Enabling `ireffutable_let_patterns` isn't necessary for what this tests, but it makes coming up // with examples easier. -#![feature(irrefutable_let_patterns)] #[allow(irrefutable_let_patterns)] fn main() { diff --git a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr index b3579973ca2bd..cbba2d7473334 100644 --- a/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr +++ b/src/test/ui/rfc-2497-if-let-chains/syntax-ambiguity-2018.stderr @@ -1,5 +1,5 @@ error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2018.rs:11:47 + --> $DIR/syntax-ambiguity-2018.rs:10:47 | LL | if let Range { start: _, end: _ } = true..true && false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` @@ -8,7 +8,7 @@ LL | if let Range { start: _, end: _ } = true..true && false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `||` - --> $DIR/syntax-ambiguity-2018.rs:14:47 + --> $DIR/syntax-ambiguity-2018.rs:13:47 | LL | if let Range { start: _, end: _ } = true..true || false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` @@ -17,7 +17,7 @@ LL | if let Range { start: _, end: _ } = true..true || false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2018.rs:17:50 + --> $DIR/syntax-ambiguity-2018.rs:16:50 | LL | while let Range { start: _, end: _ } = true..true && false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true && false)` @@ -26,7 +26,7 @@ LL | while let Range { start: _, end: _ } = true..true && false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `||` - --> $DIR/syntax-ambiguity-2018.rs:20:50 + --> $DIR/syntax-ambiguity-2018.rs:19:50 | LL | while let Range { start: _, end: _ } = true..true || false { } | ^^^^^^^^^^^^^ help: consider adding parentheses: `(true || false)` @@ -35,7 +35,7 @@ LL | while let Range { start: _, end: _ } = true..true || false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2018.rs:23:19 + --> $DIR/syntax-ambiguity-2018.rs:22:19 | LL | if let true = false && false { } | ^^^^^^^^^^^^^^ help: consider adding parentheses: `(false && false)` @@ -44,7 +44,7 @@ LL | if let true = false && false { } = note: see rust-lang/rust#53668 for more information error: ambiguous use of `&&` - --> $DIR/syntax-ambiguity-2018.rs:26:22 + --> $DIR/syntax-ambiguity-2018.rs:25:22 | LL | while let true = (1 == 2) && false { } | ^^^^^^^^^^^^^^^^^ help: consider adding parentheses: `((1 == 2) && false)` diff --git a/src/test/ui/should-fail-no_gate_irrefutable_if_let_pattern.rs b/src/test/ui/should-fail-no_gate_irrefutable_if_let_pattern.rs deleted file mode 100644 index 2899298a0cb1d..0000000000000 --- a/src/test/ui/should-fail-no_gate_irrefutable_if_let_pattern.rs +++ /dev/null @@ -1,5 +0,0 @@ -// should-fail-irrefutable_let_patterns -fn main() { - if let _ = 5 {} - //~^ ERROR irrefutable if-let pattern [E0162] -} diff --git a/src/test/ui/should-fail-no_gate_irrefutable_if_let_pattern.stderr b/src/test/ui/should-fail-no_gate_irrefutable_if_let_pattern.stderr deleted file mode 100644 index 9c9ebc6659b73..0000000000000 --- a/src/test/ui/should-fail-no_gate_irrefutable_if_let_pattern.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0162]: irrefutable if-let pattern - --> $DIR/should-fail-no_gate_irrefutable_if_let_pattern.rs:3:12 - | -LL | if let _ = 5 {} - | ^ irrefutable pattern - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0162`. diff --git a/src/test/ui/should-fail-with_gate_irrefutable_pattern_deny.rs b/src/test/ui/should-fail-with_gate_irrefutable_pattern_deny.rs deleted file mode 100644 index 1b9b3dc1a4cbe..0000000000000 --- a/src/test/ui/should-fail-with_gate_irrefutable_pattern_deny.rs +++ /dev/null @@ -1,7 +0,0 @@ -#![feature(irrefutable_let_patterns)] - -// should-fail-irrefutable_let_patterns_with_gate -fn main() { - if let _ = 5 {} - //~^ ERROR irrefutable if-let pattern [irrefutable_let_patterns] -} diff --git a/src/test/ui/should-fail-with_gate_irrefutable_pattern_deny.stderr b/src/test/ui/should-fail-with_gate_irrefutable_pattern_deny.stderr deleted file mode 100644 index dc670f0e59081..0000000000000 --- a/src/test/ui/should-fail-with_gate_irrefutable_pattern_deny.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: irrefutable if-let pattern - --> $DIR/should-fail-with_gate_irrefutable_pattern_deny.rs:5:5 - | -LL | if let _ = 5 {} - | ^^^^^^^^^^^^^^^ - | - = note: #[deny(irrefutable_let_patterns)] on by default - -error: aborting due to previous error - diff --git a/src/test/ui/static/static-mut-not-constant.rs b/src/test/ui/static/static-mut-not-constant.rs index 2091fffd418ee..84d401c9fa61d 100644 --- a/src/test/ui/static/static-mut-not-constant.rs +++ b/src/test/ui/static/static-mut-not-constant.rs @@ -2,5 +2,6 @@ static mut a: Box = box 3; //~^ ERROR allocations are not allowed in statics +//~| ERROR static contains unimplemented expression type fn main() {} diff --git a/src/test/ui/static/static-mut-not-constant.stderr b/src/test/ui/static/static-mut-not-constant.stderr index a0fa245156f87..d2c6ba6a2f85a 100644 --- a/src/test/ui/static/static-mut-not-constant.stderr +++ b/src/test/ui/static/static-mut-not-constant.stderr @@ -4,6 +4,13 @@ error[E0010]: allocations are not allowed in statics LL | static mut a: Box = box 3; | ^^^^^ allocation not allowed in statics -error: aborting due to previous error +error[E0019]: static contains unimplemented expression type + --> $DIR/static-mut-not-constant.rs:3:32 + | +LL | static mut a: Box = box 3; + | ^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0010`. +Some errors occurred: E0010, E0019. +For more information about an error, try `rustc --explain E0010`. diff --git a/src/test/ui/underscore_const_names.rs b/src/test/ui/underscore_const_names.rs index 811d166ed65a7..1db022e886208 100644 --- a/src/test/ui/underscore_const_names.rs +++ b/src/test/ui/underscore_const_names.rs @@ -1,6 +1,5 @@ // compile-pass -#![feature(const_let)] #![feature(underscore_const_names)] trait Trt {} diff --git a/src/test/ui/unsafe/ranged_ints2_const.rs b/src/test/ui/unsafe/ranged_ints2_const.rs index a61e3329bdce8..788f49f743cda 100644 --- a/src/test/ui/unsafe/ranged_ints2_const.rs +++ b/src/test/ui/unsafe/ranged_ints2_const.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, const_let, const_fn)] +#![feature(rustc_attrs)] #[rustc_layout_scalar_valid_range_start(1)] #[repr(transparent)] @@ -8,13 +8,13 @@ fn main() { const fn foo() -> NonZero { let mut x = unsafe { NonZero(1) }; - let y = &mut x.0; //~ ERROR references in constant functions may only refer to immutable + let y = &mut x.0; //~ ERROR references in const fn are unstable //~^ ERROR mutation of layout constrained field is unsafe unsafe { NonZero(1) } } const fn bar() -> NonZero { let mut x = unsafe { NonZero(1) }; - let y = unsafe { &mut x.0 }; //~ ERROR references in constant functions may only refer to immut + let y = unsafe { &mut x.0 }; //~ ERROR mutable references in const fn are unstable unsafe { NonZero(1) } } diff --git a/src/test/ui/unsafe/ranged_ints2_const.stderr b/src/test/ui/unsafe/ranged_ints2_const.stderr index f79792ffba9be..39a55190b17de 100644 --- a/src/test/ui/unsafe/ranged_ints2_const.stderr +++ b/src/test/ui/unsafe/ranged_ints2_const.stderr @@ -1,24 +1,23 @@ -error[E0017]: references in constant functions may only refer to immutable values - --> $DIR/ranged_ints2_const.rs:11:13 +error: mutable references in const fn are unstable + --> $DIR/ranged_ints2_const.rs:11:9 | -LL | let y = &mut x.0; //~ ERROR references in constant functions may only refer to immutable - | ^^^^^^^^ constant functions require immutable values +LL | let y = &mut x.0; //~ ERROR references in const fn are unstable + | ^ -error[E0017]: references in constant functions may only refer to immutable values - --> $DIR/ranged_ints2_const.rs:18:22 +error: mutable references in const fn are unstable + --> $DIR/ranged_ints2_const.rs:18:9 | -LL | let y = unsafe { &mut x.0 }; //~ ERROR references in constant functions may only refer to immut - | ^^^^^^^^ constant functions require immutable values +LL | let y = unsafe { &mut x.0 }; //~ ERROR mutable references in const fn are unstable + | ^ error[E0133]: mutation of layout constrained field is unsafe and requires unsafe function or block --> $DIR/ranged_ints2_const.rs:11:13 | -LL | let y = &mut x.0; //~ ERROR references in constant functions may only refer to immutable +LL | let y = &mut x.0; //~ ERROR references in const fn are unstable | ^^^^^^^^ mutation of layout constrained field | = note: mutating layout constrained fields cannot statically be checked for valid values error: aborting due to 3 previous errors -Some errors occurred: E0017, E0133. -For more information about an error, try `rustc --explain E0017`. +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/unsafe/ranged_ints3_const.rs b/src/test/ui/unsafe/ranged_ints3_const.rs index 6497b611224b6..7b03d8eda9380 100644 --- a/src/test/ui/unsafe/ranged_ints3_const.rs +++ b/src/test/ui/unsafe/ranged_ints3_const.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, const_let, const_fn)] +#![feature(rustc_attrs)] use std::cell::Cell; diff --git a/src/test/ui/unsafe/ranged_ints4_const.rs b/src/test/ui/unsafe/ranged_ints4_const.rs index f589e4739baf1..f09168c3d3f9c 100644 --- a/src/test/ui/unsafe/ranged_ints4_const.rs +++ b/src/test/ui/unsafe/ranged_ints4_const.rs @@ -1,4 +1,4 @@ -#![feature(rustc_attrs, const_let, const_fn)] +#![feature(rustc_attrs)] #[rustc_layout_scalar_valid_range_start(1)] #[repr(transparent)] diff --git a/src/test/ui/where-clauses/where-equality-constraints.stderr b/src/test/ui/where-clauses/where-equality-constraints.stderr index 56caaaeee401e..220447079c629 100644 --- a/src/test/ui/where-clauses/where-equality-constraints.stderr +++ b/src/test/ui/where-clauses/where-equality-constraints.stderr @@ -1,10 +1,10 @@ -error: equality constraints are not yet supported in where clauses (#20041) +error: equality constraints are not yet supported in where clauses (see #20041) --> $DIR/where-equality-constraints.rs:1:14 | LL | fn f() where u8 = u16 {} | ^^^^^^^^ -error: equality constraints are not yet supported in where clauses (#20041) +error: equality constraints are not yet supported in where clauses (see #20041) --> $DIR/where-equality-constraints.rs:3:14 | LL | fn g() where for<'a> &'static (u8,) == u16, {} diff --git a/src/test/ui/while-let.rs b/src/test/ui/while-let.rs index 348edc15aca4c..69f9de9497740 100644 --- a/src/test/ui/while-let.rs +++ b/src/test/ui/while-let.rs @@ -1,3 +1,5 @@ +// run-pass + fn macros() { macro_rules! foo{ ($p:pat, $e:expr, $b:block) => {{ @@ -10,16 +12,17 @@ fn macros() { }} } - foo!(a, 1, { //~ ERROR irrefutable while-let + foo!(a, 1, { //~ WARN irrefutable while-let println!("irrefutable pattern"); }); - bar!(a, 1, { //~ ERROR irrefutable while-let + bar!(a, 1, { //~ WARN irrefutable while-let println!("irrefutable pattern"); }); } pub fn main() { - while let a = 1 { //~ ERROR irrefutable while-let + while let a = 1 { //~ WARN irrefutable while-let println!("irrefutable pattern"); + break; } } diff --git a/src/test/ui/while-let.stderr b/src/test/ui/while-let.stderr index 838dd8c14d7b5..6d61143d33c84 100644 --- a/src/test/ui/while-let.stderr +++ b/src/test/ui/while-let.stderr @@ -1,21 +1,33 @@ -error[E0165]: irrefutable while-let pattern - --> $DIR/while-let.rs:13:10 +warning: irrefutable while-let pattern + --> $DIR/while-let.rs:6:13 | -LL | foo!(a, 1, { //~ ERROR irrefutable while-let - | ^ irrefutable pattern - -error[E0165]: irrefutable while-let pattern - --> $DIR/while-let.rs:16:10 +LL | while let $p = $e $b + | ^^^^^ +... +LL | / foo!(a, 1, { //~ WARN irrefutable while-let +LL | | println!("irrefutable pattern"); +LL | | }); + | |_______- in this macro invocation | -LL | bar!(a, 1, { //~ ERROR irrefutable while-let - | ^ irrefutable pattern + = note: #[warn(irrefutable_let_patterns)] on by default -error[E0165]: irrefutable while-let pattern - --> $DIR/while-let.rs:22:15 +warning: irrefutable while-let pattern + --> $DIR/while-let.rs:6:13 | -LL | while let a = 1 { //~ ERROR irrefutable while-let - | ^ irrefutable pattern +LL | while let $p = $e $b + | ^^^^^ +... +LL | / bar!(a, 1, { //~ WARN irrefutable while-let +LL | | println!("irrefutable pattern"); +LL | | }); + | |_______- in this macro invocation -error: aborting due to 3 previous errors +warning: irrefutable while-let pattern + --> $DIR/while-let.rs:24:5 + | +LL | / while let a = 1 { //~ WARN irrefutable while-let +LL | | println!("irrefutable pattern"); +LL | | break; +LL | | } + | |_____^ -For more information about this error, try `rustc --explain E0165`. diff --git a/src/test/ui/write-to-static-mut-in-static.rs b/src/test/ui/write-to-static-mut-in-static.rs index 3c34a7704e0df..43c63fed8cef1 100644 --- a/src/test/ui/write-to-static-mut-in-static.rs +++ b/src/test/ui/write-to-static-mut-in-static.rs @@ -1,5 +1,3 @@ -#![feature(const_let)] - pub static mut A: u32 = 0; pub static mut B: () = unsafe { A = 1; }; //~^ ERROR could not evaluate static initializer diff --git a/src/test/ui/write-to-static-mut-in-static.stderr b/src/test/ui/write-to-static-mut-in-static.stderr index 7be83b8dafcfd..eba1c609d2f83 100644 --- a/src/test/ui/write-to-static-mut-in-static.stderr +++ b/src/test/ui/write-to-static-mut-in-static.stderr @@ -1,23 +1,23 @@ error[E0080]: could not evaluate static initializer - --> $DIR/write-to-static-mut-in-static.rs:4:33 + --> $DIR/write-to-static-mut-in-static.rs:2:33 | LL | pub static mut B: () = unsafe { A = 1; }; | ^^^^^ tried to modify a static's initial value from another static's initializer error[E0391]: cycle detected when const-evaluating `C` - --> $DIR/write-to-static-mut-in-static.rs:7:34 + --> $DIR/write-to-static-mut-in-static.rs:5:34 | LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ^^^^^ | note: ...which requires const-evaluating `C`... - --> $DIR/write-to-static-mut-in-static.rs:7:1 + --> $DIR/write-to-static-mut-in-static.rs:5:1 | LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating `C`, completing the cycle note: cycle used when const-evaluating + checking `C` - --> $DIR/write-to-static-mut-in-static.rs:7:1 + --> $DIR/write-to-static-mut-in-static.rs:5:1 | LL | pub static mut C: u32 = unsafe { C = 1; 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 28c0b6ccb3187..b00daa716777f 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -131,7 +131,8 @@ struct Manifest { manifest_version: String, date: String, pkg: BTreeMap, - renames: BTreeMap + renames: BTreeMap, + profiles: BTreeMap>, } #[derive(Serialize)] @@ -340,6 +341,7 @@ impl Builder { date: self.date.to_string(), pkg: BTreeMap::new(), renames: BTreeMap::new(), + profiles: BTreeMap::new(), }; self.package("rustc", &mut manifest.pkg, HOSTS); @@ -355,6 +357,20 @@ impl Builder { self.package("llvm-tools-preview", &mut manifest.pkg, TARGETS); self.package("lldb-preview", &mut manifest.pkg, TARGETS); + self.profile("minimal", + &mut manifest.profiles, + &["rustc", "cargo", "rust-std", "rust-mingw"]); + self.profile("default", + &mut manifest.profiles, + &["rustc", "cargo", "rust-std", "rust-mingw", + "rust-docs", "rustfmt-preview", "clippy-preview"]); + self.profile("complete", + &mut manifest.profiles, + &["rustc", "cargo", "rust-std", "rust-mingw", + "rust-docs", "rustfmt-preview", "clippy-preview", + "rls-preview", "rust-src", "llvm-tools-preview", + "lldb-preview", "rust-analysis"]); + manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() }); manifest.renames.insert("rustfmt".to_owned(), Rename { to: "rustfmt-preview".to_owned() }); manifest.renames.insert("clippy".to_owned(), Rename { to: "clippy-preview".to_owned() }); @@ -453,6 +469,13 @@ impl Builder { return manifest; } + fn profile(&mut self, + profile_name: &str, + dst: &mut BTreeMap>, + pkgs: &[&str]) { + dst.insert(profile_name.to_owned(), pkgs.iter().map(|s| (*s).to_owned()).collect()); + } + fn package(&mut self, pkgname: &str, dst: &mut BTreeMap,