diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index a053253ec16..5a362a37f2b 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -633,6 +633,7 @@ macro_rules! untracked { untracked!(dump_mir_graphviz, true); untracked!(emit_future_incompat_report, true); untracked!(emit_stack_sizes, true); + untracked!(future_incompat_test, true); untracked!(hir_stats, true); untracked!(identify_regions, true); untracked!(incremental_ignore_spans, true); diff --git a/compiler/rustc_middle/src/ich/impls_syntax.rs b/compiler/rustc_middle/src/ich/impls_syntax.rs index 2d8f661ef59..1c66f831b5f 100644 --- a/compiler/rustc_middle/src/ich/impls_syntax.rs +++ b/compiler/rustc_middle/src/ich/impls_syntax.rs @@ -6,6 +6,7 @@ use rustc_ast as ast; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_span::{BytePos, NormalizedPos, SourceFile}; +use std::assert::assert_matches; use smallvec::SmallVec; diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index 484e30027e5..848e60fe134 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -8,7 +8,7 @@ use rustc_index::vec::IndexVec; use rustc_session::lint::{ builtin::{self, FORBIDDEN_LINT_GROUPS}, - FutureIncompatibilityReason, FutureIncompatibleInfo, Level, Lint, LintId, + FutureIncompatibilityReason, Level, Lint, LintId, }; use rustc_session::{DiagnosticMessageId, Session}; use rustc_span::hygiene::MacroKind; @@ -223,12 +223,12 @@ fn struct_lint_level_impl( let lint_id = LintId::of(lint); let future_incompatible = lint.future_incompatible; - let has_future_breakage = matches!( - future_incompatible, - Some(FutureIncompatibleInfo { - reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, - .. - }) + let has_future_breakage = future_incompatible.map_or( + // Default allow lints trigger too often for testing. + sess.opts.debugging_opts.future_incompat_test && lint.default_level != Level::Allow, + |incompat| { + matches!(incompat.reason, FutureIncompatibilityReason::FutureReleaseErrorReportNow) + }, ); let mut err = match (level, span) { diff --git a/compiler/rustc_mir/src/interpret/memory.rs b/compiler/rustc_mir/src/interpret/memory.rs index 5f719cc1607..194c478cc99 100644 --- a/compiler/rustc_mir/src/interpret/memory.rs +++ b/compiler/rustc_mir/src/interpret/memory.rs @@ -6,6 +6,7 @@ //! integer. It is crucial that these operations call `check_align` *before* //! short-circuiting the empty case! +use std::assert::assert_matches; use std::borrow::Cow; use std::collections::VecDeque; use std::convert::{TryFrom, TryInto}; diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 03d94f43897..7439cd9a0fe 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -502,14 +502,14 @@ impl<'a> Resolver<'a> { err } - ResolutionError::SelfInTyParamDefault => { + ResolutionError::SelfInGenericParamDefault => { let mut err = struct_span_err!( self.session, span, E0735, - "type parameters cannot use `Self` in their defaults" + "generic parameters cannot use `Self` in their defaults" ); - err.span_label(span, "`Self` in type parameter default".to_string()); + err.span_label(span, "`Self` in generic parameter default".to_string()); err } ResolutionError::UnreachableLabel { name, definition_span, suggestion } => { diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 4d124152151..fb2eb749e11 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -249,7 +249,7 @@ enum ResolutionError<'a> { /// This error is only emitted when using `min_const_generics`. ParamInNonTrivialAnonConst { name: Symbol, is_type: bool }, /// Error E0735: generic parameters with a default cannot use `Self` - SelfInTyParamDefault, + SelfInGenericParamDefault, /// Error E0767: use of unreachable label UnreachableLabel { name: Symbol, definition_span: Span, suggestion: Option }, } @@ -2643,7 +2643,7 @@ fn validate_res_from_ribs( if let ForwardGenericParamBanRibKind = all_ribs[rib_index].kind { if record_used { let res_error = if rib_ident.name == kw::SelfUpper { - ResolutionError::SelfInTyParamDefault + ResolutionError::SelfInGenericParamDefault } else { ResolutionError::ForwardDeclaredGenericParam }; diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 4c40d0c367e..474cd86f43b 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1084,6 +1084,8 @@ mod parse { "set the optimization fuel quota for a crate"), function_sections: Option = (None, parse_opt_bool, [TRACKED], "whether each function should go in its own section"), + future_incompat_test: bool = (false, parse_bool, [UNTRACKED], + "forces all lints to be future incompatible, used for internal testing (default: no)"), gcc_ld: Option = (None, parse_gcc_ld, [TRACKED], "implementation of ld used by cc"), graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED], "use dark-themed colors in graphviz output (default: no)"), diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index 4b34a7dc894..d821e715622 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -19,7 +19,6 @@ use core::mem::size_of_val; use core::mem::{self, align_of_val_raw}; use core::ops::{CoerceUnsized, Deref, DispatchFromDyn, Receiver}; -#[cfg(not(no_global_oom_handling))] use core::pin::Pin; use core::ptr::{self, NonNull}; #[cfg(not(no_global_oom_handling))] @@ -494,6 +493,13 @@ pub fn pin(data: T) -> Pin> { unsafe { Pin::new_unchecked(Arc::new(data)) } } + /// Constructs a new `Pin>`, return an error if allocation fails. + #[unstable(feature = "allocator_api", issue = "32838")] + #[inline] + pub fn try_pin(data: T) -> Result>, AllocError> { + unsafe { Ok(Pin::new_unchecked(Arc::try_new(data)?)) } + } + /// Constructs a new `Arc`, returning an error if allocation fails. /// /// # Examples diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 3557dbad90c..01d33409a42 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -179,6 +179,16 @@ #[macro_use] mod macros; +// We don't export this through #[macro_export] for now, to avoid breakage. +// See https://github.com/rust-lang/rust/issues/82913 +#[cfg(not(test))] +#[unstable(feature = "assert_matches", issue = "82775")] +/// Unstable module containing the unstable `assert_matches` macro. +pub mod assert { + #[unstable(feature = "assert_matches", issue = "82775")] + pub use crate::macros::{assert_matches, debug_assert_matches}; +} + #[macro_use] mod internal_macros; diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 7d22bfedb93..8ce441e80bf 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -127,6 +127,8 @@ macro_rules! assert_ne { /// ``` /// #![feature(assert_matches)] /// +/// use std::assert::assert_matches; +/// /// let a = 1u32.checked_add(2); /// let b = 1u32.checked_sub(2); /// assert_matches!(a, Some(_)); @@ -135,10 +137,10 @@ macro_rules! assert_ne { /// let c = Ok("abc".to_string()); /// assert_matches!(c, Ok(x) | Err(x) if x.len() < 100); /// ``` -#[macro_export] #[unstable(feature = "assert_matches", issue = "82775")] #[allow_internal_unstable(core_panic)] -macro_rules! assert_matches { +#[rustc_macro_transparency = "semitransparent"] +pub macro assert_matches { ($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => ({ match $left { $( $pattern )|+ $( if $guard )? => {} @@ -150,7 +152,7 @@ macro_rules! assert_matches { ); } } - }); + }), ($left:expr, $( $pattern:pat_param )|+ $( if $guard: expr )?, $($arg:tt)+) => ({ match $left { $( $pattern )|+ $( if $guard )? => {} @@ -162,7 +164,7 @@ macro_rules! assert_matches { ); } } - }); + }), } /// Asserts that a boolean expression is `true` at runtime. @@ -284,6 +286,8 @@ macro_rules! debug_assert_ne { /// ``` /// #![feature(assert_matches)] /// +/// use std::assert::debug_assert_matches; +/// /// let a = 1u32.checked_add(2); /// let b = 1u32.checked_sub(2); /// debug_assert_matches!(a, Some(_)); @@ -295,8 +299,9 @@ macro_rules! debug_assert_ne { #[macro_export] #[unstable(feature = "assert_matches", issue = "82775")] #[allow_internal_unstable(assert_matches)] -macro_rules! debug_assert_matches { - ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_matches!($($arg)*); }) +#[rustc_macro_transparency = "semitransparent"] +pub macro debug_assert_matches($($arg:tt)*) { + if $crate::cfg!(debug_assertions) { $crate::assert::assert_matches!($($arg)*); } } /// Returns whether the given expression matches any of the given patterns. diff --git a/library/core/src/slice/rotate.rs b/library/core/src/slice/rotate.rs index a89596b15ef..7528927ef33 100644 --- a/library/core/src/slice/rotate.rs +++ b/library/core/src/slice/rotate.rs @@ -1,5 +1,3 @@ -// ignore-tidy-undocumented-unsafe - use crate::cmp; use crate::mem::{self, MaybeUninit}; use crate::ptr; @@ -79,8 +77,10 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) // the way until about `left + right == 32`, but the worst case performance breaks even // around 16. 24 was chosen as middle ground. If the size of `T` is larger than 4 // `usize`s, this algorithm also outperforms other algorithms. + // SAFETY: callers must ensure `mid - left` is valid for reading and writing. let x = unsafe { mid.sub(left) }; // beginning of first round + // SAFETY: see previous comment. let mut tmp: T = unsafe { x.read() }; let mut i = right; // `gcd` can be found before hand by calculating `gcd(left + right, right)`, @@ -92,6 +92,21 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) // the very end. This is possibly due to the fact that swapping or replacing temporaries // uses only one memory address in the loop instead of needing to manage two. loop { + // [long-safety-expl] + // SAFETY: callers must ensure `[left, left+mid+right)` are all valid for reading and + // writing. + // + // - `i` start with `right` so `mid-left <= x+i = x+right = mid-left+right < mid+right` + // - `i <= left+right-1` is always true + // - if `i < left`, `right` is added so `i < left+right` and on the next + // iteration `left` is removed from `i` so it doesn't go further + // - if `i >= left`, `left` is removed immediately and so it doesn't go further. + // - overflows cannot happen for `i` since the function's safety contract ask for + // `mid+right-1 = x+left+right` to be valid for writing + // - underflows cannot happen because `i` must be bigger or equal to `left` for + // a substraction of `left` to happen. + // + // So `x+i` is valid for reading and writing if the caller respected the contract tmp = unsafe { x.add(i).replace(tmp) }; // instead of incrementing `i` and then checking if it is outside the bounds, we // check if `i` will go outside the bounds on the next increment. This prevents @@ -100,6 +115,8 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) i -= left; if i == 0 { // end of first round + // SAFETY: tmp has been read from a valid source and x is valid for writing + // according to the caller. unsafe { x.write(tmp) }; break; } @@ -113,13 +130,24 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) } // finish the chunk with more rounds for start in 1..gcd { + // SAFETY: `gcd` is at most equal to `right` so all values in `1..gcd` are valid for + // reading and writing as per the function's safety contract, see [long-safety-expl] + // above tmp = unsafe { x.add(start).read() }; + // [safety-expl-addition] + // + // Here `start < gcd` so `start < right` so `i < right+right`: `right` being the + // greatest common divisor of `(left+right, right)` means that `left = right` so + // `i < left+right` so `x+i = mid-left+i` is always valid for reading and writing + // according to the function's safety contract. i = start + right; loop { + // SAFETY: see [long-safety-expl] and [safety-expl-addition] tmp = unsafe { x.add(i).replace(tmp) }; if i >= left { i -= left; if i == start { + // SAFETY: see [long-safety-expl] and [safety-expl-addition] unsafe { x.add(start).write(tmp) }; break; } @@ -135,14 +163,30 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) // The `[T; 0]` here is to ensure this is appropriately aligned for T let mut rawarray = MaybeUninit::<(BufType, [T; 0])>::uninit(); let buf = rawarray.as_mut_ptr() as *mut T; + // SAFETY: `mid-left <= mid-left+right < mid+right` let dim = unsafe { mid.sub(left).add(right) }; if left <= right { + // SAFETY: + // + // 1) The `else if` condition about the sizes ensures `[mid-left; left]` will fit in + // `buf` without overflow and `buf` was created just above and so cannot be + // overlapped with any value of `[mid-left; left]` + // 2) [mid-left, mid+right) are all valid for reading and writing and we don't care + // about overlaps here. + // 3) The `if` condition about `left <= right` ensures writing `left` elements to + // `dim = mid-left+right` is valid because: + // - `buf` is valid and `left` elements were written in it in 1) + // - `dim+left = mid-left+right+left = mid+right` and we write `[dim, dim+left)` unsafe { + // 1) ptr::copy_nonoverlapping(mid.sub(left), buf, left); + // 2) ptr::copy(mid, mid.sub(left), right); + // 3) ptr::copy_nonoverlapping(buf, dim, left); } } else { + // SAFETY: same reasoning as above but with `left` and `right` reversed unsafe { ptr::copy_nonoverlapping(mid, buf, right); ptr::copy(mid.sub(left), dim, left); @@ -156,6 +200,10 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) // of this algorithm would be, and swapping using that last chunk instead of swapping // adjacent chunks like this algorithm is doing, but this way is still faster. loop { + // SAFETY: + // `left >= right` so `[mid-right, mid+right)` is valid for reading and writing + // Substracting `right` from `mid` each turn is counterbalanced by the addition and + // check after it. unsafe { ptr::swap_nonoverlapping(mid.sub(right), mid, right); mid = mid.sub(right); @@ -168,6 +216,10 @@ pub unsafe fn ptr_rotate(mut left: usize, mut mid: *mut T, mut right: usize) } else { // Algorithm 3, `left < right` loop { + // SAFETY: `[mid-left, mid+left)` is valid for reading and writing because + // `left < right` so `mid+left < mid+right`. + // Adding `left` to `mid` each turn is counterbalanced by the substraction and check + // after it. unsafe { ptr::swap_nonoverlapping(mid.sub(left), mid, left); mid = mid.add(left); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 8c120f4af28..472bca3460f 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -548,8 +548,8 @@ pub mod task { #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::{ - assert_eq, assert_matches, assert_ne, debug_assert, debug_assert_eq, debug_assert_matches, - debug_assert_ne, matches, r#try, todo, unimplemented, unreachable, write, writeln, + assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, r#try, todo, + unimplemented, unreachable, write, writeln, }; // Re-export built-in macros defined through libcore. diff --git a/library/std/src/os/wasi/fs.rs b/library/std/src/os/wasi/fs.rs index 7f26f419a4b..bd30d6ae3f3 100644 --- a/library/std/src/os/wasi/fs.rs +++ b/library/std/src/os/wasi/fs.rs @@ -1,7 +1,7 @@ //! WASI-specific extensions to primitives in the `std::fs` module. #![deny(unsafe_op_in_unsafe_fn)] -#![unstable(feature = "wasi_ext", issue = "none")] +#![unstable(feature = "wasi_ext", issue = "71213")] use crate::ffi::OsStr; use crate::fs::{self, File, Metadata, OpenOptions}; diff --git a/library/std/src/os/wasi/io.rs b/library/std/src/os/wasi/io.rs index b2e79cc1b4a..cf4501b98cb 100644 --- a/library/std/src/os/wasi/io.rs +++ b/library/std/src/os/wasi/io.rs @@ -1,7 +1,7 @@ //! WASI-specific extensions to general I/O primitives #![deny(unsafe_op_in_unsafe_fn)] -#![unstable(feature = "wasi_ext", issue = "none")] +#![unstable(feature = "wasi_ext", issue = "71213")] use crate::fs; use crate::io; diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 3b599e4997a..e21469dc9c3 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -621,8 +621,7 @@ fn next(&mut self) -> Option { is_paragraph = true; } html::push_html(&mut ret, content.into_iter()); - write!(ret, " ", id) - .unwrap(); + write!(ret, " ", id).unwrap(); if is_paragraph { ret.push_str("

"); } diff --git a/src/test/ui/const-generics/defaults/default-const-param-cannot-reference-self.rs b/src/test/ui/const-generics/defaults/default-const-param-cannot-reference-self.rs new file mode 100644 index 00000000000..9af84439252 --- /dev/null +++ b/src/test/ui/const-generics/defaults/default-const-param-cannot-reference-self.rs @@ -0,0 +1,16 @@ +#![feature(const_generics_defaults)] + +struct Struct; +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] + +enum Enum { } +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] + +union Union { not_empty: () } +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] + +fn main() { + let _: Struct; + let _: Enum; + let _: Union; +} diff --git a/src/test/ui/const-generics/defaults/default-const-param-cannot-reference-self.stderr b/src/test/ui/const-generics/defaults/default-const-param-cannot-reference-self.stderr new file mode 100644 index 00000000000..5dfec2fcb73 --- /dev/null +++ b/src/test/ui/const-generics/defaults/default-const-param-cannot-reference-self.stderr @@ -0,0 +1,21 @@ +error[E0735]: generic parameters cannot use `Self` in their defaults + --> $DIR/default-const-param-cannot-reference-self.rs:3:34 + | +LL | struct Struct; + | ^^^^ `Self` in generic parameter default + +error[E0735]: generic parameters cannot use `Self` in their defaults + --> $DIR/default-const-param-cannot-reference-self.rs:6:30 + | +LL | enum Enum { } + | ^^^^ `Self` in generic parameter default + +error[E0735]: generic parameters cannot use `Self` in their defaults + --> $DIR/default-const-param-cannot-reference-self.rs:9:32 + | +LL | union Union { not_empty: () } + | ^^^^ `Self` in generic parameter default + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0735`. diff --git a/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs b/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs index b560cc2ce70..12db143e474 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs +++ b/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.rs @@ -11,25 +11,25 @@ // compatibility concern. struct Snobound<'a, P = Self> { x: Option<&'a P> } -//~^ ERROR type parameters cannot use `Self` in their defaults [E0735] +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] enum Enobound<'a, P = Self> { A, B(Option<&'a P>) } -//~^ ERROR type parameters cannot use `Self` in their defaults [E0735] +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] union Unobound<'a, P = Self> { x: i32, y: Option<&'a P> } -//~^ ERROR type parameters cannot use `Self` in their defaults [E0735] +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] // Disallowing `Self` in defaults sidesteps need to check the bounds // on the defaults in cases like these. struct Ssized<'a, P: Sized = [Self]> { x: Option<&'a P> } -//~^ ERROR type parameters cannot use `Self` in their defaults [E0735] +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] enum Esized<'a, P: Sized = [Self]> { A, B(Option<&'a P>) } -//~^ ERROR type parameters cannot use `Self` in their defaults [E0735] +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] union Usized<'a, P: Sized = [Self]> { x: i32, y: Option<&'a P> } -//~^ ERROR type parameters cannot use `Self` in their defaults [E0735] +//~^ ERROR generic parameters cannot use `Self` in their defaults [E0735] fn demo_usages() { // An ICE means you only get the error from the first line of the diff --git a/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr b/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr index 689ffbd0feb..f3a550801b9 100644 --- a/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr +++ b/src/test/ui/generics/issue-61631-default-type-param-cannot-reference-self.stderr @@ -1,38 +1,38 @@ -error[E0735]: type parameters cannot use `Self` in their defaults +error[E0735]: generic parameters cannot use `Self` in their defaults --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:13:25 | LL | struct Snobound<'a, P = Self> { x: Option<&'a P> } - | ^^^^ `Self` in type parameter default + | ^^^^ `Self` in generic parameter default -error[E0735]: type parameters cannot use `Self` in their defaults +error[E0735]: generic parameters cannot use `Self` in their defaults --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:16:23 | LL | enum Enobound<'a, P = Self> { A, B(Option<&'a P>) } - | ^^^^ `Self` in type parameter default + | ^^^^ `Self` in generic parameter default -error[E0735]: type parameters cannot use `Self` in their defaults +error[E0735]: generic parameters cannot use `Self` in their defaults --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:19:24 | LL | union Unobound<'a, P = Self> { x: i32, y: Option<&'a P> } - | ^^^^ `Self` in type parameter default + | ^^^^ `Self` in generic parameter default -error[E0735]: type parameters cannot use `Self` in their defaults +error[E0735]: generic parameters cannot use `Self` in their defaults --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:25:31 | LL | struct Ssized<'a, P: Sized = [Self]> { x: Option<&'a P> } - | ^^^^ `Self` in type parameter default + | ^^^^ `Self` in generic parameter default -error[E0735]: type parameters cannot use `Self` in their defaults +error[E0735]: generic parameters cannot use `Self` in their defaults --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:28:29 | LL | enum Esized<'a, P: Sized = [Self]> { A, B(Option<&'a P>) } - | ^^^^ `Self` in type parameter default + | ^^^^ `Self` in generic parameter default -error[E0735]: type parameters cannot use `Self` in their defaults +error[E0735]: generic parameters cannot use `Self` in their defaults --> $DIR/issue-61631-default-type-param-cannot-reference-self.rs:31:30 | LL | union Usized<'a, P: Sized = [Self]> { x: i32, y: Option<&'a P> } - | ^^^^ `Self` in type parameter default + | ^^^^ `Self` in generic parameter default error: aborting due to 6 previous errors diff --git a/src/test/ui/lint/future-incompat-test.rs b/src/test/ui/lint/future-incompat-test.rs new file mode 100644 index 00000000000..ce8c118dab2 --- /dev/null +++ b/src/test/ui/lint/future-incompat-test.rs @@ -0,0 +1,10 @@ +// compile-flags: -Zfuture-incompat-test -Zemit-future-incompat-report +// check-pass + +// The `-Zfuture-incompat-test flag causes any normal warning to be included +// in the future-incompatible report. The stderr output here should mention +// the future incompatible report (as extracted by compiletest). + +fn main() { + let x = 1; +} diff --git a/src/test/ui/lint/future-incompat-test.stderr b/src/test/ui/lint/future-incompat-test.stderr new file mode 100644 index 00000000000..52674a84384 --- /dev/null +++ b/src/test/ui/lint/future-incompat-test.stderr @@ -0,0 +1,9 @@ +Future incompatibility report: Future breakage diagnostic: +warning: unused variable: `x` + --> $DIR/future-incompat-test.rs:9:9 + | +LL | let x = 1; + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | + = note: `-A unused-variables` implied by `-A unused` + diff --git a/src/test/ui/macros/assert-matches-macro-msg.rs b/src/test/ui/macros/assert-matches-macro-msg.rs index 43be9532f5d..714a6561a6d 100644 --- a/src/test/ui/macros/assert-matches-macro-msg.rs +++ b/src/test/ui/macros/assert-matches-macro-msg.rs @@ -6,6 +6,8 @@ #![feature(assert_matches)] +use std::assert::assert_matches; + fn main() { assert_matches!(1 + 1, 3, "1 + 1 definitely should be 3"); } diff --git a/src/test/ui/matches2021.rs b/src/test/ui/matches2021.rs index 1090b1578ba..a6fa5128d2f 100644 --- a/src/test/ui/matches2021.rs +++ b/src/test/ui/matches2021.rs @@ -6,6 +6,8 @@ #![feature(assert_matches)] +use std::assert::assert_matches; + fn main() { assert!(matches!((), ())); assert_matches!((), ()); diff --git a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr index e764480e8e5..070b0667213 100644 --- a/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr +++ b/src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr @@ -81,7 +81,7 @@ LL | tuple_from_req!(Foo); warning: 5 warnings emitted -Future incompatibility report: Future breakage date: None, diagnostic: +Future incompatibility report: Future breakage diagnostic: warning: using an old version of `time-macros-impl` --> $DIR/time-macros-impl/src/lib.rs:5:32 | @@ -99,7 +99,7 @@ LL | impl_macros!(Foo); = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) -Future breakage date: None, diagnostic: +Future breakage diagnostic: warning: using an old version of `time-macros-impl` --> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32 | @@ -116,7 +116,7 @@ LL | impl_macros!(Foo); = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info) -Future breakage date: None, diagnostic: +Future breakage diagnostic: warning: using an old version of `js-sys` --> $DIR/js-sys-0.3.17/src/lib.rs:5:32 | @@ -133,7 +133,7 @@ LL | arrays!(Foo); = note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above = note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info) -Future breakage date: None, diagnostic: +Future breakage diagnostic: warning: using an old version of `actix-web` --> $DIR/actix-web/src/extract.rs:5:34 | @@ -150,7 +150,7 @@ LL | tuple_from_req!(Foo); = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info) -Future breakage date: None, diagnostic: +Future breakage diagnostic: warning: using an old version of `actix-web` --> $DIR/actix-web-2.0.0/src/extract.rs:5:34 | diff --git a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr index 0b930705e35..4d6edab08e2 100644 --- a/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr +++ b/src/test/ui/proc-macro/issue-73933-procedural-masquerade.stderr @@ -11,7 +11,7 @@ LL | enum ProceduralMasqueradeDummyType { warning: 1 warning emitted -Future incompatibility report: Future breakage date: None, diagnostic: +Future incompatibility report: Future breakage diagnostic: warning: using `procedural-masquerade` crate --> $DIR/issue-73933-procedural-masquerade.rs:8:6 | diff --git a/src/test/ui/resolve/resolve-hint-macro.rs b/src/test/ui/resolve/resolve-hint-macro.rs index 6155ae7bcdf..5532c8b90e3 100644 --- a/src/test/ui/resolve/resolve-hint-macro.rs +++ b/src/test/ui/resolve/resolve-hint-macro.rs @@ -1,4 +1,4 @@ fn main() { - assert(true); - //~^ ERROR expected function, found macro `assert` + assert_eq(1, 1); + //~^ ERROR expected function, found macro `assert_eq` } diff --git a/src/test/ui/resolve/resolve-hint-macro.stderr b/src/test/ui/resolve/resolve-hint-macro.stderr index 7d35ce7e65e..efcfc7198ab 100644 --- a/src/test/ui/resolve/resolve-hint-macro.stderr +++ b/src/test/ui/resolve/resolve-hint-macro.stderr @@ -1,13 +1,13 @@ -error[E0423]: expected function, found macro `assert` +error[E0423]: expected function, found macro `assert_eq` --> $DIR/resolve-hint-macro.rs:2:5 | -LL | assert(true); - | ^^^^^^ not a function +LL | assert_eq(1, 1); + | ^^^^^^^^^ not a function | help: use `!` to invoke the macro | -LL | assert!(true); - | ^ +LL | assert_eq!(1, 1); + | ^ error: aborting due to previous error diff --git a/src/tools/cargo b/src/tools/cargo index 3ebb5f15a94..66a6737a0c9 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 3ebb5f15a940810f250b68821149387af583a79e +Subproject commit 66a6737a0c9f3a974af2dd032a65d3e409c77aac diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 8d23227fdb8..dc6d67983c5 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -43,7 +43,6 @@ struct FutureIncompatReport { #[derive(Deserialize)] struct FutureBreakageItem { - future_breakage_date: Option, diagnostic: Diagnostic, } @@ -104,9 +103,7 @@ pub fn extract_rendered(output: &str) -> String { .into_iter() .map(|item| { format!( - "Future breakage date: {}, diagnostic:\n{}", - item.future_breakage_date - .unwrap_or_else(|| "None".to_string()), + "Future breakage diagnostic:\n{}", item.diagnostic .rendered .unwrap_or_else(|| "Not rendered".to_string())