diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index a8c0aeb787078..970b9115d8d79 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -1557,31 +1557,46 @@ impl<'a> TraitDef<'a> { }), ), ); - // In general, fields in packed structs are copied via a - // block, e.g. `&{self.0}`. The one exception is `[u8]` - // fields, which cannot be copied and also never cause - // unaligned references. This exception is allowed to - // handle the `FlexZeroSlice` type in the `zerovec` crate - // within `icu4x-0.9.0`. - // - // Once use of `icu4x-0.9.0` has dropped sufficiently, this - // exception should be removed. - let is_u8_slice = if let TyKind::Slice(ty) = &struct_field.ty.kind && - let TyKind::Path(None, rustc_ast::Path { segments, .. }) = &ty.kind && - let [seg] = segments.as_slice() && - seg.ident.name == sym::u8 && seg.args.is_none() - { - true - } else { - false - }; if is_packed { - if is_u8_slice { + // In general, fields in packed structs are copied via a + // block, e.g. `&{self.0}`. The two exceptions are `[u8]` + // and `str` fields, which cannot be copied and also never + // cause unaligned references. These exceptions are allowed + // to handle the `FlexZeroSlice` type in the `zerovec` + // crate within `icu4x-0.9.0`. + // + // Once use of `icu4x-0.9.0` has dropped sufficiently, this + // exception should be removed. + let is_simple_path = |ty: &P, sym| { + if let TyKind::Path(None, ast::Path { segments, .. }) = &ty.kind && + let [seg] = segments.as_slice() && + seg.ident.name == sym && seg.args.is_none() + { + true + } else { + false + } + }; + + let exception = if let TyKind::Slice(ty) = &struct_field.ty.kind && + is_simple_path(ty, sym::u8) + { + Some("byte") + } else if is_simple_path(&struct_field.ty, sym::str) { + Some("string") + } else { + None + }; + + if let Some(ty) = exception { cx.sess.parse_sess.buffer_lint_with_diagnostic( BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE, sp, ast::CRATE_NODE_ID, - "byte slice in a packed struct that derives a built-in trait", + &format!( + "{} slice in a packed struct that derives a built-in trait", + ty + ), rustc_lint_defs::BuiltinLintDiagnostics::ByteSliceInPackedStructWithDerive ); } else { diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index a392d70f100a4..bdf2978cee258 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -229,10 +229,6 @@ fn run_compiler( registry: diagnostics_registry(), }; - if !tracing::dispatcher::has_been_set() { - init_rustc_env_logger_with_backtrace_option(&config.opts.unstable_opts.log_backtrace); - } - match make_input(config.opts.error_format, &matches.free) { Err(reported) => return Err(reported), Ok(Some(input)) => { @@ -1251,16 +1247,7 @@ pub fn install_ice_hook() { /// This allows tools to enable rust logging without having to magically match rustc's /// tracing crate version. pub fn init_rustc_env_logger() { - init_rustc_env_logger_with_backtrace_option(&None); -} - -/// This allows tools to enable rust logging without having to magically match rustc's -/// tracing crate version. In contrast to `init_rustc_env_logger` it allows you to -/// choose a target module you wish to show backtraces along with its logging. -pub fn init_rustc_env_logger_with_backtrace_option(backtrace_target: &Option) { - if let Err(error) = rustc_log::init_rustc_env_logger_with_backtrace_option(backtrace_target) { - early_error(ErrorOutputType::default(), &error.to_string()); - } + init_env_logger("RUSTC_LOG"); } /// This allows tools to enable rust logging without having to magically match rustc's @@ -1324,6 +1311,7 @@ mod signal_handler { pub fn main() -> ! { let start_time = Instant::now(); let start_rss = get_resident_set_size(); + init_rustc_env_logger(); signal_handler::install(); let mut callbacks = TimePassesCallbacks::default(); install_ice_hook(); diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 52a4e0e74181f..5165ee424e31b 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -758,7 +758,6 @@ fn test_unstable_options_tracking_hash() { tracked!(link_only, true); tracked!(llvm_plugins, vec![String::from("plugin_name")]); tracked!(location_detail, LocationDetail { file: true, line: false, column: false }); - tracked!(log_backtrace, Some("filter".to_string())); tracked!(maximal_hir_to_mir_coverage, true); tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(mir_emit_retag, true); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 7e9ba4cd22b8d..9d8ad9d9ed9f6 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -4073,7 +4073,8 @@ declare_lint! { declare_lint! { /// The `byte_slice_in_packed_struct_with_derive` lint detects cases where a byte slice field - /// (`[u8]`) is used in a `packed` struct that derives one or more built-in traits. + /// (`[u8]`) or string slice field (`str`) is used in a `packed` struct that derives one or + /// more built-in traits. /// /// ### Example /// @@ -4091,11 +4092,11 @@ declare_lint! { /// ### Explanation /// /// This was previously accepted but is being phased out, because fields in packed structs are - /// now required to implement `Copy` for `derive` to work. Byte slices are a temporary - /// exception because certain crates depended on them. + /// now required to implement `Copy` for `derive` to work. Byte slices and string slices are a + /// temporary exception because certain crates depended on them. pub BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE, Warn, - "`[u8]` slice used in a packed struct with `derive`", + "`[u8]` or `str` used in a packed struct with `derive`", @future_incompatible = FutureIncompatibleInfo { reference: "issue #107457 ", reason: FutureIncompatibilityReason::FutureReleaseErrorReportNow, diff --git a/compiler/rustc_log/src/lib.rs b/compiler/rustc_log/src/lib.rs index fc1cabd2de951..019fdc30dcec5 100644 --- a/compiler/rustc_log/src/lib.rs +++ b/compiler/rustc_log/src/lib.rs @@ -54,25 +54,12 @@ use tracing_subscriber::fmt::{ use tracing_subscriber::layer::SubscriberExt; pub fn init_rustc_env_logger() -> Result<(), Error> { - init_rustc_env_logger_with_backtrace_option(&None) -} - -pub fn init_rustc_env_logger_with_backtrace_option( - backtrace_target: &Option, -) -> Result<(), Error> { - init_env_logger_with_backtrace_option("RUSTC_LOG", backtrace_target) + init_env_logger("RUSTC_LOG") } /// In contrast to `init_rustc_env_logger` this allows you to choose an env var /// other than `RUSTC_LOG`. pub fn init_env_logger(env: &str) -> Result<(), Error> { - init_env_logger_with_backtrace_option(env, &None) -} - -pub fn init_env_logger_with_backtrace_option( - env: &str, - backtrace_target: &Option, -) -> Result<(), Error> { let filter = match env::var(env) { Ok(env) => EnvFilter::new(env), _ => EnvFilter::default().add_directive(Directive::from(LevelFilter::WARN)), @@ -106,8 +93,8 @@ pub fn init_env_logger_with_backtrace_option( let layer = layer.with_thread_ids(true).with_thread_names(true); let subscriber = tracing_subscriber::Registry::default().with(filter).with(layer); - match backtrace_target { - Some(str) => { + match env::var(format!("{env}_BACKTRACE")) { + Ok(str) => { let fmt_layer = tracing_subscriber::fmt::layer() .with_writer(io::stderr) .without_time() @@ -115,7 +102,7 @@ pub fn init_env_logger_with_backtrace_option( let subscriber = subscriber.with(fmt_layer); tracing::subscriber::set_global_default(subscriber).unwrap(); } - None => { + Err(_) => { tracing::subscriber::set_global_default(subscriber).unwrap(); } }; diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index a19ea04fa5e75..5b92563fc358b 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -694,8 +694,9 @@ impl<'a> Parser<'a> { // `where`, so stop if it's it. // We also continue if we find types (not traits), again for error recovery. while self.can_begin_bound() - || self.token.can_begin_type() - || (self.token.is_reserved_ident() && !self.token.is_keyword(kw::Where)) + || (self.may_recover() + && (self.token.can_begin_type() + || (self.token.is_reserved_ident() && !self.token.is_keyword(kw::Where)))) { if self.token.is_keyword(kw::Dyn) { // Account for `&dyn Trait + dyn Other`. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 0db4d85ff4b67..61cb81aec3de0 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1413,8 +1413,6 @@ options! { "what location details should be tracked when using caller_location, either \ `none`, or a comma separated list of location details, for which \ valid options are `file`, `line`, and `column` (default: `file,line,column`)"), - log_backtrace: Option = (None, parse_opt_string, [TRACKED], - "add a backtrace along with logging"), ls: bool = (false, parse_bool, [UNTRACKED], "list the symbols defined by a library crate (default: no)"), macro_backtrace: bool = (false, parse_bool, [UNTRACKED], diff --git a/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs b/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs index 7514c7ee55170..a2ca4bc189c87 100644 --- a/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs +++ b/compiler/rustc_trait_selection/src/solve/search_graph/mod.rs @@ -7,7 +7,7 @@ use cache::ProvisionalCache; use overflow::OverflowData; use rustc_index::vec::IndexVec; use rustc_middle::ty::TyCtxt; -use std::collections::hash_map::Entry; +use std::{collections::hash_map::Entry, mem}; rustc_index::newtype_index! { pub struct StackDepth {} @@ -134,12 +134,15 @@ impl<'tcx> SearchGraph<'tcx> { let provisional_entry_index = *cache.lookup_table.get(&goal).unwrap(); let provisional_entry = &mut cache.entries[provisional_entry_index]; let depth = provisional_entry.depth; + // We eagerly update the response in the cache here. If we have to reevaluate + // this goal we use the new response when hitting a cycle, and we definitely + // want to access the final response whenever we look at the cache. + let prev_response = mem::replace(&mut provisional_entry.response, response); + // Was the current goal the root of a cycle and was the provisional response // different from the final one. - if has_been_used && provisional_entry.response != response { - // If so, update the provisional reponse for this goal... - provisional_entry.response = response; - // ...remove all entries whose result depends on this goal + if has_been_used && prev_response != response { + // If so, remove all entries whose result depends on this goal // from the provisional cache... // // That's not completely correct, as a nested goal can also diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 76dabfb429dd5..e9cc3875f683b 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -116,7 +116,6 @@ #![feature(const_eval_select)] #![feature(const_pin)] #![feature(const_waker)] -#![feature(cstr_from_bytes_until_nul)] #![feature(dispatch_from_dyn)] #![feature(error_generic_member_access)] #![feature(error_in_core)] diff --git a/library/core/src/error.rs b/library/core/src/error.rs index d2fac23ff18be..e11a5e99184cb 100644 --- a/library/core/src/error.rs +++ b/library/core/src/error.rs @@ -505,7 +505,7 @@ impl Error for crate::ffi::FromBytesWithNulError { } } -#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")] +#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")] impl Error for crate::ffi::FromBytesUntilNulError {} #[unstable(feature = "get_many_mut", issue = "104642")] diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index 15dd9ea7e8036..82e5fa75ded84 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -150,10 +150,10 @@ impl FromBytesWithNulError { /// This error is created by the [`CStr::from_bytes_until_nul`] method. /// #[derive(Clone, PartialEq, Eq, Debug)] -#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")] +#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")] pub struct FromBytesUntilNulError(()); -#[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")] +#[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for FromBytesUntilNulError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "data provided does not contain a nul") @@ -306,8 +306,6 @@ impl CStr { /// /// # Examples /// ``` - /// #![feature(cstr_from_bytes_until_nul)] - /// /// use std::ffi::CStr; /// /// let mut buffer = [0u8; 16]; @@ -322,8 +320,9 @@ impl CStr { /// assert_eq!(c_str.to_str().unwrap(), "AAAAAAAA"); /// ``` /// - #[unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")] - #[rustc_const_unstable(feature = "cstr_from_bytes_until_nul", issue = "95027")] + #[rustc_allow_const_fn_unstable(const_slice_index)] + #[stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "cstr_from_bytes_until_nul", since = "CURRENT_RUSTC_VERSION")] pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError> { let nul_pos = memchr::memchr(0, bytes); match nul_pos { diff --git a/library/core/src/slice/memchr.rs b/library/core/src/slice/memchr.rs index c848c2e18e9b5..98c8349eb6024 100644 --- a/library/core/src/slice/memchr.rs +++ b/library/core/src/slice/memchr.rs @@ -16,25 +16,29 @@ const USIZE_BYTES: usize = mem::size_of::(); /// bytes where the borrow propagated all the way to the most significant /// bit." #[inline] +#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")] const fn contains_zero_byte(x: usize) -> bool { x.wrapping_sub(LO_USIZE) & !x & HI_USIZE != 0 } -#[cfg(target_pointer_width = "16")] #[inline] +#[cfg(target_pointer_width = "16")] +#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")] const fn repeat_byte(b: u8) -> usize { (b as usize) << 8 | b as usize } -#[cfg(not(target_pointer_width = "16"))] #[inline] +#[cfg(not(target_pointer_width = "16"))] +#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")] const fn repeat_byte(b: u8) -> usize { (b as usize) * (usize::MAX / 255) } /// Returns the first index matching the byte `x` in `text`. -#[must_use] #[inline] +#[must_use] +#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")] pub const fn memchr(x: u8, text: &[u8]) -> Option { // Fast path for small slices. if text.len() < 2 * USIZE_BYTES { @@ -45,6 +49,7 @@ pub const fn memchr(x: u8, text: &[u8]) -> Option { } #[inline] +#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")] const fn memchr_naive(x: u8, text: &[u8]) -> Option { let mut i = 0; @@ -60,6 +65,10 @@ const fn memchr_naive(x: u8, text: &[u8]) -> Option { None } +#[rustc_allow_const_fn_unstable(const_cmp)] +#[rustc_allow_const_fn_unstable(const_slice_index)] +#[rustc_allow_const_fn_unstable(const_align_offset)] +#[rustc_const_stable(feature = "const_memchr", since = "1.65.0")] const fn memchr_aligned(x: u8, text: &[u8]) -> Option { // Scan for a single byte value by reading two `usize` words at a time. // diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 762f7a7c9a1a0..cd9f74820ae9b 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -278,7 +278,6 @@ #![feature(char_error_internals)] #![feature(char_internals)] #![feature(core_intrinsics)] -#![feature(cstr_from_bytes_until_nul)] #![feature(cstr_internals)] #![feature(duration_constants)] #![feature(error_generic_member_access)] diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index c41e093a7e5c6..439b8d52a2d86 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -396,6 +396,14 @@ impl AsFd for crate::sync::Arc { } } +#[stable(feature = "asfd_rc", since = "CURRENT_RUSTC_VERSION")] +impl AsFd for crate::rc::Rc { + #[inline] + fn as_fd(&self) -> BorrowedFd<'_> { + (**self).as_fd() + } +} + #[stable(feature = "asfd_ptrs", since = "1.64.0")] impl AsFd for Box { #[inline] diff --git a/library/std/src/os/fd/raw.rs b/library/std/src/os/fd/raw.rs index f92a05066706d..c138162f1ab08 100644 --- a/library/std/src/os/fd/raw.rs +++ b/library/std/src/os/fd/raw.rs @@ -244,6 +244,14 @@ impl AsRawFd for crate::sync::Arc { } } +#[stable(feature = "asfd_rc", since = "CURRENT_RUSTC_VERSION")] +impl AsRawFd for crate::rc::Rc { + #[inline] + fn as_raw_fd(&self) -> RawFd { + (**self).as_raw_fd() + } +} + #[stable(feature = "asrawfd_ptrs", since = "1.63.0")] impl AsRawFd for Box { #[inline] diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 5b19a658fb543..c298817895cd1 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -87,14 +87,16 @@ def _download(path, url, probably_big, verbose, exception): # If curl is not present on Win32, we should not sys.exit # but raise `CalledProcessError` or `OSError` instead require(["curl", "--version"], exception=platform_is_win32) - run(["curl", option, - "-L", # Follow redirect. - "-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds - "--connect-timeout", "30", # timeout if cannot connect within 30 seconds - "--retry", "3", "-Sf", "-o", path, url], - verbose=verbose, - exception=True, # Will raise RuntimeError on failure - ) + with open(path, "wb") as outfile: + run(["curl", option, + "-L", # Follow redirect. + "-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds + "--connect-timeout", "30", # timeout if cannot connect within 30 seconds + "--retry", "3", "-Sf", url], + stdout=outfile, #Implements cli redirect operator '>' + verbose=verbose, + exception=True, # Will raise RuntimeError on failure + ) except (subprocess.CalledProcessError, OSError, RuntimeError): # see http://serverfault.com/questions/301128/how-to-download if platform_is_win32: diff --git a/src/bootstrap/setup.rs b/src/bootstrap/setup.rs index c98a52450849e..2b613ad50ee48 100644 --- a/src/bootstrap/setup.rs +++ b/src/bootstrap/setup.rs @@ -24,10 +24,12 @@ pub enum Profile { } /// A list of historical hashes of `src/etc/vscode_settings.json`. -/// New entries should be appended whenever this is updated so we can detected +/// New entries should be appended whenever this is updated so we can detect /// outdated vs. user-modified settings files. -static SETTINGS_HASHES: &[&str] = - &["ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8"]; +static SETTINGS_HASHES: &[&str] = &[ + "ea67e259dedf60d4429b6c349a564ffcd1563cf41c920a856d1f5b16b4701ac8", + "56e7bf011c71c5d81e0bf42e84938111847a810eee69d906bba494ea90b51922", +]; static VSCODE_SETTINGS: &str = include_str!("../etc/vscode_settings.json"); impl Profile { diff --git a/src/etc/vscode_settings.json b/src/etc/vscode_settings.json index cd61a38c5da98..04c34ce91c0b7 100644 --- a/src/etc/vscode_settings.json +++ b/src/etc/vscode_settings.json @@ -1,4 +1,6 @@ { + "rust-analyzer.check.invocationLocation": "root", + "rust-analyzer.check.invocationStrategy": "once", "rust-analyzer.checkOnSave.overrideCommand": [ "python3", "x.py", diff --git a/src/librustdoc/html/static/images/wheel.svg b/src/librustdoc/html/static/images/wheel.svg index 01da3b24c7c4f..83c07f63d10ab 100644 --- a/src/librustdoc/html/static/images/wheel.svg +++ b/src/librustdoc/html/static/images/wheel.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/tools/miri/tests/pass-dep/shims/pthreads.rs b/src/tools/miri/tests/pass-dep/shims/pthreads.rs index 09dd92564d39a..80b8d67401ad1 100644 --- a/src/tools/miri/tests/pass-dep/shims/pthreads.rs +++ b/src/tools/miri/tests/pass-dep/shims/pthreads.rs @@ -1,5 +1,4 @@ //@ignore-target-windows: No libc on Windows -#![feature(cstr_from_bytes_until_nul)] use std::ffi::{CStr, CString}; use std::thread; diff --git a/tests/rustdoc-ui/z-help.stdout b/tests/rustdoc-ui/z-help.stdout index 4f07fca82d1eb..706db892cb30d 100644 --- a/tests/rustdoc-ui/z-help.stdout +++ b/tests/rustdoc-ui/z-help.stdout @@ -77,7 +77,6 @@ -Z llvm-plugins=val -- a list LLVM plugins to enable (space separated) -Z llvm-time-trace=val -- generate JSON tracing data file from LLVM data (default: no) -Z location-detail=val -- what location details should be tracked when using caller_location, either `none`, or a comma separated list of location details, for which valid options are `file`, `line`, and `column` (default: `file,line,column`) - -Z log-backtrace=val -- add a backtrace along with logging -Z ls=val -- list the symbols defined by a library crate (default: no) -Z macro-backtrace=val -- show macro backtraces (default: no) -Z maximal-hir-to-mir-coverage=val -- save as much information as possible about the correspondence between MIR and HIR as source scopes (default: no) diff --git a/tests/ui/attributes/log-backtrace.rs b/tests/ui/attributes/log-backtrace.rs index 3979d2001fc59..e42edf1d4af51 100644 --- a/tests/ui/attributes/log-backtrace.rs +++ b/tests/ui/attributes/log-backtrace.rs @@ -1,9 +1,9 @@ // run-pass // -// This test makes sure that log-backtrace option doesn't give a compilation error. +// This test makes sure that log-backtrace option at least parses correctly // // dont-check-compiler-stdout // dont-check-compiler-stderr // rustc-env:RUSTC_LOG=info -// compile-flags: -Zlog-backtrace=rustc_metadata::creader +// rustc-env:RUSTC_LOG_BACKTRACE=rustc_metadata::creader fn main() {} diff --git a/tests/ui/derives/deriving-with-repr-packed.rs b/tests/ui/derives/deriving-with-repr-packed.rs index afa91da133dc0..58be451972017 100644 --- a/tests/ui/derives/deriving-with-repr-packed.rs +++ b/tests/ui/derives/deriving-with-repr-packed.rs @@ -33,4 +33,14 @@ struct FlexZeroSlice { //~^^ this was previously accepted } +// Again, currently allowed, but will be phased out. +#[derive(Debug)] +#[repr(packed)] +struct WithStr { + width: u8, + data: str, + //~^ WARNING string slice in a packed struct that derives a built-in trait + //~^^ this was previously accepted +} + fn main() {} diff --git a/tests/ui/derives/deriving-with-repr-packed.stderr b/tests/ui/derives/deriving-with-repr-packed.stderr index 7ed84af91bdc3..0cfe03869af1b 100644 --- a/tests/ui/derives/deriving-with-repr-packed.stderr +++ b/tests/ui/derives/deriving-with-repr-packed.stderr @@ -13,6 +13,20 @@ LL | data: [u8], = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +warning: string slice in a packed struct that derives a built-in trait + --> $DIR/deriving-with-repr-packed.rs:41:5 + | +LL | #[derive(Debug)] + | ----- in this derive macro expansion +... +LL | data: str, + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #107457 + = help: consider implementing the trait by hand, or remove the `packed` attribute + = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0507]: cannot move out of `self` which is behind a shared reference --> $DIR/deriving-with-repr-packed.rs:22:10 | @@ -24,7 +38,7 @@ LL | struct X(Y); | = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error; 2 warnings emitted For more information about this error, try `rustc --explain E0507`. Future incompatibility report: Future breakage diagnostic: @@ -43,3 +57,19 @@ LL | data: [u8], = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) +Future breakage diagnostic: +warning: string slice in a packed struct that derives a built-in trait + --> $DIR/deriving-with-repr-packed.rs:41:5 + | +LL | #[derive(Debug)] + | ----- in this derive macro expansion +... +LL | data: str, + | ^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #107457 + = help: consider implementing the trait by hand, or remove the `packed` attribute + = note: `#[warn(byte_slice_in_packed_struct_with_derive)]` on by default + = note: this warning originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) + diff --git a/tests/ui/parser/bad-recover-kw-after-impl.rs b/tests/ui/parser/bad-recover-kw-after-impl.rs new file mode 100644 index 0000000000000..218cd7678594f --- /dev/null +++ b/tests/ui/parser/bad-recover-kw-after-impl.rs @@ -0,0 +1,15 @@ +// check-pass + +// edition:2021 +// for the `impl` + keyword test + +macro_rules! impl_primitive { + ($ty:ty) => { + compile_error!("whoops"); + }; + (impl async) => {}; +} + +impl_primitive!(impl async); + +fn main() {} diff --git a/tests/ui/parser/bad-recover-ty-after-impl.rs b/tests/ui/parser/bad-recover-ty-after-impl.rs new file mode 100644 index 0000000000000..510e08ba091a4 --- /dev/null +++ b/tests/ui/parser/bad-recover-ty-after-impl.rs @@ -0,0 +1,17 @@ +// check-pass + +macro_rules! impl_primitive { + ($ty:ty) => { impl_primitive!(impl $ty); }; + (impl $ty:ty) => { fn a(_: $ty) {} } +} + +impl_primitive! { u8 } + +macro_rules! test { + ($ty:ty) => { compile_error!("oh no"); }; + (impl &) => {}; +} + +test!(impl &); + +fn main() {} diff --git a/tests/ui/traits/new-solver/provisional-result-done.rs b/tests/ui/traits/new-solver/provisional-result-done.rs new file mode 100644 index 0000000000000..a3d97927bad22 --- /dev/null +++ b/tests/ui/traits/new-solver/provisional-result-done.rs @@ -0,0 +1,37 @@ +// known-bug: unknown +// compile-flags: -Ztrait-solver=next +// failure-status: 101 +// normalize-stderr-test "note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// rustc-env:RUST_BACKTRACE=0 + +// This tests checks that we update results in the provisional cache when +// we pop a goal from the stack. +#![feature(auto_traits)] +auto trait Coinductive {} +struct Foo(T); +struct Bar(T); + +impl Coinductive for Foo +where + Bar: Coinductive +{} + +impl Coinductive for Bar +where + Foo: Coinductive, + Bar: ConstrainInfer, +{} + +trait ConstrainInfer {} +impl ConstrainInfer for Bar {} +impl ConstrainInfer for Foo {} + +fn impls() -> T { todo!() } + +fn constrain(_: T) {} + +fn main() { + // This should constrain `_` to `u8`. + impls::>(); +} diff --git a/tests/ui/traits/new-solver/provisional-result-done.stderr b/tests/ui/traits/new-solver/provisional-result-done.stderr new file mode 100644 index 0000000000000..ffc92b81f089e --- /dev/null +++ b/tests/ui/traits/new-solver/provisional-result-done.stderr @@ -0,0 +1,6 @@ +error: the compiler unexpectedly panicked. this is a bug. + +query stack during panic: +#0 [check_well_formed] checking that `` is well-formed +#1 [check_mod_type_wf] checking that types are well-formed in top-level module +end of query stack