diff options
335 files changed, 2497 insertions, 1034 deletions
diff --git a/RELEASES.md b/RELEASES.md index 1ae221774dc..b6dc0628646 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,140 @@ +Version 1.89.0 (2025-08-07) +========================== + +<a id="1.89.0-Language"></a> + +Language +-------- +- [Stabilize explicitly inferred const arguments (`feature(generic_arg_infer)`)](https://github.com/rust-lang/rust/pull/141610) +- [Add a warn-by-default `mismatched_lifetime_syntaxes` lint.](https://github.com/rust-lang/rust/pull/138677) + This lint detects when the same lifetime is referred to by different syntax categories between function arguments and return values, which can be confusing to read, especially in unsafe code. + This lint supersedes the warn-by-default `elided_named_lifetimes` lint. +- [Expand `unpredictable_function_pointer_comparisons` to also lint on function pointer comparisons in external macros](https://github.com/rust-lang/rust/pull/134536) +- [Make the `dangerous_implicit_autorefs` lint deny-by-default](https://github.com/rust-lang/rust/pull/141661) +- [Stabilize the avx512 target features](https://github.com/rust-lang/rust/pull/138940) +- [Stabilize `kl` and `widekl` target features for x86](https://github.com/rust-lang/rust/pull/140766) +- [Stabilize `sha512`, `sm3` and `sm4` target features for x86](https://github.com/rust-lang/rust/pull/140767) +- [Stabilize LoongArch target features `f`, `d`, `frecipe`, `lasx`, `lbt`, `lsx`, and `lvz`](https://github.com/rust-lang/rust/pull/135015) +- [Remove `i128` and `u128` from `improper_ctypes_definitions`](https://github.com/rust-lang/rust/pull/137306) +- [Stabilize `repr128` (`#[repr(u128)]`, `#[repr(i128)]`)](https://github.com/rust-lang/rust/pull/138285) +- [Allow `#![doc(test(attr(..)))]` everywhere](https://github.com/rust-lang/rust/pull/140560) +- [Extend temporary lifetime extension to also go through tuple struct and tuple variant constructors](https://github.com/rust-lang/rust/pull/140593) +- [`extern "C"` functions on the `wasm32-unknown-unknown` target now have a standards compliant ABI](https://blog.rust-lang.org/2025/04/04/c-abi-changes-for-wasm32-unknown-unknown/) + +<a id="1.89.0-Compiler"></a> + +Compiler +-------- +- [Default to non-leaf frame pointers on aarch64-linux](https://github.com/rust-lang/rust/pull/140832) +- [Enable non-leaf frame pointers for Arm64EC Windows](https://github.com/rust-lang/rust/pull/140862) +- [Set Apple frame pointers by architecture](https://github.com/rust-lang/rust/pull/141797) + + +<a id="1.89.0-Platform-Support"></a> + +Platform Support +---------------- +- [Add new Tier-3 targets `loongarch32-unknown-none` and `loongarch32-unknown-none-softfloat`](https://github.com/rust-lang/rust/pull/142053) +- [`x86_64-apple-darwin` is in the process of being demoted to Tier 2 with host tools](https://github.com/rust-lang/rfcs/pull/3841) + +Refer to Rust's [platform support page][platform-support-doc] +for more information on Rust's tiered platform support. + +[platform-support-doc]: https://doc.rust-lang.org/rustc/platform-support.html + +<a id="1.89.0-Libraries"></a> + +Libraries +--------- +- [Specify the base path for `file!`](https://github.com/rust-lang/rust/pull/134442) +- [Allow storing `format_args!()` in a variable](https://github.com/rust-lang/rust/pull/140748) +- [Add `#[must_use]` to `[T; N]::map`](https://github.com/rust-lang/rust/pull/140957) +- [Implement `DerefMut` for `Lazy{Cell,Lock}`](https://github.com/rust-lang/rust/pull/129334) +- [Implement `Default` for `array::IntoIter`](https://github.com/rust-lang/rust/pull/141574) +- [Implement `Clone` for `slice::ChunkBy`](https://github.com/rust-lang/rust/pull/138016) +- [Implement `io::Seek` for `io::Take`](https://github.com/rust-lang/rust/pull/138023) + + +<a id="1.89.0-Stabilized-APIs"></a> + +Stabilized APIs +--------------- + +- [`NonZero<char>`](https://doc.rust-lang.org/stable/std/num/struct.NonZero.html) +- Many intrinsics for x86, not enumerated here + - [AVX512 intrinsics](https://github.com/rust-lang/rust/issues/111137) + - [`SHA512`, `SM3` and `SM4` intrinsics](https://github.com/rust-lang/rust/issues/126624) +- [`File::lock`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.lock) +- [`File::lock_shared`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.lock_shared) +- [`File::try_lock`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.try_lock) +- [`File::try_lock_shared`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.try_lock_shared) +- [`File::unlock`](https://doc.rust-lang.org/stable/std/fs/struct.File.html#method.unlock) +- [`NonNull::from_ref`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.from_ref) +- [`NonNull::from_mut`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.from_mut) +- [`NonNull::without_provenance`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.without_provenance) +- [`NonNull::with_exposed_provenance`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.with_exposed_provenance) +- [`NonNull::expose_provenance`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.expose_provenance) +- [`OsString::leak`](https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.leak) +- [`PathBuf::leak`](https://doc.rust-lang.org/stable/std/path/struct.PathBuf.html#method.leak) +- [`Result::flatten`](https://doc.rust-lang.org/stable/std/result/enum.Result.html#method.flatten) +- [`std::os::linux::net::TcpStreamExt::quickack`](https://doc.rust-lang.org/stable/std/os/linux/net/trait.TcpStreamExt.html#tymethod.quickack) +- [`std::os::linux::net::TcpStreamExt::set_quickack`](https://doc.rust-lang.org/stable/std/os/linux/net/trait.TcpStreamExt.html#tymethod.set_quickack) + +These previously stable APIs are now stable in const contexts: + +- [`<[T; N]>::as_mut_slice`](https://doc.rust-lang.org/stable/std/primitive.array.html#method.as_mut_slice) +- [`<[u8]>::eq_ignore_ascii_case`](https://doc.rust-lang.org/stable/std/primitive.slice.html#impl-%5Bu8%5D/method.eq_ignore_ascii_case) +- [`str::eq_ignore_ascii_case`](https://doc.rust-lang.org/stable/std/primitive.str.html#impl-str/method.eq_ignore_ascii_case) + + +<a id="1.89.0-Cargo"></a> + +Cargo +----- +- [`cargo fix` and `cargo clippy --fix` now default to the same Cargo target selection as other build commands.](https://github.com/rust-lang/cargo/pull/15192/) Previously it would apply to all targets (like binaries, examples, tests, etc.). The `--edition` flag still applies to all targets. +- [Stabilize doctest-xcompile.](https://github.com/rust-lang/cargo/pull/15462/) Doctests are now tested when cross-compiling. Just like other tests, it will use the [`runner` setting](https://doc.rust-lang.org/cargo/reference/config.html#targettriplerunner) to run the tests. If you need to disable tests for a target, you can use the [ignore doctest attribute](https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html#ignoring-targets) to specify the targets to ignore. + + +<a id="1.89.0-Rustdoc"></a> + +Rustdoc +----- +- [On mobile, make the sidebar full width and linewrap](https://github.com/rust-lang/rust/pull/139831). This makes long section and item names much easier to deal with on mobile. + + +<a id="1.89.0-Compatibility-Notes"></a> + +Compatibility Notes +------------------- +- [Make `missing_fragment_specifier` an unconditional error](https://github.com/rust-lang/rust/pull/128425) +- [Enabling the `neon` target feature on `aarch64-unknown-none-softfloat` causes a warning](https://github.com/rust-lang/rust/pull/135160) because mixing code with and without that target feature is not properly supported by LLVM +- [Sized Hierarchy: Part I](https://github.com/rust-lang/rust/pull/137944) + - Introduces a small breaking change affecting `?Sized` bounds on impls on recursive types which contain associated type projections. It is not expected to affect any existing published crates. Can be fixed by refactoring the involved types or opting into the `sized_hierarchy` unstable feature. See the [FCP report](https://github.com/rust-lang/rust/pull/137944#issuecomment-2912207485) for a code example. +- The warn-by-default `elided_named_lifetimes` lint is [superseded by the warn-by-default `mismatched_lifetime_syntaxes` lint.](https://github.com/rust-lang/rust/pull/138677) +- [Error on recursive opaque types earlier in the type checker](https://github.com/rust-lang/rust/pull/139419) +- [Type inference side effects from requiring element types of array repeat expressions are `Copy` are now only available at the end of type checking](https://github.com/rust-lang/rust/pull/139635) +- [The deprecated accidentally-stable `std::intrinsics::{copy,copy_nonoverlapping,write_bytes}` are now proper intrinsics](https://github.com/rust-lang/rust/pull/139916). There are no debug assertions guarding against UB, and they cannot be coerced to function pointers. +- [Remove long-deprecated `std::intrinsics::drop_in_place`](https://github.com/rust-lang/rust/pull/140151) +- [Make well-formedness predicates no longer coinductive](https://github.com/rust-lang/rust/pull/140208) +- [Remove hack when checking impl method compatibility](https://github.com/rust-lang/rust/pull/140557) +- [Remove unnecessary type inference due to built-in trait object impls](https://github.com/rust-lang/rust/pull/141352) +- [Lint against "stdcall", "fastcall", and "cdecl" on non-x86-32 targets](https://github.com/rust-lang/rust/pull/141435) +- [Future incompatibility warnings relating to the never type (`!`) are now reported in dependencies](https://github.com/rust-lang/rust/pull/141937) +- [Ensure `std::ptr::copy_*` intrinsics also perform the static self-init checks](https://github.com/rust-lang/rust/pull/142575) +- [`extern "C"` functions on the `wasm32-unknown-unknown` target now have a standards compliant ABI](https://blog.rust-lang.org/2025/04/04/c-abi-changes-for-wasm32-unknown-unknown/) + +<a id="1.89.0-Internal-Changes"></a> + +Internal Changes +---------------- + +These changes do not affect any public interfaces of Rust, but they represent +significant improvements to the performance or internals of rustc and related +tools. + +- [Correctly un-remap compiler sources paths with the `rustc-dev` component](https://github.com/rust-lang/rust/pull/142377) + + Version 1.88.0 (2025-06-26) ========================== diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index 1245d489754..fb42cfea30b 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -98,7 +98,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } let expr_hir_id = self.lower_node_id(e.id); - self.lower_attrs(expr_hir_id, &e.attrs, e.span); + let attrs = self.lower_attrs(expr_hir_id, &e.attrs, e.span); let kind = match &e.kind { ExprKind::Array(exprs) => hir::ExprKind::Array(self.lower_exprs(exprs)), @@ -232,10 +232,10 @@ impl<'hir> LoweringContext<'_, 'hir> { *fn_arg_span, ), None => self.lower_expr_closure( + attrs, binder, *capture_clause, e.id, - expr_hir_id, *constness, *movability, fn_decl, @@ -1052,10 +1052,10 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_expr_closure( &mut self, + attrs: &[rustc_hir::Attribute], binder: &ClosureBinder, capture_clause: CaptureBy, closure_id: NodeId, - closure_hir_id: hir::HirId, constness: Const, movability: Movability, decl: &FnDecl, @@ -1067,15 +1067,9 @@ impl<'hir> LoweringContext<'_, 'hir> { let (binder_clause, generic_params) = self.lower_closure_binder(binder); let (body_id, closure_kind) = self.with_new_scopes(fn_decl_span, move |this| { - let mut coroutine_kind = if this - .attrs - .get(&closure_hir_id.local_id) - .is_some_and(|attrs| attrs.iter().any(|attr| attr.has_name(sym::coroutine))) - { - Some(hir::CoroutineKind::Coroutine(Movability::Movable)) - } else { - None - }; + + let mut coroutine_kind = find_attr!(attrs, AttributeKind::Coroutine(_) => hir::CoroutineKind::Coroutine(Movability::Movable)); + // FIXME(contracts): Support contracts on closures? let body_id = this.lower_fn_body(decl, None, |this| { this.coroutine_kind = coroutine_kind; diff --git a/compiler/rustc_ast_passes/messages.ftl b/compiler/rustc_ast_passes/messages.ftl index 42f3569f0f1..53e64439afc 100644 --- a/compiler/rustc_ast_passes/messages.ftl +++ b/compiler/rustc_ast_passes/messages.ftl @@ -40,7 +40,7 @@ ast_passes_auto_generic = auto traits cannot have generic parameters ast_passes_auto_items = auto traits cannot have associated items .label = {ast_passes_auto_items} - .suggestion = remove these associated items + .suggestion = remove the associated items ast_passes_auto_super_lifetime = auto traits cannot have super traits or lifetime bounds .label = {ast_passes_auto_super_lifetime} diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index ae482ceb9b7..1c1c5f82f3e 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -699,19 +699,23 @@ impl<'a> AstValidator<'a> { } } - fn deny_super_traits(&self, bounds: &GenericBounds, ident_span: Span) { + fn deny_super_traits(&self, bounds: &GenericBounds, ident: Span) { if let [.., last] = &bounds[..] { - let span = ident_span.shrink_to_hi().to(last.span()); - self.dcx().emit_err(errors::AutoTraitBounds { span, ident: ident_span }); + let span = bounds.iter().map(|b| b.span()).collect(); + let removal = ident.shrink_to_hi().to(last.span()); + self.dcx().emit_err(errors::AutoTraitBounds { span, removal, ident }); } } - fn deny_where_clause(&self, where_clause: &WhereClause, ident_span: Span) { + fn deny_where_clause(&self, where_clause: &WhereClause, ident: Span) { if !where_clause.predicates.is_empty() { // FIXME: The current diagnostic is misleading since it only talks about // super trait and lifetime bounds while we should just say “bounds”. - self.dcx() - .emit_err(errors::AutoTraitBounds { span: where_clause.span, ident: ident_span }); + self.dcx().emit_err(errors::AutoTraitBounds { + span: vec![where_clause.span], + removal: where_clause.span, + ident, + }); } } diff --git a/compiler/rustc_ast_passes/src/errors.rs b/compiler/rustc_ast_passes/src/errors.rs index 8b5873a3ef3..60f47490f12 100644 --- a/compiler/rustc_ast_passes/src/errors.rs +++ b/compiler/rustc_ast_passes/src/errors.rs @@ -344,7 +344,7 @@ pub(crate) struct ModuleNonAscii { #[diag(ast_passes_auto_generic, code = E0567)] pub(crate) struct AutoTraitGeneric { #[primary_span] - #[suggestion(code = "", applicability = "machine-applicable")] + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] pub span: Span, #[label] pub ident: Span, @@ -354,8 +354,9 @@ pub(crate) struct AutoTraitGeneric { #[diag(ast_passes_auto_super_lifetime, code = E0568)] pub(crate) struct AutoTraitBounds { #[primary_span] - #[suggestion(code = "", applicability = "machine-applicable")] - pub span: Span, + pub span: Vec<Span>, + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] + pub removal: Span, #[label] pub ident: Span, } @@ -365,7 +366,7 @@ pub(crate) struct AutoTraitBounds { pub(crate) struct AutoTraitItems { #[primary_span] pub spans: Vec<Span>, - #[suggestion(code = "", applicability = "machine-applicable")] + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] pub total: Span, #[label] pub ident: Span, diff --git a/compiler/rustc_attr_parsing/src/attributes/body.rs b/compiler/rustc_attr_parsing/src/attributes/body.rs new file mode 100644 index 00000000000..ab9330216f6 --- /dev/null +++ b/compiler/rustc_attr_parsing/src/attributes/body.rs @@ -0,0 +1,15 @@ +//! Attributes that can be found in function body. + +use rustc_hir::attrs::AttributeKind; +use rustc_span::{Symbol, sym}; + +use super::{NoArgsAttributeParser, OnDuplicate}; +use crate::context::Stage; + +pub(crate) struct CoroutineParser; + +impl<S: Stage> NoArgsAttributeParser<S> for CoroutineParser { + const PATH: &[Symbol] = &[sym::coroutine]; + const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error; + const CREATE: fn(rustc_span::Span) -> AttributeKind = |span| AttributeKind::Coroutine(span); +} diff --git a/compiler/rustc_attr_parsing/src/attributes/mod.rs b/compiler/rustc_attr_parsing/src/attributes/mod.rs index c574ef78bdf..f7946ade6d2 100644 --- a/compiler/rustc_attr_parsing/src/attributes/mod.rs +++ b/compiler/rustc_attr_parsing/src/attributes/mod.rs @@ -26,6 +26,7 @@ use crate::parser::ArgParser; use crate::session_diagnostics::UnusedMultiple; pub(crate) mod allow_unstable; +pub(crate) mod body; pub(crate) mod cfg; pub(crate) mod cfg_old; pub(crate) mod codegen_attrs; diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index f43cc8fd450..80dfdffdb55 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -16,6 +16,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym}; use crate::attributes::allow_unstable::{ AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser, }; +use crate::attributes::body::CoroutineParser; use crate::attributes::codegen_attrs::{ ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser, @@ -185,6 +186,7 @@ attribute_parsers!( Single<WithoutArgs<ConstContinueParser>>, Single<WithoutArgs<ConstStabilityIndirectParser>>, Single<WithoutArgs<ConstTraitParser>>, + Single<WithoutArgs<CoroutineParser>>, Single<WithoutArgs<DenyExplicitImplParser>>, Single<WithoutArgs<DoNotImplementViaObjectParser>>, Single<WithoutArgs<ExportStableParser>>, diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index f5fedbf95c1..148d0de3bab 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -769,9 +769,13 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { } TerminatorKind::Call { func, args, .. } | TerminatorKind::TailCall { func, args, .. } => { - let call_source = match term.kind { - TerminatorKind::Call { call_source, .. } => call_source, - TerminatorKind::TailCall { .. } => CallSource::Normal, + let (call_source, destination, is_diverging) = match term.kind { + TerminatorKind::Call { call_source, destination, target, .. } => { + (call_source, destination, target.is_none()) + } + TerminatorKind::TailCall { .. } => { + (CallSource::Normal, RETURN_PLACE.into(), false) + } _ => unreachable!(), }; @@ -845,9 +849,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { ); } - if let TerminatorKind::Call { destination, target, .. } = term.kind { - self.check_call_dest(term, &sig, destination, target, term_location); - } + self.check_call_dest(term, &sig, destination, is_diverging, term_location); // The ordinary liveness rules will ensure that all // regions in the type of the callee are live here. We @@ -1874,65 +1876,61 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { term: &Terminator<'tcx>, sig: &ty::FnSig<'tcx>, destination: Place<'tcx>, - target: Option<BasicBlock>, + is_diverging: bool, term_location: Location, ) { let tcx = self.tcx(); - match target { - Some(_) => { - let dest_ty = destination.ty(self.body, tcx).ty; - let dest_ty = self.normalize(dest_ty, term_location); - let category = match destination.as_local() { - Some(RETURN_PLACE) => { - if let DefiningTy::Const(def_id, _) | DefiningTy::InlineConst(def_id, _) = - self.universal_regions.defining_ty - { - if tcx.is_static(def_id) { - ConstraintCategory::UseAsStatic - } else { - ConstraintCategory::UseAsConst - } + if is_diverging { + // The signature in this call can reference region variables, + // so erase them before calling a query. + let output_ty = self.tcx().erase_regions(sig.output()); + if !output_ty + .is_privately_uninhabited(self.tcx(), self.infcx.typing_env(self.infcx.param_env)) + { + span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig); + } + } else { + let dest_ty = destination.ty(self.body, tcx).ty; + let dest_ty = self.normalize(dest_ty, term_location); + let category = match destination.as_local() { + Some(RETURN_PLACE) => { + if let DefiningTy::Const(def_id, _) | DefiningTy::InlineConst(def_id, _) = + self.universal_regions.defining_ty + { + if tcx.is_static(def_id) { + ConstraintCategory::UseAsStatic } else { - ConstraintCategory::Return(ReturnConstraint::Normal) + ConstraintCategory::UseAsConst } + } else { + ConstraintCategory::Return(ReturnConstraint::Normal) } - Some(l) if !self.body.local_decls[l].is_user_variable() => { - ConstraintCategory::Boring - } - // The return type of a call is interesting for diagnostics. - _ => ConstraintCategory::Assignment, - }; - - let locations = term_location.to_locations(); - - if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations, category) { - span_mirbug!( - self, - term, - "call dest mismatch ({:?} <- {:?}): {:?}", - dest_ty, - sig.output(), - terr - ); } - - // When `unsized_fn_params` is not enabled, - // this check is done at `check_local`. - if self.unsized_feature_enabled() { - let span = term.source_info.span; - self.ensure_place_sized(dest_ty, span); + Some(l) if !self.body.local_decls[l].is_user_variable() => { + ConstraintCategory::Boring } + // The return type of a call is interesting for diagnostics. + _ => ConstraintCategory::Assignment, + }; + + let locations = term_location.to_locations(); + + if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations, category) { + span_mirbug!( + self, + term, + "call dest mismatch ({:?} <- {:?}): {:?}", + dest_ty, + sig.output(), + terr + ); } - None => { - // The signature in this call can reference region variables, - // so erase them before calling a query. - let output_ty = self.tcx().erase_regions(sig.output()); - if !output_ty.is_privately_uninhabited( - self.tcx(), - self.infcx.typing_env(self.infcx.param_env), - ) { - span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig); - } + + // When `unsized_fn_params` is not enabled, + // this check is done at `check_local`. + if self.unsized_feature_enabled() { + let span = term.source_info.span; + self.ensure_place_sized(dest_ty, span); } } } diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 53899da183a..3b290e5a129 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -262,6 +262,15 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea // Filter out features that are not supported by the current LLVM version ("aarch64", "fpmr") => None, // only existed in 18 ("arm", "fp16") => Some(LLVMFeature::new("fullfp16")), + // NVPTX targets added in LLVM 20 + ("nvptx64", "sm_100") if get_version().0 < 20 => None, + ("nvptx64", "sm_100a") if get_version().0 < 20 => None, + ("nvptx64", "sm_101") if get_version().0 < 20 => None, + ("nvptx64", "sm_101a") if get_version().0 < 20 => None, + ("nvptx64", "sm_120") if get_version().0 < 20 => None, + ("nvptx64", "sm_120a") if get_version().0 < 20 => None, + ("nvptx64", "ptx86") if get_version().0 < 20 => None, + ("nvptx64", "ptx87") if get_version().0 < 20 => None, // Filter out features that are not supported by the current LLVM version ("loongarch64", "div32" | "lam-bh" | "lamcas" | "ld-seq-sa" | "scq") if get_version().0 < 20 => @@ -324,15 +333,12 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea /// /// We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled outside codegen. pub(crate) fn target_config(sess: &Session) -> TargetConfig { - // Add base features for the target. - // We do *not* add the -Ctarget-features there, and instead duplicate the logic for that below. - // The reason is that if LLVM considers a feature implied but we do not, we don't want that to - // show up in `cfg`. That way, `cfg` is entirely under our control -- except for the handling of - // the target CPU, that is still expanded to target features (with all their implied features) - // by LLVM. let target_machine = create_informational_target_machine(sess, true); let (unstable_target_features, target_features) = cfg_target_feature(sess, |feature| { + // This closure determines whether the target CPU has the feature according to LLVM. We do + // *not* consider the `-Ctarget-feature`s here, as that will be handled later in + // `cfg_target_feature`. if let Some(feat) = to_llvm_features(sess, feature) { // All the LLVM features this expands to must be enabled. for llvm_feature in feat { diff --git a/compiler/rustc_codegen_ssa/src/target_features.rs b/compiler/rustc_codegen_ssa/src/target_features.rs index d984156c674..7e4341a8236 100644 --- a/compiler/rustc_codegen_ssa/src/target_features.rs +++ b/compiler/rustc_codegen_ssa/src/target_features.rs @@ -197,7 +197,10 @@ fn parse_rust_feature_flag<'a>( /// 2nd component of the return value, respectively). /// /// `target_base_has_feature` should check whether the given feature (a Rust feature name!) is -/// enabled in the "base" target machine, i.e., without applying `-Ctarget-feature`. +/// enabled in the "base" target machine, i.e., without applying `-Ctarget-feature`. Note that LLVM +/// may consider features to be implied that we do not and vice-versa. We want `cfg` to be entirely +/// consistent with Rust feature implications, and thus only consult LLVM to expand the target CPU +/// to target features. /// /// We do not have to worry about RUSTC_SPECIFIC_FEATURES here, those are handled elsewhere. pub fn cfg_target_feature( @@ -211,7 +214,15 @@ pub fn cfg_target_feature( .rust_target_features() .iter() .filter(|(feature, _, _)| target_base_has_feature(feature)) - .map(|(feature, _, _)| Symbol::intern(feature)) + .flat_map(|(base_feature, _, _)| { + // Expand the direct base feature into all transitively-implied features. Note that we + // cannot simply use the `implied` field of the tuple since that only contains + // directly-implied features. + // + // Iteration order is irrelevant because we're collecting into an `UnordSet`. + #[allow(rustc::potential_query_instability)] + sess.target.implied_target_features(base_feature).into_iter().map(|f| Symbol::intern(f)) + }) .collect(); // Add enabled and remove disabled features. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 1303b3317e0..266a940b054 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -327,6 +327,7 @@ declare_features! ( (unstable, m68k_target_feature, "1.85.0", Some(134328)), (unstable, mips_target_feature, "1.27.0", Some(44839)), (unstable, movrs_target_feature, "1.88.0", Some(137976)), + (unstable, nvptx_target_feature, "CURRENT_RUSTC_VERSION", Some(44839)), (unstable, powerpc_target_feature, "1.27.0", Some(44839)), (unstable, prfchw_target_feature, "1.78.0", Some(44839)), (unstable, riscv_target_feature, "1.45.0", Some(44839)), diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index c531d72b53c..5f419315467 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -297,6 +297,9 @@ pub enum AttributeKind { /// Represents `#[const_trait]`. ConstTrait(Span), + /// Represents `#[coroutine]`. + Coroutine(Span), + /// Represents `#[coverage(..)]`. Coverage(Span, CoverageAttrKind), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index a1a381bda0f..e3a7f0b97a8 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -28,6 +28,7 @@ impl AttributeKind { ConstStability { .. } => Yes, ConstStabilityIndirect => No, ConstTrait(..) => No, + Coroutine(..) => No, Coverage(..) => No, DenyExplicitImpl(..) => No, Deprecation { .. } => Yes, diff --git a/compiler/rustc_hir_analysis/src/collect/generics_of.rs b/compiler/rustc_hir_analysis/src/collect/generics_of.rs index e2462c2d465..ce0e51f106f 100644 --- a/compiler/rustc_hir_analysis/src/collect/generics_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/generics_of.rs @@ -223,60 +223,27 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { "synthetic HIR should have its `generics_of` explicitly fed" ), - _ => span_bug!(tcx.def_span(def_id), "unhandled node {node:?}"), + _ => span_bug!(tcx.def_span(def_id), "generics_of: unexpected node kind {node:?}"), }; - enum Defaults { - Allowed, - // See #36887 - FutureCompatDisallowed, - Deny, - } - - let hir_generics = node.generics().unwrap_or(hir::Generics::empty()); - let (opt_self, allow_defaults) = match node { - Node::Item(item) => { - match item.kind { - ItemKind::Trait(..) | ItemKind::TraitAlias(..) => { - // Add in the self type parameter. - // - // Something of a hack: use the node id for the trait, also as - // the node id for the Self type parameter. - let opt_self = Some(ty::GenericParamDef { - index: 0, - name: kw::SelfUpper, - def_id: def_id.to_def_id(), - pure_wrt_drop: false, - kind: ty::GenericParamDefKind::Type { - has_default: false, - synthetic: false, - }, - }); - - (opt_self, Defaults::Allowed) - } - ItemKind::TyAlias(..) - | ItemKind::Enum(..) - | ItemKind::Struct(..) - | ItemKind::Union(..) => (None, Defaults::Allowed), - ItemKind::Const(..) => (None, Defaults::Deny), - _ => (None, Defaults::FutureCompatDisallowed), - } - } - - Node::OpaqueTy(..) => (None, Defaults::Allowed), - - // GATs - Node::TraitItem(item) if matches!(item.kind, TraitItemKind::Type(..)) => { - (None, Defaults::Deny) - } - Node::ImplItem(item) if matches!(item.kind, ImplItemKind::Type(..)) => { - (None, Defaults::Deny) - } - - _ => (None, Defaults::FutureCompatDisallowed), + // Add in the self type parameter. + let opt_self = if let Node::Item(item) = node + && let ItemKind::Trait(..) | ItemKind::TraitAlias(..) = item.kind + { + // Something of a hack: We reuse the node ID of the trait for the self type parameter. + Some(ty::GenericParamDef { + index: 0, + name: kw::SelfUpper, + def_id: def_id.to_def_id(), + pure_wrt_drop: false, + kind: ty::GenericParamDefKind::Type { has_default: false, synthetic: false }, + }) + } else { + None }; + let param_default_policy = param_default_policy(node); + let hir_generics = node.generics().unwrap_or(hir::Generics::empty()); let has_self = opt_self.is_some(); let mut parent_has_self = false; let mut own_start = has_self as u32; @@ -312,60 +279,53 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { prev + type_start }; - const TYPE_DEFAULT_NOT_ALLOWED: &'static str = "defaults for type parameters are only allowed in \ - `struct`, `enum`, `type`, or `trait` definitions"; - - own_params.extend(hir_generics.params.iter().filter_map(|param| match param.kind { - GenericParamKind::Lifetime { .. } => None, - GenericParamKind::Type { default, synthetic, .. } => { - if default.is_some() { - match allow_defaults { - Defaults::Allowed => {} - Defaults::FutureCompatDisallowed => { - tcx.node_span_lint( - lint::builtin::INVALID_TYPE_PARAM_DEFAULT, - param.hir_id, - param.span, - |lint| { - lint.primary_message(TYPE_DEFAULT_NOT_ALLOWED); - }, - ); - } - Defaults::Deny => { - tcx.dcx().span_err(param.span, TYPE_DEFAULT_NOT_ALLOWED); + own_params.extend(hir_generics.params.iter().filter_map(|param| { + const MESSAGE: &str = "defaults for generic parameters are not allowed here"; + let kind = match param.kind { + GenericParamKind::Lifetime { .. } => return None, + GenericParamKind::Type { default, synthetic } => { + if default.is_some() { + match param_default_policy.expect("no policy for generic param default") { + ParamDefaultPolicy::Allowed => {} + ParamDefaultPolicy::FutureCompatForbidden => { + tcx.node_span_lint( + lint::builtin::INVALID_TYPE_PARAM_DEFAULT, + param.hir_id, + param.span, + |lint| { + lint.primary_message(MESSAGE); + }, + ); + } + ParamDefaultPolicy::Forbidden => { + tcx.dcx().span_err(param.span, MESSAGE); + } } } - } - - let kind = ty::GenericParamDefKind::Type { has_default: default.is_some(), synthetic }; - Some(ty::GenericParamDef { - index: next_index(), - name: param.name.ident().name, - def_id: param.def_id.to_def_id(), - pure_wrt_drop: param.pure_wrt_drop, - kind, - }) - } - GenericParamKind::Const { ty: _, default, synthetic } => { - if !matches!(allow_defaults, Defaults::Allowed) && default.is_some() { - tcx.dcx().span_err( - param.span, - "defaults for const parameters are only allowed in \ - `struct`, `enum`, `type`, or `trait` definitions", - ); + ty::GenericParamDefKind::Type { has_default: default.is_some(), synthetic } } + GenericParamKind::Const { ty: _, default, synthetic } => { + if default.is_some() { + match param_default_policy.expect("no policy for generic param default") { + ParamDefaultPolicy::Allowed => {} + ParamDefaultPolicy::FutureCompatForbidden + | ParamDefaultPolicy::Forbidden => { + tcx.dcx().span_err(param.span, MESSAGE); + } + } + } - let index = next_index(); - - Some(ty::GenericParamDef { - index, - name: param.name.ident().name, - def_id: param.def_id.to_def_id(), - pure_wrt_drop: param.pure_wrt_drop, - kind: ty::GenericParamDefKind::Const { has_default: default.is_some(), synthetic }, - }) - } + ty::GenericParamDefKind::Const { has_default: default.is_some(), synthetic } + } + }; + Some(ty::GenericParamDef { + index: next_index(), + name: param.name.ident().name, + def_id: param.def_id.to_def_id(), + pure_wrt_drop: param.pure_wrt_drop, + kind, + }) })); // provide junk type parameter defs - the only place that @@ -438,6 +398,48 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics { } } +#[derive(Clone, Copy)] +enum ParamDefaultPolicy { + Allowed, + /// Tracked in <https://github.com/rust-lang/rust/issues/36887>. + FutureCompatForbidden, + Forbidden, +} + +fn param_default_policy(node: Node<'_>) -> Option<ParamDefaultPolicy> { + use rustc_hir::*; + + Some(match node { + Node::Item(item) => match item.kind { + ItemKind::Trait(..) + | ItemKind::TraitAlias(..) + | ItemKind::TyAlias(..) + | ItemKind::Enum(..) + | ItemKind::Struct(..) + | ItemKind::Union(..) => ParamDefaultPolicy::Allowed, + ItemKind::Fn { .. } | ItemKind::Impl(_) => ParamDefaultPolicy::FutureCompatForbidden, + // Re. GCI, we're not bound by backward compatibility. + ItemKind::Const(..) => ParamDefaultPolicy::Forbidden, + _ => return None, + }, + Node::TraitItem(item) => match item.kind { + // Re. GATs and GACs (generic_const_items), we're not bound by backward compatibility. + TraitItemKind::Const(..) | TraitItemKind::Type(..) => ParamDefaultPolicy::Forbidden, + TraitItemKind::Fn(..) => ParamDefaultPolicy::FutureCompatForbidden, + }, + Node::ImplItem(item) => match item.kind { + // Re. GATs and GACs (generic_const_items), we're not bound by backward compatibility. + ImplItemKind::Const(..) | ImplItemKind::Type(..) => ParamDefaultPolicy::Forbidden, + ImplItemKind::Fn(..) => ParamDefaultPolicy::FutureCompatForbidden, + }, + // Generic params are (semantically) invalid on foreign items. Still, for maximum forward + // compatibility, let's hard-reject defaults on them. + Node::ForeignItem(_) => ParamDefaultPolicy::Forbidden, + Node::OpaqueTy(..) => ParamDefaultPolicy::Allowed, + _ => return None, + }) +} + fn has_late_bound_regions<'tcx>(tcx: TyCtxt<'tcx>, node: Node<'tcx>) -> Option<Span> { struct LateBoundRegionsDetector<'tcx> { tcx: TyCtxt<'tcx>, diff --git a/compiler/rustc_middle/src/mir/visit.rs b/compiler/rustc_middle/src/mir/visit.rs index 929ebe1aee1..42a68b29ec7 100644 --- a/compiler/rustc_middle/src/mir/visit.rs +++ b/compiler/rustc_middle/src/mir/visit.rs @@ -1205,18 +1205,19 @@ macro_rules! visit_place_fns { self.super_projection_elem(place_ref, elem, context, location); } - fn super_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) { - let mut context = context; - - if !place.projection.is_empty() { - if context.is_use() { - // ^ Only change the context if it is a real use, not a "use" in debuginfo. - context = if context.is_mutating_use() { - PlaceContext::MutatingUse(MutatingUseContext::Projection) - } else { - PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) - }; - } + fn super_place( + &mut self, + place: &Place<'tcx>, + mut context: PlaceContext, + location: Location, + ) { + if !place.projection.is_empty() && context.is_use() { + // ^ Only change the context if it is a real use, not a "use" in debuginfo. + context = if context.is_mutating_use() { + PlaceContext::MutatingUse(MutatingUseContext::Projection) + } else { + PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) + }; } self.visit_local(place.local, context, location); @@ -1239,7 +1240,7 @@ macro_rules! visit_place_fns { &mut self, _place_ref: PlaceRef<'tcx>, elem: PlaceElem<'tcx>, - _context: PlaceContext, + context: PlaceContext, location: Location, ) { match elem { @@ -1252,7 +1253,12 @@ macro_rules! visit_place_fns { ProjectionElem::Index(local) => { self.visit_local( local, - PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy), + if context.is_use() { + // ^ Only change the context if it is a real use, not a "use" in debuginfo. + PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) + } else { + context + }, location, ); } diff --git a/compiler/rustc_mir_build/src/builder/block.rs b/compiler/rustc_mir_build/src/builder/block.rs index a71196f79d7..566d89f4269 100644 --- a/compiler/rustc_mir_build/src/builder/block.rs +++ b/compiler/rustc_mir_build/src/builder/block.rs @@ -6,7 +6,7 @@ use rustc_span::Span; use tracing::debug; use crate::builder::ForGuard::OutsideGuard; -use crate::builder::matches::{DeclareLetBindings, EmitStorageLive, ScheduleDrops}; +use crate::builder::matches::{DeclareLetBindings, ScheduleDrops}; use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; impl<'a, 'tcx> Builder<'a, 'tcx> { @@ -199,15 +199,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { None, Some((Some(&destination), initializer_span)), ); - this.visit_primary_bindings(pattern, &mut |this, node, span| { - this.storage_live_binding( - block, - node, - span, - OutsideGuard, - ScheduleDrops::Yes, - ); - }); let else_block_span = this.thir[*else_block].span; let (matching, failure) = this.in_if_then_scope(last_remainder_scope, else_block_span, |this| { @@ -218,7 +209,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { None, initializer_span, DeclareLetBindings::No, - EmitStorageLive::No, ) }); matching.and(failure) diff --git a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs index 3a7854a5e11..7a848536d0e 100644 --- a/compiler/rustc_mir_build/src/builder/matches/match_pair.rs +++ b/compiler/rustc_mir_build/src/builder/matches/match_pair.rs @@ -124,9 +124,19 @@ impl<'tcx> MatchPairTree<'tcx> { let test_case = match pattern.kind { PatKind::Missing | PatKind::Wild | PatKind::Error(_) => None, - PatKind::Or { ref pats } => Some(TestCase::Or { - pats: pats.iter().map(|pat| FlatPat::new(place_builder.clone(), pat, cx)).collect(), - }), + PatKind::Or { ref pats } => { + let pats: Box<[FlatPat<'tcx>]> = + pats.iter().map(|pat| FlatPat::new(place_builder.clone(), pat, cx)).collect(); + if !pats[0].extra_data.bindings.is_empty() { + // Hold a place for any bindings established in (possibly-nested) or-patterns. + // By only holding a place when bindings are present, we skip over any + // or-patterns that will be simplified by `merge_trivial_subcandidates`. In + // other words, we can assume this expands into subcandidates. + // FIXME(@dianne): this needs updating/removing if we always merge or-patterns + extra_data.bindings.push(super::SubpatternBindings::FromOrPattern); + } + Some(TestCase::Or { pats }) + } PatKind::Range(ref range) => { if range.is_full_range(cx.tcx) == Some(true) { @@ -194,12 +204,12 @@ impl<'tcx> MatchPairTree<'tcx> { // Then push this binding, after any bindings in the subpattern. if let Some(source) = place { - extra_data.bindings.push(super::Binding { + extra_data.bindings.push(super::SubpatternBindings::One(super::Binding { span: pattern.span, source, var_id: var, binding_mode: mode, - }); + })); } None diff --git a/compiler/rustc_mir_build/src/builder/matches/mod.rs b/compiler/rustc_mir_build/src/builder/matches/mod.rs index 2c29b862841..aebd78515a2 100644 --- a/compiler/rustc_mir_build/src/builder/matches/mod.rs +++ b/compiler/rustc_mir_build/src/builder/matches/mod.rs @@ -5,11 +5,11 @@ //! This also includes code for pattern bindings in `let` statements and //! function parameters. -use std::assert_matches::assert_matches; use std::borrow::Borrow; use std::mem; use std::sync::Arc; +use itertools::{Itertools, Position}; use rustc_abi::VariantIdx; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::stack::ensure_sufficient_stack; @@ -69,18 +69,6 @@ pub(crate) enum DeclareLetBindings { LetNotPermitted, } -/// Used by [`Builder::bind_matched_candidate_for_arm_body`] to determine -/// whether or not to call [`Builder::storage_live_binding`] to emit -/// [`StatementKind::StorageLive`]. -#[derive(Clone, Copy)] -pub(crate) enum EmitStorageLive { - /// Yes, emit `StorageLive` as normal. - Yes, - /// No, don't emit `StorageLive`. The caller has taken responsibility for - /// emitting `StorageLive` as appropriate. - No, -} - /// Used by [`Builder::storage_live_binding`] and [`Builder::bind_matched_candidate_for_arm_body`] /// to decide whether to schedule drops. #[derive(Clone, Copy, Debug)] @@ -207,7 +195,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Some(args.variable_source_info.scope), args.variable_source_info.span, args.declare_let_bindings, - EmitStorageLive::Yes, ), _ => { let mut block = block; @@ -479,7 +466,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &built_match_tree.fake_borrow_temps, scrutinee_span, Some((arm, match_scope)), - EmitStorageLive::Yes, ); this.fixed_temps_scope = old_dedup_scope; @@ -533,7 +519,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fake_borrow_temps: &[(Place<'tcx>, Local, FakeBorrowKind)], scrutinee_span: Span, arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>, - emit_storage_live: EmitStorageLive, ) -> BasicBlock { if branch.sub_branches.len() == 1 { let [sub_branch] = branch.sub_branches.try_into().unwrap(); @@ -544,7 +529,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scrutinee_span, arm_match_scope, ScheduleDrops::Yes, - emit_storage_live, ) } else { // It's helpful to avoid scheduling drops multiple times to save @@ -561,27 +545,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // return: it isn't bound by move until right before enter the arm. // To handle this we instead unschedule it's drop after each time // we lower the guard. + // As a result, we end up with the drop order of the last sub-branch we lower. To use + // the drop order for the first sub-branch, we lower sub-branches in reverse (#142163). let target_block = self.cfg.start_new_block(); - let mut schedule_drops = ScheduleDrops::Yes; - let arm = arm_match_scope.unzip().0; - // We keep a stack of all of the bindings and type ascriptions - // from the parent candidates that we visit, that also need to - // be bound for each candidate. - for sub_branch in branch.sub_branches { - if let Some(arm) = arm { - self.clear_top_scope(arm.scope); - } + for (pos, sub_branch) in branch.sub_branches.into_iter().rev().with_position() { + debug_assert!(pos != Position::Only); + let schedule_drops = + if pos == Position::Last { ScheduleDrops::Yes } else { ScheduleDrops::No }; let binding_end = self.bind_and_guard_matched_candidate( sub_branch, fake_borrow_temps, scrutinee_span, arm_match_scope, schedule_drops, - emit_storage_live, ); - if arm.is_none() { - schedule_drops = ScheduleDrops::No; - } self.cfg.goto(binding_end, outer_source_info, target_block); } @@ -741,7 +718,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &[], irrefutable_pat.span, None, - EmitStorageLive::Yes, ) .unit() } @@ -996,7 +972,7 @@ struct PatternExtraData<'tcx> { span: Span, /// Bindings that must be established. - bindings: Vec<Binding<'tcx>>, + bindings: Vec<SubpatternBindings<'tcx>>, /// Types that must be asserted. ascriptions: Vec<Ascription<'tcx>>, @@ -1011,6 +987,15 @@ impl<'tcx> PatternExtraData<'tcx> { } } +#[derive(Debug, Clone)] +enum SubpatternBindings<'tcx> { + /// A single binding. + One(Binding<'tcx>), + /// Holds the place for an or-pattern's bindings. This ensures their drops are scheduled in the + /// order the primary bindings appear. See rust-lang/rust#142163 for more information. + FromOrPattern, +} + /// A pattern in a form suitable for lowering the match tree, with all irrefutable /// patterns simplified away. /// @@ -1226,7 +1211,7 @@ fn traverse_candidate<'tcx, C, T, I>( } } -#[derive(Clone, Debug)] +#[derive(Clone, Copy, Debug)] struct Binding<'tcx> { span: Span, source: Place<'tcx>, @@ -1452,12 +1437,7 @@ impl<'tcx> MatchTreeSubBranch<'tcx> { span: candidate.extra_data.span, success_block: candidate.pre_binding_block.unwrap(), otherwise_block: candidate.otherwise_block.unwrap(), - bindings: parent_data - .iter() - .flat_map(|d| &d.bindings) - .chain(&candidate.extra_data.bindings) - .cloned() - .collect(), + bindings: sub_branch_bindings(parent_data, &candidate.extra_data.bindings), ascriptions: parent_data .iter() .flat_map(|d| &d.ascriptions) @@ -1490,6 +1470,68 @@ impl<'tcx> MatchTreeBranch<'tcx> { } } +/// Collects the bindings for a [`MatchTreeSubBranch`], preserving the order they appear in the +/// pattern, as though the or-alternatives chosen in this sub-branch were inlined. +fn sub_branch_bindings<'tcx>( + parents: &[PatternExtraData<'tcx>], + leaf_bindings: &[SubpatternBindings<'tcx>], +) -> Vec<Binding<'tcx>> { + // In the common case, all bindings will be in leaves. Allocate to fit the leaf's bindings. + let mut all_bindings = Vec::with_capacity(leaf_bindings.len()); + let mut remainder = parents + .iter() + .map(|parent| parent.bindings.as_slice()) + .chain([leaf_bindings]) + // Skip over unsimplified or-patterns without bindings. + .filter(|bindings| !bindings.is_empty()); + if let Some(candidate_bindings) = remainder.next() { + push_sub_branch_bindings(&mut all_bindings, candidate_bindings, &mut remainder); + } + // Make sure we've included all bindings. For ill-formed patterns like `(x, _ | y)`, we may not + // have collected all bindings yet, since we only check the first alternative when determining + // whether to inline subcandidates' bindings. + // FIXME(@dianne): prevent ill-formed patterns from getting here + while let Some(candidate_bindings) = remainder.next() { + ty::tls::with(|tcx| { + tcx.dcx().delayed_bug("mismatched or-pattern bindings but no error emitted") + }); + // To recover, we collect the rest in an arbitrary order. + push_sub_branch_bindings(&mut all_bindings, candidate_bindings, &mut remainder); + } + all_bindings +} + +/// Helper for [`sub_branch_bindings`]. Collects bindings from `candidate_bindings` into +/// `flattened`. Bindings in or-patterns are collected recursively from `remainder`. +fn push_sub_branch_bindings<'c, 'tcx: 'c>( + flattened: &mut Vec<Binding<'tcx>>, + candidate_bindings: &'c [SubpatternBindings<'tcx>], + remainder: &mut impl Iterator<Item = &'c [SubpatternBindings<'tcx>]>, +) { + for subpat_bindings in candidate_bindings { + match subpat_bindings { + SubpatternBindings::One(binding) => flattened.push(*binding), + SubpatternBindings::FromOrPattern => { + // Inline bindings from an or-pattern. By construction, this always + // corresponds to a subcandidate and its closest descendants (i.e. those + // from nested or-patterns, but not adjacent or-patterns). To handle + // adjacent or-patterns, e.g. `(x | x, y | y)`, we update the `remainder` to + // point to the first descendant candidate from outside this or-pattern. + if let Some(subcandidate_bindings) = remainder.next() { + push_sub_branch_bindings(flattened, subcandidate_bindings, remainder); + } else { + // For ill-formed patterns like `x | _`, we may not have any subcandidates left + // to inline bindings from. + // FIXME(@dianne): prevent ill-formed patterns from getting here + ty::tls::with(|tcx| { + tcx.dcx().delayed_bug("mismatched or-pattern bindings but no error emitted") + }); + }; + } + } + } +} + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub(crate) enum HasMatchGuard { Yes, @@ -2364,7 +2406,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { source_scope: Option<SourceScope>, scope_span: Span, declare_let_bindings: DeclareLetBindings, - emit_storage_live: EmitStorageLive, ) -> BlockAnd<()> { let expr_span = self.thir[expr_id].span; let scrutinee = unpack!(block = self.lower_scrutinee(block, expr_id, expr_span)); @@ -2398,14 +2439,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - let success = self.bind_pattern( - self.source_info(pat.span), - branch, - &[], - expr_span, - None, - emit_storage_live, - ); + let success = self.bind_pattern(self.source_info(pat.span), branch, &[], expr_span, None); // If branch coverage is enabled, record this branch. self.visit_coverage_conditional_let(pat, success, built_tree.otherwise_block); @@ -2428,7 +2462,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { scrutinee_span: Span, arm_match_scope: Option<(&Arm<'tcx>, region::Scope)>, schedule_drops: ScheduleDrops, - emit_storage_live: EmitStorageLive, ) -> BasicBlock { debug!("bind_and_guard_matched_candidate(subbranch={:?})", sub_branch); @@ -2453,11 +2486,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Bindings for guards require some extra handling to automatically // insert implicit references/dereferences. - self.bind_matched_candidate_for_guard( - block, - schedule_drops, - sub_branch.bindings.iter(), - ); + // This always schedules storage drops, so we may need to unschedule them below. + self.bind_matched_candidate_for_guard(block, sub_branch.bindings.iter()); let guard_frame = GuardFrame { locals: sub_branch .bindings @@ -2489,6 +2519,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) }); + // If this isn't the final sub-branch being lowered, we need to unschedule drops of + // bindings and temporaries created for and by the guard. As a result, the drop order + // for the arm will correspond to the binding order of the final sub-branch lowered. + if matches!(schedule_drops, ScheduleDrops::No) { + self.clear_top_scope(arm.scope); + } + let source_info = self.source_info(guard_span); let guard_end = self.source_info(tcx.sess.source_map().end_point(guard_span)); let guard_frame = self.guard_context.pop().unwrap(); @@ -2538,16 +2575,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let cause = FakeReadCause::ForGuardBinding; self.cfg.push_fake_read(post_guard_block, guard_end, cause, Place::from(local_id)); } - assert_matches!( - schedule_drops, - ScheduleDrops::Yes, - "patterns with guards must schedule drops" - ); + // Only schedule drops for the last sub-branch we lower. self.bind_matched_candidate_for_arm_body( post_guard_block, - ScheduleDrops::Yes, + schedule_drops, by_value_bindings, - emit_storage_live, ); post_guard_block @@ -2559,7 +2591,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block, schedule_drops, sub_branch.bindings.iter(), - emit_storage_live, ); block } @@ -2671,7 +2702,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn bind_matched_candidate_for_guard<'b>( &mut self, block: BasicBlock, - schedule_drops: ScheduleDrops, bindings: impl IntoIterator<Item = &'b Binding<'tcx>>, ) where 'tcx: 'b, @@ -2690,12 +2720,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // a reference R: &T pointing to the location matched by // the pattern, and every occurrence of P within a guard // denotes *R. + // Drops must be scheduled to emit `StorageDead` on the guard's failure/break branches. let ref_for_guard = self.storage_live_binding( block, binding.var_id, binding.span, RefWithinGuard, - schedule_drops, + ScheduleDrops::Yes, ); match binding.binding_mode.0 { ByRef::No => { @@ -2705,13 +2736,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.cfg.push_assign(block, source_info, ref_for_guard, rvalue); } ByRef::Yes(mutbl) => { - // The arm binding will be by reference, so eagerly create it now. + // The arm binding will be by reference, so eagerly create it now. Drops must + // be scheduled to emit `StorageDead` on the guard's failure/break branches. let value_for_arm = self.storage_live_binding( block, binding.var_id, binding.span, OutsideGuard, - schedule_drops, + ScheduleDrops::Yes, ); let rvalue = @@ -2730,7 +2762,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { block: BasicBlock, schedule_drops: ScheduleDrops, bindings: impl IntoIterator<Item = &'b Binding<'tcx>>, - emit_storage_live: EmitStorageLive, ) where 'tcx: 'b, { @@ -2740,19 +2771,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Assign each of the bindings. This may trigger moves out of the candidate. for binding in bindings { let source_info = self.source_info(binding.span); - let local = match emit_storage_live { - // Here storages are already alive, probably because this is a binding - // from let-else. - // We just need to schedule drop for the value. - EmitStorageLive::No => self.var_local_id(binding.var_id, OutsideGuard).into(), - EmitStorageLive::Yes => self.storage_live_binding( - block, - binding.var_id, - binding.span, - OutsideGuard, - schedule_drops, - ), - }; + let local = self.storage_live_binding( + block, + binding.var_id, + binding.span, + OutsideGuard, + schedule_drops, + ); if matches!(schedule_drops, ScheduleDrops::Yes) { self.schedule_drop_for_binding(binding.var_id, binding.span, OutsideGuard); } diff --git a/compiler/rustc_mir_build/src/builder/matches/util.rs b/compiler/rustc_mir_build/src/builder/matches/util.rs index 589e350a03f..2c8ad95b6af 100644 --- a/compiler/rustc_mir_build/src/builder/matches/util.rs +++ b/compiler/rustc_mir_build/src/builder/matches/util.rs @@ -138,7 +138,9 @@ impl<'a, 'b, 'tcx> FakeBorrowCollector<'a, 'b, 'tcx> { fn visit_candidate(&mut self, candidate: &Candidate<'tcx>) { for binding in &candidate.extra_data.bindings { - self.visit_binding(binding); + if let super::SubpatternBindings::One(binding) = binding { + self.visit_binding(binding); + } } for match_pair in &candidate.match_pairs { self.visit_match_pair(match_pair); @@ -147,7 +149,9 @@ impl<'a, 'b, 'tcx> FakeBorrowCollector<'a, 'b, 'tcx> { fn visit_flat_pat(&mut self, flat_pat: &FlatPat<'tcx>) { for binding in &flat_pat.extra_data.bindings { - self.visit_binding(binding); + if let super::SubpatternBindings::One(binding) = binding { + self.visit_binding(binding); + } } for match_pair in &flat_pat.match_pairs { self.visit_match_pair(match_pair); diff --git a/compiler/rustc_mir_build/src/check_tail_calls.rs b/compiler/rustc_mir_build/src/check_tail_calls.rs index b4c8b20e50f..3ecccb422c4 100644 --- a/compiler/rustc_mir_build/src/check_tail_calls.rs +++ b/compiler/rustc_mir_build/src/check_tail_calls.rs @@ -60,9 +60,13 @@ impl<'tcx> TailCallCkVisitor<'_, 'tcx> { let BodyTy::Fn(caller_sig) = self.thir.body_type else { span_bug!( call.span, - "`become` outside of functions should have been disallowed by hit_typeck" + "`become` outside of functions should have been disallowed by hir_typeck" ) }; + // While the `caller_sig` does have its regions erased, it does not have its + // binders anonymized. We call `erase_regions` once again to anonymize any binders + // within the signature, such as in function pointer or `dyn Trait` args. + let caller_sig = self.tcx.erase_regions(caller_sig); let ExprKind::Scope { value, .. } = call.kind else { span_bug!(call.span, "expected scope, found: {call:?}") diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index db933da6413..468ef742dfb 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -225,6 +225,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { current = target; } let last = current; + *changed |= *start != last; *start = last; while let Some((current, mut terminator)) = terminators.pop() { let Terminator { kind: TerminatorKind::Goto { ref mut target }, .. } = terminator diff --git a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs index 231fb3e2964..5e08c3a03d8 100644 --- a/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs @@ -959,36 +959,23 @@ where // Even when a trait bound has been proven using a where-bound, we // still need to consider alias-bounds for normalization, see // `tests/ui/next-solver/alias-bound-shadowed-by-env.rs`. - let candidates_from_env_and_bounds: Vec<_> = self + let mut candidates: Vec<_> = self .assemble_and_evaluate_candidates(goal, AssembleCandidatesFrom::EnvAndBounds); // We still need to prefer where-bounds over alias-bounds however. // See `tests/ui/winnowing/norm-where-bound-gt-alias-bound.rs`. - let mut considered_candidates: Vec<_> = if candidates_from_env_and_bounds - .iter() - .any(|c| matches!(c.source, CandidateSource::ParamEnv(_))) - { - candidates_from_env_and_bounds - .into_iter() - .filter(|c| matches!(c.source, CandidateSource::ParamEnv(_))) - .map(|c| c.result) - .collect() - } else { - candidates_from_env_and_bounds.into_iter().map(|c| c.result).collect() - }; - - // If the trait goal has been proven by using the environment, we want to treat - // aliases as rigid if there are no applicable projection bounds in the environment. - if considered_candidates.is_empty() { - if let Ok(response) = inject_normalize_to_rigid_candidate(self) { - considered_candidates.push(response); - } + if candidates.iter().any(|c| matches!(c.source, CandidateSource::ParamEnv(_))) { + candidates.retain(|c| matches!(c.source, CandidateSource::ParamEnv(_))); + } else if candidates.is_empty() { + // If the trait goal has been proven by using the environment, we want to treat + // aliases as rigid if there are no applicable projection bounds in the environment. + return inject_normalize_to_rigid_candidate(self); } - if let Some(response) = self.try_merge_responses(&considered_candidates) { + if let Some(response) = self.try_merge_candidates(&candidates) { Ok(response) } else { - self.flounder(&considered_candidates) + self.flounder(&candidates) } } TraitGoalProvenVia::Misc => { @@ -998,11 +985,9 @@ where // Prefer "orphaned" param-env normalization predicates, which are used // (for example, and ideally only) when proving item bounds for an impl. let candidates_from_env: Vec<_> = candidates - .iter() - .filter(|c| matches!(c.source, CandidateSource::ParamEnv(_))) - .map(|c| c.result) + .extract_if(.., |c| matches!(c.source, CandidateSource::ParamEnv(_))) .collect(); - if let Some(response) = self.try_merge_responses(&candidates_from_env) { + if let Some(response) = self.try_merge_candidates(&candidates_from_env) { return Ok(response); } @@ -1012,12 +997,10 @@ where // means we can just ignore inference constraints and don't have to special-case // constraining the normalized-to `term`. self.filter_specialized_impls(AllowInferenceConstraints::Yes, &mut candidates); - - let responses: Vec<_> = candidates.iter().map(|c| c.result).collect(); - if let Some(response) = self.try_merge_responses(&responses) { + if let Some(response) = self.try_merge_candidates(&candidates) { Ok(response) } else { - self.flounder(&responses) + self.flounder(&candidates) } } } diff --git a/compiler/rustc_next_trait_solver/src/solve/mod.rs b/compiler/rustc_next_trait_solver/src/solve/mod.rs index aec9594b834..2feebe270a6 100644 --- a/compiler/rustc_next_trait_solver/src/solve/mod.rs +++ b/compiler/rustc_next_trait_solver/src/solve/mod.rs @@ -29,6 +29,7 @@ use tracing::instrument; pub use self::eval_ctxt::{EvalCtxt, GenerateProofTree, SolverDelegateEvalExt}; use crate::delegate::SolverDelegate; +use crate::solve::assembly::Candidate; /// How many fixpoint iterations we should attempt inside of the solver before bailing /// with overflow. @@ -244,50 +245,51 @@ where /// /// In this case we tend to flounder and return ambiguity by calling `[EvalCtxt::flounder]`. #[instrument(level = "trace", skip(self), ret)] - fn try_merge_responses( + fn try_merge_candidates( &mut self, - responses: &[CanonicalResponse<I>], + candidates: &[Candidate<I>], ) -> Option<CanonicalResponse<I>> { - if responses.is_empty() { + if candidates.is_empty() { return None; } - let one = responses[0]; - if responses[1..].iter().all(|&resp| resp == one) { + let one: CanonicalResponse<I> = candidates[0].result; + if candidates[1..].iter().all(|candidate| candidate.result == one) { return Some(one); } - responses + candidates .iter() - .find(|response| { - response.value.certainty == Certainty::Yes - && has_no_inference_or_external_constraints(**response) + .find(|candidate| { + candidate.result.value.certainty == Certainty::Yes + && has_no_inference_or_external_constraints(candidate.result) }) - .copied() + .map(|candidate| candidate.result) } - fn bail_with_ambiguity(&mut self, responses: &[CanonicalResponse<I>]) -> CanonicalResponse<I> { - debug_assert!(responses.len() > 1); - let maybe_cause = responses.iter().fold(MaybeCause::Ambiguity, |maybe_cause, response| { - // Pull down the certainty of `Certainty::Yes` to ambiguity when combining - // these responses, b/c we're combining more than one response and this we - // don't know which one applies. - let candidate = match response.value.certainty { - Certainty::Yes => MaybeCause::Ambiguity, - Certainty::Maybe(candidate) => candidate, - }; - maybe_cause.or(candidate) - }); + fn bail_with_ambiguity(&mut self, candidates: &[Candidate<I>]) -> CanonicalResponse<I> { + debug_assert!(candidates.len() > 1); + let maybe_cause = + candidates.iter().fold(MaybeCause::Ambiguity, |maybe_cause, candidates| { + // Pull down the certainty of `Certainty::Yes` to ambiguity when combining + // these responses, b/c we're combining more than one response and this we + // don't know which one applies. + let candidate = match candidates.result.value.certainty { + Certainty::Yes => MaybeCause::Ambiguity, + Certainty::Maybe(candidate) => candidate, + }; + maybe_cause.or(candidate) + }); self.make_ambiguous_response_no_constraints(maybe_cause) } /// If we fail to merge responses we flounder and return overflow or ambiguity. #[instrument(level = "trace", skip(self), ret)] - fn flounder(&mut self, responses: &[CanonicalResponse<I>]) -> QueryResult<I> { - if responses.is_empty() { + fn flounder(&mut self, candidates: &[Candidate<I>]) -> QueryResult<I> { + if candidates.is_empty() { return Err(NoSolution); } else { - Ok(self.bail_with_ambiguity(responses)) + Ok(self.bail_with_ambiguity(candidates)) } } diff --git a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs index f760c2c07ff..60bae738e61 100644 --- a/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs +++ b/compiler/rustc_next_trait_solver/src/solve/trait_goals.rs @@ -1346,11 +1346,10 @@ where mut candidates: Vec<Candidate<I>>, ) -> Result<(CanonicalResponse<I>, Option<TraitGoalProvenVia>), NoSolution> { if let TypingMode::Coherence = self.typing_mode() { - let all_candidates: Vec<_> = candidates.into_iter().map(|c| c.result).collect(); - return if let Some(response) = self.try_merge_responses(&all_candidates) { + return if let Some(response) = self.try_merge_candidates(&candidates) { Ok((response, Some(TraitGoalProvenVia::Misc))) } else { - self.flounder(&all_candidates).map(|r| (r, None)) + self.flounder(&candidates).map(|r| (r, None)) }; } @@ -1375,11 +1374,9 @@ where .any(|c| matches!(c.source, CandidateSource::ParamEnv(ParamEnvSource::NonGlobal))); if has_non_global_where_bounds { let where_bounds: Vec<_> = candidates - .iter() - .filter(|c| matches!(c.source, CandidateSource::ParamEnv(_))) - .map(|c| c.result) + .extract_if(.., |c| matches!(c.source, CandidateSource::ParamEnv(_))) .collect(); - return if let Some(response) = self.try_merge_responses(&where_bounds) { + return if let Some(response) = self.try_merge_candidates(&where_bounds) { Ok((response, Some(TraitGoalProvenVia::ParamEnv))) } else { Ok((self.bail_with_ambiguity(&where_bounds), None)) @@ -1388,11 +1385,9 @@ where if candidates.iter().any(|c| matches!(c.source, CandidateSource::AliasBound)) { let alias_bounds: Vec<_> = candidates - .iter() - .filter(|c| matches!(c.source, CandidateSource::AliasBound)) - .map(|c| c.result) + .extract_if(.., |c| matches!(c.source, CandidateSource::AliasBound)) .collect(); - return if let Some(response) = self.try_merge_responses(&alias_bounds) { + return if let Some(response) = self.try_merge_candidates(&alias_bounds) { Ok((response, Some(TraitGoalProvenVia::AliasBound))) } else { Ok((self.bail_with_ambiguity(&alias_bounds), None)) @@ -1417,11 +1412,10 @@ where TraitGoalProvenVia::Misc }; - let all_candidates: Vec<_> = candidates.into_iter().map(|c| c.result).collect(); - if let Some(response) = self.try_merge_responses(&all_candidates) { + if let Some(response) = self.try_merge_candidates(&candidates) { Ok((response, Some(proven_via))) } else { - self.flounder(&all_candidates).map(|r| (r, None)) + self.flounder(&candidates).map(|r| (r, None)) } } diff --git a/compiler/rustc_parse/messages.ftl b/compiler/rustc_parse/messages.ftl index 859118a4ade..7059ffbf375 100644 --- a/compiler/rustc_parse/messages.ftl +++ b/compiler/rustc_parse/messages.ftl @@ -71,6 +71,17 @@ parse_attr_without_generics = attribute without generic parameters parse_attribute_on_param_type = attributes cannot be applied to a function parameter's type .label = attributes are not allowed here +parse_attribute_on_type = attributes cannot be applied to types + .label = attributes are not allowed here + .suggestion = remove attribute from here + +parse_attribute_on_generic_arg = attributes cannot be applied to generic arguments + .label = attributes are not allowed here + .suggestion = remove attribute from here + +parse_attribute_on_empty_type = attributes cannot be applied here + .label = attributes are not allowed here + parse_bad_assoc_type_bounds = bounds on associated types do not belong here .label = belongs in `where` clause diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index 4aaaba01fae..48ff0394d46 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -1490,6 +1490,34 @@ pub(crate) struct AttributeOnParamType { } #[derive(Diagnostic)] +#[diag(parse_attribute_on_type)] +pub(crate) struct AttributeOnType { + #[primary_span] + #[label] + pub span: Span, + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] + pub fix_span: Span, +} + +#[derive(Diagnostic)] +#[diag(parse_attribute_on_generic_arg)] +pub(crate) struct AttributeOnGenericArg { + #[primary_span] + #[label] + pub span: Span, + #[suggestion(code = "", applicability = "machine-applicable", style = "tool-only")] + pub fix_span: Span, +} + +#[derive(Diagnostic)] +#[diag(parse_attribute_on_empty_type)] +pub(crate) struct AttributeOnEmptyType { + #[primary_span] + #[label] + pub span: Span, +} + +#[derive(Diagnostic)] #[diag(parse_pattern_method_param_without_body, code = E0642)] pub(crate) struct PatternMethodParamWithoutBody { #[primary_span] diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 65d84b3e3d9..cb7c5649433 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -885,6 +885,9 @@ impl<'a> Parser<'a> { /// Parses `unsafe? auto? trait Foo { ... }` or `trait Foo = Bar;`. fn parse_item_trait(&mut self, attrs: &mut AttrVec, lo: Span) -> PResult<'a, ItemKind> { let constness = self.parse_constness(Case::Sensitive); + if let Const::Yes(span) = constness { + self.psess.gated_spans.gate(sym::const_trait_impl, span); + } let safety = self.parse_safety(Case::Sensitive); // Parse optional `auto` prefix. let is_auto = if self.eat_keyword(exp!(Auto)) { diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 1f4049f197f..8e65ab99c5e 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -17,11 +17,11 @@ use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign}; use super::{Parser, Restrictions, TokenType}; use crate::ast::{PatKind, TyKind}; use crate::errors::{ - self, FnPathFoundNamedParams, PathFoundAttributeInParams, PathFoundCVariadicParams, - PathSingleColon, PathTripleColon, + self, AttributeOnEmptyType, AttributeOnGenericArg, FnPathFoundNamedParams, + PathFoundAttributeInParams, PathFoundCVariadicParams, PathSingleColon, PathTripleColon, }; use crate::exp; -use crate::parser::{CommaRecoveryMode, RecoverColon, RecoverComma}; +use crate::parser::{CommaRecoveryMode, ExprKind, RecoverColon, RecoverComma}; /// Specifies how to parse a path. #[derive(Copy, Clone, PartialEq)] @@ -880,6 +880,12 @@ impl<'a> Parser<'a> { &mut self, ty_generics: Option<&Generics>, ) -> PResult<'a, Option<GenericArg>> { + let mut attr_span: Option<Span> = None; + if self.token == token::Pound && self.look_ahead(1, |t| *t == token::OpenBracket) { + let attrs_wrapper = self.parse_outer_attributes()?; + let raw_attrs = attrs_wrapper.take_for_recovery(self.psess); + attr_span = Some(raw_attrs[0].span.to(raw_attrs.last().unwrap().span)); + } let start = self.token.span; let arg = if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) { // Parse lifetime argument. @@ -934,6 +940,9 @@ impl<'a> Parser<'a> { } } else if self.token.is_keyword(kw::Const) { return self.recover_const_param_declaration(ty_generics); + } else if let Some(attr_span) = attr_span { + let diag = self.dcx().create_err(AttributeOnEmptyType { span: attr_span }); + return Err(diag); } else { // Fall back by trying to parse a const-expr expression. If we successfully do so, // then we should report an error that it needs to be wrapped in braces. @@ -953,6 +962,22 @@ impl<'a> Parser<'a> { } } }; + + if let Some(attr_span) = attr_span { + let guar = self.dcx().emit_err(AttributeOnGenericArg { + span: attr_span, + fix_span: attr_span.until(arg.span()), + }); + return Ok(Some(match arg { + GenericArg::Type(_) => GenericArg::Type(self.mk_ty(attr_span, TyKind::Err(guar))), + GenericArg::Const(_) => { + let error_expr = self.mk_expr(attr_span, ExprKind::Err(guar)); + GenericArg::Const(AnonConst { id: ast::DUMMY_NODE_ID, value: error_expr }) + } + GenericArg::Lifetime(lt) => GenericArg::Lifetime(lt), + })); + } + Ok(Some(arg)) } diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 740dd10ea8b..59048e42e6f 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -14,10 +14,10 @@ use thin_vec::{ThinVec, thin_vec}; use super::{Parser, PathStyle, SeqSep, TokenType, Trailing}; use crate::errors::{ - self, DynAfterMut, ExpectedFnPathFoundFnKeyword, ExpectedMutOrConstInRawPointerType, - FnPtrWithGenerics, FnPtrWithGenericsSugg, HelpUseLatestEdition, InvalidDynKeyword, - LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime, NestedCVariadicType, - ReturnTypesUseThinArrow, + self, AttributeOnEmptyType, AttributeOnType, DynAfterMut, ExpectedFnPathFoundFnKeyword, + ExpectedMutOrConstInRawPointerType, FnPtrWithGenerics, FnPtrWithGenericsSugg, + HelpUseLatestEdition, InvalidDynKeyword, LifetimeAfterMut, NeedPlusAfterTraitObjectLifetime, + NestedCVariadicType, ReturnTypesUseThinArrow, }; use crate::parser::item::FrontMatterParsingMode; use crate::{exp, maybe_recover_from_interpolated_ty_qpath}; @@ -253,7 +253,27 @@ impl<'a> Parser<'a> { ) -> PResult<'a, P<Ty>> { let allow_qpath_recovery = recover_qpath == RecoverQPath::Yes; maybe_recover_from_interpolated_ty_qpath!(self, allow_qpath_recovery); + if self.token == token::Pound && self.look_ahead(1, |t| *t == token::OpenBracket) { + let attrs_wrapper = self.parse_outer_attributes()?; + let raw_attrs = attrs_wrapper.take_for_recovery(self.psess); + let attr_span = raw_attrs[0].span.to(raw_attrs.last().unwrap().span); + let (full_span, guar) = match self.parse_ty() { + Ok(ty) => { + let full_span = attr_span.until(ty.span); + let guar = self + .dcx() + .emit_err(AttributeOnType { span: attr_span, fix_span: full_span }); + (attr_span, guar) + } + Err(err) => { + err.cancel(); + let guar = self.dcx().emit_err(AttributeOnEmptyType { span: attr_span }); + (attr_span, guar) + } + }; + return Ok(self.mk_ty(full_span, TyKind::Err(guar))); + } if let Some(ty) = self.eat_metavar_seq_with_matcher( |mv_kind| matches!(mv_kind, MetaVarKind::Ty { .. }), |this| this.parse_ty_no_question_mark_recover(), diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index 33db97dde2c..10c532b436a 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -326,6 +326,9 @@ impl<'tcx> CheckAttrVisitor<'tcx> { &Attribute::Parsed(AttributeKind::Coverage(attr_span, _)) => { self.check_coverage(attr_span, span, target) } + &Attribute::Parsed(AttributeKind::Coroutine(attr_span)) => { + self.check_coroutine(attr_span, target) + } Attribute::Unparsed(attr_item) => { style = Some(attr_item.style); match attr.path().as_slice() { @@ -389,9 +392,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { [sym::autodiff_forward, ..] | [sym::autodiff_reverse, ..] => { self.check_autodiff(hir_id, attr, span, target) } - [sym::coroutine, ..] => { - self.check_coroutine(attr, target); - } [sym::linkage, ..] => self.check_linkage(attr, span, target), [ // ok @@ -2650,11 +2650,11 @@ impl<'tcx> CheckAttrVisitor<'tcx> { } } - fn check_coroutine(&self, attr: &Attribute, target: Target) { + fn check_coroutine(&self, attr_span: Span, target: Target) { match target { Target::Closure => return, _ => { - self.dcx().emit_err(errors::CoroutineOnNonClosure { span: attr.span() }); + self.dcx().emit_err(errors::CoroutineOnNonClosure { span: attr_span }); } } } diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index d54175548e3..752a3355718 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -1512,6 +1512,7 @@ symbols! { not, notable_trait, note, + nvptx_target_feature, object_safe_for_dispatch, of, off, diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index b2af99228fe..297d9ed84c5 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -517,6 +517,71 @@ const MIPS_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-end ]; +const NVPTX_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ + // tidy-alphabetical-start + ("sm_20", Unstable(sym::nvptx_target_feature), &[]), + ("sm_21", Unstable(sym::nvptx_target_feature), &["sm_20"]), + ("sm_30", Unstable(sym::nvptx_target_feature), &["sm_21"]), + ("sm_32", Unstable(sym::nvptx_target_feature), &["sm_30"]), + ("sm_35", Unstable(sym::nvptx_target_feature), &["sm_32"]), + ("sm_37", Unstable(sym::nvptx_target_feature), &["sm_35"]), + ("sm_50", Unstable(sym::nvptx_target_feature), &["sm_37"]), + ("sm_52", Unstable(sym::nvptx_target_feature), &["sm_50"]), + ("sm_53", Unstable(sym::nvptx_target_feature), &["sm_52"]), + ("sm_60", Unstable(sym::nvptx_target_feature), &["sm_53"]), + ("sm_61", Unstable(sym::nvptx_target_feature), &["sm_60"]), + ("sm_62", Unstable(sym::nvptx_target_feature), &["sm_61"]), + ("sm_70", Unstable(sym::nvptx_target_feature), &["sm_62"]), + ("sm_72", Unstable(sym::nvptx_target_feature), &["sm_70"]), + ("sm_75", Unstable(sym::nvptx_target_feature), &["sm_72"]), + ("sm_80", Unstable(sym::nvptx_target_feature), &["sm_75"]), + ("sm_86", Unstable(sym::nvptx_target_feature), &["sm_80"]), + ("sm_87", Unstable(sym::nvptx_target_feature), &["sm_86"]), + ("sm_89", Unstable(sym::nvptx_target_feature), &["sm_87"]), + ("sm_90", Unstable(sym::nvptx_target_feature), &["sm_89"]), + ("sm_90a", Unstable(sym::nvptx_target_feature), &["sm_90"]), + // tidy-alphabetical-end + // tidy-alphabetical-start + ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90"]), + ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]), + ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100"]), + ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]), + ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101"]), + ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]), + // tidy-alphabetical-end + // tidy-alphabetical-start + ("ptx32", Unstable(sym::nvptx_target_feature), &[]), + ("ptx40", Unstable(sym::nvptx_target_feature), &["ptx32"]), + ("ptx41", Unstable(sym::nvptx_target_feature), &["ptx40"]), + ("ptx42", Unstable(sym::nvptx_target_feature), &["ptx41"]), + ("ptx43", Unstable(sym::nvptx_target_feature), &["ptx42"]), + ("ptx50", Unstable(sym::nvptx_target_feature), &["ptx43"]), + ("ptx60", Unstable(sym::nvptx_target_feature), &["ptx50"]), + ("ptx61", Unstable(sym::nvptx_target_feature), &["ptx60"]), + ("ptx62", Unstable(sym::nvptx_target_feature), &["ptx61"]), + ("ptx63", Unstable(sym::nvptx_target_feature), &["ptx62"]), + ("ptx64", Unstable(sym::nvptx_target_feature), &["ptx63"]), + ("ptx65", Unstable(sym::nvptx_target_feature), &["ptx64"]), + ("ptx70", Unstable(sym::nvptx_target_feature), &["ptx65"]), + ("ptx71", Unstable(sym::nvptx_target_feature), &["ptx70"]), + ("ptx72", Unstable(sym::nvptx_target_feature), &["ptx71"]), + ("ptx73", Unstable(sym::nvptx_target_feature), &["ptx72"]), + ("ptx74", Unstable(sym::nvptx_target_feature), &["ptx73"]), + ("ptx75", Unstable(sym::nvptx_target_feature), &["ptx74"]), + ("ptx76", Unstable(sym::nvptx_target_feature), &["ptx75"]), + ("ptx77", Unstable(sym::nvptx_target_feature), &["ptx76"]), + ("ptx78", Unstable(sym::nvptx_target_feature), &["ptx77"]), + ("ptx80", Unstable(sym::nvptx_target_feature), &["ptx78"]), + ("ptx81", Unstable(sym::nvptx_target_feature), &["ptx80"]), + ("ptx82", Unstable(sym::nvptx_target_feature), &["ptx81"]), + ("ptx83", Unstable(sym::nvptx_target_feature), &["ptx82"]), + ("ptx84", Unstable(sym::nvptx_target_feature), &["ptx83"]), + ("ptx85", Unstable(sym::nvptx_target_feature), &["ptx84"]), + ("ptx86", Unstable(sym::nvptx_target_feature), &["ptx85"]), + ("ptx87", Unstable(sym::nvptx_target_feature), &["ptx86"]), + // tidy-alphabetical-end +]; + static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ // tidy-alphabetical-start ("a", Stable, &["zaamo", "zalrsc"]), @@ -782,6 +847,7 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> { .chain(HEXAGON_FEATURES.iter()) .chain(POWERPC_FEATURES.iter()) .chain(MIPS_FEATURES.iter()) + .chain(NVPTX_FEATURES.iter()) .chain(RISCV_FEATURES.iter()) .chain(WASM_FEATURES.iter()) .chain(BPF_FEATURES.iter()) @@ -847,6 +913,7 @@ impl Target { "x86" | "x86_64" => X86_FEATURES, "hexagon" => HEXAGON_FEATURES, "mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES, + "nvptx64" => NVPTX_FEATURES, "powerpc" | "powerpc64" => POWERPC_FEATURES, "riscv32" | "riscv64" => RISCV_FEATURES, "wasm32" | "wasm64" => WASM_FEATURES, @@ -873,7 +940,7 @@ impl Target { "sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI, "hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI, "mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI, - "bpf" | "m68k" => &[], // no vector ABI + "nvptx64" | "bpf" | "m68k" => &[], // no vector ABI "csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI, // FIXME: for some tier3 targets, we are overly cautious and always give warnings // when passing args in vector registers. diff --git a/compiler/rustc_thread_pool/Cargo.toml b/compiler/rustc_thread_pool/Cargo.toml index b0194834264..c92984470b7 100644 --- a/compiler/rustc_thread_pool/Cargo.toml +++ b/compiler/rustc_thread_pool/Cargo.toml @@ -7,7 +7,6 @@ authors = [ ] description = "Core APIs for Rayon - fork for rustc" license = "MIT OR Apache-2.0" -rust-version = "1.63" edition = "2021" readme = "README.md" keywords = ["parallel", "thread", "concurrency", "join", "performance"] diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index 17c16e4aaff..acbbb6df9a5 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -382,6 +382,7 @@ impl<'a, K: 'a, V: 'a> Default for Iter<'a, K, V> { /// documentation for more. /// /// [`iter_mut`]: BTreeMap::iter_mut +#[must_use = "iterators are lazy and do nothing unless consumed"] #[stable(feature = "rust1", since = "1.0.0")] pub struct IterMut<'a, K: 'a, V: 'a> { range: LazyLeafRange<marker::ValMut<'a>, K, V>, @@ -391,7 +392,6 @@ pub struct IterMut<'a, K: 'a, V: 'a> { _marker: PhantomData<&'a mut (K, V)>, } -#[must_use = "iterators are lazy and do nothing unless consumed"] #[stable(feature = "collection_debug", since = "1.17.0")] impl<K: fmt::Debug, V: fmt::Debug> fmt::Debug for IterMut<'_, K, V> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs index 106cc725fee..c6b92df5fe1 100644 --- a/library/core/src/intrinsics/mod.rs +++ b/library/core/src/intrinsics/mod.rs @@ -2667,7 +2667,7 @@ pub unsafe fn vtable_align(ptr: *const ()) -> usize; /// More specifically, this is the offset in bytes between successive /// items of the same type, including alignment padding. /// -/// The stabilized version of this intrinsic is [`size_of`]. +/// The stabilized version of this intrinsic is [`core::mem::size_of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] @@ -2681,7 +2681,7 @@ pub const fn size_of<T>() -> usize; /// Therefore, implementations must not require the user to uphold /// any safety invariants. /// -/// The stabilized version of this intrinsic is [`align_of`]. +/// The stabilized version of this intrinsic is [`core::mem::align_of`]. #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] @@ -2704,7 +2704,7 @@ pub const fn variant_count<T>() -> usize; /// The size of the referenced value in bytes. /// -/// The stabilized version of this intrinsic is [`size_of_val`]. +/// The stabilized version of this intrinsic is [`core::mem::size_of_val`]. /// /// # Safety /// @@ -2717,7 +2717,7 @@ pub const unsafe fn size_of_val<T: ?Sized>(ptr: *const T) -> usize; /// The required alignment of the referenced value. /// -/// The stabilized version of this intrinsic is [`align_of_val`]. +/// The stabilized version of this intrinsic is [`core::mem::align_of_val`]. /// /// # Safety /// diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index 3c33f4b1368..d5bce6ad233 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -195,6 +195,7 @@ #![feature(hexagon_target_feature)] #![feature(loongarch_target_feature)] #![feature(mips_target_feature)] +#![feature(nvptx_target_feature)] #![feature(powerpc_target_feature)] #![feature(riscv_target_feature)] #![feature(rtm_target_feature)] diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 5683d5ec92d..10efb8aff4a 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -177,14 +177,14 @@ macro_rules! int_impl { /// #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] /// - /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); - #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// assert_eq!(n.isolate_highest_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_highest_one(), 0);")] /// ``` #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn isolate_most_significant_one(self) -> Self { + pub const fn isolate_highest_one(self) -> Self { self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) } @@ -198,14 +198,14 @@ macro_rules! int_impl { /// #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] /// - /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); - #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// assert_eq!(n.isolate_lowest_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_lowest_one(), 0);")] /// ``` #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn isolate_least_significant_one(self) -> Self { + pub const fn isolate_lowest_one(self) -> Self { self & self.wrapping_neg() } diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index f793602de50..2d3a680b348 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -629,7 +629,7 @@ macro_rules! nonzero_integer { #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_01000000)?;")] /// - /// assert_eq!(a.isolate_most_significant_one(), b); + /// assert_eq!(a.isolate_highest_one(), b); /// # Some(()) /// # } /// ``` @@ -637,7 +637,7 @@ macro_rules! nonzero_integer { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn isolate_most_significant_one(self) -> Self { + pub const fn isolate_highest_one(self) -> Self { let n = self.get() & (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros())); // SAFETY: @@ -659,7 +659,7 @@ macro_rules! nonzero_integer { #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_00000100)?;")] /// - /// assert_eq!(a.isolate_least_significant_one(), b); + /// assert_eq!(a.isolate_lowest_one(), b); /// # Some(()) /// # } /// ``` @@ -667,7 +667,7 @@ macro_rules! nonzero_integer { #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn isolate_least_significant_one(self) -> Self { + pub const fn isolate_lowest_one(self) -> Self { let n = self.get(); let n = n & n.wrapping_neg(); diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index 584cd60fbe5..5a41a302916 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -229,14 +229,14 @@ macro_rules! uint_impl { /// #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] /// - /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); - #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// assert_eq!(n.isolate_highest_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_highest_one(), 0);")] /// ``` #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn isolate_most_significant_one(self) -> Self { + pub const fn isolate_highest_one(self) -> Self { self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) } @@ -250,14 +250,14 @@ macro_rules! uint_impl { /// #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] /// - /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); - #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// assert_eq!(n.isolate_lowest_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_lowest_one(), 0);")] /// ``` #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] - pub const fn isolate_least_significant_one(self) -> Self { + pub const fn isolate_lowest_one(self) -> Self { self & self.wrapping_neg() } diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index 26661b20c12..7489a8bb6e7 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -187,6 +187,80 @@ impl<B, C> ControlFlow<B, C> { } } + /// Converts the `ControlFlow` into an `Result` which is `Ok` if the + /// `ControlFlow` was `Break` and `Err` if otherwise. + /// + /// # Examples + /// + /// ``` + /// #![feature(control_flow_ok)] + /// + /// use std::ops::ControlFlow; + /// + /// struct TreeNode<T> { + /// value: T, + /// left: Option<Box<TreeNode<T>>>, + /// right: Option<Box<TreeNode<T>>>, + /// } + /// + /// impl<T> TreeNode<T> { + /// fn find<'a>(&'a self, mut predicate: impl FnMut(&T) -> bool) -> Result<&'a T, ()> { + /// let mut f = |t: &'a T| -> ControlFlow<&'a T> { + /// if predicate(t) { + /// ControlFlow::Break(t) + /// } else { + /// ControlFlow::Continue(()) + /// } + /// }; + /// + /// self.traverse_inorder(&mut f).break_ok() + /// } + /// + /// fn traverse_inorder<'a, B>( + /// &'a self, + /// f: &mut impl FnMut(&'a T) -> ControlFlow<B>, + /// ) -> ControlFlow<B> { + /// if let Some(left) = &self.left { + /// left.traverse_inorder(f)?; + /// } + /// f(&self.value)?; + /// if let Some(right) = &self.right { + /// right.traverse_inorder(f)?; + /// } + /// ControlFlow::Continue(()) + /// } + /// + /// fn leaf(value: T) -> Option<Box<TreeNode<T>>> { + /// Some(Box::new(Self { + /// value, + /// left: None, + /// right: None, + /// })) + /// } + /// } + /// + /// let node = TreeNode { + /// value: 0, + /// left: TreeNode::leaf(1), + /// right: Some(Box::new(TreeNode { + /// value: -1, + /// left: TreeNode::leaf(5), + /// right: TreeNode::leaf(2), + /// })), + /// }; + /// + /// let res = node.find(|val: &i32| *val > 3); + /// assert_eq!(res, Ok(&5)); + /// ``` + #[inline] + #[unstable(feature = "control_flow_ok", issue = "140266")] + pub fn break_ok(self) -> Result<B, C> { + match self { + ControlFlow::Continue(c) => Err(c), + ControlFlow::Break(b) => Ok(b), + } + } + /// Maps `ControlFlow<B, C>` to `ControlFlow<T, C>` by applying a function /// to the break value in case it exists. #[inline] @@ -218,6 +292,79 @@ impl<B, C> ControlFlow<B, C> { } } + /// Converts the `ControlFlow` into an `Result` which is `Ok` if the + /// `ControlFlow` was `Continue` and `Err` if otherwise. + /// + /// # Examples + /// + /// ``` + /// #![feature(control_flow_ok)] + /// + /// use std::ops::ControlFlow; + /// + /// struct TreeNode<T> { + /// value: T, + /// left: Option<Box<TreeNode<T>>>, + /// right: Option<Box<TreeNode<T>>>, + /// } + /// + /// impl<T> TreeNode<T> { + /// fn validate<B>(&self, f: &mut impl FnMut(&T) -> ControlFlow<B>) -> Result<(), B> { + /// self.traverse_inorder(f).continue_ok() + /// } + /// + /// fn traverse_inorder<B>(&self, f: &mut impl FnMut(&T) -> ControlFlow<B>) -> ControlFlow<B> { + /// if let Some(left) = &self.left { + /// left.traverse_inorder(f)?; + /// } + /// f(&self.value)?; + /// if let Some(right) = &self.right { + /// right.traverse_inorder(f)?; + /// } + /// ControlFlow::Continue(()) + /// } + /// + /// fn leaf(value: T) -> Option<Box<TreeNode<T>>> { + /// Some(Box::new(Self { + /// value, + /// left: None, + /// right: None, + /// })) + /// } + /// } + /// + /// let node = TreeNode { + /// value: 0, + /// left: TreeNode::leaf(1), + /// right: Some(Box::new(TreeNode { + /// value: -1, + /// left: TreeNode::leaf(5), + /// right: TreeNode::leaf(2), + /// })), + /// }; + /// + /// let res = node.validate(&mut |val| { + /// if *val < 0 { + /// return ControlFlow::Break("negative value detected"); + /// } + /// + /// if *val > 4 { + /// return ControlFlow::Break("too big value detected"); + /// } + /// + /// ControlFlow::Continue(()) + /// }); + /// assert_eq!(res, Err("too big value detected")); + /// ``` + #[inline] + #[unstable(feature = "control_flow_ok", issue = "140266")] + pub fn continue_ok(self) -> Result<C, B> { + match self { + ControlFlow::Continue(c) => Ok(c), + ControlFlow::Break(b) => Err(b), + } + } + /// Maps `ControlFlow<B, C>` to `ControlFlow<B, T>` by applying a function /// to the continue value in case it exists. #[inline] diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 0a9c0c61c95..a0c594d2d59 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -22,6 +22,7 @@ #![feature(const_ref_cell)] #![feature(const_result_trait_fn)] #![feature(const_trait_impl)] +#![feature(control_flow_ok)] #![feature(core_float_math)] #![feature(core_intrinsics)] #![feature(core_intrinsics_fallbacks)] diff --git a/library/coretests/tests/nonzero.rs b/library/coretests/tests/nonzero.rs index 00232c9b706..60e1149f6e6 100644 --- a/library/coretests/tests/nonzero.rs +++ b/library/coretests/tests/nonzero.rs @@ -321,7 +321,7 @@ fn nonzero_trailing_zeros() { } #[test] -fn test_nonzero_isolate_most_significant_one() { +fn test_nonzero_isolate_highest_one() { // Signed most significant one macro_rules! nonzero_int_impl { ($($T:ty),+) => { @@ -335,8 +335,8 @@ fn test_nonzero_isolate_most_significant_one() { let mut i = 0; while i < <$T>::BITS { assert_eq!( - NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), - NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one() + NonZero::<$T>::new(BITS >> i).unwrap().isolate_highest_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_highest_one() ); i += 1; } @@ -356,8 +356,8 @@ fn test_nonzero_isolate_most_significant_one() { let mut i = 0; while i < <$T>::BITS { assert_eq!( - NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), - NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(BITS >> i).unwrap().isolate_highest_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_highest_one(), ); i += 1; } @@ -371,7 +371,7 @@ fn test_nonzero_isolate_most_significant_one() { } #[test] -fn test_nonzero_isolate_least_significant_one() { +fn test_nonzero_isolate_lowest_one() { // Signed least significant one macro_rules! nonzero_int_impl { ($($T:ty),+) => { @@ -385,8 +385,8 @@ fn test_nonzero_isolate_least_significant_one() { let mut i = 0; while i < <$T>::BITS { assert_eq!( - NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), - NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one() + NonZero::<$T>::new(BITS << i).unwrap().isolate_lowest_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_lowest_one() ); i += 1; } @@ -406,8 +406,8 @@ fn test_nonzero_isolate_least_significant_one() { let mut i = 0; while i < <$T>::BITS { assert_eq!( - NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), - NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(BITS << i).unwrap().isolate_lowest_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_lowest_one(), ); i += 1; } diff --git a/library/coretests/tests/num/int_macros.rs b/library/coretests/tests/num/int_macros.rs index 41d399c1ad9..ca32fce861f 100644 --- a/library/coretests/tests/num/int_macros.rs +++ b/library/coretests/tests/num/int_macros.rs @@ -194,7 +194,7 @@ macro_rules! int_module { } #[test] - fn test_isolate_most_significant_one() { + fn test_isolate_highest_one() { const BITS: $T = -1; const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); @@ -203,15 +203,15 @@ macro_rules! int_module { let mut i = 0; while i < <$T>::BITS { assert_eq!( - (BITS >> i).isolate_most_significant_one(), - (MOST_SIG_ONE >> i).isolate_most_significant_one() + (BITS >> i).isolate_highest_one(), + (MOST_SIG_ONE >> i).isolate_highest_one() ); i += 1; } } #[test] - fn test_isolate_least_significant_one() { + fn test_isolate_lowest_one() { const BITS: $T = -1; const LEAST_SIG_ONE: $T = 1; @@ -220,8 +220,8 @@ macro_rules! int_module { let mut i = 0; while i < <$T>::BITS { assert_eq!( - (BITS << i).isolate_least_significant_one(), - (LEAST_SIG_ONE << i).isolate_least_significant_one() + (BITS << i).isolate_lowest_one(), + (LEAST_SIG_ONE << i).isolate_lowest_one() ); i += 1; } diff --git a/library/coretests/tests/num/uint_macros.rs b/library/coretests/tests/num/uint_macros.rs index 7e02027bdd6..8f389de70aa 100644 --- a/library/coretests/tests/num/uint_macros.rs +++ b/library/coretests/tests/num/uint_macros.rs @@ -151,7 +151,7 @@ macro_rules! uint_module { } #[test] - fn test_isolate_most_significant_one() { + fn test_isolate_highest_one() { const BITS: $T = <$T>::MAX; const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); @@ -160,15 +160,15 @@ macro_rules! uint_module { let mut i = 0; while i < <$T>::BITS { assert_eq!( - (BITS >> i).isolate_most_significant_one(), - (MOST_SIG_ONE >> i).isolate_most_significant_one(), + (BITS >> i).isolate_highest_one(), + (MOST_SIG_ONE >> i).isolate_highest_one(), ); i += 1; } } #[test] - fn test_isolate_least_significant_one() { + fn test_isolate_lowest_one() { const BITS: $T = <$T>::MAX; const LEAST_SIG_ONE: $T = 1; @@ -177,8 +177,8 @@ macro_rules! uint_module { let mut i = 0; while i < <$T>::BITS { assert_eq!( - (BITS << i).isolate_least_significant_one(), - (LEAST_SIG_ONE << i).isolate_least_significant_one(), + (BITS << i).isolate_lowest_one(), + (LEAST_SIG_ONE << i).isolate_lowest_one(), ); i += 1; } diff --git a/library/coretests/tests/ops/control_flow.rs b/library/coretests/tests/ops/control_flow.rs index eacfd63a6c4..1df6599ac4a 100644 --- a/library/coretests/tests/ops/control_flow.rs +++ b/library/coretests/tests/ops/control_flow.rs @@ -16,3 +16,15 @@ fn control_flow_discriminants_match_result() { discriminant_value(&Result::<i32, i32>::Ok(3)), ); } + +#[test] +fn control_flow_break_ok() { + assert_eq!(ControlFlow::<char, i32>::Break('b').break_ok(), Ok('b')); + assert_eq!(ControlFlow::<char, i32>::Continue(3).break_ok(), Err(3)); +} + +#[test] +fn control_flow_continue_ok() { + assert_eq!(ControlFlow::<char, i32>::Break('b').continue_ok(), Err('b')); + assert_eq!(ControlFlow::<char, i32>::Continue(3).continue_ok(), Ok(3)); +} diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 72ad7c244ee..b3ca118a452 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1111,6 +1111,11 @@ impl File { /// `futimes` on macOS before 10.13) and the `SetFileTime` function on Windows. Note that this /// [may change in the future][changes]. /// + /// On most platforms, including UNIX and Windows platforms, this function can also change the + /// timestamps of a directory. To get a `File` representing a directory in order to call + /// `set_times`, open the directory with `File::open` without attempting to obtain write + /// permission. + /// /// [changes]: io#platform-specific-behavior /// /// # Errors @@ -1128,7 +1133,7 @@ impl File { /// use std::fs::{self, File, FileTimes}; /// /// let src = fs::metadata("src")?; - /// let dest = File::options().write(true).open("dest")?; + /// let dest = File::open("dest")?; /// let times = FileTimes::new() /// .set_accessed(src.accessed()?) /// .set_modified(src.modified()?); diff --git a/library/std/src/panic.rs b/library/std/src/panic.rs index 913ef72f674..cff4f20b5a8 100644 --- a/library/std/src/panic.rs +++ b/library/std/src/panic.rs @@ -108,8 +108,6 @@ impl<'a> PanicHookInfo<'a> { /// # Example /// /// ```should_panic - /// #![feature(panic_payload_as_str)] - /// /// std::panic::set_hook(Box::new(|panic_info| { /// if let Some(s) = panic_info.payload_as_str() { /// println!("panic occurred: {s:?}"); @@ -122,7 +120,7 @@ impl<'a> PanicHookInfo<'a> { /// ``` #[must_use] #[inline] - #[unstable(feature = "panic_payload_as_str", issue = "125175")] + #[stable(feature = "panic_payload_as_str", since = "CURRENT_RUSTC_VERSION")] pub fn payload_as_str(&self) -> Option<&str> { if let Some(s) = self.payload.downcast_ref::<&str>() { Some(s) diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 224cd39855a..547906ca7dc 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -269,6 +269,7 @@ fn default_hook(info: &PanicHookInfo<'_>) { thread::with_current_name(|name| { let name = name.unwrap_or("<unnamed>"); + let tid = thread::current_os_id(); // Try to write the panic message to a buffer first to prevent other concurrent outputs // interleaving with it. @@ -277,7 +278,7 @@ fn default_hook(info: &PanicHookInfo<'_>) { let write_msg = |dst: &mut dyn crate::io::Write| { // We add a newline to ensure the panic message appears at the start of a line. - writeln!(dst, "\nthread '{name}' panicked at {location}:\n{msg}") + writeln!(dst, "\nthread '{name}' ({tid}) panicked at {location}:\n{msg}") }; if write_msg(&mut cursor).is_ok() { diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 055e7f81480..e7ba6936435 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2683,6 +2683,8 @@ impl Path { /// /// assert_eq!("foo", Path::new("foo.rs").file_prefix().unwrap()); /// assert_eq!("foo", Path::new("foo.tar.gz").file_prefix().unwrap()); + /// assert_eq!(".config", Path::new(".config").file_prefix().unwrap()); + /// assert_eq!(".config", Path::new(".config.toml").file_prefix().unwrap()); /// ``` /// /// # See Also diff --git a/library/std/src/sys/args/common.rs b/library/std/src/sys/args/common.rs index e787105a05a..33f3794ee63 100644 --- a/library/std/src/sys/args/common.rs +++ b/library/std/src/sys/args/common.rs @@ -12,7 +12,7 @@ impl !Sync for Args {} impl Args { #[inline] - pub(super) fn new(args: Vec<OsString>) -> Self { + pub fn new(args: Vec<OsString>) -> Self { Args { iter: args.into_iter() } } } diff --git a/library/std/src/sys/pal/hermit/thread.rs b/library/std/src/sys/pal/hermit/thread.rs index 95fe4f902d3..cc4734b6819 100644 --- a/library/std/src/sys/pal/hermit/thread.rs +++ b/library/std/src/sys/pal/hermit/thread.rs @@ -115,6 +115,10 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { unsafe { Ok(NonZero::new_unchecked(hermit_abi::available_parallelism())) } } diff --git a/library/std/src/sys/pal/itron/thread.rs b/library/std/src/sys/pal/itron/thread.rs index 0d28051fcc4..4e14cb3cbca 100644 --- a/library/std/src/sys/pal/itron/thread.rs +++ b/library/std/src/sys/pal/itron/thread.rs @@ -361,6 +361,10 @@ unsafe fn terminate_and_delete_current_task() -> ! { unsafe { crate::hint::unreachable_unchecked() }; } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { super::unsupported() } diff --git a/library/std/src/sys/pal/sgx/thread.rs b/library/std/src/sys/pal/sgx/thread.rs index a236c362706..1f613badcd7 100644 --- a/library/std/src/sys/pal/sgx/thread.rs +++ b/library/std/src/sys/pal/sgx/thread.rs @@ -1,6 +1,6 @@ #![cfg_attr(test, allow(dead_code))] // why is this necessary? -use super::abi::usercalls; +use super::abi::{thread, usercalls}; use super::unsupported; use crate::ffi::CStr; use crate::io; @@ -149,6 +149,10 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + Some(thread::current().addr().get() as u64) +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { unsupported() } diff --git a/library/std/src/sys/pal/teeos/thread.rs b/library/std/src/sys/pal/teeos/thread.rs index a91d95626e7..1812d11e692 100644 --- a/library/std/src/sys/pal/teeos/thread.rs +++ b/library/std/src/sys/pal/teeos/thread.rs @@ -144,6 +144,10 @@ impl Drop for Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + // Note: Both `sched_getaffinity` and `sysconf` are available but not functional on // teeos, so this function always returns an Error! pub fn available_parallelism() -> io::Result<NonZero<usize>> { diff --git a/library/std/src/sys/pal/uefi/thread.rs b/library/std/src/sys/pal/uefi/thread.rs index 75c364362b2..47a48008c76 100644 --- a/library/std/src/sys/pal/uefi/thread.rs +++ b/library/std/src/sys/pal/uefi/thread.rs @@ -56,6 +56,10 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { // UEFI is single threaded Ok(NonZero::new(1).unwrap()) diff --git a/library/std/src/sys/pal/unix/stack_overflow.rs b/library/std/src/sys/pal/unix/stack_overflow.rs index d89100e6919..0d2100d66bc 100644 --- a/library/std/src/sys/pal/unix/stack_overflow.rs +++ b/library/std/src/sys/pal/unix/stack_overflow.rs @@ -119,7 +119,8 @@ mod imp { && thread_info.guard_page_range.contains(&fault_addr) { let name = thread_info.thread_name.as_deref().unwrap_or("<unknown>"); - rtprintpanic!("\nthread '{name}' has overflowed its stack\n"); + let tid = crate::thread::current_os_id(); + rtprintpanic!("\nthread '{name}' ({tid}) has overflowed its stack\n"); rtabort!("stack overflow"); } }) @@ -696,7 +697,8 @@ mod imp { if code == c::EXCEPTION_STACK_OVERFLOW { crate::thread::with_current_name(|name| { let name = name.unwrap_or("<unknown>"); - rtprintpanic!("\nthread '{name}' has overflowed its stack\n"); + let tid = crate::thread::current_os_id(); + rtprintpanic!("\nthread '{name}' ({tid}) has overflowed its stack\n"); }); } c::EXCEPTION_CONTINUE_SEARCH diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 7f6440152d4..36e53e7cadc 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -398,6 +398,62 @@ impl Drop for Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + // Most Unix platforms have a way to query an integer ID of the current thread, all with + // slightly different spellings. + // + // The OS thread ID is used rather than `pthread_self` so as to match what will be displayed + // for process inspection (debuggers, trace, `top`, etc.). + cfg_if::cfg_if! { + // Most platforms have a function returning a `pid_t` or int, which is an `i32`. + if #[cfg(any(target_os = "android", target_os = "linux"))] { + use crate::sys::weak::syscall; + + // `libc::gettid` is only available on glibc 2.30+, but the syscall is available + // since Linux 2.4.11. + syscall!(fn gettid() -> libc::pid_t;); + + // SAFETY: FFI call with no preconditions. + let id: libc::pid_t = unsafe { gettid() }; + Some(id as u64) + } else if #[cfg(target_os = "nto")] { + // SAFETY: FFI call with no preconditions. + let id: libc::pid_t = unsafe { libc::gettid() }; + Some(id as u64) + } else if #[cfg(target_os = "openbsd")] { + // SAFETY: FFI call with no preconditions. + let id: libc::pid_t = unsafe { libc::getthrid() }; + Some(id as u64) + } else if #[cfg(target_os = "freebsd")] { + // SAFETY: FFI call with no preconditions. + let id: libc::c_int = unsafe { libc::pthread_getthreadid_np() }; + Some(id as u64) + } else if #[cfg(target_os = "netbsd")] { + // SAFETY: FFI call with no preconditions. + let id: libc::lwpid_t = unsafe { libc::_lwp_self() }; + Some(id as u64) + } else if #[cfg(any(target_os = "illumos", target_os = "solaris"))] { + // On Illumos and Solaris, the `pthread_t` is the same as the OS thread ID. + // SAFETY: FFI call with no preconditions. + let id: libc::pthread_t = unsafe { libc::pthread_self() }; + Some(id as u64) + } else if #[cfg(target_vendor = "apple")] { + // Apple allows querying arbitrary thread IDs, `thread=NULL` queries the current thread. + let mut id = 0u64; + // SAFETY: `thread_id` is a valid pointer, no other preconditions. + let status: libc::c_int = unsafe { libc::pthread_threadid_np(0, &mut id) }; + if status == 0 { + Some(id) + } else { + None + } + } else { + // Other platforms don't have an OS thread ID or don't have a way to access it. + None + } + } +} + #[cfg(any( target_os = "linux", target_os = "nto", diff --git a/library/std/src/sys/pal/unsupported/thread.rs b/library/std/src/sys/pal/unsupported/thread.rs index 5a1e3fde986..34d9b5ec70c 100644 --- a/library/std/src/sys/pal/unsupported/thread.rs +++ b/library/std/src/sys/pal/unsupported/thread.rs @@ -39,6 +39,10 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { unsupported() } diff --git a/library/std/src/sys/pal/wasi/thread.rs b/library/std/src/sys/pal/wasi/thread.rs index a46c74630c9..4755e2ef5da 100644 --- a/library/std/src/sys/pal/wasi/thread.rs +++ b/library/std/src/sys/pal/wasi/thread.rs @@ -194,6 +194,10 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { cfg_if::cfg_if! { if #[cfg(target_feature = "atomics")] { diff --git a/library/std/src/sys/pal/windows/c/bindings.txt b/library/std/src/sys/pal/windows/c/bindings.txt index 827d96e73db..c8e4dca4781 100644 --- a/library/std/src/sys/pal/windows/c/bindings.txt +++ b/library/std/src/sys/pal/windows/c/bindings.txt @@ -2185,6 +2185,7 @@ GetSystemInfo GetSystemTimeAsFileTime GetSystemTimePreciseAsFileTime GetTempPathW +GetThreadId GetUserProfileDirectoryW GetWindowsDirectoryW HANDLE diff --git a/library/std/src/sys/pal/windows/c/windows_sys.rs b/library/std/src/sys/pal/windows/c/windows_sys.rs index b2e3aabc633..45a273d241a 100644 --- a/library/std/src/sys/pal/windows/c/windows_sys.rs +++ b/library/std/src/sys/pal/windows/c/windows_sys.rs @@ -61,6 +61,7 @@ windows_targets::link!("kernel32.dll" "system" fn GetSystemInfo(lpsysteminfo : * windows_targets::link!("kernel32.dll" "system" fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); windows_targets::link!("kernel32.dll" "system" fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); windows_targets::link!("kernel32.dll" "system" fn GetTempPathW(nbufferlength : u32, lpbuffer : PWSTR) -> u32); +windows_targets::link!("kernel32.dll" "system" fn GetThreadId(thread : HANDLE) -> u32); windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn GetWindowsDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32); windows_targets::link!("kernel32.dll" "system" fn InitOnceBeginInitialize(lpinitonce : *mut INIT_ONCE, dwflags : u32, fpending : *mut BOOL, lpcontext : *mut *mut core::ffi::c_void) -> BOOL); diff --git a/library/std/src/sys/pal/windows/stack_overflow.rs b/library/std/src/sys/pal/windows/stack_overflow.rs index 734cd30bed0..9a40551b985 100644 --- a/library/std/src/sys/pal/windows/stack_overflow.rs +++ b/library/std/src/sys/pal/windows/stack_overflow.rs @@ -20,7 +20,8 @@ unsafe extern "system" fn vectored_handler(ExceptionInfo: *mut c::EXCEPTION_POIN if code == c::EXCEPTION_STACK_OVERFLOW { thread::with_current_name(|name| { let name = name.unwrap_or("<unknown>"); - rtprintpanic!("\nthread '{name}' has overflowed its stack\n"); + let tid = thread::current_os_id(); + rtprintpanic!("\nthread '{name}' ({tid}) has overflowed its stack\n"); }); } c::EXCEPTION_CONTINUE_SEARCH diff --git a/library/std/src/sys/pal/windows/thread.rs b/library/std/src/sys/pal/windows/thread.rs index b45f76fb546..c708da5af12 100644 --- a/library/std/src/sys/pal/windows/thread.rs +++ b/library/std/src/sys/pal/windows/thread.rs @@ -127,6 +127,14 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + // SAFETY: FFI call with no preconditions. + let id: u32 = unsafe { c::GetThreadId(c::GetCurrentThread()) }; + + // A return value of 0 indicates failed lookup. + if id == 0 { None } else { Some(id.into()) } +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { let res = unsafe { let mut sysinfo: c::SYSTEM_INFO = crate::mem::zeroed(); diff --git a/library/std/src/sys/pal/xous/thread.rs b/library/std/src/sys/pal/xous/thread.rs index f2404a62abf..92803c94c6e 100644 --- a/library/std/src/sys/pal/xous/thread.rs +++ b/library/std/src/sys/pal/xous/thread.rs @@ -145,6 +145,10 @@ impl Thread { } } +pub(crate) fn current_os_id() -> Option<u64> { + None +} + pub fn available_parallelism() -> io::Result<NonZero<usize>> { // We're unicore right now. Ok(unsafe { NonZero::new_unchecked(1) }) diff --git a/library/std/src/thread/current.rs b/library/std/src/thread/current.rs index 414711298f0..5c879903526 100644 --- a/library/std/src/thread/current.rs +++ b/library/std/src/thread/current.rs @@ -1,4 +1,4 @@ -use super::{Thread, ThreadId}; +use super::{Thread, ThreadId, imp}; use crate::mem::ManuallyDrop; use crate::ptr; use crate::sys::thread_local::local_pointer; @@ -148,6 +148,17 @@ pub(crate) fn current_id() -> ThreadId { id::get_or_init() } +/// Gets the OS thread ID of the thread that invokes it, if available. If not, return the Rust +/// thread ID. +/// +/// We use a `u64` to all possible platform IDs without excess `cfg`; most use `int`, some use a +/// pointer, and Apple uses `uint64_t`. This is a "best effort" approach for diagnostics and is +/// allowed to fall back to a non-OS ID (such as the Rust thread ID) or a non-unique ID (such as a +/// PID) if the thread ID cannot be retrieved. +pub(crate) fn current_os_id() -> u64 { + imp::current_os_id().unwrap_or_else(|| current_id().as_u64().get()) +} + /// Gets a reference to the handle of the thread that invokes it, if the handle /// has been initialized. pub(super) fn try_with_current<F, R>(f: F) -> R diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 8d3ab82ace1..292323d0118 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -183,7 +183,7 @@ mod current; #[stable(feature = "rust1", since = "1.0.0")] pub use current::current; -pub(crate) use current::{current_id, current_or_unnamed, drop_current}; +pub(crate) use current::{current_id, current_or_unnamed, current_os_id, drop_current}; use current::{set_current, try_with_current}; mod spawnhook; diff --git a/library/std/src/thread/tests.rs b/library/std/src/thread/tests.rs index 59ec48a57d1..ae889f1e778 100644 --- a/library/std/src/thread/tests.rs +++ b/library/std/src/thread/tests.rs @@ -347,6 +347,13 @@ fn test_thread_id_not_equal() { } #[test] +fn test_thread_os_id_not_equal() { + let spawned_id = thread::spawn(|| thread::current_os_id()).join().unwrap(); + let current_id = thread::current_os_id(); + assert!(current_id != spawned_id); +} + +#[test] fn test_scoped_threads_drop_result_before_join() { let actually_finished = &AtomicBool::new(false); struct X<'scope, 'env>(&'scope Scope<'scope, 'env>, &'env AtomicBool); diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index f6653ed899b..f931aae3c2e 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -84,7 +84,7 @@ impl Step for Std { Kind::Check, ); - std_cargo(builder, target, stage, &mut cargo); + std_cargo(builder, target, &mut cargo); if matches!(builder.config.cmd, Subcommand::Fix) { // By default, cargo tries to fix all targets. Tell it not to fix tests until we've added `test` to the sysroot. cargo.arg("--lib"); @@ -125,7 +125,7 @@ impl Step for Std { Kind::Check, ); - std_cargo(builder, target, build_compiler.stage, &mut cargo); + std_cargo(builder, target, &mut cargo); // Explicitly pass -p for all dependencies krates -- this will force cargo // to also check the tests/benches/examples for these crates, rather diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index b119f2dc3ce..93c767bdd25 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -154,7 +154,7 @@ impl Step for Std { Kind::Clippy, ); - std_cargo(builder, target, compiler.stage, &mut cargo); + std_cargo(builder, target, &mut cargo); for krate in &*self.crates { cargo.arg("-p").arg(krate); diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 95707e37018..7039f31cdde 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -269,7 +269,7 @@ impl Step for Std { target, Kind::Build, ); - std_cargo(builder, target, compiler.stage, &mut cargo); + std_cargo(builder, target, &mut cargo); for krate in &*self.crates { cargo.arg("-p").arg(krate); } @@ -497,7 +497,7 @@ fn compiler_rt_for_profiler(builder: &Builder<'_>) -> PathBuf { /// Configure cargo to compile the standard library, adding appropriate env vars /// and such. -pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, cargo: &mut Cargo) { +pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, cargo: &mut Cargo) { // rustc already ensures that it builds with the minimum deployment // target, so ideally we shouldn't need to do anything here. // @@ -645,12 +645,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car // built with bitcode so that the produced rlibs can be used for both LTO // builds (which use bitcode) and non-LTO builds (which use object code). // So we override the override here! - // - // But we don't bother for the stage 0 compiler because it's never used - // with LTO. - if stage >= 1 { - cargo.rustflag("-Cembed-bitcode=yes"); - } + cargo.rustflag("-Cembed-bitcode=yes"); + if builder.config.rust_lto == RustcLto::Off { cargo.rustflag("-Clto=off"); } diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index d4539a0eb34..9f3524905d7 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -722,7 +722,7 @@ fn doc_std( let mut cargo = builder::Cargo::new(builder, compiler, Mode::Std, SourceType::InTree, target, Kind::Doc); - compile::std_cargo(builder, target, compiler.stage, &mut cargo); + compile::std_cargo(builder, target, &mut cargo); cargo .arg("--no-deps") .arg("--target-dir") diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 09d2657b666..b6199c74fb1 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2858,7 +2858,7 @@ impl Step for Crate { .arg("--manifest-path") .arg(builder.src.join("library/sysroot/Cargo.toml")); } else { - compile::std_cargo(builder, target, compiler.stage, &mut cargo); + compile::std_cargo(builder, target, &mut cargo); } } Mode::Rustc => { diff --git a/src/doc/rustc-dev-guide/src/stability.md b/src/doc/rustc-dev-guide/src/stability.md index d0cee54adb6..c26d34273d7 100644 --- a/src/doc/rustc-dev-guide/src/stability.md +++ b/src/doc/rustc-dev-guide/src/stability.md @@ -181,4 +181,7 @@ the `deprecated_in_future` lint is triggered which is default `allow`, but most of the standard library raises it to a warning with `#![warn(deprecated_in_future)]`. +## unstable_feature_bound +The `#[unstable_feature_bound(foo)]` attribute can be used together with `#[unstable]` attribute to mark an `impl` of stable type and stable trait as unstable. In std/core, an item annotated with `#[unstable_feature_bound(foo)]` can only be used by another item that is also annotated with `#[unstable_feature_bound(foo)]`. Outside of std/core, using an item with `#[unstable_feature_bound(foo)]` requires the feature to be enabled with `#![feature(foo)]` attribute on the crate. Currently, only `impl`s and free functions can be annotated with `#[unstable_feature_bound]`. + [blog]: https://www.ralfj.de/blog/2018/07/19/const.html diff --git a/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md b/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md index 106ec562bfc..36598982481 100644 --- a/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md +++ b/src/doc/rustc/src/platform-support/nvptx64-nvidia-cuda.md @@ -10,6 +10,46 @@ platform. [@RDambrosio016](https://github.com/RDambrosio016) [@kjetilkjeka](https://github.com/kjetilkjeka) +## Requirements + +This target is `no_std` and will typically be built with crate-type `cdylib` and `-C linker-flavor=llbc`, which generates PTX. +The necessary components for this workflow are: + +- `rustup toolchain add nightly` +- `rustup component add llvm-tools --toolchain nightly` +- `rustup component add llvm-bitcode-linker --toolchain nightly` + +There are two options for using the core library: + +- `rustup component add rust-src --toolchain nightly` and build using `-Z build-std=core`. +- `rustup target add nvptx64-nvidia-cuda --toolchain nightly` + +### Target and features + +It is generally necessary to specify the target, such as `-C target-cpu=sm_89`, because the default is very old. This implies two target features: `sm_89` and `ptx78` (and all preceding features within `sm_*` and `ptx*`). Rust will default to using the oldest PTX version that supports the target processor (see [this table](https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#release-notes-ptx-release-history)), which maximizes driver compatibility. +One can use `-C target-feature=+ptx80` to choose a later PTX version without changing the target (the default in this case, `ptx78`, requires CUDA driver version 11.8, while `ptx80` would require driver version 12.0). +Later PTX versions may allow more efficient code generation. + +Although Rust follows LLVM in representing `ptx*` and `sm_*` as target features, they should be thought of as having crate granularity, set via (either via `-Ctarget-cpu` and optionally `-Ctarget-feature`). +While the compiler accepts `#[target_feature(enable = "ptx80", enable = "sm_89")]`, it is not supported, may not behave as intended, and may become erroneous in the future. + +## Building Rust kernels + +A `no_std` crate containing one or more functions with `extern "ptx-kernel"` can be compiled to PTX using a command like the following. + +```console +$ RUSTFLAGS='-Ctarget-cpu=sm_89' cargo +nightly rustc --target=nvptx64-nvidia-cuda -Zbuild-std=core --crate-type=cdylib -- -Clinker-flavor=llbc -Zunstable-options +``` + +Intrinsics in `core::arch::nvptx` may use `#[cfg(target_feature = "...")]`, thus it's necessary to use `-Zbuild-std=core` with appropriate `RUSTFLAGS`. The following components are needed for this workflow: + +```console +$ rustup component add rust-src --toolchain nightly +$ rustup component add llvm-tools --toolchain nightly +$ rustup component add llvm-bitcode-linker --toolchain nightly +``` + + <!-- FIXME: fill this out ## Requirements diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 782311e593b..26b087feb16 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -480,10 +480,28 @@ impl Item { } } + /// If the item has doc comments from a reexport, returns the item id of that reexport, + /// otherwise returns returns the item id. + /// + /// This is used as a key for caching intra-doc link resolution, + /// to prevent two reexports of the same item from using the same cache. + pub(crate) fn item_or_reexport_id(&self) -> ItemId { + // added documentation on a reexport is always prepended. + self.attrs + .doc_strings + .first() + .map(|x| x.item_id) + .flatten() + .map(ItemId::from) + .unwrap_or(self.item_id) + } + pub(crate) fn links(&self, cx: &Context<'_>) -> Vec<RenderedLink> { use crate::html::format::{href, link_tooltip}; - let Some(links) = cx.cache().intra_doc_links.get(&self.item_id) else { return vec![] }; + let Some(links) = cx.cache().intra_doc_links.get(&self.item_or_reexport_id()) else { + return vec![]; + }; links .iter() .filter_map(|ItemLink { link: s, link_text, page_id: id, fragment }| { diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index fed4296fa22..c52c7236883 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -804,8 +804,7 @@ impl Options { let scrape_examples_options = ScrapeExamplesOptions::new(matches, dcx); let with_examples = matches.opt_strs("with-examples"); - let call_locations = - crate::scrape_examples::load_call_locations(with_examples, dcx, &mut loaded_paths); + let call_locations = crate::scrape_examples::load_call_locations(with_examples, dcx); let doctest_build_args = matches.opt_strs("doctest-build-arg"); let unstable_features = diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 99b3da8b2cd..c48863b4681 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1838,6 +1838,10 @@ instead, we check that it's not a "finger" cursor. border-right: 3px solid var(--target-border-color); } +a.tooltip { + font-family: var(--font-family); +} + .code-header a.tooltip { color: inherit; margin-right: 15px; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index c9fa3a4837f..bcb676cd1f1 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -1082,7 +1082,12 @@ impl LinkCollector<'_, '_> { for md_link in preprocessed_markdown_links(&doc) { let link = self.resolve_link(&doc, item, item_id, module_id, &md_link); if let Some(link) = link { - self.cx.cache.intra_doc_links.entry(item.item_id).or_default().insert(link); + self.cx + .cache + .intra_doc_links + .entry(item.item_or_reexport_id()) + .or_default() + .insert(link); } } } diff --git a/src/librustdoc/scrape_examples.rs b/src/librustdoc/scrape_examples.rs index 4d29c74e1eb..9f71d6ae789 100644 --- a/src/librustdoc/scrape_examples.rs +++ b/src/librustdoc/scrape_examples.rs @@ -333,11 +333,14 @@ pub(crate) fn run( pub(crate) fn load_call_locations( with_examples: Vec<String>, dcx: DiagCtxtHandle<'_>, - loaded_paths: &mut Vec<PathBuf>, ) -> AllCallLocations { let mut all_calls: AllCallLocations = FxIndexMap::default(); for path in with_examples { - loaded_paths.push(path.clone().into()); + // FIXME: Figure out why this line is causing this feature to crash in specific contexts. + // Full issue backlog is available here: <https://github.com/rust-lang/rust/pull/144600>. + // + // Can be checked with `tests/run-make/rustdoc-scrape-examples-paths`. + // loaded_paths.push(path.clone().into()); let bytes = match fs::read(&path) { Ok(bytes) => bytes, Err(e) => dcx.fatal(format!("failed to load examples: {e}")), diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 35670ba89e9..f283a625f97 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -356,7 +356,7 @@ impl<'test> TestCx<'test> { if proc_res.status.success() { let err = &format!("{} test did not emit an error", self.config.mode); let extra_note = (self.config.mode == crate::common::TestMode::Ui) - .then_some("note: by default, ui tests are expected not to compile"); + .then_some("note: by default, ui tests are expected not to compile.\nhint: use check-pass, build-pass, or run-pass directive to change this behavior."); self.fatal_proc_rec_general(err, extra_note, proc_res, || ()); } @@ -2567,6 +2567,11 @@ impl<'test> TestCx<'test> { }) .into_owned(); + // Normalize thread IDs in panic messages + normalized = static_regex!(r"thread '(?P<name>.*?)' \((rtid )?\d+\) panicked") + .replace_all(&normalized, "thread '$name' ($$TID) panicked") + .into_owned(); + normalized = normalized.replace("\t", "\\t"); // makes tabs visible // Remove test annotations like `//~ ERROR text` from the output, diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr index 9e6abf219f1..afabb8572bd 100644 --- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr +++ b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind1.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind1.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind1.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr index 14b3be02a79..1246ad5a713 100644 --- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr +++ b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.both.stderr @@ -1,10 +1,10 @@ -thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr index 14b3be02a79..1246ad5a713 100644 --- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr +++ b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.definition.stderr @@ -1,10 +1,10 @@ -thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr index 5a3d5b4a5eb..e755b262474 100644 --- a/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr +++ b/src/tools/miri/tests/fail/function_calls/exported_symbol_bad_unwind2.extern_block.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/function_calls/exported_symbol_bad_unwind2.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr b/src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr index 93720ca7d27..77dc2c61e26 100644 --- a/src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr +++ b/src/tools/miri/tests/fail/function_calls/return_pointer_on_unwind.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/function_calls/return_pointer_on_unwind.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/panic/abort_unwind.stderr b/src/tools/miri/tests/fail/panic/abort_unwind.stderr index 35052f37dfc..09f19a6e494 100644 --- a/src/tools/miri/tests/fail/panic/abort_unwind.stderr +++ b/src/tools/miri/tests/fail/panic/abort_unwind.stderr @@ -1,10 +1,10 @@ -thread 'main' panicked at tests/fail/panic/abort_unwind.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/abort_unwind.rs:LL:CC: PANIC!!! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/src/tools/miri/tests/fail/panic/bad_unwind.stderr b/src/tools/miri/tests/fail/panic/bad_unwind.stderr index b8404c4e457..b0a8492b6a6 100644 --- a/src/tools/miri/tests/fail/panic/bad_unwind.stderr +++ b/src/tools/miri/tests/fail/panic/bad_unwind.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/panic/bad_unwind.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/bad_unwind.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/panic/double_panic.stderr b/src/tools/miri/tests/fail/panic/double_panic.stderr index 3f1fbfef721..f6aa0a34749 100644 --- a/src/tools/miri/tests/fail/panic/double_panic.stderr +++ b/src/tools/miri/tests/fail/panic/double_panic.stderr @@ -1,14 +1,14 @@ -thread 'main' panicked at tests/fail/panic/double_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/double_panic.rs:LL:CC: first note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at tests/fail/panic/double_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/double_panic.rs:LL:CC: second stack backtrace: -thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC: panic in a destructor during cleanup thread caused non-unwinding panic. aborting. error: abnormal termination: the program aborted execution diff --git a/src/tools/miri/tests/fail/panic/panic_abort1.stderr b/src/tools/miri/tests/fail/panic/panic_abort1.stderr index 9aca2ed654f..ebdf57f0f03 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort1.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort1.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/panic/panic_abort1.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/panic_abort1.rs:LL:CC: panicking from libstd note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/panic/panic_abort2.stderr b/src/tools/miri/tests/fail/panic/panic_abort2.stderr index 425817d5f86..d63e4ed79b2 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort2.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort2.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/panic/panic_abort2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/panic_abort2.rs:LL:CC: 42-panicking from libstd note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/panic/panic_abort3.stderr b/src/tools/miri/tests/fail/panic/panic_abort3.stderr index a21e185219e..9751053396a 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort3.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort3.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/panic/panic_abort3.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/panic_abort3.rs:LL:CC: panicking from libcore note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/panic/panic_abort4.stderr b/src/tools/miri/tests/fail/panic/panic_abort4.stderr index a3cf5d72198..a84824fcc81 100644 --- a/src/tools/miri/tests/fail/panic/panic_abort4.stderr +++ b/src/tools/miri/tests/fail/panic/panic_abort4.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/panic/panic_abort4.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/panic/panic_abort4.rs:LL:CC: 42-panicking from libcore note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr b/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr index 1dcdb4a3996..ef87e7fe6db 100644 --- a/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr +++ b/src/tools/miri/tests/fail/panic/tls_macro_const_drop_panic.stderr @@ -1,5 +1,5 @@ -thread $NAME panicked at tests/fail/panic/tls_macro_const_drop_panic.rs:LL:CC: +thread $NAME ($TID) panicked at tests/fail/panic/tls_macro_const_drop_panic.rs:LL:CC: ow fatal runtime error: thread local panicked on drop, aborting error: abnormal termination: the program aborted execution diff --git a/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr b/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr index 7e4907abd93..4fdaa97e1d0 100644 --- a/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr +++ b/src/tools/miri/tests/fail/panic/tls_macro_drop_panic.stderr @@ -1,5 +1,5 @@ -thread $NAME panicked at tests/fail/panic/tls_macro_drop_panic.rs:LL:CC: +thread $NAME ($TID) panicked at tests/fail/panic/tls_macro_drop_panic.rs:LL:CC: ow fatal runtime error: thread local panicked on drop, aborting error: abnormal termination: the program aborted execution diff --git a/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr b/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr index 8295a581060..d2b557f13f3 100644 --- a/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr +++ b/src/tools/miri/tests/fail/ptr_swap_nonoverlapping.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/fail/ptr_swap_nonoverlapping.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/ptr_swap_nonoverlapping.rs:LL:CC: unsafe precondition(s) violated: ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null and the specified memory ranges do not overlap This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety. diff --git a/src/tools/miri/tests/fail/terminate-terminator.stderr b/src/tools/miri/tests/fail/terminate-terminator.stderr index f0f305d76bc..96df302c397 100644 --- a/src/tools/miri/tests/fail/terminate-terminator.stderr +++ b/src/tools/miri/tests/fail/terminate-terminator.stderr @@ -1,12 +1,12 @@ warning: You have explicitly enabled MIR optimizations, overriding Miri's default which is to completely disable them. Any optimizations may hide UB that Miri would otherwise detect, and it is not necessarily possible to predict what kind of UB will be missed. If you are enabling optimizations to make Miri run faster, we advise using cfg(miri) to shrink your workload instead. The performance benefit of enabling MIR optimizations is usually marginal at best. -thread 'main' panicked at tests/fail/terminate-terminator.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/terminate-terminator.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/src/tools/miri/tests/fail/unwind-action-terminate.stderr b/src/tools/miri/tests/fail/unwind-action-terminate.stderr index 216ae84512a..06c63c70ede 100644 --- a/src/tools/miri/tests/fail/unwind-action-terminate.stderr +++ b/src/tools/miri/tests/fail/unwind-action-terminate.stderr @@ -1,10 +1,10 @@ -thread 'main' panicked at tests/fail/unwind-action-terminate.rs:LL:CC: +thread 'main' ($TID) panicked at tests/fail/unwind-action-terminate.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at RUSTLIB/core/src/panicking.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/panicking.rs:LL:CC: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/src/tools/miri/tests/panic/alloc_error_handler_hook.stderr b/src/tools/miri/tests/panic/alloc_error_handler_hook.stderr index 2be06968321..ad2bfc3f2a3 100644 --- a/src/tools/miri/tests/panic/alloc_error_handler_hook.stderr +++ b/src/tools/miri/tests/panic/alloc_error_handler_hook.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/alloc_error_handler_hook.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/alloc_error_handler_hook.rs:LL:CC: alloc error hook called note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr b/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr index ddee4fd6ce3..7c2d089f952 100644 --- a/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr +++ b/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at RUSTLIB/std/src/alloc.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/std/src/alloc.rs:LL:CC: memory allocation of 4 bytes failed note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/div-by-zero-2.stderr b/src/tools/miri/tests/panic/div-by-zero-2.stderr index 4d4b0062d5e..013f3cd3c20 100644 --- a/src/tools/miri/tests/panic/div-by-zero-2.stderr +++ b/src/tools/miri/tests/panic/div-by-zero-2.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/div-by-zero-2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/div-by-zero-2.rs:LL:CC: attempt to divide by zero note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/function_calls/exported_symbol_good_unwind.stderr b/src/tools/miri/tests/panic/function_calls/exported_symbol_good_unwind.stderr index 8bcd635e8be..dad94377d12 100644 --- a/src/tools/miri/tests/panic/function_calls/exported_symbol_good_unwind.stderr +++ b/src/tools/miri/tests/panic/function_calls/exported_symbol_good_unwind.stderr @@ -1,11 +1,11 @@ -thread 'main' panicked at tests/panic/function_calls/exported_symbol_good_unwind.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/function_calls/exported_symbol_good_unwind.rs:LL:CC: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at tests/panic/function_calls/exported_symbol_good_unwind.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/function_calls/exported_symbol_good_unwind.rs:LL:CC: explicit panic -thread 'main' panicked at tests/panic/function_calls/exported_symbol_good_unwind.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/function_calls/exported_symbol_good_unwind.rs:LL:CC: explicit panic diff --git a/src/tools/miri/tests/panic/mir-validation.rs b/src/tools/miri/tests/panic/mir-validation.rs index e4b75cccbb5..b9097f2e8c5 100644 --- a/src/tools/miri/tests/panic/mir-validation.rs +++ b/src/tools/miri/tests/panic/mir-validation.rs @@ -8,6 +8,12 @@ // Somehow on rustc Windows CI, the "Miri caused an ICE" message is not shown // and we don't even get a regular panic; rustc aborts with a different exit code instead. //@ignore-host: windows + +// FIXME: this tests a crash in rustc. For stage1, rustc is built with the downloaded standard +// library which doesn't yet print the thread ID. Normalization can be removed at the stage bump. +// For the grep: cfg(bootstrap) +//@normalize-stderr-test: "thread 'rustc' panicked" -> "thread 'rustc' ($$TID) panicked" + #![feature(custom_mir, core_intrinsics)] use core::intrinsics::mir::*; diff --git a/src/tools/miri/tests/panic/mir-validation.stderr b/src/tools/miri/tests/panic/mir-validation.stderr index f801ac907e6..1d40c93d709 100644 --- a/src/tools/miri/tests/panic/mir-validation.stderr +++ b/src/tools/miri/tests/panic/mir-validation.stderr @@ -6,7 +6,7 @@ LL | *(tuple.0) = 1; | ^^^^^^^^^^^^^^ -thread 'rustc' panicked at compiler/rustc_mir_transform/src/validate.rs:LL:CC: +thread 'rustc' ($TID) panicked at compiler/rustc_mir_transform/src/validate.rs:LL:CC: Box<dyn Any> stack backtrace: diff --git a/src/tools/miri/tests/panic/oob_subslice.stderr b/src/tools/miri/tests/panic/oob_subslice.stderr index c0dabaff772..f8270f4ad4d 100644 --- a/src/tools/miri/tests/panic/oob_subslice.stderr +++ b/src/tools/miri/tests/panic/oob_subslice.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/oob_subslice.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/oob_subslice.rs:LL:CC: range end index 5 out of range for slice of length 4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/overflowing-lsh-neg.stderr b/src/tools/miri/tests/panic/overflowing-lsh-neg.stderr index d674e2beb8d..8e618b978ef 100644 --- a/src/tools/miri/tests/panic/overflowing-lsh-neg.stderr +++ b/src/tools/miri/tests/panic/overflowing-lsh-neg.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/overflowing-lsh-neg.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/overflowing-lsh-neg.rs:LL:CC: attempt to shift left with overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/overflowing-rsh-1.stderr b/src/tools/miri/tests/panic/overflowing-rsh-1.stderr index bb94f2e12c4..471bc849abb 100644 --- a/src/tools/miri/tests/panic/overflowing-rsh-1.stderr +++ b/src/tools/miri/tests/panic/overflowing-rsh-1.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/overflowing-rsh-1.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/overflowing-rsh-1.rs:LL:CC: attempt to shift right with overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/overflowing-rsh-2.stderr b/src/tools/miri/tests/panic/overflowing-rsh-2.stderr index 0a29a57f3e1..94f5fb0f1ca 100644 --- a/src/tools/miri/tests/panic/overflowing-rsh-2.stderr +++ b/src/tools/miri/tests/panic/overflowing-rsh-2.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/overflowing-rsh-2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/overflowing-rsh-2.rs:LL:CC: attempt to shift right with overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/panic1.stderr b/src/tools/miri/tests/panic/panic1.stderr index 130bc7737a4..9ca5234dd03 100644 --- a/src/tools/miri/tests/panic/panic1.stderr +++ b/src/tools/miri/tests/panic/panic1.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/panic1.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/panic1.rs:LL:CC: panicking from libstd stack backtrace: 0: std::panicking::begin_panic_handler diff --git a/src/tools/miri/tests/panic/panic2.stderr b/src/tools/miri/tests/panic/panic2.stderr index 157ffdb6b5d..c2e55178333 100644 --- a/src/tools/miri/tests/panic/panic2.stderr +++ b/src/tools/miri/tests/panic/panic2.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/panic2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/panic2.rs:LL:CC: 42-panicking from libstd note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/panic3.stderr b/src/tools/miri/tests/panic/panic3.stderr index 529ef70870b..2fc761a4f3d 100644 --- a/src/tools/miri/tests/panic/panic3.stderr +++ b/src/tools/miri/tests/panic/panic3.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/panic3.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/panic3.rs:LL:CC: panicking from libcore note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/panic4.stderr b/src/tools/miri/tests/panic/panic4.stderr index ecd07dd7ded..f2f4c038000 100644 --- a/src/tools/miri/tests/panic/panic4.stderr +++ b/src/tools/miri/tests/panic/panic4.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/panic4.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/panic4.rs:LL:CC: 42-panicking from libcore note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/panic/transmute_fat2.stderr b/src/tools/miri/tests/panic/transmute_fat2.stderr index 71e2d7a8208..8846c4c7fbc 100644 --- a/src/tools/miri/tests/panic/transmute_fat2.stderr +++ b/src/tools/miri/tests/panic/transmute_fat2.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at tests/panic/transmute_fat2.rs:LL:CC: +thread 'main' ($TID) panicked at tests/panic/transmute_fat2.rs:LL:CC: index out of bounds: the len is 0 but the index is 0 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect diff --git a/src/tools/miri/tests/pass/panic/catch_panic.stderr b/src/tools/miri/tests/pass/panic/catch_panic.stderr index bc745fca578..cd7384fb107 100644 --- a/src/tools/miri/tests/pass/panic/catch_panic.stderr +++ b/src/tools/miri/tests/pass/panic/catch_panic.stderr @@ -1,47 +1,47 @@ -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: Hello from std::panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect Caught panic message (&str): Hello from std::panic -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: Hello from std::panic: 1 Caught panic message (String): Hello from std::panic: 1 -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: Hello from std::panic_any: 2 Caught panic message (String): Hello from std::panic_any: 2 -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: Box<dyn Any> Failed to get caught panic message. -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: Hello from core::panic Caught panic message (&str): Hello from core::panic -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: Hello from core::panic: 5 Caught panic message (String): Hello from core::panic: 5 -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: index out of bounds: the len is 3 but the index is 4 Caught panic message (String): index out of bounds: the len is 3 but the index is 4 -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: attempt to divide by zero Caught panic message (&str): attempt to divide by zero -thread 'main' panicked at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC: +thread 'main' ($TID) panicked at RUSTLIB/core/src/ptr/const_ptr.rs:LL:CC: align_offset: align is not a power-of-two Caught panic message (&str): align_offset: align is not a power-of-two -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: assertion failed: false Caught panic message (&str): assertion failed: false -thread 'main' panicked at tests/pass/panic/catch_panic.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/catch_panic.rs:LL:CC: assertion failed: false Caught panic message (&str): assertion failed: false Success! diff --git a/src/tools/miri/tests/pass/panic/concurrent-panic.stderr b/src/tools/miri/tests/pass/panic/concurrent-panic.stderr index 4a3ac16debc..b388a3bedc0 100644 --- a/src/tools/miri/tests/pass/panic/concurrent-panic.stderr +++ b/src/tools/miri/tests/pass/panic/concurrent-panic.stderr @@ -1,7 +1,7 @@ Thread 1 starting, will block on mutex Thread 1 reported it has started -thread '<unnamed>' panicked at tests/pass/panic/concurrent-panic.rs:LL:CC: +thread '<unnamed>' ($TID) panicked at tests/pass/panic/concurrent-panic.rs:LL:CC: panic in thread 2 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect @@ -9,7 +9,7 @@ Thread 2 blocking on thread 1 Thread 2 reported it has started Unlocking mutex -thread '<unnamed>' panicked at tests/pass/panic/concurrent-panic.rs:LL:CC: +thread '<unnamed>' ($TID) panicked at tests/pass/panic/concurrent-panic.rs:LL:CC: panic in thread 1 Thread 1 has exited Thread 2 has exited diff --git a/src/tools/miri/tests/pass/panic/nested_panic_caught.stderr b/src/tools/miri/tests/pass/panic/nested_panic_caught.stderr index 8aff8f6ec55..7ae39204d4e 100644 --- a/src/tools/miri/tests/pass/panic/nested_panic_caught.stderr +++ b/src/tools/miri/tests/pass/panic/nested_panic_caught.stderr @@ -1,9 +1,9 @@ -thread 'main' panicked at tests/pass/panic/nested_panic_caught.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/nested_panic_caught.rs:LL:CC: once note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'main' panicked at tests/pass/panic/nested_panic_caught.rs:LL:CC: +thread 'main' ($TID) panicked at tests/pass/panic/nested_panic_caught.rs:LL:CC: twice stack backtrace: diff --git a/src/tools/miri/tests/pass/panic/thread_panic.stderr b/src/tools/miri/tests/pass/panic/thread_panic.stderr index 3bb2991805c..92403d5152d 100644 --- a/src/tools/miri/tests/pass/panic/thread_panic.stderr +++ b/src/tools/miri/tests/pass/panic/thread_panic.stderr @@ -1,8 +1,8 @@ -thread '<unnamed>' panicked at tests/pass/panic/thread_panic.rs:LL:CC: +thread '<unnamed>' ($TID) panicked at tests/pass/panic/thread_panic.rs:LL:CC: Hello! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -thread 'childthread' panicked at tests/pass/panic/thread_panic.rs:LL:CC: +thread 'childthread' ($TID) panicked at tests/pass/panic/thread_panic.rs:LL:CC: Hello, world! diff --git a/src/tools/miri/tests/ui.rs b/src/tools/miri/tests/ui.rs index 73fbe2cc020..f021d5194cd 100644 --- a/src/tools/miri/tests/ui.rs +++ b/src/tools/miri/tests/ui.rs @@ -248,7 +248,8 @@ regexes! { // erase alloc ids "alloc[0-9]+" => "ALLOC", // erase thread ids - r"unnamed-[0-9]+" => "unnamed-ID", + r"unnamed-[0-9]+" => "unnamed-ID", + r"thread '(?P<name>.*?)' \(\d+\) panicked" => "thread '$name' ($$TID) panicked", // erase borrow tags "<[0-9]+>" => "<TAG>", "<[0-9]+=" => "<TAG=", diff --git a/src/tools/run-make-support/src/diff/mod.rs b/src/tools/run-make-support/src/diff/mod.rs index ee48e373366..739eff72f05 100644 --- a/src/tools/run-make-support/src/diff/mod.rs +++ b/src/tools/run-make-support/src/diff/mod.rs @@ -23,6 +23,7 @@ pub struct Diff { actual: Option<String>, actual_name: Option<String>, normalizers: Vec<(String, String)>, + bless_dir: Option<String>, drop_bomb: DropBomb, } @@ -37,6 +38,7 @@ impl Diff { actual: None, actual_name: None, normalizers: Vec::new(), + bless_dir: std::env::var("RUSTC_BLESS_TEST").ok(), drop_bomb: DropBomb::arm("diff"), } } @@ -44,6 +46,13 @@ impl Diff { /// Specify the expected output for the diff from a file. pub fn expected_file<P: AsRef<Path>>(&mut self, path: P) -> &mut Self { let path = path.as_ref(); + // In `--bless` mode, create the snapshot file if it doesn't already exist. + // The empty file will be overwritten with the actual text. + if self.bless_dir.is_some() + && let Ok(false) = std::fs::exists(path) + { + fs::write(path, ""); + } let content = fs::read_to_string(path); let name = path.to_string_lossy().to_string(); @@ -148,7 +157,7 @@ impl Diff { let Some(ref expected_file) = self.expected_file else { return false; }; - let Ok(bless_dir) = std::env::var("RUSTC_BLESS_TEST") else { + let Some(ref bless_dir) = self.bless_dir else { return false; }; diff --git a/src/tools/rustfmt/tests/rustfmt/main.rs b/src/tools/rustfmt/tests/rustfmt/main.rs index a9f58b9328e..4a9399377d1 100644 --- a/src/tools/rustfmt/tests/rustfmt/main.rs +++ b/src/tools/rustfmt/tests/rustfmt/main.rs @@ -185,10 +185,11 @@ fn dont_emit_ICE() { "tests/target/issue-6105.rs", ]; + let panic_re = regex::Regex::new("thread.*panicked").unwrap(); for file in files { let args = [file]; let (_stdout, stderr) = rustfmt(&args); - assert!(!stderr.contains("thread 'main' panicked")); + assert!(!panic_re.is_match(&stderr)); } } diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index e59b23fdd20..8a36c901eed 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -24,7 +24,6 @@ fn main() -> () { _1 = Option::<u8>::Some(const 1_u8); FakeRead(ForLet(None), _1); AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); - StorageLive(_5); PlaceMention(_1); _6 = discriminant(_1); switchInt(move _6) -> [1: bb4, otherwise: bb3]; @@ -55,6 +54,7 @@ fn main() -> () { } bb6: { + StorageLive(_5); _5 = copy ((_1 as Some).0: u8); _0 = const (); StorageDead(_5); @@ -63,7 +63,6 @@ fn main() -> () { } bb7: { - StorageDead(_5); goto -> bb1; } diff --git a/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir index 6369dbec750..3d26fe24ac9 100644 --- a/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir @@ -21,9 +21,6 @@ fn let_else() -> () { } bb0: { - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); StorageLive(_5); StorageLive(_6); StorageLive(_7); @@ -51,16 +48,19 @@ fn let_else() -> () { bb4: { AscribeUserType(_5, +, UserTypeProjection { base: UserType(1), projs: [] }); + StorageLive(_2); _2 = copy (_5.0: u32); + StorageLive(_3); _3 = copy (_5.1: u64); + StorageLive(_4); _4 = copy (_5.2: &char); StorageDead(_7); StorageDead(_5); _0 = const (); - StorageDead(_8); StorageDead(_4); StorageDead(_3); StorageDead(_2); + StorageDead(_8); return; } @@ -68,9 +68,6 @@ fn let_else() -> () { StorageDead(_7); StorageDead(_5); StorageDead(_8); - StorageDead(_4); - StorageDead(_3); - StorageDead(_2); goto -> bb1; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b3eb3e1f8b9..484bc7dad12 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -85,11 +85,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_12); - StorageLive(_13); - _13 = copy _1; -- switchInt(move _13) -> [0: bb16, otherwise: bb15]; -+ switchInt(move _13) -> [0: bb13, otherwise: bb12]; + StorageLive(_9); + StorageLive(_10); + _10 = copy _1; +- switchInt(move _10) -> [0: bb12, otherwise: bb11]; ++ switchInt(move _10) -> [0: bb9, otherwise: bb8]; } - bb9: { @@ -100,11 +100,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_9); - StorageLive(_10); - _10 = copy _1; -- switchInt(move _10) -> [0: bb12, otherwise: bb11]; -+ switchInt(move _10) -> [0: bb9, otherwise: bb8]; + StorageLive(_12); + StorageLive(_13); + _13 = copy _1; +- switchInt(move _13) -> [0: bb16, otherwise: bb15]; ++ switchInt(move _13) -> [0: bb13, otherwise: bb12]; } - bb10: { @@ -139,7 +139,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.1: bool); + _5 = copy (_2.0: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -152,8 +152,8 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb1, imaginary: bb1]; -+ goto -> bb1; +- falseEdge -> [real: bb3, imaginary: bb3]; ++ goto -> bb2; } - bb15: { @@ -181,7 +181,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.0: bool); + _5 = copy (_2.1: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -194,8 +194,8 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb3, imaginary: bb3]; -+ goto -> bb2; +- falseEdge -> [real: bb1, imaginary: bb1]; ++ goto -> bb1; } - bb19: { diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b3eb3e1f8b9..484bc7dad12 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -85,11 +85,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_12); - StorageLive(_13); - _13 = copy _1; -- switchInt(move _13) -> [0: bb16, otherwise: bb15]; -+ switchInt(move _13) -> [0: bb13, otherwise: bb12]; + StorageLive(_9); + StorageLive(_10); + _10 = copy _1; +- switchInt(move _10) -> [0: bb12, otherwise: bb11]; ++ switchInt(move _10) -> [0: bb9, otherwise: bb8]; } - bb9: { @@ -100,11 +100,11 @@ _8 = &(_2.2: std::string::String); - _3 = &fake shallow (_2.0: bool); - _4 = &fake shallow (_2.1: bool); - StorageLive(_9); - StorageLive(_10); - _10 = copy _1; -- switchInt(move _10) -> [0: bb12, otherwise: bb11]; -+ switchInt(move _10) -> [0: bb9, otherwise: bb8]; + StorageLive(_12); + StorageLive(_13); + _13 = copy _1; +- switchInt(move _13) -> [0: bb16, otherwise: bb15]; ++ switchInt(move _13) -> [0: bb13, otherwise: bb12]; } - bb10: { @@ -139,7 +139,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.1: bool); + _5 = copy (_2.0: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -152,8 +152,8 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb1, imaginary: bb1]; -+ goto -> bb1; +- falseEdge -> [real: bb3, imaginary: bb3]; ++ goto -> bb2; } - bb15: { @@ -181,7 +181,7 @@ - FakeRead(ForGuardBinding, _6); - FakeRead(ForGuardBinding, _8); StorageLive(_5); - _5 = copy (_2.0: bool); + _5 = copy (_2.1: bool); StorageLive(_7); _7 = move (_2.2: std::string::String); - goto -> bb10; @@ -194,8 +194,8 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb3, imaginary: bb3]; -+ goto -> bb2; +- falseEdge -> [real: bb1, imaginary: bb1]; ++ goto -> bb1; } - bb19: { diff --git a/tests/run-make/libtest-json/output-default.json b/tests/run-make/libtest-json/output-default.json index a6a8a9f3b47..5371715d17c 100644 --- a/tests/run-make/libtest-json/output-default.json +++ b/tests/run-make/libtest-json/output-default.json @@ -2,7 +2,7 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' ($TID) panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } { "type": "test", "name": "c", "event": "ok" } { "type": "test", "event": "started", "name": "d" } diff --git a/tests/run-make/libtest-json/output-stdout-success.json b/tests/run-make/libtest-json/output-stdout-success.json index a6c36e746b3..5caadcf56cf 100644 --- a/tests/run-make/libtest-json/output-stdout-success.json +++ b/tests/run-make/libtest-json/output-stdout-success.json @@ -2,9 +2,9 @@ { "type": "test", "event": "started", "name": "a" } { "type": "test", "name": "a", "event": "ok", "stdout": "print from successful test\n" } { "type": "test", "event": "started", "name": "b" } -{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } +{ "type": "test", "name": "b", "event": "failed", "stdout": "\nthread 'b' ($TID) panicked at f.rs:9:5:\nassertion failed: false\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" } { "type": "test", "event": "started", "name": "c" } -{ "type": "test", "name": "c", "event": "ok", "stdout": "\nthread 'c' panicked at f.rs:15:5:\nassertion failed: false\n" } +{ "type": "test", "name": "c", "event": "ok", "stdout": "\nthread 'c' ($TID) panicked at f.rs:15:5:\nassertion failed: false\n" } { "type": "test", "event": "started", "name": "d" } { "type": "test", "name": "d", "event": "ignored", "message": "msg" } { "type": "suite", "event": "failed", "passed": 2, "failed": 1, "ignored": 1, "measured": 0, "filtered_out": 0, "exec_time": "$EXEC_TIME" } diff --git a/tests/run-make/libtest-json/rmake.rs b/tests/run-make/libtest-json/rmake.rs index c31f4a79b64..034ba6246f1 100644 --- a/tests/run-make/libtest-json/rmake.rs +++ b/tests/run-make/libtest-json/rmake.rs @@ -38,5 +38,6 @@ fn run_tests(extra_args: &[&str], expected_file: &str) { .expected_file(expected_file) .actual_text("stdout", test_stdout) .normalize(r#"(?<prefix>"exec_time": )[0-9.]+"#, r#"${prefix}"$$EXEC_TIME""#) + .normalize(r"thread '(?P<name>.*?)' \(\d+\) panicked", "thread '$name' ($$TID) panicked") .run(); } diff --git a/tests/run-make/libtest-junit/output-default.xml b/tests/run-make/libtest-junit/output-default.xml index aa1b8c855aa..2467d8d940a 100644 --- a/tests/run-make/libtest-junit/output-default.xml +++ b/tests/run-make/libtest-junit/output-default.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites> +<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"/><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' ($TID) panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"/><system-out/><system-err/></testsuite></testsuites> diff --git a/tests/run-make/libtest-junit/output-stdout-success.xml b/tests/run-make/libtest-junit/output-stdout-success.xml index 2592ec7efb1..6bf1d7008a4 100644 --- a/tests/run-make/libtest-junit/output-stdout-success.xml +++ b/tests/run-make/libtest-junit/output-stdout-success.xml @@ -1 +1 @@ -<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[]]>
<![CDATA[thread 'c' panicked at f.rs:16:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites> +<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="1" tests="4" skipped="1" ><testcase classname="unknown" name="a" time="$TIME"><system-out><![CDATA[print from successful test]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="b" time="$TIME"><failure type="assert"/><system-out><![CDATA[print from failing test]]>

<![CDATA[thread 'b' ($TID) panicked at f.rs:10:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace]]>
<![CDATA[]]></system-out></testcase><testcase classname="unknown" name="c" time="$TIME"><system-out><![CDATA[]]>
<![CDATA[thread 'c' ($TID) panicked at f.rs:16:5:]]>
<![CDATA[assertion failed: false]]>
<![CDATA[]]></system-out></testcase><system-out/><system-err/></testsuite></testsuites> diff --git a/tests/run-make/libtest-junit/rmake.rs b/tests/run-make/libtest-junit/rmake.rs index 5917660b6c7..6961be21513 100644 --- a/tests/run-make/libtest-junit/rmake.rs +++ b/tests/run-make/libtest-junit/rmake.rs @@ -27,5 +27,6 @@ fn run_tests(extra_args: &[&str], expected_file: &str) { .expected_file(expected_file) .actual_text("stdout", test_stdout) .normalize(r#"\btime="[0-9.]+""#, r#"time="$$TIME""#) + .normalize(r"thread '(?P<name>.*?)' \(\d+\) panicked", "thread '$name' ($$TID) panicked") .run(); } diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/Cargo.toml b/tests/run-make/rustdoc-scrape-examples-paths/foo/Cargo.toml new file mode 100644 index 00000000000..6962028375b --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-paths/foo/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "foo" +version = "0.0.1" +edition = "2024" + +[[example]] +name = "complex" +doc-scrape-examples = true diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/complex.rs b/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/complex.rs new file mode 100644 index 00000000000..1cda7e098f4 --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/complex.rs @@ -0,0 +1,3 @@ +fn main() { + let mut x = foo::X::new(); +} diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/tester.rs b/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/tester.rs new file mode 100644 index 00000000000..fbd1906ec09 --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/tester.rs @@ -0,0 +1 @@ +// This file MUST exist to trigger the original bug. diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/src/lib.rs b/tests/run-make/rustdoc-scrape-examples-paths/foo/src/lib.rs new file mode 100644 index 00000000000..a9bb0272c78 --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-paths/foo/src/lib.rs @@ -0,0 +1,7 @@ +pub struct X; + +impl X { + pub fn new() -> Self { + X + } +} diff --git a/tests/run-make/rustdoc-scrape-examples-paths/rmake.rs b/tests/run-make/rustdoc-scrape-examples-paths/rmake.rs new file mode 100644 index 00000000000..03888f69eab --- /dev/null +++ b/tests/run-make/rustdoc-scrape-examples-paths/rmake.rs @@ -0,0 +1,16 @@ +//! Test to ensure that the rustdoc `scrape-examples` feature is not panicking. +//! Regression test for <https://github.com/rust-lang/rust/issues/144752>. + +use run_make_support::{cargo, path, rfs}; + +fn main() { + // We copy the crate to be documented "outside" to prevent documenting + // the whole compiler. + let tmp = std::env::temp_dir(); + let test_crate = tmp.join("foo"); + rfs::copy_dir_all(path("foo"), &test_crate); + + // The `scrape-examples` feature is also implemented in `cargo` so instead of reproducing + // what `cargo` does, better to just let `cargo` do it. + cargo().current_dir(&test_crate).args(["doc", "-p", "foo", "-Zrustdoc-scrape-examples"]).run(); +} diff --git a/tests/rustdoc-gui/notable-trait.goml b/tests/rustdoc-gui/notable-trait.goml index 7fc70e0675d..423a273fde7 100644 --- a/tests/rustdoc-gui/notable-trait.goml +++ b/tests/rustdoc-gui/notable-trait.goml @@ -8,10 +8,10 @@ define-function: ( [x, i_x], block { // Checking they have the same y position. - compare-elements-position: ( + compare-elements-position-near: ( "//*[@id='method.create_an_iterator_from_read']//a[normalize-space()='NotableStructWithLongName']", "//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']", - ["y"], + {"y": 1}, ) // Checking they don't have the same x position. compare-elements-position-false: ( diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index e8afe8b5687..623f5b33e9b 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -767,3 +767,17 @@ pub mod impls_indent { pub fn bar() {} } } + +pub mod tooltips { + pub struct X; + + impl X { + pub fn bar() -> Vec<u8> { + Vec::new() + } + } + + pub fn bar() -> Vec<u8> { + Vec::new() + } +} diff --git a/tests/rustdoc-gui/tooltips.goml b/tests/rustdoc-gui/tooltips.goml new file mode 100644 index 00000000000..6e79196be27 --- /dev/null +++ b/tests/rustdoc-gui/tooltips.goml @@ -0,0 +1,15 @@ +// This test checks that the right font is applied to the `i` tooltip element. + +define-function: ( + "check-font", + [path], + block { + go-to: "file://" + |DOC_PATH| + "/test_docs/" + |path| + assert-css: ( + "a.tooltip", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ALL, + ) + } +) + +call-function: ("check-font", {"path": "tooltips/fn.bar.html"}) +call-function: ("check-font", {"path": "tooltips/struct.X.html"}) diff --git a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout index ab6aca239af..c8acbe4eda7 100644 --- a/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout +++ b/tests/rustdoc-ui/doctest/edition-2024-error-output.stdout @@ -9,7 +9,7 @@ Test executable failed (exit status: 101). stderr: -thread 'main' panicked at $TMP:6:1: +thread 'main' ($TID) panicked at $TMP:6:1: assertion `left == right` failed left: 4 right: 5 diff --git a/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout index 7aa965d543b..12a59d435fe 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output-windows.stdout @@ -27,7 +27,7 @@ stderr: stderr 1 stderr 2 -thread 'main' panicked at $DIR/failed-doctest-output-windows.rs:7:1: +thread 'main' ($TID) panicked at $DIR/failed-doctest-output-windows.rs:7:1: oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc-ui/doctest/failed-doctest-output.stdout b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout index a333f341ce5..3dbb2179b8f 100644 --- a/tests/rustdoc-ui/doctest/failed-doctest-output.stdout +++ b/tests/rustdoc-ui/doctest/failed-doctest-output.stdout @@ -27,7 +27,7 @@ stderr: stderr 1 stderr 2 -thread 'main' panicked at $DIR/failed-doctest-output.rs:7:1: +thread 'main' ($TID) panicked at $DIR/failed-doctest-output.rs:7:1: oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout index a35a4d7c3cb..dfdcd7759d5 100644 --- a/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout +++ b/tests/rustdoc-ui/doctest/stdout-and-stderr.stdout @@ -14,7 +14,7 @@ stdout: stderr: -thread 'main' panicked at $TMP:7:1: +thread 'main' ($TID) panicked at $TMP:7:1: assertion `left == right` failed left: "doc" right: "test" @@ -26,7 +26,7 @@ Test executable failed (exit status: 101). stderr: -thread 'main' panicked at $TMP:15:1: +thread 'main' ($TID) panicked at $TMP:15:1: assertion `left == right` failed left: "doc" right: "test" diff --git a/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout b/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout index 87d1e772b80..08f7a4ddd3a 100644 --- a/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout +++ b/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.stdout @@ -9,7 +9,7 @@ Test executable failed (exit status: 101). stderr: -thread 'main' panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1: +thread 'main' ($TID) panicked at remapped_path/remap-path-prefix-failed-doctest-output.rs:3:1: oh no note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/rustdoc/intra-doc/macro-caching-144965.rs b/tests/rustdoc/intra-doc/macro-caching-144965.rs new file mode 100644 index 00000000000..e14b465aeea --- /dev/null +++ b/tests/rustdoc/intra-doc/macro-caching-144965.rs @@ -0,0 +1,35 @@ +// regression test for https://github.com/rust-lang/rust/issues/144965 + +#![crate_name = "foo"] +#![no_std] + +#[doc(hidden)] +pub struct MyStruct; + +macro_rules! my_macro { + () => { + pub fn my_function() {} + + /// Incorrect: [`my_function()`]. + #[doc(inline)] + pub use $crate::MyStruct; + + /// Correct: [`my_function`]. + pub struct AnotherStruct; + }; +} + + +pub mod one { + //@ has 'foo/one/index.html' + //@ has - '//dl[@class="item-table"]/dd[1]/a[@href="fn.my_function.html"]/code' 'my_function' + //@ has - '//dl[@class="item-table"]/dd[2]/a[@href="fn.my_function.html"]/code' 'my_function()' + my_macro!(); +} + +pub mod two { + //@ has 'foo/two/index.html' + //@ has - '//dl[@class="item-table"]/dd[1]/a[@href="fn.my_function.html"]/code' 'my_function' + //@ has - '//dl[@class="item-table"]/dd[2]/a[@href="fn.my_function.html"]/code' 'my_function()' + my_macro!(); +} diff --git a/tests/ui/issues/issue-5754.rs b/tests/ui/abi/extern-c-two-doubles-x86_64-5754.rs index 0aa09882959..7f44ef9c685 100644 --- a/tests/ui/issues/issue-5754.rs +++ b/tests/ui/abi/extern-c-two-doubles-x86_64-5754.rs @@ -1,8 +1,8 @@ +// https://github.com/rust-lang/rust/issues/5754 //@ build-pass #![allow(dead_code)] #![allow(improper_ctypes)] - struct TwoDoubles { r: f64, i: f64 diff --git a/tests/ui/issues/issue-8898.rs b/tests/ui/array-slice-vec/fixed-size-arrays-zero-size-types-8898.rs index 4447704f059..fe627b00f53 100644 --- a/tests/ui/issues/issue-8898.rs +++ b/tests/ui/array-slice-vec/fixed-size-arrays-zero-size-types-8898.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/8898 //@ run-pass fn assert_repr_eq<T: std::fmt::Debug>(obj : T, expected : String) { diff --git a/tests/ui/issues/issue-43483.rs b/tests/ui/associated-consts/trait-associated-const-usage-43483.rs index 2c62671d0c7..c24157d45e7 100644 --- a/tests/ui/issues/issue-43483.rs +++ b/tests/ui/associated-consts/trait-associated-const-usage-43483.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/43483 //@ check-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/issues/issue-21946.rs b/tests/ui/associated-types/recursive-associated-type-overflow-21946.rs index d0c052cb2fd..ba84ea11300 100644 --- a/tests/ui/issues/issue-21946.rs +++ b/tests/ui/associated-types/recursive-associated-type-overflow-21946.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/21946 trait Foo { type A; } diff --git a/tests/ui/issues/issue-21946.stderr b/tests/ui/associated-types/recursive-associated-type-overflow-21946.stderr index d1b4a808d2e..37fb0ed7eb8 100644 --- a/tests/ui/issues/issue-21946.stderr +++ b/tests/ui/associated-types/recursive-associated-type-overflow-21946.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow evaluating the requirement `<FooStruct as Foo>::A == _` - --> $DIR/issue-21946.rs:8:14 + --> $DIR/recursive-associated-type-overflow-21946.rs:9:14 | LL | type A = <FooStruct as Foo>::A; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs index a8b05a4befa..ed99614914a 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-completion.rs @@ -2,7 +2,7 @@ // be talking about `async fn`s instead. //@ run-fail -//@ error-pattern: thread 'main' panicked +//@ regex-error-pattern: thread 'main'.*panicked //@ error-pattern: `async fn` resumed after completion //@ edition:2018 diff --git a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs index 94366e66263..881fafb010f 100644 --- a/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs +++ b/tests/ui/async-await/issues/issue-65419/issue-65419-async-fn-resume-after-panic.rs @@ -3,7 +3,7 @@ //@ run-fail //@ needs-unwind -//@ error-pattern: thread 'main' panicked +//@ regex-error-pattern: thread 'main'.*panicked //@ error-pattern: `async fn` resumed after panicking //@ edition:2018 diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 1b51075b4e8..e8ae4715398 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -55,12 +55,6 @@ error: malformed `patchable_function_entry` attribute input LL | #[patchable_function_entry] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` -error: malformed `coroutine` attribute input - --> $DIR/malformed-attrs.rs:108:5 - | -LL | #[coroutine = 63] || {} - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[coroutine]` - error: malformed `must_not_suspend` attribute input --> $DIR/malformed-attrs.rs:129:1 | @@ -436,6 +430,15 @@ LL | #[proc_macro = 18] | | didn't expect any arguments here | help: must be of the form: `#[proc_macro]` +error[E0565]: malformed `coroutine` attribute input + --> $DIR/malformed-attrs.rs:108:5 + | +LL | #[coroutine = 63] || {} + | ^^^^^^^^^^^^----^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[coroutine]` + error[E0565]: malformed `proc_macro_attribute` attribute input --> $DIR/malformed-attrs.rs:113:1 | diff --git a/tests/ui/auto-traits/assoc-ty.current.stderr b/tests/ui/auto-traits/assoc-ty.current.stderr index 77a1c8fb654..d793ae66526 100644 --- a/tests/ui/auto-traits/assoc-ty.current.stderr +++ b/tests/ui/auto-traits/assoc-ty.current.stderr @@ -5,7 +5,7 @@ LL | auto trait Trait { | ----- auto traits cannot have associated items LL | LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error[E0658]: auto traits are experimental and possibly buggy --> $DIR/assoc-ty.rs:8:1 diff --git a/tests/ui/auto-traits/assoc-ty.next.stderr b/tests/ui/auto-traits/assoc-ty.next.stderr index 4ce00d17475..a41f7d99278 100644 --- a/tests/ui/auto-traits/assoc-ty.next.stderr +++ b/tests/ui/auto-traits/assoc-ty.next.stderr @@ -5,7 +5,7 @@ LL | auto trait Trait { | ----- auto traits cannot have associated items LL | LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error[E0658]: auto traits are experimental and possibly buggy --> $DIR/assoc-ty.rs:8:1 diff --git a/tests/ui/auto-traits/auto-trait-validation.fixed b/tests/ui/auto-traits/auto-trait-validation.fixed index 8a445448c85..b24dc1cb2c3 100644 --- a/tests/ui/auto-traits/auto-trait-validation.fixed +++ b/tests/ui/auto-traits/auto-trait-validation.fixed @@ -11,4 +11,15 @@ auto trait LifetimeBound {} //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] auto trait MyTrait { } //~^ ERROR auto traits cannot have associated items [E0380] +auto trait AssocTy { } +//~^ ERROR auto traits cannot have associated items [E0380] +auto trait All { + //~^ ERROR auto traits cannot have generic parameters [E0567] + +} +// We can't test both generic params and super-traits because the suggestion span overlaps. +auto trait All2 { + //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] + +} fn main() {} diff --git a/tests/ui/auto-traits/auto-trait-validation.rs b/tests/ui/auto-traits/auto-trait-validation.rs index b5e7505d86a..9665e5bc393 100644 --- a/tests/ui/auto-traits/auto-trait-validation.rs +++ b/tests/ui/auto-traits/auto-trait-validation.rs @@ -11,4 +11,19 @@ auto trait LifetimeBound : 'static {} //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] auto trait MyTrait { fn foo() {} } //~^ ERROR auto traits cannot have associated items [E0380] +auto trait AssocTy { type Bar; } +//~^ ERROR auto traits cannot have associated items [E0380] +auto trait All<'a, T> { + //~^ ERROR auto traits cannot have generic parameters [E0567] + type Bar; + //~^ ERROR auto traits cannot have associated items [E0380] + fn foo() {} +} +// We can't test both generic params and super-traits because the suggestion span overlaps. +auto trait All2: Copy + 'static { + //~^ ERROR auto traits cannot have super traits or lifetime bounds [E0568] + type Bar; + //~^ ERROR auto traits cannot have associated items [E0380] + fn foo() {} +} fn main() {} diff --git a/tests/ui/auto-traits/auto-trait-validation.stderr b/tests/ui/auto-traits/auto-trait-validation.stderr index a6e5ac54869..60757db6d1e 100644 --- a/tests/ui/auto-traits/auto-trait-validation.stderr +++ b/tests/ui/auto-traits/auto-trait-validation.stderr @@ -2,23 +2,23 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/auto-trait-validation.rs:6:19 | LL | auto trait Generic<T> {} - | -------^^^ help: remove the parameters + | -------^^^ | | | auto trait cannot have generic parameters error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/auto-trait-validation.rs:8:17 + --> $DIR/auto-trait-validation.rs:8:20 | LL | auto trait Bound : Copy {} - | -----^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/auto-trait-validation.rs:10:25 + --> $DIR/auto-trait-validation.rs:10:28 | LL | auto trait LifetimeBound : 'static {} - | -------------^^^^^^^^^^ help: remove the super traits or lifetime bounds + | ------------- ^^^^^^^ | | | auto traits cannot have super traits or lifetime bounds @@ -26,12 +26,59 @@ error[E0380]: auto traits cannot have associated items --> $DIR/auto-trait-validation.rs:12:25 | LL | auto trait MyTrait { fn foo() {} } - | ------- ---^^^----- - | | | - | | help: remove these associated items + | ------- ^^^ + | | + | auto traits cannot have associated items + +error[E0380]: auto traits cannot have associated items + --> $DIR/auto-trait-validation.rs:14:27 + | +LL | auto trait AssocTy { type Bar; } + | ------- ^^^ + | | | auto traits cannot have associated items -error: aborting due to 4 previous errors +error[E0567]: auto traits cannot have generic parameters + --> $DIR/auto-trait-validation.rs:16:15 + | +LL | auto trait All<'a, T> { + | ---^^^^^^^ + | | + | auto trait cannot have generic parameters + +error[E0380]: auto traits cannot have associated items + --> $DIR/auto-trait-validation.rs:18:10 + | +LL | auto trait All<'a, T> { + | --- auto traits cannot have associated items +LL | +LL | type Bar; + | ^^^ +LL | +LL | fn foo() {} + | ^^^ + +error[E0568]: auto traits cannot have super traits or lifetime bounds + --> $DIR/auto-trait-validation.rs:23:18 + | +LL | auto trait All2: Copy + 'static { + | ---- ^^^^ ^^^^^^^ + | | + | auto traits cannot have super traits or lifetime bounds + +error[E0380]: auto traits cannot have associated items + --> $DIR/auto-trait-validation.rs:25:10 + | +LL | auto trait All2: Copy + 'static { + | ---- auto traits cannot have associated items +LL | +LL | type Bar; + | ^^^ +LL | +LL | fn foo() {} + | ^^^ + +error: aborting due to 9 previous errors Some errors have detailed explanations: E0380, E0567, E0568. For more information about an error, try `rustc --explain E0380`. diff --git a/tests/ui/auto-traits/bad-generics-on-dyn.stderr b/tests/ui/auto-traits/bad-generics-on-dyn.stderr index 06c7cbcd76d..a6977c2037e 100644 --- a/tests/ui/auto-traits/bad-generics-on-dyn.stderr +++ b/tests/ui/auto-traits/bad-generics-on-dyn.stderr @@ -2,7 +2,7 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/bad-generics-on-dyn.rs:3:18 | LL | auto trait Trait1<'a> {} - | ------^^^^ help: remove the parameters + | ------^^^^ | | | auto trait cannot have generic parameters diff --git a/tests/ui/auto-traits/has-arguments.stderr b/tests/ui/auto-traits/has-arguments.stderr index b8a680e6a5c..5228b6d2d1a 100644 --- a/tests/ui/auto-traits/has-arguments.stderr +++ b/tests/ui/auto-traits/has-arguments.stderr @@ -2,7 +2,7 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/has-arguments.rs:3:18 | LL | auto trait Trait1<'outer> {} - | ------^^^^^^^^ help: remove the parameters + | ------^^^^^^^^ | | | auto trait cannot have generic parameters diff --git a/tests/ui/auto-traits/issue-117789.stderr b/tests/ui/auto-traits/issue-117789.stderr index 99efb213417..1e047c7d2e0 100644 --- a/tests/ui/auto-traits/issue-117789.stderr +++ b/tests/ui/auto-traits/issue-117789.stderr @@ -2,7 +2,7 @@ error[E0567]: auto traits cannot have generic parameters --> $DIR/issue-117789.rs:1:17 | LL | auto trait Trait<P> {} - | -----^^^ help: remove the parameters + | -----^^^ | | | auto trait cannot have generic parameters diff --git a/tests/ui/auto-traits/issue-23080-2.current.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr index 62c7b37041f..3af97f57d48 100644 --- a/tests/ui/auto-traits/issue-23080-2.current.stderr +++ b/tests/ui/auto-traits/issue-23080-2.current.stderr @@ -4,7 +4,7 @@ error[E0380]: auto traits cannot have associated items LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/auto-traits/issue-23080-2.next.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr index 62c7b37041f..3af97f57d48 100644 --- a/tests/ui/auto-traits/issue-23080-2.next.stderr +++ b/tests/ui/auto-traits/issue-23080-2.next.stderr @@ -4,7 +4,7 @@ error[E0380]: auto traits cannot have associated items LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items LL | type Output; - | -----^^^^^^- help: remove these associated items + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/auto-traits/issue-23080.stderr b/tests/ui/auto-traits/issue-23080.stderr index 5cea45060c8..02a75519102 100644 --- a/tests/ui/auto-traits/issue-23080.stderr +++ b/tests/ui/auto-traits/issue-23080.stderr @@ -1,13 +1,10 @@ error[E0380]: auto traits cannot have associated items --> $DIR/issue-23080.rs:5:8 | -LL | unsafe auto trait Trait { - | ----- auto traits cannot have associated items -LL | fn method(&self) { - | _____- ^^^^^^ -LL | | println!("Hello"); -LL | | } - | |_____- help: remove these associated items +LL | unsafe auto trait Trait { + | ----- auto traits cannot have associated items +LL | fn method(&self) { + | ^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/auto-traits/issue-84075.stderr b/tests/ui/auto-traits/issue-84075.stderr index 943d521ce9e..4edf2ecdf06 100644 --- a/tests/ui/auto-traits/issue-84075.stderr +++ b/tests/ui/auto-traits/issue-84075.stderr @@ -2,7 +2,7 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/issue-84075.rs:5:18 | LL | auto trait Magic where Self: Copy {} - | ----- ^^^^^^^^^^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^^^^^^^^^^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr index 27e38ce06a4..bc17fefc944 100644 --- a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr +++ b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits-2.stderr @@ -1,8 +1,8 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:17 + --> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:20 | LL | auto trait Magic : Sized where Option<Self> : Magic {} - | -----^^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^^ | | | auto traits cannot have super traits or lifetime bounds @@ -10,7 +10,7 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds --> $DIR/typeck-auto-trait-no-supertraits-2.rs:4:26 | LL | auto trait Magic : Sized where Option<Self> : Magic {} - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr index 23aae13639c..bc9791a5799 100644 --- a/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr +++ b/tests/ui/auto-traits/typeck-auto-trait-no-supertraits.stderr @@ -1,8 +1,8 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/typeck-auto-trait-no-supertraits.rs:28:17 + --> $DIR/typeck-auto-trait-no-supertraits.rs:28:19 | LL | auto trait Magic: Copy {} - | -----^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/backtrace/synchronized-panic-handler.run.stderr b/tests/ui/backtrace/synchronized-panic-handler.run.stderr index 7a60ef2da60..c604d49c193 100644 --- a/tests/ui/backtrace/synchronized-panic-handler.run.stderr +++ b/tests/ui/backtrace/synchronized-panic-handler.run.stderr @@ -1,7 +1,7 @@ -thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:11:5: +thread '<unnamed>' ($TID) panicked at $DIR/synchronized-panic-handler.rs:11:5: oops oh no woe is me note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread '<unnamed>' panicked at $DIR/synchronized-panic-handler.rs:11:5: +thread '<unnamed>' ($TID) panicked at $DIR/synchronized-panic-handler.rs:11:5: oops oh no woe is me diff --git a/tests/ui/issues/issue-7061.rs b/tests/ui/borrowck/mismatched-pointer-type-in-self-7061.rs index c5d5a9d9498..521a5ee9c37 100644 --- a/tests/ui/issues/issue-7061.rs +++ b/tests/ui/borrowck/mismatched-pointer-type-in-self-7061.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7061 //@ dont-require-annotations: NOTE struct BarStruct; diff --git a/tests/ui/issues/issue-7061.stderr b/tests/ui/borrowck/mismatched-pointer-type-in-self-7061.stderr index b4c0ebfbdd5..39b9072dc30 100644 --- a/tests/ui/issues/issue-7061.stderr +++ b/tests/ui/borrowck/mismatched-pointer-type-in-self-7061.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-7061.rs:6:46 + --> $DIR/mismatched-pointer-type-in-self-7061.rs:7:46 | LL | fn foo(&'a mut self) -> Box<BarStruct> { self } | -------------- ^^^^ expected `Box<BarStruct>`, found `&mut BarStruct` diff --git a/tests/ui/issues/issue-13665.rs b/tests/ui/borrowck/region-checker-map-closure-13665.rs index e1d8be16f45..72efa42fe38 100644 --- a/tests/ui/issues/issue-13665.rs +++ b/tests/ui/borrowck/region-checker-map-closure-13665.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/13665 //@ run-pass fn foo<'r>() { diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index f422919983b..44fc23b6390 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -198,6 +198,35 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `power9-altivec` `power9-vector` `prfchw` +`ptx32` +`ptx40` +`ptx41` +`ptx42` +`ptx43` +`ptx50` +`ptx60` +`ptx61` +`ptx62` +`ptx63` +`ptx64` +`ptx65` +`ptx70` +`ptx71` +`ptx72` +`ptx73` +`ptx74` +`ptx75` +`ptx76` +`ptx77` +`ptx78` +`ptx80` +`ptx81` +`ptx82` +`ptx83` +`ptx84` +`ptx85` +`ptx86` +`ptx87` `quadword-atomics` `rand` `ras` @@ -222,6 +251,33 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `simd128` `sm3` `sm4` +`sm_100` +`sm_100a` +`sm_101` +`sm_101a` +`sm_120` +`sm_120a` +`sm_20` +`sm_21` +`sm_30` +`sm_32` +`sm_35` +`sm_37` +`sm_50` +`sm_52` +`sm_53` +`sm_60` +`sm_61` +`sm_62` +`sm_70` +`sm_72` +`sm_75` +`sm_80` +`sm_86` +`sm_87` +`sm_89` +`sm_90` +`sm_90a` `sme` `sme-b16b16` `sme-f16f16` diff --git a/tests/ui/issues/issue-21600.rs b/tests/ui/closures/aliasability-violation-with-closure-21600.rs index 2e22e5e6fa2..d4c658319ab 100644 --- a/tests/ui/issues/issue-21600.rs +++ b/tests/ui/closures/aliasability-violation-with-closure-21600.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/21600 fn call_it<F>(f: F) where F: Fn() { f(); } struct A; diff --git a/tests/ui/issues/issue-21600.stderr b/tests/ui/closures/aliasability-violation-with-closure-21600.stderr index f7905934424..2d2397a2141 100644 --- a/tests/ui/issues/issue-21600.stderr +++ b/tests/ui/closures/aliasability-violation-with-closure-21600.stderr @@ -1,5 +1,5 @@ error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/issue-21600.rs:14:20 + --> $DIR/aliasability-violation-with-closure-21600.rs:15:20 | LL | fn call_it<F>(f: F) where F: Fn() { f(); } | - change this to accept `FnMut` instead of `Fn` @@ -11,7 +11,7 @@ LL | call_it(|| x.gen_mut()); | expects `Fn` instead of `FnMut` error[E0596]: cannot borrow `x` as mutable, as it is a captured variable in a `Fn` closure - --> $DIR/issue-21600.rs:14:17 + --> $DIR/aliasability-violation-with-closure-21600.rs:15:17 | LL | fn call_it<F>(f: F) where F: Fn() { f(); } | - change this to accept `FnMut` instead of `Fn` diff --git a/tests/ui/const-generics/defaults/default-on-impl.rs b/tests/ui/const-generics/defaults/default-on-impl.rs index 9ce46aa09de..85d0c583965 100644 --- a/tests/ui/const-generics/defaults/default-on-impl.rs +++ b/tests/ui/const-generics/defaults/default-on-impl.rs @@ -1,6 +1,6 @@ struct Foo<const N: usize>; impl<const N: usize = 1> Foo<N> {} -//~^ ERROR defaults for const parameters are only allowed +//~^ ERROR defaults for generic parameters are not allowed here fn main() {} diff --git a/tests/ui/const-generics/defaults/default-on-impl.stderr b/tests/ui/const-generics/defaults/default-on-impl.stderr index 691e0354edd..eb5d57e14bf 100644 --- a/tests/ui/const-generics/defaults/default-on-impl.stderr +++ b/tests/ui/const-generics/defaults/default-on-impl.stderr @@ -1,4 +1,4 @@ -error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/default-on-impl.rs:3:6 | LL | impl<const N: usize = 1> Foo<N> {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-105257.rs b/tests/ui/const-generics/generic_const_exprs/issue-105257.rs index a107556fd79..85a28f2b330 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-105257.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-105257.rs @@ -1,10 +1,10 @@ #![feature(generic_const_exprs)] -#![allow(incomplete_features)] +#![expect(incomplete_features)] trait Trait<T> { - fn fnc<const N: usize = "">(&self) {} //~ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + fn fnc<const N: usize = "">(&self) {} //~ERROR defaults for generic parameters are not allowed here //~^ ERROR: mismatched types - fn foo<const N: usize = { std::mem::size_of::<T>() }>(&self) {} //~ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + fn foo<const N: usize = { std::mem::size_of::<T>() }>(&self) {} //~ERROR defaults for generic parameters are not allowed here } fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-105257.stderr b/tests/ui/const-generics/generic_const_exprs/issue-105257.stderr index d7ded0f1f74..1d0ab56519c 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-105257.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-105257.stderr @@ -1,10 +1,10 @@ -error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/issue-105257.rs:5:12 | LL | fn fnc<const N: usize = "">(&self) {} | ^^^^^^^^^^^^^^^^^^^ -error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/issue-105257.rs:7:12 | LL | fn foo<const N: usize = { std::mem::size_of::<T>() }>(&self) {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs index 73357d208c0..ac4d9fc0f4f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.rs @@ -2,7 +2,7 @@ //@ known-bug: #97477 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/const-generics/min_const_generics/default_function_param.rs b/tests/ui/const-generics/min_const_generics/default_function_param.rs index 92d495ef665..153cd94849e 100644 --- a/tests/ui/const-generics/min_const_generics/default_function_param.rs +++ b/tests/ui/const-generics/min_const_generics/default_function_param.rs @@ -1,4 +1,4 @@ #![crate_type = "lib"] fn foo<const SIZE: usize = 5usize>() {} -//~^ ERROR defaults for const parameters are +//~^ ERROR defaults for generic parameters are not allowed here diff --git a/tests/ui/const-generics/min_const_generics/default_function_param.stderr b/tests/ui/const-generics/min_const_generics/default_function_param.stderr index 247eea3d989..261298a1c63 100644 --- a/tests/ui/const-generics/min_const_generics/default_function_param.stderr +++ b/tests/ui/const-generics/min_const_generics/default_function_param.stderr @@ -1,4 +1,4 @@ -error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/default_function_param.rs:3:8 | LL | fn foo<const SIZE: usize = 5usize>() {} diff --git a/tests/ui/issues/issue-32086.rs b/tests/ui/consts/const-pattern-rewrite-error-32086.rs index d595d1dd7e6..d35dfe57687 100644 --- a/tests/ui/issues/issue-32086.rs +++ b/tests/ui/consts/const-pattern-rewrite-error-32086.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/32086 struct S(u8); const C: S = S(10); diff --git a/tests/ui/issues/issue-32086.stderr b/tests/ui/consts/const-pattern-rewrite-error-32086.stderr index e566dea8908..47616b06632 100644 --- a/tests/ui/issues/issue-32086.stderr +++ b/tests/ui/consts/const-pattern-rewrite-error-32086.stderr @@ -1,5 +1,5 @@ error[E0532]: expected tuple struct or tuple variant, found constant `C` - --> $DIR/issue-32086.rs:5:9 + --> $DIR/const-pattern-rewrite-error-32086.rs:6:9 | LL | struct S(u8); | ------------- similarly named tuple struct `S` defined here @@ -8,7 +8,7 @@ LL | let C(a) = S(11); | ^ help: a tuple struct with a similar name exists: `S` error[E0532]: expected tuple struct or tuple variant, found constant `C` - --> $DIR/issue-32086.rs:6:9 + --> $DIR/const-pattern-rewrite-error-32086.rs:7:9 | LL | struct S(u8); | ------------- similarly named tuple struct `S` defined here diff --git a/tests/ui/issues/auxiliary/issue-5521.rs b/tests/ui/cross-crate/auxiliary/aux-5521.rs index c2f81779b35..c2f81779b35 100644 --- a/tests/ui/issues/auxiliary/issue-5521.rs +++ b/tests/ui/cross-crate/auxiliary/aux-5521.rs diff --git a/tests/ui/issues/issue-5521.rs b/tests/ui/cross-crate/cross-crate-map-usage-5521.rs index 45896ae8128..ffce846be2c 100644 --- a/tests/ui/issues/issue-5521.rs +++ b/tests/ui/cross-crate/cross-crate-map-usage-5521.rs @@ -1,10 +1,9 @@ +// https://github.com/rust-lang/rust/issues/5521 //@ run-pass #![allow(dead_code)] -//@ aux-build:issue-5521.rs +//@ aux-build:aux-5521.rs - - -extern crate issue_5521 as foo; +extern crate aux_5521 as foo; fn bar(a: foo::map) { if false { diff --git a/tests/ui/issues/issue-46332.rs b/tests/ui/did_you_mean/typo-suggestion-improvement-46332.rs index bed74e3138a..3dd686a66b0 100644 --- a/tests/ui/issues/issue-46332.rs +++ b/tests/ui/did_you_mean/typo-suggestion-improvement-46332.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/46332 // Original Levenshtein distance for both of this is 1. We improved accuracy with // additional case insensitive comparison. diff --git a/tests/ui/issues/issue-46332.stderr b/tests/ui/did_you_mean/typo-suggestion-improvement-46332.stderr index 8c0c1dfa6ee..502f8151878 100644 --- a/tests/ui/issues/issue-46332.stderr +++ b/tests/ui/did_you_mean/typo-suggestion-improvement-46332.stderr @@ -1,5 +1,5 @@ error[E0422]: cannot find struct, variant or union type `TyUInt` in this scope - --> $DIR/issue-46332.rs:9:5 + --> $DIR/typo-suggestion-improvement-46332.rs:10:5 | LL | struct TyUint {} | ------------- similarly named struct `TyUint` defined here diff --git a/tests/ui/issues/issue-6892.rs b/tests/ui/drop/destructor-run-for-let-ignore-6892.rs index 7d99aef4ac5..0fcf133c2b1 100644 --- a/tests/ui/issues/issue-6892.rs +++ b/tests/ui/drop/destructor-run-for-let-ignore-6892.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6892 //@ run-pass #![allow(dead_code)] // Ensures that destructors are run for expressions of the form "let _ = e;" diff --git a/tests/ui/issues/issue-16151.rs b/tests/ui/drop/drop-count-assertion-16151.rs index b18108e0a8a..ede6bc23e73 100644 --- a/tests/ui/issues/issue-16151.rs +++ b/tests/ui/drop/drop-count-assertion-16151.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/16151 //@ run-pass // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint diff --git a/tests/ui/drop/or-pattern-drop-order.rs b/tests/ui/drop/or-pattern-drop-order.rs index fdc28225c35..cca81673ac3 100644 --- a/tests/ui/drop/or-pattern-drop-order.rs +++ b/tests/ui/drop/or-pattern-drop-order.rs @@ -1,6 +1,7 @@ //@ run-pass //! Test drop order for different ways of declaring pattern bindings involving or-patterns. -//! Currently, it's inconsistent between language constructs (#142163). +//! In particular, are ordered based on the order in which the first occurrence of each binding +//! appears (i.e. the "primary" bindings). Regression test for #142163. use std::cell::RefCell; use std::ops::Drop; @@ -43,11 +44,10 @@ fn main() { y = LogDrop(o, 1); }); - // When bindings are declared with `let pat = expr;`, bindings within or-patterns are seen last, - // thus they're dropped first. + // `let pat = expr;` should have the same drop order. assert_drop_order(1..=3, |o| { - // Drops are right-to-left, treating `y` as rightmost: `y`, `z`, `x`. - let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)); + // Drops are right-to-left: `z`, `y`, `x`. + let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)); }); assert_drop_order(1..=2, |o| { // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. @@ -58,30 +58,29 @@ fn main() { let ((true, x, y) | (false, y, x)) = (false, LogDrop(o, 1), LogDrop(o, 2)); }); - // `match` treats or-patterns as last like `let pat = expr;`, but also determines drop order - // using the order of the bindings in the *last* or-pattern alternative. + // `match` should have the same drop order. assert_drop_order(1..=3, |o| { - // Drops are right-to-left, treating `y` as rightmost: `y`, `z`, `x`. - match (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) { (x, Ok(y) | Err(y), z) => {} } + // Drops are right-to-left: `z`, `y` `x`. + match (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) { (x, Ok(y) | Err(y), z) => {} } }); assert_drop_order(1..=2, |o| { - // The last or-pattern alternative determines the bindings' drop order: `x`, `y`. - match (true, LogDrop(o, 1), LogDrop(o, 2)) { (true, x, y) | (false, y, x) => {} } + // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. + match (true, LogDrop(o, 2), LogDrop(o, 1)) { (true, x, y) | (false, y, x) => {} } }); assert_drop_order(1..=2, |o| { - // That drop order is used regardless of which or-pattern alternative matches: `x`, `y`. - match (false, LogDrop(o, 2), LogDrop(o, 1)) { (true, x, y) | (false, y, x) => {} } + // That drop order is used regardless of which or-pattern alternative matches: `y`, `x`. + match (false, LogDrop(o, 1), LogDrop(o, 2)) { (true, x, y) | (false, y, x) => {} } }); // Function params are visited one-by-one, and the order of bindings within a param's pattern is - // the same as `let pat = expr`; + // the same as `let pat = expr;` assert_drop_order(1..=3, |o| { // Among separate params, the drop order is right-to-left: `z`, `y`, `x`. (|x, (Ok(y) | Err(y)), z| {})(LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)); }); assert_drop_order(1..=3, |o| { - // Within a param's pattern, or-patterns are treated as rightmost: `y`, `z`, `x`. - (|(x, Ok(y) | Err(y), z)| {})((LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2))); + // Within a param's pattern, likewise: `z`, `y`, `x`. + (|(x, Ok(y) | Err(y), z)| {})((LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1))); }); assert_drop_order(1..=2, |o| { // The first or-pattern alternative determines the bindings' drop order: `y`, `x`. @@ -89,12 +88,11 @@ fn main() { }); // `if let` and `let`-`else` see bindings in the same order as `let pat = expr;`. - // Vars in or-patterns are seen last (dropped first), and the first alternative's order is used. assert_drop_order(1..=3, |o| { - if let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) {} + if let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) {} }); assert_drop_order(1..=3, |o| { - let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 1)), LogDrop(o, 2)) else { + let (x, Ok(y) | Err(y), z) = (LogDrop(o, 3), Ok(LogDrop(o, 2)), LogDrop(o, 1)) else { unreachable!(); }; }); @@ -106,4 +104,21 @@ fn main() { unreachable!(); }; }); + + // Test nested and adjacent or-patterns, including or-patterns without bindings under a guard. + assert_drop_order(1..=6, |o| { + // The `LogDrop`s that aren't moved into bindings are dropped last. + match [ + [LogDrop(o, 6), LogDrop(o, 4)], + [LogDrop(o, 3), LogDrop(o, 2)], + [LogDrop(o, 1), LogDrop(o, 5)], + ] { + [ + [_ | _, w | w] | [w | w, _ | _], + [x | x, y | y] | [y | y, x | x], + [z | z, _ | _] | [_ | _, z | z], + ] if true => {} + _ => unreachable!(), + } + }); } diff --git a/tests/ui/dropck/eager-by-ref-binding-for-guards.rs b/tests/ui/dropck/eager-by-ref-binding-for-guards.rs index 3f475839171..90ff9a747ae 100644 --- a/tests/ui/dropck/eager-by-ref-binding-for-guards.rs +++ b/tests/ui/dropck/eager-by-ref-binding-for-guards.rs @@ -17,15 +17,15 @@ fn main() { (mut long2, ref short2) if true => long2.0 = &short2, _ => unreachable!(), } - // This depends on the binding modes of the final or-pattern alternatives (see #142163): + // This depends on the binding modes of the first or-pattern alternatives: let res: &Result<u8, &u8> = &Ok(1); match (Struct(&&0), res) { (mut long3, Ok(short3) | &Err(short3)) if true => long3.0 = &short3, - //~^ ERROR `short3` does not live long enough _ => unreachable!(), } match (Struct(&&0), res) { (mut long4, &Err(short4) | Ok(short4)) if true => long4.0 = &short4, + //~^ ERROR `short4` does not live long enough _ => unreachable!(), } } diff --git a/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr b/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr index cb1a04cd444..2648ce6f99c 100644 --- a/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr +++ b/tests/ui/dropck/eager-by-ref-binding-for-guards.stderr @@ -11,15 +11,15 @@ LL | (mut long1, ref short1) => long1.0 = &short1, | = note: values in a scope are dropped in the opposite order they are defined -error[E0597]: `short3` does not live long enough - --> $DIR/eager-by-ref-binding-for-guards.rs:23:69 +error[E0597]: `short4` does not live long enough + --> $DIR/eager-by-ref-binding-for-guards.rs:27:69 | -LL | (mut long3, Ok(short3) | &Err(short3)) if true => long3.0 = &short3, - | ------ ^^^^^^- - | | | | - | | | `short3` dropped here while still borrowed - | | | borrow might be used here, when `long3` is dropped and runs the `Drop` code for type `Struct` - | binding `short3` declared here borrowed value does not live long enough +LL | (mut long4, &Err(short4) | Ok(short4)) if true => long4.0 = &short4, + | ------ ^^^^^^- + | | | | + | | | `short4` dropped here while still borrowed + | | | borrow might be used here, when `long4` is dropped and runs the `Drop` code for type `Struct` + | binding `short4` declared here borrowed value does not live long enough | = note: values in a scope are dropped in the opposite order they are defined diff --git a/tests/ui/dropck/let-else-more-permissive.rs b/tests/ui/dropck/let-else-more-permissive.rs index 0020814aa81..6247b0eb5e2 100644 --- a/tests/ui/dropck/let-else-more-permissive.rs +++ b/tests/ui/dropck/let-else-more-permissive.rs @@ -1,5 +1,5 @@ -//! The drop check is currently more permissive when `let` statements have an `else` block, due to -//! scheduling drops for bindings' storage before pattern-matching (#142056). +//! Regression test for #142056. The drop check used to be more permissive for `let` statements with +//! `else` blocks, due to scheduling drops for bindings' storage before pattern-matching. struct Struct<T>(T); impl<T> Drop for Struct<T> { @@ -14,10 +14,11 @@ fn main() { //~^ ERROR `short1` does not live long enough } { - // This is OK: `short2`'s storage is live until after `long2`'s drop runs. + // This was OK: `short2`'s storage was live until after `long2`'s drop ran. #[expect(irrefutable_let_patterns)] let (mut long2, short2) = (Struct(&0), 1) else { unreachable!() }; long2.0 = &short2; + //~^ ERROR `short2` does not live long enough } { // Sanity check: `short3`'s drop is significant; it's dropped before `long3`: diff --git a/tests/ui/dropck/let-else-more-permissive.stderr b/tests/ui/dropck/let-else-more-permissive.stderr index 7c37e170afa..4f0c193a78d 100644 --- a/tests/ui/dropck/let-else-more-permissive.stderr +++ b/tests/ui/dropck/let-else-more-permissive.stderr @@ -14,8 +14,24 @@ LL | } | = note: values in a scope are dropped in the opposite order they are defined +error[E0597]: `short2` does not live long enough + --> $DIR/let-else-more-permissive.rs:20:19 + | +LL | let (mut long2, short2) = (Struct(&0), 1) else { unreachable!() }; + | ------ binding `short2` declared here +LL | long2.0 = &short2; + | ^^^^^^^ borrowed value does not live long enough +LL | +LL | } + | - + | | + | `short2` dropped here while still borrowed + | borrow might be used here, when `long2` is dropped and runs the `Drop` code for type `Struct` + | + = note: values in a scope are dropped in the opposite order they are defined + error[E0597]: `short3` does not live long enough - --> $DIR/let-else-more-permissive.rs:27:19 + --> $DIR/let-else-more-permissive.rs:28:19 | LL | let (mut long3, short3) = (Struct(&tmp), Box::new(1)) else { unreachable!() }; | ------ binding `short3` declared here @@ -30,6 +46,6 @@ LL | } | = note: values in a scope are dropped in the opposite order they are defined -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/issues/issue-20939.rs b/tests/ui/dyn-compatibility/dyn-compatible-trait-implementation-20939.rs index c0c22297897..c7938b275e9 100644 --- a/tests/ui/issues/issue-20939.rs +++ b/tests/ui/dyn-compatibility/dyn-compatible-trait-implementation-20939.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/20939 trait Foo {} impl<'a> Foo for dyn Foo + 'a {} diff --git a/tests/ui/issues/issue-20939.stderr b/tests/ui/dyn-compatibility/dyn-compatible-trait-implementation-20939.stderr index 00357155c8a..196d8b6a880 100644 --- a/tests/ui/issues/issue-20939.stderr +++ b/tests/ui/dyn-compatibility/dyn-compatible-trait-implementation-20939.stderr @@ -1,5 +1,5 @@ error[E0371]: the object type `(dyn Foo + 'a)` automatically implements the trait `Foo` - --> $DIR/issue-20939.rs:3:1 + --> $DIR/dyn-compatible-trait-implementation-20939.rs:4:1 | LL | impl<'a> Foo for dyn Foo + 'a {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Foo + 'a)` automatically implements trait `Foo` diff --git a/tests/ui/explicit-tail-calls/higher-ranked-arg.rs b/tests/ui/explicit-tail-calls/higher-ranked-arg.rs new file mode 100644 index 00000000000..e60686ab511 --- /dev/null +++ b/tests/ui/explicit-tail-calls/higher-ranked-arg.rs @@ -0,0 +1,13 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/144826>. +//@ check-pass + +#![feature(explicit_tail_calls)] +#![expect(incomplete_features)] + +fn foo(x: fn(&i32)) { + become bar(x); +} + +fn bar(_: fn(&i32)) {} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/ret-ty-borrowck-constraints.rs b/tests/ui/explicit-tail-calls/ret-ty-borrowck-constraints.rs new file mode 100644 index 00000000000..111ae849c0f --- /dev/null +++ b/tests/ui/explicit-tail-calls/ret-ty-borrowck-constraints.rs @@ -0,0 +1,16 @@ +#![feature(explicit_tail_calls)] +#![expect(incomplete_features)] + +fn link(x: &str) -> &'static str { + become passthrough(x); + //~^ ERROR lifetime may not live long enough +} + +fn passthrough<T>(t: T) -> T { t } + +fn main() { + let x = String::from("hello, world"); + let s = link(&x); + drop(x); + println!("{s}"); +} diff --git a/tests/ui/explicit-tail-calls/ret-ty-borrowck-constraints.stderr b/tests/ui/explicit-tail-calls/ret-ty-borrowck-constraints.stderr new file mode 100644 index 00000000000..26a8e1f0122 --- /dev/null +++ b/tests/ui/explicit-tail-calls/ret-ty-borrowck-constraints.stderr @@ -0,0 +1,10 @@ +error: lifetime may not live long enough + --> $DIR/ret-ty-borrowck-constraints.rs:5:5 + | +LL | fn link(x: &str) -> &'static str { + | - let's call the lifetime of this reference `'1` +LL | become passthrough(x); + | ^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static` + +error: aborting due to 1 previous error + diff --git a/tests/ui/extern/extern-types-field-offset.run.stderr b/tests/ui/extern/extern-types-field-offset.run.stderr index 07bd4fcb13f..b096e8044a7 100644 --- a/tests/ui/extern/extern-types-field-offset.run.stderr +++ b/tests/ui/extern/extern-types-field-offset.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: attempted to compute the size or alignment of extern type `Opaque` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.align.run.stderr b/tests/ui/extern/extern-types-size_of_val.align.run.stderr index 5ba372d60fa..66206f37501 100644 --- a/tests/ui/extern/extern-types-size_of_val.align.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.align.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: attempted to compute the size or alignment of extern type `A` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/extern/extern-types-size_of_val.size.run.stderr b/tests/ui/extern/extern-types-size_of_val.size.run.stderr index 5ba372d60fa..66206f37501 100644 --- a/tests/ui/extern/extern-types-size_of_val.size.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.size.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: attempted to compute the size or alignment of extern type `A` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread caused non-unwinding panic. aborting. diff --git a/tests/ui/generic-associated-types/type-param-defaults.rs b/tests/ui/generic-associated-types/type-param-defaults.rs index eea54c46073..6e9a62b96c4 100644 --- a/tests/ui/generic-associated-types/type-param-defaults.rs +++ b/tests/ui/generic-associated-types/type-param-defaults.rs @@ -4,17 +4,17 @@ trait Trait { type Assoc<T = u32>; - //~^ ERROR defaults for type parameters are only allowed + //~^ ERROR defaults for generic parameters are not allowed here } impl Trait for () { type Assoc<T = u32> = u64; - //~^ ERROR defaults for type parameters are only allowed + //~^ ERROR defaults for generic parameters are not allowed here } impl Trait for u32 { type Assoc<T = u32> = T; - //~^ ERROR defaults for type parameters are only allowed + //~^ ERROR defaults for generic parameters are not allowed here } trait Other {} diff --git a/tests/ui/generic-associated-types/type-param-defaults.stderr b/tests/ui/generic-associated-types/type-param-defaults.stderr index 3c094d45fff..d9872dadbdb 100644 --- a/tests/ui/generic-associated-types/type-param-defaults.stderr +++ b/tests/ui/generic-associated-types/type-param-defaults.stderr @@ -1,16 +1,16 @@ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/type-param-defaults.rs:6:16 | LL | type Assoc<T = u32>; | ^^^^^^^ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/type-param-defaults.rs:11:16 | LL | type Assoc<T = u32> = u64; | ^^^^^^^ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/type-param-defaults.rs:16:16 | LL | type Assoc<T = u32> = T; diff --git a/tests/ui/generic-const-items/parameter-defaults.rs b/tests/ui/generic-const-items/parameter-defaults.rs index c933db17fa2..b52cb0fd002 100644 --- a/tests/ui/generic-const-items/parameter-defaults.rs +++ b/tests/ui/generic-const-items/parameter-defaults.rs @@ -7,9 +7,17 @@ // FIXME(default_type_parameter_fallback): Consider reallowing them once they work properly. -const NONE<T = ()>: Option<T> = None::<T>; //~ ERROR defaults for type parameters are only allowed +const NONE<T = ()>: Option<T> = None::<T>; +//~^ ERROR defaults for generic parameters are not allowed here -fn main() { - let _ = NONE; - //~^ ERROR type annotations needed +impl Host { + const NADA<T = ()>: Option<T> = None::<T>; + //~^ ERROR defaults for generic parameters are not allowed here } + +enum Host {} + +fn body0() { let _ = NONE; } //~ ERROR type annotations needed +fn body1() { let _ = Host::NADA; } //~ ERROR type annotations needed + +fn main() {} diff --git a/tests/ui/generic-const-items/parameter-defaults.stderr b/tests/ui/generic-const-items/parameter-defaults.stderr index 13562c98f6d..9bf1f6412f5 100644 --- a/tests/ui/generic-const-items/parameter-defaults.stderr +++ b/tests/ui/generic-const-items/parameter-defaults.stderr @@ -1,20 +1,37 @@ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/parameter-defaults.rs:10:12 | LL | const NONE<T = ()>: Option<T> = None::<T>; | ^^^^^^ +error: defaults for generic parameters are not allowed here + --> $DIR/parameter-defaults.rs:14:16 + | +LL | const NADA<T = ()>: Option<T> = None::<T>; + | ^^^^^^ + +error[E0282]: type annotations needed for `Option<_>` + --> $DIR/parameter-defaults.rs:20:18 + | +LL | fn body0() { let _ = NONE; } + | ^ ---- type must be known at this point + | +help: consider giving this pattern a type, where the type for type parameter `T` is specified + | +LL | fn body0() { let _: Option<T> = NONE; } + | +++++++++++ + error[E0282]: type annotations needed for `Option<_>` - --> $DIR/parameter-defaults.rs:13:9 + --> $DIR/parameter-defaults.rs:21:18 | -LL | let _ = NONE; - | ^ ---- type must be known at this point +LL | fn body1() { let _ = Host::NADA; } + | ^ ---------- type must be known at this point | help: consider giving this pattern a type, where the type for type parameter `T` is specified | -LL | let _: Option<T> = NONE; - | +++++++++++ +LL | fn body1() { let _: Option<T> = Host::NADA; } + | +++++++++++ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/generics/generic-extern.rs b/tests/ui/generics/generic-extern.rs index 36fa5eaafd6..b4f00fc1187 100644 --- a/tests/ui/generics/generic-extern.rs +++ b/tests/ui/generics/generic-extern.rs @@ -1,7 +1,15 @@ +// Ensure that we reject generic parameters on foreign items. + extern "C" { fn foo<T>(); //~ ERROR foreign items may not have type parameters + + // Furthermore, check that type parameter defaults lead to a *hard* error, + // not just a lint error, for maximum forward compatibility. + #[allow(invalid_type_param_default)] // Should have no effect here. + fn bar<T = ()>(); //~ ERROR foreign items may not have type parameters + //~^ ERROR defaults for generic parameters are not allowed here } fn main() { - foo::<i32>(); //~ ERROR requires unsafe + unsafe { foo::<i32>() }; } diff --git a/tests/ui/generics/generic-extern.stderr b/tests/ui/generics/generic-extern.stderr index a3f28825316..6e837156812 100644 --- a/tests/ui/generics/generic-extern.stderr +++ b/tests/ui/generics/generic-extern.stderr @@ -1,20 +1,25 @@ error[E0044]: foreign items may not have type parameters - --> $DIR/generic-extern.rs:2:5 + --> $DIR/generic-extern.rs:4:5 | LL | fn foo<T>(); | ^^^^^^^^^^^^ can't have type parameters | = help: replace the type parameters with concrete types like `u32` -error[E0133]: call to unsafe function `foo` is unsafe and requires unsafe function or block - --> $DIR/generic-extern.rs:6:5 +error: defaults for generic parameters are not allowed here + --> $DIR/generic-extern.rs:9:12 | -LL | foo::<i32>(); - | ^^^^^^^^^^^^ call to unsafe function +LL | fn bar<T = ()>(); + | ^^^^^^ + +error[E0044]: foreign items may not have type parameters + --> $DIR/generic-extern.rs:9:5 | - = note: consult the function's documentation for information on how to avoid undefined behavior +LL | fn bar<T = ()>(); + | ^^^^^^^^^^^^^^^^^ can't have type parameters + | + = help: replace the type parameters with concrete types like `u32` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0044, E0133. -For more information about an error, try `rustc --explain E0044`. +For more information about this error, try `rustc --explain E0044`. diff --git a/tests/ui/generics/invalid-type-param-default.rs b/tests/ui/generics/invalid-type-param-default.rs new file mode 100644 index 00000000000..b47e142605c --- /dev/null +++ b/tests/ui/generics/invalid-type-param-default.rs @@ -0,0 +1,22 @@ +// Ensure that we emit the deny-by-default lint `invalid_type_param_default` in locations where +// type parameter defaults were accidentally allowed but don't have any effect whatsoever. +// +// Tracked in <https://github.com/rust-lang/rust/issues/36887>. +// FIXME(default_type_parameter_fallback): Consider reallowing them once they work properly. + +fn avg<T = i32>(_: T) {} +//~^ ERROR defaults for generic parameters are not allowed here [invalid_type_param_default] +//~| WARN this was previously accepted + +// issue: <https://github.com/rust-lang/rust/issues/26812> +fn mdn<T = T::Item>(_: T) {} +//~^ ERROR generic parameter defaults cannot reference parameters before they are declared +//~| ERROR defaults for generic parameters are not allowed here [invalid_type_param_default] +//~| WARN this was previously accepted + +struct S<T>(T); +impl<T = i32> S<T> {} +//~^ ERROR defaults for generic parameters are not allowed here [invalid_type_param_default] +//~| WARN this was previously accepted + +fn main() {} diff --git a/tests/ui/generics/invalid-type-param-default.stderr b/tests/ui/generics/invalid-type-param-default.stderr new file mode 100644 index 00000000000..1c8fdd8ab5c --- /dev/null +++ b/tests/ui/generics/invalid-type-param-default.stderr @@ -0,0 +1,70 @@ +error[E0128]: generic parameter defaults cannot reference parameters before they are declared + --> $DIR/invalid-type-param-default.rs:12:12 + | +LL | fn mdn<T = T::Item>(_: T) {} + | ^^^^^^^ cannot reference `T` before it is declared + +error: defaults for generic parameters are not allowed here + --> $DIR/invalid-type-param-default.rs:7:8 + | +LL | fn avg<T = i32>(_: T) {} + | ^^^^^^^ + | + = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +error: defaults for generic parameters are not allowed here + --> $DIR/invalid-type-param-default.rs:12:8 + | +LL | fn mdn<T = T::Item>(_: T) {} + | ^^^^^^^^^^^ + | + = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> + +error: defaults for generic parameters are not allowed here + --> $DIR/invalid-type-param-default.rs:18:6 + | +LL | impl<T = i32> S<T> {} + | ^^^^^^^ + | + = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0128`. +Future incompatibility report: Future breakage diagnostic: +error: defaults for generic parameters are not allowed here + --> $DIR/invalid-type-param-default.rs:7:8 + | +LL | fn avg<T = i32>(_: T) {} + | ^^^^^^^ + | + = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +Future breakage diagnostic: +error: defaults for generic parameters are not allowed here + --> $DIR/invalid-type-param-default.rs:12:8 + | +LL | fn mdn<T = T::Item>(_: T) {} + | ^^^^^^^^^^^ + | + = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + +Future breakage diagnostic: +error: defaults for generic parameters are not allowed here + --> $DIR/invalid-type-param-default.rs:18:6 + | +LL | impl<T = i32> S<T> {} + | ^^^^^^^ + | + = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> + = note: `#[deny(invalid_type_param_default)]` on by default + diff --git a/tests/ui/generics/overlapping-errors-span-issue-123861.rs b/tests/ui/generics/overlapping-errors-span-issue-123861.rs index e0a27f68748..2549f4b3714 100644 --- a/tests/ui/generics/overlapping-errors-span-issue-123861.rs +++ b/tests/ui/generics/overlapping-errors-span-issue-123861.rs @@ -1,7 +1,7 @@ fn mainIterator<_ = _> {} //~^ ERROR expected identifier, found reserved identifier `_` //~| ERROR missing parameters for function definition -//~| ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions [invalid_type_param_default] +//~| ERROR defaults for generic parameters are not allowed here [invalid_type_param_default] //~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! //~| ERROR the placeholder `_` is not allowed within types on item signatures for functions [E0121] diff --git a/tests/ui/generics/overlapping-errors-span-issue-123861.stderr b/tests/ui/generics/overlapping-errors-span-issue-123861.stderr index 7d08d8fed9f..44e8b4a01e7 100644 --- a/tests/ui/generics/overlapping-errors-span-issue-123861.stderr +++ b/tests/ui/generics/overlapping-errors-span-issue-123861.stderr @@ -15,7 +15,7 @@ help: add a parameter list LL | fn mainIterator<_ = _>() {} | ++ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/overlapping-errors-span-issue-123861.rs:1:17 | LL | fn mainIterator<_ = _> {} @@ -35,7 +35,7 @@ error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0121`. Future incompatibility report: Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/overlapping-errors-span-issue-123861.rs:1:17 | LL | fn mainIterator<_ = _> {} diff --git a/tests/ui/issues/issue-36075.rs b/tests/ui/generics/unused-type-parameter-regression-36075.rs index a563332ad78..4d6eb617b59 100644 --- a/tests/ui/issues/issue-36075.rs +++ b/tests/ui/generics/unused-type-parameter-regression-36075.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/36075 //@ check-pass #![allow(dead_code)] trait DeclarationParser { diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index 5cd07dcda4c..d28ab864183 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/panic-location.rs:LL:CC: +thread 'main' ($TID) panicked at $DIR/panic-location.rs:LL:CC: capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs index 1c3c66c537f..04a95f7f6f0 100644 --- a/tests/ui/impl-trait/where-allowed.rs +++ b/tests/ui/impl-trait/where-allowed.rs @@ -236,17 +236,15 @@ type InTypeAliasGenericParamDefault<T = impl Debug> = T; //~^ ERROR `impl Trait` is not allowed in generic parameter defaults // Disallowed -impl <T = impl Debug> T {} -//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions -//~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` is not allowed in generic parameter defaults +#[expect(invalid_type_param_default)] +impl<T = impl Debug> T {} +//~^ ERROR `impl Trait` is not allowed in generic parameter defaults //~| ERROR no nominal type found // Disallowed +#[expect(invalid_type_param_default)] fn in_method_generic_param_default<T = impl Debug>(_: T) {} -//~^ ERROR defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions -//~| WARNING this was previously accepted by the compiler but is being phased out -//~| ERROR `impl Trait` is not allowed in generic parameter defaults +//~^ ERROR `impl Trait` is not allowed in generic parameter defaults fn main() { let _in_local_variable: impl Fn() = || {}; diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index 052ae5a9931..08caff326c4 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -311,10 +311,10 @@ LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in generic parameter defaults - --> $DIR/where-allowed.rs:239:11 + --> $DIR/where-allowed.rs:240:10 | -LL | impl <T = impl Debug> T {} - | ^^^^^^^^^^ +LL | impl<T = impl Debug> T {} + | ^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods @@ -327,7 +327,7 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/where-allowed.rs:252:29 + --> $DIR/where-allowed.rs:250:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ @@ -338,7 +338,7 @@ LL | let _in_local_variable: impl Fn() = || {}; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in closure return types - --> $DIR/where-allowed.rs:254:46 + --> $DIR/where-allowed.rs:252:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ @@ -368,25 +368,6 @@ LL - fn in_trait_impl_return() -> impl Debug { () } LL + fn in_trait_impl_return() -> <() as DummyTrait>::Out { () } | -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:246:36 - | -LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} - | ^^^^^^^^^^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:239:7 - | -LL | impl <T = impl Debug> T {} - | ^^^^^^^^^^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - error[E0283]: type annotations needed --> $DIR/where-allowed.rs:46:57 | @@ -408,10 +389,10 @@ LL | fn in_impl_Fn_return_in_return() -> &'static impl Fn() -> impl Debug { pani where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized; error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:239:1 + --> $DIR/where-allowed.rs:240:1 | -LL | impl <T = impl Debug> T {} - | ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type +LL | impl<T = impl Debug> T {} + | ^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type | = note: either implement a trait on it or create a newtype to wrap it instead @@ -431,29 +412,21 @@ LL | type InTypeAlias<R> = impl Debug; | = note: `InTypeAlias` must be used in combination with a concrete type within the same crate -error: aborting due to 50 previous errors +error: aborting due to 48 previous errors Some errors have detailed explanations: E0053, E0118, E0283, E0562, E0658, E0666. For more information about an error, try `rustc --explain E0053`. Future incompatibility report: Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +warning: defaults for generic parameters are not allowed here --> $DIR/where-allowed.rs:246:36 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:239:7 - | -LL | impl <T = impl Debug> T {} - | ^^^^^^^^^^^^^^ +warning: defaults for generic parameters are not allowed here + --> $DIR/where-allowed.rs:240:6 | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default +LL | impl<T = impl Debug> T {} + | ^^^^^^^^^^^^^^ diff --git a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr index 71d792b7f77..397eeaf600a 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace-std.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/const-eval-select-backtrace-std.rs:6:8: +thread 'main' ($TID) panicked at $DIR/const-eval-select-backtrace-std.rs:6:8: byte index 1 is out of bounds of `` note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr b/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr index 4f11f5966ed..649174017e9 100644 --- a/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr +++ b/tests/ui/intrinsics/const-eval-select-backtrace.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/const-eval-select-backtrace.rs:15:5: +thread 'main' ($TID) panicked at $DIR/const-eval-select-backtrace.rs:15:5: Aaah! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/intrinsics/not-overridden.rs b/tests/ui/intrinsics/not-overridden.rs index 2359eee8b26..ce855483527 100644 --- a/tests/ui/intrinsics/not-overridden.rs +++ b/tests/ui/intrinsics/not-overridden.rs @@ -4,7 +4,7 @@ //@ build-fail //@ failure-status:101 //@ normalize-stderr: ".*note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*:\n.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ normalize-stderr: "internal compiler error:.*: intrinsic const_deallocate " -> "" //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/issues/issue-26812.rs b/tests/ui/issues/issue-26812.rs deleted file mode 100644 index 8eb030a8ec9..00000000000 --- a/tests/ui/issues/issue-26812.rs +++ /dev/null @@ -1,6 +0,0 @@ -fn avg<T=T::Item>(_: T) {} -//~^ ERROR generic parameter defaults cannot reference parameters before they are declared -//~| ERROR defaults for type parameters -//~| WARN previously accepted - -fn main() {} diff --git a/tests/ui/issues/issue-26812.stderr b/tests/ui/issues/issue-26812.stderr deleted file mode 100644 index bb60d67e287..00000000000 --- a/tests/ui/issues/issue-26812.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0128]: generic parameter defaults cannot reference parameters before they are declared - --> $DIR/issue-26812.rs:1:10 - | -LL | fn avg<T=T::Item>(_: T) {} - | ^^^^^^^ cannot reference `T` before it is declared - -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/issue-26812.rs:1:8 - | -LL | fn avg<T=T::Item>(_: T) {} - | ^^^^^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0128`. -Future incompatibility report: Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/issue-26812.rs:1:8 - | -LL | fn avg<T=T::Item>(_: T) {} - | ^^^^^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - diff --git a/tests/ui/issues/issue-87707.run.stderr b/tests/ui/issues/issue-87707.run.stderr index eb1d65a081f..8485c0578b8 100644 --- a/tests/ui/issues/issue-87707.run.stderr +++ b/tests/ui/issues/issue-87707.run.stderr @@ -1,7 +1,7 @@ -thread 'main' panicked at $DIR/issue-87707.rs:14:24: +thread 'main' ($TID) panicked at $DIR/issue-87707.rs:14:24: Here Once instance is poisoned. note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/issue-87707.rs:16:7: +thread 'main' ($TID) panicked at $DIR/issue-87707.rs:16:7: Once instance has previously been poisoned diff --git a/tests/ui/issues/issue-9188.rs b/tests/ui/issues/issue-9188.rs deleted file mode 100644 index df2f90a0f16..00000000000 --- a/tests/ui/issues/issue-9188.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass -//@ aux-build:issue-9188.rs - - -extern crate issue_9188; - -pub fn main() { - let a = issue_9188::bar(); - let b = issue_9188::foo::<isize>(); - assert_eq!(*a, *b); -} diff --git a/tests/ui/issues/issue-23966.rs b/tests/ui/iterators/fold-iterator-error-23966.rs index 5fdec28ac2c..970c943da0b 100644 --- a/tests/ui/issues/issue-23966.rs +++ b/tests/ui/iterators/fold-iterator-error-23966.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/23966 fn main() { "".chars().fold(|_, _| (), ()); //~^ ERROR E0277 diff --git a/tests/ui/issues/issue-23966.stderr b/tests/ui/iterators/fold-iterator-error-23966.stderr index 3f7a4fa312f..15249a93597 100644 --- a/tests/ui/issues/issue-23966.stderr +++ b/tests/ui/iterators/fold-iterator-error-23966.stderr @@ -1,5 +1,5 @@ error[E0277]: expected a `FnMut(_, char)` closure, found `()` - --> $DIR/issue-23966.rs:2:32 + --> $DIR/fold-iterator-error-23966.rs:3:32 | LL | "".chars().fold(|_, _| (), ()); | ---- ^^ expected an `FnMut(_, char)` closure, found `()` diff --git a/tests/ui/layout/valid_range_oob.rs b/tests/ui/layout/valid_range_oob.rs index df816e74066..8ae9f6e9726 100644 --- a/tests/ui/layout/valid_range_oob.rs +++ b/tests/ui/layout/valid_range_oob.rs @@ -1,6 +1,6 @@ //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![feature(rustc_attrs)] diff --git a/tests/ui/issues/issue-15735.rs b/tests/ui/lifetimes/lifetime-inference-miss-15735.rs index f5b3803f155..c75d59a2f4b 100644 --- a/tests/ui/issues/issue-15735.rs +++ b/tests/ui/lifetimes/lifetime-inference-miss-15735.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/15735 //@ check-pass #![allow(dead_code)] struct A<'a> { diff --git a/tests/ui/lifetimes/unusual-rib-combinations.rs b/tests/ui/lifetimes/unusual-rib-combinations.rs index 0e92b41ae1e..b3e9642332b 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.rs +++ b/tests/ui/lifetimes/unusual-rib-combinations.rs @@ -14,7 +14,7 @@ fn b<const C: u8()>() {} // Paren generic args in AnonymousReportError fn c<T = u8()>() {} //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait -//~| ERROR defaults for type parameters are only allowed in +//~| ERROR defaults for generic parameters are not allowed here //~| WARN this was previously accepted // Elided lifetime in path in ConstGeneric diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index 7373ca8cf84..bd68479c58c 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -22,7 +22,7 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait LL | fn c<T = u8()>() {} | ^^^^ only `Fn` traits may use parentheses -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/unusual-rib-combinations.rs:15:6 | LL | fn c<T = u8()>() {} @@ -43,7 +43,7 @@ error: aborting due to 6 previous errors Some errors have detailed explanations: E0106, E0214, E0308, E0770. For more information about an error, try `rustc --explain E0106`. Future incompatibility report: Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/unusual-rib-combinations.rs:15:6 | LL | fn c<T = u8()>() {} diff --git a/tests/ui/issues/issue-75704.rs b/tests/ui/loops/infinite-loop-simplify-cfg-75704.rs index 1672bf0b4c3..8bc5fba7a68 100644 --- a/tests/ui/issues/issue-75704.rs +++ b/tests/ui/loops/infinite-loop-simplify-cfg-75704.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/75704 // Caused an infinite loop during SimlifyCfg MIR transform previously. // //@ build-pass diff --git a/tests/ui/macros/assert-long-condition.run.stderr b/tests/ui/macros/assert-long-condition.run.stderr index c2c5fe5d7d5..a9fac037143 100644 --- a/tests/ui/macros/assert-long-condition.run.stderr +++ b/tests/ui/macros/assert-long-condition.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/assert-long-condition.rs:7:5: +thread 'main' ($TID) panicked at $DIR/assert-long-condition.rs:7:5: assertion failed: 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 == 0 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/issues/issue-19100.fixed b/tests/ui/match/unreachable-pattern-if-variant-not-imported-19100.fixed index 1162490048c..40c92322519 100644 --- a/tests/ui/issues/issue-19100.fixed +++ b/tests/ui/match/unreachable-pattern-if-variant-not-imported-19100.fixed @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/19100 //@ run-rustfix #![allow(non_snake_case)] diff --git a/tests/ui/issues/issue-19100.rs b/tests/ui/match/unreachable-pattern-if-variant-not-imported-19100.rs index fefed0daa72..9ef6fd77b50 100644 --- a/tests/ui/issues/issue-19100.rs +++ b/tests/ui/match/unreachable-pattern-if-variant-not-imported-19100.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/19100 //@ run-rustfix #![allow(non_snake_case)] diff --git a/tests/ui/issues/issue-19100.stderr b/tests/ui/match/unreachable-pattern-if-variant-not-imported-19100.stderr index ebbf083b7de..7356a4a003b 100644 --- a/tests/ui/issues/issue-19100.stderr +++ b/tests/ui/match/unreachable-pattern-if-variant-not-imported-19100.stderr @@ -1,5 +1,5 @@ error[E0170]: pattern binding `Bar` is named the same as one of the variants of the type `Foo` - --> $DIR/issue-19100.rs:17:1 + --> $DIR/unreachable-pattern-if-variant-not-imported-19100.rs:18:1 | LL | Bar if true | ^^^ help: to match on the variant, qualify the path: `Foo::Bar` @@ -7,7 +7,7 @@ LL | Bar if true = note: `#[deny(bindings_with_variant_name)]` on by default error[E0170]: pattern binding `Baz` is named the same as one of the variants of the type `Foo` - --> $DIR/issue-19100.rs:21:1 + --> $DIR/unreachable-pattern-if-variant-not-imported-19100.rs:22:1 | LL | Baz if false | ^^^ help: to match on the variant, qualify the path: `Foo::Baz` diff --git a/tests/ui/methods/issues/issue-105732.stderr b/tests/ui/methods/issues/issue-105732.stderr index 6244f983550..93ce695f27b 100644 --- a/tests/ui/methods/issues/issue-105732.stderr +++ b/tests/ui/methods/issues/issue-105732.stderr @@ -4,7 +4,7 @@ error[E0380]: auto traits cannot have associated items LL | auto trait Foo { | --- auto traits cannot have associated items LL | fn g(&self); - | ---^-------- help: remove these associated items + | ^ error[E0599]: no method named `g` found for reference `&Self` in the current scope --> $DIR/issue-105732.rs:10:14 diff --git a/tests/ui/issues/issue-22684.rs b/tests/ui/methods/trait-method-resolution-over-inherent-22684.rs index a5b042706ed..9f317b576e6 100644 --- a/tests/ui/issues/issue-22684.rs +++ b/tests/ui/methods/trait-method-resolution-over-inherent-22684.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/22684 mod foo { pub struct Foo; impl Foo { diff --git a/tests/ui/issues/issue-22684.stderr b/tests/ui/methods/trait-method-resolution-over-inherent-22684.stderr index e2ca54caeac..0ab7701fa9e 100644 --- a/tests/ui/issues/issue-22684.stderr +++ b/tests/ui/methods/trait-method-resolution-over-inherent-22684.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-22684.rs:17:17 + --> $DIR/trait-method-resolution-over-inherent-22684.rs:18:17 | LL | let _: () = foo::Foo.bar(); | -- ^^^^^^^^^^^^^^ expected `()`, found `bool` diff --git a/tests/ui/mir/lint/storage-live.rs b/tests/ui/mir/lint/storage-live.rs index 252e3b8456c..32bd32754dd 100644 --- a/tests/ui/mir/lint/storage-live.rs +++ b/tests/ui/mir/lint/storage-live.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Zlint-mir -Ztreat-err-as-bug //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "storage_live\[....\]" -> "storage_live[HASH]" //@ normalize-stderr: "(delayed at [^:]+):\d+:\d+ - " -> "$1:LL:CC - " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/issues/issue-24352.rs b/tests/ui/mismatched_types/float-integer-subtraction-error-24352.rs index 5c8246d179f..eb632398c62 100644 --- a/tests/ui/issues/issue-24352.rs +++ b/tests/ui/mismatched_types/float-integer-subtraction-error-24352.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/24352 fn main() { 1.0f64 - 1.0; 1.0f64 - 1 //~ ERROR E0277 diff --git a/tests/ui/issues/issue-24352.stderr b/tests/ui/mismatched_types/float-integer-subtraction-error-24352.stderr index 3e0f812b5c7..7dc1fa777fc 100644 --- a/tests/ui/issues/issue-24352.stderr +++ b/tests/ui/mismatched_types/float-integer-subtraction-error-24352.stderr @@ -1,5 +1,5 @@ error[E0277]: cannot subtract `{integer}` from `f64` - --> $DIR/issue-24352.rs:3:12 + --> $DIR/float-integer-subtraction-error-24352.rs:4:12 | LL | 1.0f64 - 1 | ^ no implementation for `f64 - {integer}` diff --git a/tests/ui/issues/issue-50585.rs b/tests/ui/mismatched_types/for-loop-in-vec-type-mismatchrs-50585.rs index ca2ece8d53b..4abef0bee81 100644 --- a/tests/ui/issues/issue-50585.rs +++ b/tests/ui/mismatched_types/for-loop-in-vec-type-mismatchrs-50585.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/50585 fn main() { |y: Vec<[(); for x in 0..2 {}]>| {}; //~^ ERROR mismatched types diff --git a/tests/ui/issues/issue-50585.stderr b/tests/ui/mismatched_types/for-loop-in-vec-type-mismatchrs-50585.stderr index 7e83ea35fbb..d60d97a02ab 100644 --- a/tests/ui/issues/issue-50585.stderr +++ b/tests/ui/mismatched_types/for-loop-in-vec-type-mismatchrs-50585.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-50585.rs:2:18 + --> $DIR/for-loop-in-vec-type-mismatchrs-50585.rs:3:18 | LL | |y: Vec<[(); for x in 0..2 {}]>| {}; | ^^^^^^^^^^^^^^^^ expected `usize`, found `()` diff --git a/tests/ui/issues/issue-48364.rs b/tests/ui/mismatched_types/starts-with-stringify-type-mismatch-48364.rs index 14ee75e7c9c..13ba8b1e59c 100644 --- a/tests/ui/issues/issue-48364.rs +++ b/tests/ui/mismatched_types/starts-with-stringify-type-mismatch-48364.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/48364 fn foo() -> bool { b"".starts_with(stringify!(foo)) //~^ ERROR mismatched types diff --git a/tests/ui/issues/issue-48364.stderr b/tests/ui/mismatched_types/starts-with-stringify-type-mismatch-48364.stderr index 74bfa1e0693..bb767d50bb0 100644 --- a/tests/ui/issues/issue-48364.stderr +++ b/tests/ui/mismatched_types/starts-with-stringify-type-mismatch-48364.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-48364.rs:2:21 + --> $DIR/starts-with-stringify-type-mismatch-48364.rs:3:21 | LL | b"".starts_with(stringify!(foo)) | ----------- ^^^^^^^^^^^^^^^ expected `&[u8]`, found `&str` diff --git a/tests/ui/missing/missing-items/missing-type-parameter2.rs b/tests/ui/missing/missing-items/missing-type-parameter2.rs index e9b32fb7198..772e60b1376 100644 --- a/tests/ui/missing/missing-items/missing-type-parameter2.rs +++ b/tests/ui/missing/missing-items/missing-type-parameter2.rs @@ -5,7 +5,7 @@ impl X<N> {} //~| ERROR unresolved item provided when a constant was expected impl<T, const A: u8 = 2> X<N> {} //~^ ERROR cannot find type `N` in this scope -//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +//~| ERROR defaults for generic parameters are not allowed here //~| ERROR unresolved item provided when a constant was expected fn foo(_: T) where T: Send {} diff --git a/tests/ui/missing/missing-items/missing-type-parameter2.stderr b/tests/ui/missing/missing-items/missing-type-parameter2.stderr index f6418de20b6..3c132e769ea 100644 --- a/tests/ui/missing/missing-items/missing-type-parameter2.stderr +++ b/tests/ui/missing/missing-items/missing-type-parameter2.stderr @@ -103,7 +103,7 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | impl X<{ N }> {} | + + -error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/missing-type-parameter2.rs:6:9 | LL | impl<T, const A: u8 = 2> X<N> {} diff --git a/tests/ui/issues/issue-32797.rs b/tests/ui/modules/circular-module-imports-32797.rs index 470d661cb28..5a2f2990795 100644 --- a/tests/ui/issues/issue-32797.rs +++ b/tests/ui/modules/circular-module-imports-32797.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/32797 //@ check-pass pub use bar::*; diff --git a/tests/ui/issues/issue-17385.rs b/tests/ui/moves/matching-partially-moved-value-17385.rs index 7400aadb059..c50fe048bfb 100644 --- a/tests/ui/issues/issue-17385.rs +++ b/tests/ui/moves/matching-partially-moved-value-17385.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/17385 struct X(isize); enum Enum { diff --git a/tests/ui/issues/issue-17385.stderr b/tests/ui/moves/matching-partially-moved-value-17385.stderr index 3c451a859e9..906f7868bcc 100644 --- a/tests/ui/issues/issue-17385.stderr +++ b/tests/ui/moves/matching-partially-moved-value-17385.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `foo` - --> $DIR/issue-17385.rs:18:5 + --> $DIR/matching-partially-moved-value-17385.rs:19:5 | LL | let foo = X(1); | --- move occurs because `foo` has type `X`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | match foo { | ^^^^^^^^^ value used here after move | note: if `X` implemented `Clone`, you could clone the value - --> $DIR/issue-17385.rs:1:1 + --> $DIR/matching-partially-moved-value-17385.rs:2:1 | LL | struct X(isize); | ^^^^^^^^ consider implementing `Clone` for this type @@ -18,7 +18,7 @@ LL | drop(foo); | --- you could clone this value error[E0382]: use of moved value: `e` - --> $DIR/issue-17385.rs:25:11 + --> $DIR/matching-partially-moved-value-17385.rs:26:11 | LL | let e = Enum::Variant2; | - move occurs because `e` has type `Enum`, which does not implement the `Copy` trait @@ -28,7 +28,7 @@ LL | match e { | ^ value used here after move | note: if `Enum` implemented `Clone`, you could clone the value - --> $DIR/issue-17385.rs:3:1 + --> $DIR/matching-partially-moved-value-17385.rs:4:1 | LL | enum Enum { | ^^^^^^^^^ consider implementing `Clone` for this type diff --git a/tests/ui/nll/issue-51345-2.rs b/tests/ui/nll/issue-51345-2.rs index 39871d56a9a..6c424d436f1 100644 --- a/tests/ui/nll/issue-51345-2.rs +++ b/tests/ui/nll/issue-51345-2.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:explicit panic +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: explicit panic //@ needs-subprocess fn main() { diff --git a/tests/ui/issues/issue-32805.rs b/tests/ui/numbers-arithmetic/f32-literal-rounding-32805.rs index 717c00a248a..59efdb9a1aa 100644 --- a/tests/ui/issues/issue-32805.rs +++ b/tests/ui/numbers-arithmetic/f32-literal-rounding-32805.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/32805 //@ run-pass fn const_mir() -> f32 { 9007199791611905.0 } diff --git a/tests/ui/numbers-arithmetic/overflowing-add.rs b/tests/ui/numbers-arithmetic/overflowing-add.rs index c1f498c802b..a63fc3bccf1 100644 --- a/tests/ui/numbers-arithmetic/overflowing-add.rs +++ b/tests/ui/numbers-arithmetic/overflowing-add.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to add with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to add with overflow //@ compile-flags: -C debug-assertions //@ needs-subprocess diff --git a/tests/ui/numbers-arithmetic/overflowing-mul.rs b/tests/ui/numbers-arithmetic/overflowing-mul.rs index 0eece536929..2645a32d5ad 100644 --- a/tests/ui/numbers-arithmetic/overflowing-mul.rs +++ b/tests/ui/numbers-arithmetic/overflowing-mul.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to multiply with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to multiply with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs b/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs index 28deb7cf6ba..6db6682e16f 100644 --- a/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs +++ b/tests/ui/numbers-arithmetic/overflowing-pow-signed.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to multiply with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to multiply with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs b/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs index dea9a4d5428..bde0de6f6f5 100644 --- a/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs +++ b/tests/ui/numbers-arithmetic/overflowing-pow-unsigned.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to multiply with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to multiply with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/numbers-arithmetic/overflowing-sub.rs b/tests/ui/numbers-arithmetic/overflowing-sub.rs index 88b1b693f63..1718fccad7a 100644 --- a/tests/ui/numbers-arithmetic/overflowing-sub.rs +++ b/tests/ui/numbers-arithmetic/overflowing-sub.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:attempt to subtract with overflow +//@ regex-error-pattern: thread 'main'.*panicked +//@ error-pattern: attempt to subtract with overflow //@ needs-subprocess //@ compile-flags: -C debug-assertions diff --git a/tests/ui/panics/fmt-only-once.run.stderr b/tests/ui/panics/fmt-only-once.run.stderr index faa3cc91151..f0124e4cb77 100644 --- a/tests/ui/panics/fmt-only-once.run.stderr +++ b/tests/ui/panics/fmt-only-once.run.stderr @@ -1,5 +1,5 @@ fmt -thread 'main' panicked at $DIR/fmt-only-once.rs:20:5: +thread 'main' ($TID) panicked at $DIR/fmt-only-once.rs:20:5: PrintOnFmt note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/issue-47429-short-backtraces.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.run.stderr index 32dc6592271..13b59a7c7af 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.run.stderr +++ b/tests/ui/panics/issue-47429-short-backtraces.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:24:5: +thread 'main' ($TID) panicked at $DIR/issue-47429-short-backtraces.rs:24:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/location-detail-panic-no-column.run.stderr b/tests/ui/panics/location-detail-panic-no-column.run.stderr index f63c09652b8..8f43936a0af 100644 --- a/tests/ui/panics/location-detail-panic-no-column.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-column.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/location-detail-panic-no-column.rs:7:0: +thread 'main' ($TID) panicked at $DIR/location-detail-panic-no-column.rs:7:0: column-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-file.run.stderr b/tests/ui/panics/location-detail-panic-no-file.run.stderr index 3d1c6defa31..8d0ee148006 100644 --- a/tests/ui/panics/location-detail-panic-no-file.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-file.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at <redacted>:7:5: +thread 'main' ($TID) panicked at <redacted>:7:5: file-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-line.run.stderr b/tests/ui/panics/location-detail-panic-no-line.run.stderr index 9809ab5e2b4..79f5c012b8a 100644 --- a/tests/ui/panics/location-detail-panic-no-line.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-line.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/location-detail-panic-no-line.rs:0:5: +thread 'main' ($TID) panicked at $DIR/location-detail-panic-no-line.rs:0:5: line-redacted note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-panic-no-location-info.run.stderr b/tests/ui/panics/location-detail-panic-no-location-info.run.stderr index f68a0d663c0..12b3e1b53e3 100644 --- a/tests/ui/panics/location-detail-panic-no-location-info.run.stderr +++ b/tests/ui/panics/location-detail-panic-no-location-info.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at <redacted>:0:0: +thread 'main' ($TID) panicked at <redacted>:0:0: no location info note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/location-detail-unwrap-no-file.run.stderr b/tests/ui/panics/location-detail-unwrap-no-file.run.stderr index af4a4997fae..a4a87423cdc 100644 --- a/tests/ui/panics/location-detail-unwrap-no-file.run.stderr +++ b/tests/ui/panics/location-detail-unwrap-no-file.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at <redacted>:8:9: +thread 'main' ($TID) panicked at <redacted>:8:9: called `Option::unwrap()` on a `None` value note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/panics/main-panic.rs b/tests/ui/panics/main-panic.rs index 0b3d5c3aaec..9f2a92da90f 100644 --- a/tests/ui/panics/main-panic.rs +++ b/tests/ui/panics/main-panic.rs @@ -1,5 +1,5 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked at +//@ regex-error-pattern: thread 'main' \(\d+\) panicked at //@ needs-subprocess fn main() { diff --git a/tests/ui/panics/panic-in-cleanup.run.stderr b/tests/ui/panics/panic-in-cleanup.run.stderr index 34383562c36..bfe3dc8c9d7 100644 --- a/tests/ui/panics/panic-in-cleanup.run.stderr +++ b/tests/ui/panics/panic-in-cleanup.run.stderr @@ -1,12 +1,12 @@ -thread 'main' panicked at $DIR/panic-in-cleanup.rs:22:5: +thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:22:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/panic-in-cleanup.rs:16:9: +thread 'main' ($TID) panicked at $DIR/panic-in-cleanup.rs:16:9: BOOM stack backtrace: -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: panic in a destructor during cleanup thread caused non-unwinding panic. aborting. diff --git a/tests/ui/panics/panic-in-ffi.run.stderr b/tests/ui/panics/panic-in-ffi.run.stderr index a6f3ebe5657..ce907d64358 100644 --- a/tests/ui/panics/panic-in-ffi.run.stderr +++ b/tests/ui/panics/panic-in-ffi.run.stderr @@ -1,10 +1,10 @@ -thread 'main' panicked at $DIR/panic-in-ffi.rs:21:5: +thread 'main' ($TID) panicked at $DIR/panic-in-ffi.rs:21:5: Test note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Noisy Drop -thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL: +thread 'main' ($TID) panicked at library/core/src/panicking.rs:$LINE:$COL: panic in a function that cannot unwind stack backtrace: thread caused non-unwinding panic. aborting. diff --git a/tests/ui/panics/panic-set-unset-handler.rs b/tests/ui/panics/panic-set-unset-handler.rs index 66d5003d0f1..4f646020037 100644 --- a/tests/ui/panics/panic-set-unset-handler.rs +++ b/tests/ui/panics/panic-set-unset-handler.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:foobar +//@ regex-error-pattern: thread 'main' \(\d+\) panicked +//@ error-pattern: foobar //@ needs-subprocess use std::panic; diff --git a/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr b/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr index 799a8b30e99..c3c1ce16a4b 100644 --- a/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr +++ b/tests/ui/panics/panic-short-backtrace-windows-x86_64.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'd was called', $DIR/panic-short-backtrace-windows-x86_64.rs:48:5 +thread 'main' ($TID) panicked at 'd was called', $DIR/panic-short-backtrace-windows-x86_64.rs:48:5 stack backtrace: 0: std::panicking::begin_panic 1: d diff --git a/tests/ui/panics/panic-take-handler-nop.rs b/tests/ui/panics/panic-take-handler-nop.rs index f10582872df..ebea3ef0685 100644 --- a/tests/ui/panics/panic-take-handler-nop.rs +++ b/tests/ui/panics/panic-take-handler-nop.rs @@ -1,6 +1,6 @@ //@ run-fail -//@ error-pattern:thread 'main' panicked -//@ error-pattern:foobar +//@ regex-error-pattern: thread 'main' \(\d+\) panicked +//@ error-pattern: foobar //@ needs-subprocess use std::panic; diff --git a/tests/ui/panics/panic-task-name-none.rs b/tests/ui/panics/panic-task-name-none.rs index 8695771ff5e..4471cd6795c 100644 --- a/tests/ui/panics/panic-task-name-none.rs +++ b/tests/ui/panics/panic-task-name-none.rs @@ -1,14 +1,14 @@ //@ run-fail -//@ error-pattern:thread '<unnamed>' panicked -//@ error-pattern:test +//@ regex-error-pattern: thread '<unnamed>' \(\d+\) panicked +//@ error-pattern: test //@ needs-threads use std::thread; fn main() { let r: Result<(), _> = thread::spawn(move || { - panic!("test"); - }) - .join(); + panic!("test"); + }) + .join(); assert!(r.is_ok()); } diff --git a/tests/ui/panics/panic-task-name-owned.rs b/tests/ui/panics/panic-task-name-owned.rs index 42ae33b5d35..084ac90512a 100644 --- a/tests/ui/panics/panic-task-name-owned.rs +++ b/tests/ui/panics/panic-task-name-owned.rs @@ -1,19 +1,19 @@ //@ run-fail -//@ error-pattern:thread 'owned name' panicked -//@ error-pattern:test +//@ regex-error-pattern: thread 'owned name' \(\d+\) panicked +//@ error-pattern: test //@ needs-threads use std::thread::Builder; fn main() { let r: () = Builder::new() - .name("owned name".to_string()) - .spawn(move || { - panic!("test"); - () - }) - .unwrap() - .join() - .unwrap(); + .name("owned name".to_string()) + .spawn(move || { + panic!("test"); + () + }) + .unwrap() + .join() + .unwrap(); panic!(); } diff --git a/tests/ui/panics/runtime-switch.run.stderr b/tests/ui/panics/runtime-switch.run.stderr index 70ed127af86..f3f60445952 100644 --- a/tests/ui/panics/runtime-switch.run.stderr +++ b/tests/ui/panics/runtime-switch.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/runtime-switch.rs:28:5: +thread 'main' ($TID) panicked at $DIR/runtime-switch.rs:28:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr index 664d51e185d..584b477f3a7 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:62:5: +thread 'main' ($TID) panicked at $DIR/short-ice-remove-middle-frames-2.rs:62:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr index e966462331f..1efcb7d5304 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:58:5: +thread 'main' ($TID) panicked at $DIR/short-ice-remove-middle-frames.rs:58:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/parser/attribute-on-empty.rs b/tests/ui/parser/attribute-on-empty.rs new file mode 100644 index 00000000000..5932377f73e --- /dev/null +++ b/tests/ui/parser/attribute-on-empty.rs @@ -0,0 +1,29 @@ +//! Regression test for: <https://github.com/rust-lang/rust/issues/144132> +//! <https://github.com/rust-lang/rust/issues/135017> + +struct Baz<const N: usize>(i32); + +fn main() { + let _: Baz<#[cfg(any())]> = todo!(); + //~^ ERROR attributes cannot be applied here +} + +fn f(_param: #[attr]) {} +//~^ ERROR attributes cannot be applied to a function parameter's type +//~| ERROR expected type, found `)` + +fn g() -> #[attr] { 0 } +//~^ ERROR attributes cannot be applied here + +struct S { + field: #[attr], + //~^ ERROR attributes cannot be applied here + field1: (#[attr], i32), + //~^ ERROR attributes cannot be applied here +} + +type Tuple = (#[attr], String); +//~^ ERROR attributes cannot be applied here + +impl #[attr] {} +//~^ ERROR attributes cannot be applied here diff --git a/tests/ui/parser/attribute-on-empty.stderr b/tests/ui/parser/attribute-on-empty.stderr new file mode 100644 index 00000000000..7c4806c8704 --- /dev/null +++ b/tests/ui/parser/attribute-on-empty.stderr @@ -0,0 +1,52 @@ +error: attributes cannot be applied here + --> $DIR/attribute-on-empty.rs:7:16 + | +LL | let _: Baz<#[cfg(any())]> = todo!(); + | - ^^^^^^^^^^^^^ attributes are not allowed here + | | + | while parsing the type for `_` + +error: attributes cannot be applied to a function parameter's type + --> $DIR/attribute-on-empty.rs:11:14 + | +LL | fn f(_param: #[attr]) {} + | ^^^^^^^ attributes are not allowed here + +error: expected type, found `)` + --> $DIR/attribute-on-empty.rs:11:21 + | +LL | fn f(_param: #[attr]) {} + | ^ expected type + +error: attributes cannot be applied here + --> $DIR/attribute-on-empty.rs:15:11 + | +LL | fn g() -> #[attr] { 0 } + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied here + --> $DIR/attribute-on-empty.rs:19:12 + | +LL | field: #[attr], + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied here + --> $DIR/attribute-on-empty.rs:21:14 + | +LL | field1: (#[attr], i32), + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied here + --> $DIR/attribute-on-empty.rs:25:15 + | +LL | type Tuple = (#[attr], String); + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied here + --> $DIR/attribute-on-empty.rs:28:6 + | +LL | impl #[attr] {} + | ^^^^^^^ attributes are not allowed here + +error: aborting due to 8 previous errors + diff --git a/tests/ui/parser/attribute-on-type.fixed b/tests/ui/parser/attribute-on-type.fixed new file mode 100644 index 00000000000..5024bfdc2bc --- /dev/null +++ b/tests/ui/parser/attribute-on-type.fixed @@ -0,0 +1,58 @@ +//! Regression test for: <https://github.com/rust-lang/rust/issues/144132> +//! <https://github.com/rust-lang/rust/issues/135017> + +//@ run-rustfix + +#![allow(dead_code, unused_variables)] + +struct Foo<T>(T); +struct Bar<'a>(&'a i32); +struct Baz<const N: usize>(i32); + +fn main() { + let foo: Foo<i32> = Foo(2i32); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: &'static str = "123"; + //~^ ERROR attributes cannot be applied to types + + let _: Bar<'static> = Bar(&123); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: Baz<42> = Baz(42); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: Foo<String> = Foo(String::new()); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: Bar<'static> = Bar(&456); + //~^ ERROR attributes cannot be applied to generic arguments + + let _generic: Box<i32> = Box::new(1); + //~^ ERROR attributes cannot be applied to generic arguments + + let _assignment: i32 = *Box::new(1); + //~^ ERROR attributes cannot be applied to types + + let _complex: Vec<String> = vec![]; + //~^ ERROR attributes cannot be applied to generic arguments + + let _nested: Box<Vec<u64>> = Box::new(vec![]); + //~^ ERROR attributes cannot be applied to generic arguments +} + +fn g() -> i32 { 0 } +//~^ ERROR attributes cannot be applied to types + +struct S { + field: i32, + //~^ ERROR attributes cannot be applied to types + field1: (i32, i32), + //~^ ERROR attributes cannot be applied to types +} + +type Tuple = (i32, String); +//~^ ERROR attributes cannot be applied to types + +impl S {} +//~^ ERROR attributes cannot be applied to types diff --git a/tests/ui/parser/attribute-on-type.rs b/tests/ui/parser/attribute-on-type.rs new file mode 100644 index 00000000000..196d322bdf8 --- /dev/null +++ b/tests/ui/parser/attribute-on-type.rs @@ -0,0 +1,58 @@ +//! Regression test for: <https://github.com/rust-lang/rust/issues/144132> +//! <https://github.com/rust-lang/rust/issues/135017> + +//@ run-rustfix + +#![allow(dead_code, unused_variables)] + +struct Foo<T>(T); +struct Bar<'a>(&'a i32); +struct Baz<const N: usize>(i32); + +fn main() { + let foo: Foo<#[cfg(not(wrong))] i32> = Foo(2i32); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: #[attr] &'static str = "123"; + //~^ ERROR attributes cannot be applied to types + + let _: Bar<#[cfg(any())] 'static> = Bar(&123); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: Baz<#[cfg(any())] 42> = Baz(42); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: Foo<#[cfg(not(wrong))]String> = Foo(String::new()); + //~^ ERROR attributes cannot be applied to generic arguments + + let _: Bar<#[cfg(any())] 'static> = Bar(&456); + //~^ ERROR attributes cannot be applied to generic arguments + + let _generic: Box<#[attr] i32> = Box::new(1); + //~^ ERROR attributes cannot be applied to generic arguments + + let _assignment: #[attr] i32 = *Box::new(1); + //~^ ERROR attributes cannot be applied to types + + let _complex: Vec<#[derive(Debug)] String> = vec![]; + //~^ ERROR attributes cannot be applied to generic arguments + + let _nested: Box<Vec<#[cfg(feature = "test")] u64>> = Box::new(vec![]); + //~^ ERROR attributes cannot be applied to generic arguments +} + +fn g() -> #[attr] i32 { 0 } +//~^ ERROR attributes cannot be applied to types + +struct S { + field: #[attr] i32, + //~^ ERROR attributes cannot be applied to types + field1: (#[attr] i32, i32), + //~^ ERROR attributes cannot be applied to types +} + +type Tuple = (#[attr] i32, String); +//~^ ERROR attributes cannot be applied to types + +impl #[attr] S {} +//~^ ERROR attributes cannot be applied to types diff --git a/tests/ui/parser/attribute-on-type.stderr b/tests/ui/parser/attribute-on-type.stderr new file mode 100644 index 00000000000..603c7e2be51 --- /dev/null +++ b/tests/ui/parser/attribute-on-type.stderr @@ -0,0 +1,92 @@ +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:13:18 + | +LL | let foo: Foo<#[cfg(not(wrong))] i32> = Foo(2i32); + | ^^^^^^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:16:12 + | +LL | let _: #[attr] &'static str = "123"; + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:19:16 + | +LL | let _: Bar<#[cfg(any())] 'static> = Bar(&123); + | ^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:22:16 + | +LL | let _: Baz<#[cfg(any())] 42> = Baz(42); + | ^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:25:16 + | +LL | let _: Foo<#[cfg(not(wrong))]String> = Foo(String::new()); + | ^^^^^^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:28:16 + | +LL | let _: Bar<#[cfg(any())] 'static> = Bar(&456); + | ^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:31:23 + | +LL | let _generic: Box<#[attr] i32> = Box::new(1); + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:34:22 + | +LL | let _assignment: #[attr] i32 = *Box::new(1); + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:37:23 + | +LL | let _complex: Vec<#[derive(Debug)] String> = vec![]; + | ^^^^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to generic arguments + --> $DIR/attribute-on-type.rs:40:26 + | +LL | let _nested: Box<Vec<#[cfg(feature = "test")] u64>> = Box::new(vec![]); + | ^^^^^^^^^^^^^^^^^^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:44:11 + | +LL | fn g() -> #[attr] i32 { 0 } + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:48:12 + | +LL | field: #[attr] i32, + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:50:14 + | +LL | field1: (#[attr] i32, i32), + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:54:15 + | +LL | type Tuple = (#[attr] i32, String); + | ^^^^^^^ attributes are not allowed here + +error: attributes cannot be applied to types + --> $DIR/attribute-on-type.rs:57:6 + | +LL | impl #[attr] S {} + | ^^^^^^^ attributes are not allowed here + +error: aborting due to 15 previous errors + diff --git a/tests/ui/parser/issues/issue-103143.rs b/tests/ui/parser/issues/issue-103143.rs index a584274c405..90f10fc1a08 100644 --- a/tests/ui/parser/issues/issue-103143.rs +++ b/tests/ui/parser/issues/issue-103143.rs @@ -1,5 +1,5 @@ fn main() { x::<#[a]y::<z>> - //~^ ERROR invalid const generic expression + //~^ ERROR attributes cannot be applied to generic arguments //~| ERROR cannot find value `x` in this scope } diff --git a/tests/ui/parser/issues/issue-103143.stderr b/tests/ui/parser/issues/issue-103143.stderr index 4035c69afa7..168a2077396 100644 --- a/tests/ui/parser/issues/issue-103143.stderr +++ b/tests/ui/parser/issues/issue-103143.stderr @@ -1,13 +1,8 @@ -error: invalid const generic expression - --> $DIR/issue-103143.rs:2:13 +error: attributes cannot be applied to generic arguments + --> $DIR/issue-103143.rs:2:9 | LL | x::<#[a]y::<z>> - | ^^^^^^ - | -help: expressions must be enclosed in braces to be used as const generic arguments - | -LL | x::<#[a]{ y::<z> }> - | + + + | ^^^^ attributes are not allowed here error[E0425]: cannot find value `x` in this scope --> $DIR/issue-103143.rs:2:5 diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed index a851300a982..40028307a8c 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed @@ -1,7 +1,9 @@ // Regression test for issues #100790 and #106439. //@ run-rustfix -pub struct Example(#[allow(dead_code)] usize) +#![allow(dead_code)] + +pub struct Example(usize) where (): Sized; //~^^^ ERROR where clauses are not allowed before tuple struct bodies diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs index 10f435859f1..d8dbb4238d2 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs @@ -1,10 +1,12 @@ // Regression test for issues #100790 and #106439. //@ run-rustfix +#![allow(dead_code)] + pub struct Example where (): Sized, -(#[allow(dead_code)] usize); +(usize); //~^^^ ERROR where clauses are not allowed before tuple struct bodies struct _Demo diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr index ddbf237e866..66dadd9fd4c 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr @@ -1,23 +1,23 @@ error: where clauses are not allowed before tuple struct bodies - --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:5:1 + --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:7:1 | LL | pub struct Example | ------- while parsing this tuple struct LL | / where LL | | (): Sized, | |______________^ unexpected where clause -LL | (#[allow(dead_code)] usize); - | --------------------------- the struct body +LL | (usize); + | ------- the struct body | help: move the body before the where clause | -LL ~ pub struct Example(#[allow(dead_code)] usize) +LL ~ pub struct Example(usize) LL | where LL ~ (): Sized; | error: where clauses are not allowed before tuple struct bodies - --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:11:1 + --> $DIR/recover-where-clause-before-tuple-struct-body-0.rs:13:1 | LL | struct _Demo | ----- while parsing this tuple struct diff --git a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs b/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs index 1555da2fd1f..dd23acfa235 100644 --- a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs +++ b/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.rs @@ -1,16 +1,15 @@ -//@ known-bug: unknown +//@ run-pass #![allow(unused)] struct A(u32); pub fn main() { - // The or-pattern bindings are lowered after `x`, which triggers the error. + // Bindings are lowered in the order they appear syntactically, so this works. let x @ (A(a) | A(a)) = A(10); - // ERROR: use of moved value assert!(x.0 == 10); assert!(a == 10); - // This works. + // This also works. let (x @ A(a) | x @ A(a)) = A(10); assert!(x.0 == 10); assert!(a == 10); diff --git a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.stderr b/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.stderr deleted file mode 100644 index 79808186358..00000000000 --- a/tests/ui/pattern/bindings-after-at/bind-by-copy-or-pat.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0382]: use of moved value - --> $DIR/bind-by-copy-or-pat.rs:8:16 - | -LL | let x @ (A(a) | A(a)) = A(10); - | - ^ ----- move occurs because value has type `A`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | let ref x @ (A(a) | A(a)) = A(10); - | +++ - -error[E0382]: use of moved value - --> $DIR/bind-by-copy-or-pat.rs:8:23 - | -LL | let x @ (A(a) | A(a)) = A(10); - | - ^ ----- move occurs because value has type `A`, which does not implement the `Copy` trait - | | | - | | value used here after move - | value moved here - | -help: borrow this binding in the pattern to avoid moving the value - | -LL | let ref x @ (A(a) | A(a)) = A(10); - | +++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0382`. diff --git a/tests/ui/issues/issue-3763.rs b/tests/ui/privacy/private-field-access-violation-3763.rs index 893009a2cd9..3fc2337086d 100644 --- a/tests/ui/issues/issue-3763.rs +++ b/tests/ui/privacy/private-field-access-violation-3763.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/3763 // Regression test for #3763 mod my_mod { diff --git a/tests/ui/issues/issue-3763.stderr b/tests/ui/privacy/private-field-access-violation-3763.stderr index d101e4c33ad..6ba83dc4d78 100644 --- a/tests/ui/issues/issue-3763.stderr +++ b/tests/ui/privacy/private-field-access-violation-3763.stderr @@ -1,17 +1,17 @@ error[E0616]: field `priv_field` of struct `MyStruct` is private - --> $DIR/issue-3763.rs:17:32 + --> $DIR/private-field-access-violation-3763.rs:18:32 | LL | let _woohoo = (&my_struct).priv_field; | ^^^^^^^^^^ private field error[E0616]: field `priv_field` of struct `MyStruct` is private - --> $DIR/issue-3763.rs:20:41 + --> $DIR/private-field-access-violation-3763.rs:21:41 | LL | let _woohoo = (Box::new(my_struct)).priv_field; | ^^^^^^^^^^ private field error[E0624]: method `happyfun` is private - --> $DIR/issue-3763.rs:23:18 + --> $DIR/private-field-access-violation-3763.rs:24:18 | LL | fn happyfun(&self) {} | ------------------ private method defined here @@ -20,7 +20,7 @@ LL | (&my_struct).happyfun(); | ^^^^^^^^ private method error[E0624]: method `happyfun` is private - --> $DIR/issue-3763.rs:25:27 + --> $DIR/private-field-access-violation-3763.rs:26:27 | LL | fn happyfun(&self) {} | ------------------ private method defined here @@ -29,7 +29,7 @@ LL | (Box::new(my_struct)).happyfun(); | ^^^^^^^^ private method error[E0616]: field `priv_field` of struct `MyStruct` is private - --> $DIR/issue-3763.rs:26:26 + --> $DIR/private-field-access-violation-3763.rs:27:26 | LL | let nope = my_struct.priv_field; | ^^^^^^^^^^ private field diff --git a/tests/ui/proc-macro/load-panic-backtrace.rs b/tests/ui/proc-macro/load-panic-backtrace.rs index 848bdaf9f37..82645eb4e9f 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.rs +++ b/tests/ui/proc-macro/load-panic-backtrace.rs @@ -1,7 +1,7 @@ //@ proc-macro: test-macros.rs //@ compile-flags: -Z proc-macro-backtrace //@ rustc-env:RUST_BACKTRACE=0 -//@ normalize-stderr: "thread '.*' panicked " -> "" +//@ normalize-stderr: "thread '.*' \(0x[[:xdigit:]]+\) panicked " -> "" //@ normalize-stderr: "note:.*RUST_BACKTRACE=1.*\n" -> "" //@ needs-unwind proc macro panics to report errors diff --git a/tests/ui/proc-macro/load-panic-backtrace.stderr b/tests/ui/proc-macro/load-panic-backtrace.stderr index a1049f5a324..b8872eb12b7 100644 --- a/tests/ui/proc-macro/load-panic-backtrace.stderr +++ b/tests/ui/proc-macro/load-panic-backtrace.stderr @@ -1,5 +1,5 @@ -at $DIR/auxiliary/test-macros.rs:38:5: +thread '<unnamed>' ($TID) panicked at $DIR/auxiliary/test-macros.rs:38:5: panic-derive error: proc-macro derive panicked --> $DIR/load-panic-backtrace.rs:11:10 diff --git a/tests/ui/process/multi-panic.rs b/tests/ui/process/multi-panic.rs index 481fe75c731..1fddffeb770 100644 --- a/tests/ui/process/multi-panic.rs +++ b/tests/ui/process/multi-panic.rs @@ -7,18 +7,27 @@ fn check_for_no_backtrace(test: std::process::Output) { let err = String::from_utf8_lossy(&test.stderr); let mut it = err.lines().filter(|l| !l.is_empty()); - assert_eq!(it.next().map(|l| l.starts_with("thread '<unnamed>' panicked")), Some(true)); - assert_eq!(it.next().is_some(), true); + assert_eq!( + it.next().map(|l| l.starts_with("thread '<unnamed>' (") && l.contains("panicked")), + Some(true), + "out: ```{err}```", + ); + assert_eq!(it.next().is_some(), true, "out: ```{err}```"); assert_eq!( it.next(), Some( "note: run with `RUST_BACKTRACE=1` \ environment variable to display a backtrace" - ) + ), + "out: ```{err}```", + ); + assert_eq!( + it.next().map(|l| l.starts_with("thread 'main' (") && l.contains("panicked at")), + Some(true), + "out: ```{err}```", ); - assert_eq!(it.next().map(|l| l.starts_with("thread 'main' panicked at")), Some(true)); - assert_eq!(it.next().is_some(), true); - assert_eq!(it.next(), None); + assert_eq!(it.next().is_some(), true, "out: ```{err}```"); + assert_eq!(it.next(), None, "out: ```{err}```"); } fn main() { diff --git a/tests/ui/process/println-with-broken-pipe.run.stderr b/tests/ui/process/println-with-broken-pipe.run.stderr index ab414994b56..c56793de525 100644 --- a/tests/ui/process/println-with-broken-pipe.run.stderr +++ b/tests/ui/process/println-with-broken-pipe.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at library/std/src/io/stdio.rs:LL:CC: +thread 'main' ($TID) panicked at library/std/src/io/stdio.rs:LL:CC: failed printing to stdout: Broken pipe (os error 32) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/issues/issue-2281-part1.rs b/tests/ui/resolve/cannot-find-value-in-scope-22811.rs index 8340ade2239..fc07ae5e60e 100644 --- a/tests/ui/issues/issue-2281-part1.rs +++ b/tests/ui/resolve/cannot-find-value-in-scope-22811.rs @@ -1 +1,2 @@ +// https://github.com/rust-lang/rust/issues/22811 fn main() { println!("{}", foobar); } //~ ERROR cannot find value `foobar` in this scope diff --git a/tests/ui/issues/issue-2281-part1.stderr b/tests/ui/resolve/cannot-find-value-in-scope-22811.stderr index 47a1ef8cc02..529fd7e8f49 100644 --- a/tests/ui/issues/issue-2281-part1.stderr +++ b/tests/ui/resolve/cannot-find-value-in-scope-22811.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `foobar` in this scope - --> $DIR/issue-2281-part1.rs:1:28 + --> $DIR/cannot-find-value-in-scope-22811.rs:2:28 | LL | fn main() { println!("{}", foobar); } | ^^^^^^ not found in this scope diff --git a/tests/ui/resolve/multiple_definitions_attribute_merging.rs b/tests/ui/resolve/multiple_definitions_attribute_merging.rs index 155abafdd9d..519b989fbe8 100644 --- a/tests/ui/resolve/multiple_definitions_attribute_merging.rs +++ b/tests/ui/resolve/multiple_definitions_attribute_merging.rs @@ -5,7 +5,7 @@ //@known-bug: #120873 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/resolve/proc_macro_generated_packed.rs b/tests/ui/resolve/proc_macro_generated_packed.rs index 0cba3c1616d..41236c732bb 100644 --- a/tests/ui/resolve/proc_macro_generated_packed.rs +++ b/tests/ui/resolve/proc_macro_generated_packed.rs @@ -5,7 +5,7 @@ //@known-bug: #120873 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/issues/issue-33293.rs b/tests/ui/resolve/unresolved-module-error-33293.rs index 115ae3aad20..354f9914d44 100644 --- a/tests/ui/issues/issue-33293.rs +++ b/tests/ui/resolve/unresolved-module-error-33293.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/33293 fn main() { match 0 { aaa::bbb(_) => () diff --git a/tests/ui/issues/issue-33293.stderr b/tests/ui/resolve/unresolved-module-error-33293.stderr index a82813194d7..28528148387 100644 --- a/tests/ui/issues/issue-33293.stderr +++ b/tests/ui/resolve/unresolved-module-error-33293.stderr @@ -1,5 +1,5 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `aaa` - --> $DIR/issue-33293.rs:3:9 + --> $DIR/unresolved-module-error-33293.rs:4:9 | LL | aaa::bbb(_) => () | ^^^ use of unresolved module or unlinked crate `aaa` diff --git a/tests/ui/issues/issue-47073-zero-padded-tuple-struct-indices.rs b/tests/ui/structs/tuple-struct-field-naming-47073.rs index 6cd1f144359..6cf27e55c4b 100644 --- a/tests/ui/issues/issue-47073-zero-padded-tuple-struct-indices.rs +++ b/tests/ui/structs/tuple-struct-field-naming-47073.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/47073 type Guilty = bool; type FineDollars = u32; diff --git a/tests/ui/issues/issue-47073-zero-padded-tuple-struct-indices.stderr b/tests/ui/structs/tuple-struct-field-naming-47073.stderr index 0a6fe24d5e3..efbdaeca4ea 100644 --- a/tests/ui/issues/issue-47073-zero-padded-tuple-struct-indices.stderr +++ b/tests/ui/structs/tuple-struct-field-naming-47073.stderr @@ -1,5 +1,5 @@ error[E0609]: no field `00` on type `Verdict` - --> $DIR/issue-47073-zero-padded-tuple-struct-indices.rs:8:30 + --> $DIR/tuple-struct-field-naming-47073.rs:9:30 | LL | let _condemned = justice.00; | ^^ unknown field @@ -11,7 +11,7 @@ LL + let _condemned = justice.0; | error[E0609]: no field `001` on type `Verdict` - --> $DIR/issue-47073-zero-padded-tuple-struct-indices.rs:10:31 + --> $DIR/tuple-struct-field-naming-47073.rs:11:31 | LL | let _punishment = justice.001; | ^^^ unknown field diff --git a/tests/ui/issues/auxiliary/issue-9188.rs b/tests/ui/symbol-names/auxiliary/aux-9188.rs index 3bc5697a1a6..3bc5697a1a6 100644 --- a/tests/ui/issues/auxiliary/issue-9188.rs +++ b/tests/ui/symbol-names/auxiliary/aux-9188.rs diff --git a/tests/ui/symbol-names/same-symbol-name-for-inner-statics-9188.rs b/tests/ui/symbol-names/same-symbol-name-for-inner-statics-9188.rs new file mode 100644 index 00000000000..a1014bb813f --- /dev/null +++ b/tests/ui/symbol-names/same-symbol-name-for-inner-statics-9188.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/9188 +//@ run-pass +//@ aux-build:aux-9188.rs + +extern crate aux_9188 as lib; + +pub fn main() { + let a = lib::bar(); + let b = lib::foo::<isize>(); + assert_eq!(*a, *b); +} diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index 9244a98d82f..81ed8b3de76 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -6,6 +6,7 @@ // gate-test-arm_target_feature // gate-test-hexagon_target_feature // gate-test-mips_target_feature +// gate-test-nvptx_target_feature // gate-test-wasm_target_feature // gate-test-adx_target_feature // gate-test-cmpxchg16b_target_feature diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index 32d60ce4382..3e9374be73d 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `x87` is currently unstable - --> $DIR/gate.rs:29:18 + --> $DIR/gate.rs:30:18 | LL | #[target_feature(enable = "x87")] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/implied-features-nvptx.rs b/tests/ui/target-feature/implied-features-nvptx.rs new file mode 100644 index 00000000000..1550c99f67a --- /dev/null +++ b/tests/ui/target-feature/implied-features-nvptx.rs @@ -0,0 +1,28 @@ +//@ assembly-output: ptx-linker +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_80 -Z unstable-options -Clinker-flavor=llbc +//@ only-nvptx64 +//@ build-pass +#![no_std] +#![allow(dead_code)] + +#[panic_handler] +pub fn panic(_info: &core::panic::PanicInfo) -> ! { + loop {} +} + +// -Ctarget-cpu=sm_80 directly enables sm_80 and ptx70 +#[cfg(not(all(target_feature = "sm_80", target_feature = "ptx70")))] +compile_error!("direct target features not enabled"); + +// -Ctarget-cpu=sm_80 implies all earlier sm_* and ptx* features. +#[cfg(not(all( + target_feature = "sm_60", + target_feature = "sm_70", + target_feature = "ptx50", + target_feature = "ptx60", +)))] +compile_error!("implied target features not enabled"); + +// -Ctarget-cpu=sm_80 implies all earlier sm_* and ptx* features. +#[cfg(target_feature = "ptx71")] +compile_error!("sm_80 requires only ptx70, but ptx71 enabled"); diff --git a/tests/ui/test-attrs/terse.run.stdout b/tests/ui/test-attrs/terse.run.stdout index ac1ac28c98d..381d3cbe675 100644 --- a/tests/ui/test-attrs/terse.run.stdout +++ b/tests/ui/test-attrs/terse.run.stdout @@ -10,18 +10,18 @@ failures: ---- abc stdout ---- -thread 'abc' panicked at $DIR/terse.rs:12:5: +thread 'abc' ($TID) panicked at $DIR/terse.rs:12:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- foo stdout ---- -thread 'foo' panicked at $DIR/terse.rs:17:5: +thread 'foo' ($TID) panicked at $DIR/terse.rs:17:5: explicit panic ---- foo2 stdout ---- -thread 'foo2' panicked at $DIR/terse.rs:22:5: +thread 'foo2' ($TID) panicked at $DIR/terse.rs:22:5: explicit panic diff --git a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr index b9f267838b1..8d7c62f8ec7 100644 --- a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr @@ -1,11 +1,11 @@ -thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:32:5: +thread 'main' ($TID) panicked at $DIR/test-panic-abort-nocapture.rs:32:5: assertion `left == right` failed left: 2 right: 4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:26:5: +thread 'main' ($TID) panicked at $DIR/test-panic-abort-nocapture.rs:26:5: assertion `left == right` failed left: 2 right: 4 diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout index 0faa7f0dfce..4d65c05b944 100644 --- a/tests/ui/test-attrs/test-panic-abort.run.stdout +++ b/tests/ui/test-attrs/test-panic-abort.run.stdout @@ -18,7 +18,7 @@ testing123 ---- it_fails stderr ---- testing321 -thread 'main' panicked at $DIR/test-panic-abort.rs:37:5: +thread 'main' ($TID) panicked at $DIR/test-panic-abort.rs:37:5: assertion `left == right` failed left: 2 right: 5 diff --git a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr index db379a16b52..63bc10ef5ea 100644 --- a/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr +++ b/tests/ui/test-attrs/test-should-panic-failed-show-span.run.stderr @@ -1,13 +1,13 @@ -thread 'should_panic_with_any_message' panicked at $DIR/test-should-panic-failed-show-span.rs:14:5: +thread 'should_panic_with_any_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:14:5: Panic! note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'should_panic_with_message' panicked at $DIR/test-should-panic-failed-show-span.rs:20:5: +thread 'should_panic_with_message' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:20:5: message -thread 'should_panic_with_substring_panics_with_incorrect_string' panicked at $DIR/test-should-panic-failed-show-span.rs:38:5: +thread 'should_panic_with_substring_panics_with_incorrect_string' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:38:5: ZOMGWTFBBQ -thread 'should_panic_with_substring_panics_with_non_string_value' panicked at $DIR/test-should-panic-failed-show-span.rs:45:5: +thread 'should_panic_with_substring_panics_with_non_string_value' ($TID) panicked at $DIR/test-should-panic-failed-show-span.rs:45:5: Box<dyn Any> diff --git a/tests/ui/test-attrs/test-thread-capture.run.stdout b/tests/ui/test-attrs/test-thread-capture.run.stdout index f9b9757f861..bea3dcb1041 100644 --- a/tests/ui/test-attrs/test-thread-capture.run.stdout +++ b/tests/ui/test-attrs/test-thread-capture.run.stdout @@ -11,7 +11,7 @@ fie foe fum -thread 'thready_fail' panicked at $DIR/test-thread-capture.rs:32:5: +thread 'thready_fail' ($TID) panicked at $DIR/test-thread-capture.rs:32:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/test-attrs/test-thread-nocapture.run.stderr b/tests/ui/test-attrs/test-thread-nocapture.run.stderr index 59560015fca..b9905b0c2f9 100644 --- a/tests/ui/test-attrs/test-thread-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-thread-nocapture.run.stderr @@ -1,4 +1,4 @@ -thread 'thready_fail' panicked at $DIR/test-thread-nocapture.rs:32:5: +thread 'thready_fail' ($TID) panicked at $DIR/test-thread-nocapture.rs:32:5: explicit panic note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/track-diagnostics/track.rs b/tests/ui/track-diagnostics/track.rs index 1b2558c724b..9ce0a4a555a 100644 --- a/tests/ui/track-diagnostics/track.rs +++ b/tests/ui/track-diagnostics/track.rs @@ -13,6 +13,11 @@ // top of this file are present, then assume all args are present. //@ normalize-stderr: "note: compiler flags: .*-Z ui-testing.*-Z track-diagnostics" -> "note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics" +// FIXME: this tests a crash in rustc. For stage1, rustc is built with the downloaded standard +// library which doesn't yet print the thread ID. Normalization can be removed at the stage bump. +// For the grep: cfg(bootstrap) +//@normalize-stderr: "thread 'rustc' panicked" -> "thread 'rustc' ($$TID) panicked" + fn main() { break rust //~^ ERROR cannot find value `rust` in this scope diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr index f82764958d4..bc04ded379d 100644 --- a/tests/ui/track-diagnostics/track.stderr +++ b/tests/ui/track-diagnostics/track.stderr @@ -27,7 +27,7 @@ LL | break rust = note: compiler flags: ... -Z ui-testing ... -Z track-diagnostics -thread 'rustc' panicked at compiler/rustc_hir_typeck/src/lib.rs:LL:CC: +thread 'rustc' ($TID) panicked at compiler/rustc_hir_typeck/src/lib.rs:LL:CC: Box<dyn Any> note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/issues/issue-72839-error-overflow.rs b/tests/ui/trait-bounds/trait-selection-overflow-prevention-72839.rs index 6562d228409..436657e3de5 100644 --- a/tests/ui/issues/issue-72839-error-overflow.rs +++ b/tests/ui/trait-bounds/trait-selection-overflow-prevention-72839.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/72839 // Regression test for issue #72839 // Tests that we do not overflow during trait selection after // a type error occurs diff --git a/tests/ui/issues/issue-72839-error-overflow.stderr b/tests/ui/trait-bounds/trait-selection-overflow-prevention-72839.stderr index 35be632f579..da7500f77e1 100644 --- a/tests/ui/issues/issue-72839-error-overflow.stderr +++ b/tests/ui/trait-bounds/trait-selection-overflow-prevention-72839.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `missing_var` in this scope - --> $DIR/issue-72839-error-overflow.rs:18:8 + --> $DIR/trait-selection-overflow-prevention-72839.rs:19:8 | LL | if missing_var % 8 == 0 {} | ^^^^^^^^^^^ not found in this scope diff --git a/tests/ui/issues/issue-47638.rs b/tests/ui/trait-objects/trait-object-lifetime-conversion-47638.rs index e5a51ce0c06..c70dc74f3e5 100644 --- a/tests/ui/issues/issue-47638.rs +++ b/tests/ui/trait-objects/trait-object-lifetime-conversion-47638.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/47638 //@ run-pass #![allow(unused_variables)] fn id<'c, 'b>(f: &'c &'b dyn Fn(&i32)) -> &'c &'b dyn Fn(&'static i32) { diff --git a/tests/ui/traits/const-traits/const-closure-issue-125866-error.rs b/tests/ui/traits/const-traits/const-closure-issue-125866-error.rs new file mode 100644 index 00000000000..7a44920bb72 --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-issue-125866-error.rs @@ -0,0 +1,24 @@ +#![allow(incomplete_features)] +#![feature(const_closures, const_trait_impl)] + +const fn create_array<const N: usize>(mut f: impl FnMut(usize) -> u32 + Copy) -> [u32; N] { + let mut array = [0; N]; + let mut i = 0; + loop { + array[i] = f(i); + //~^ ERROR the trait bound `impl FnMut(usize) -> u32 + Copy: [const] FnMut(usize)` is not satisfied [E0277] + i += 1; + if i == N { + break; + } + } + array +} + +fn main() { + let x = create_array(const |i| 2 * i as u32); + assert_eq!(x, [0, 2, 4, 6, 8]); + + let y = create_array(const |i| 2 * i as u32 + 1); + assert_eq!(y, [1, 3, 5, 7, 9]); +} diff --git a/tests/ui/traits/const-traits/const-closure-issue-125866-error.stderr b/tests/ui/traits/const-traits/const-closure-issue-125866-error.stderr new file mode 100644 index 00000000000..1eadd1d8426 --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-issue-125866-error.stderr @@ -0,0 +1,11 @@ +error[E0277]: the trait bound `impl FnMut(usize) -> u32 + Copy: [const] FnMut(usize)` is not satisfied + --> $DIR/const-closure-issue-125866-error.rs:8:22 + | +LL | array[i] = f(i); + | - ^ + | | + | required by a bound introduced by this call + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/const-closure-issue-125866-pass.rs b/tests/ui/traits/const-traits/const-closure-issue-125866-pass.rs new file mode 100644 index 00000000000..af7375172e6 --- /dev/null +++ b/tests/ui/traits/const-traits/const-closure-issue-125866-pass.rs @@ -0,0 +1,25 @@ +//@ check-pass + +#![allow(incomplete_features)] +#![feature(const_closures, const_trait_impl)] + +const fn create_array<const N: usize>(mut f: impl [const] FnMut(usize) -> u32 + Copy) -> [u32; N] { + let mut array = [0; N]; + let mut i = 0; + loop { + array[i] = f(i); + i += 1; + if i == N { + break; + } + } + array +} + +fn main() { + let x = create_array(const |i| 2 * i as u32); + assert_eq!(x, [0, 2, 4, 6, 8]); + + let y = create_array(const |i| 2 * i as u32 + 1); + assert_eq!(y, [1, 3, 5, 7, 9]); +} diff --git a/tests/ui/traits/const-traits/const-fn-trait-bound-issue-104314.rs b/tests/ui/traits/const-traits/const-fn-trait-bound-issue-104314.rs new file mode 100644 index 00000000000..09c89c9cecd --- /dev/null +++ b/tests/ui/traits/const-traits/const-fn-trait-bound-issue-104314.rs @@ -0,0 +1,13 @@ +//@ check-pass + +#![feature(const_trait_impl, const_destruct, const_clone)] + +use std::marker::Destruct; + +const fn f<T, F: [const] Fn(&T) -> T + [const] Destruct>(_: F) {} + +const fn g<T: [const] Clone>() { + f(<T as Clone>::clone); +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/feature-gate.rs b/tests/ui/traits/const-traits/feature-gate.rs index 5ad56ddcd33..c2918f0249b 100644 --- a/tests/ui/traits/const-traits/feature-gate.rs +++ b/tests/ui/traits/const-traits/feature-gate.rs @@ -13,6 +13,9 @@ impl const T for S {} const fn f<A: [const] T>() {} //[stock]~ ERROR const trait impls are experimental fn g<A: const T>() {} //[stock]~ ERROR const trait impls are experimental +const trait Trait {} //[stock]~ ERROR const trait impls are experimental +#[cfg(false)] const trait Trait {} //[stock]~ ERROR const trait impls are experimental + macro_rules! discard { ($ty:ty) => {} } discard! { impl [const] T } //[stock]~ ERROR const trait impls are experimental diff --git a/tests/ui/traits/const-traits/feature-gate.stock.stderr b/tests/ui/traits/const-traits/feature-gate.stock.stderr index f3ba3039a23..551c7ced7c1 100644 --- a/tests/ui/traits/const-traits/feature-gate.stock.stderr +++ b/tests/ui/traits/const-traits/feature-gate.stock.stderr @@ -29,7 +29,27 @@ LL | fn g<A: const T>() {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:18:17 + --> $DIR/feature-gate.rs:16:1 + | +LL | const trait Trait {} + | ^^^^^ + | + = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:17:15 + | +LL | #[cfg(false)] const trait Trait {} + | ^^^^^ + | + = note: see issue #143874 <https://github.com/rust-lang/rust/issues/143874> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: const trait impls are experimental + --> $DIR/feature-gate.rs:21:17 | LL | discard! { impl [const] T } | ^^^^^^^ @@ -39,7 +59,7 @@ LL | discard! { impl [const] T } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/feature-gate.rs:19:17 + --> $DIR/feature-gate.rs:22:17 | LL | discard! { impl const T } | ^^^^^ @@ -58,6 +78,6 @@ LL | #[const_trait] = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 6 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr index 3a3b99f6c5b..45602d676b3 100644 --- a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr +++ b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr @@ -1,8 +1,8 @@ error[E0568]: auto traits cannot have super traits or lifetime bounds - --> $DIR/supertrait-auto-trait.rs:8:17 + --> $DIR/supertrait-auto-trait.rs:8:19 | LL | auto trait Magic: Copy {} - | -----^^^^^^ help: remove the super traits or lifetime bounds + | ----- ^^^^ | | | auto traits cannot have super traits or lifetime bounds diff --git a/tests/ui/issues/issue-20413.rs b/tests/ui/traits/trait-impl-overflow-with-where-clause-20413.rs index 138a235e675..e8c27ff5cc8 100644 --- a/tests/ui/issues/issue-20413.rs +++ b/tests/ui/traits/trait-impl-overflow-with-where-clause-20413.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/20413 trait Foo { fn answer(self); } diff --git a/tests/ui/issues/issue-20413.stderr b/tests/ui/traits/trait-impl-overflow-with-where-clause-20413.stderr index 42f3cd2d062..72aff1b9ee8 100644 --- a/tests/ui/issues/issue-20413.stderr +++ b/tests/ui/traits/trait-impl-overflow-with-where-clause-20413.stderr @@ -1,5 +1,5 @@ error[E0392]: type parameter `T` is never used - --> $DIR/issue-20413.rs:5:15 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:6:15 | LL | struct NoData<T>; | ^ unused type parameter @@ -8,14 +8,14 @@ LL | struct NoData<T>; = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<NoData<NoData<NoData<...>>>>>>>: Foo` - --> $DIR/issue-20413.rs:8:36 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:9:36 | LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`trait_impl_overflow_with_where_clause_20413`) note: required for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Foo` - --> $DIR/issue-20413.rs:8:9 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:9:9 | LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ ^ --- unsatisfied trait bound introduced here @@ -23,19 +23,19 @@ LL | impl<T> Foo for T where NoData<T>: Foo { = note: required for `NoData<T>` to implement `Foo` error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>: Bar` - --> $DIR/issue-20413.rs:27:42 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:28:42 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`trait_impl_overflow_with_where_clause_20413`) note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Baz` - --> $DIR/issue-20413.rs:34:9 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:35:9 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ ^ --- unsatisfied trait bound introduced here note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Bar` - --> $DIR/issue-20413.rs:27:9 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:28:9 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ ^ --- unsatisfied trait bound introduced here @@ -43,19 +43,19 @@ LL | impl<T> Bar for T where EvenLessData<T>: Baz { = note: required for `EvenLessData<T>` to implement `Baz` error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>: Baz` - --> $DIR/issue-20413.rs:34:42 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:35:42 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`trait_impl_overflow_with_where_clause_20413`) note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Bar` - --> $DIR/issue-20413.rs:27:9 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:28:9 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ ^ --- unsatisfied trait bound introduced here note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<T>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` to implement `Baz` - --> $DIR/issue-20413.rs:34:9 + --> $DIR/trait-impl-overflow-with-where-clause-20413.rs:35:9 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ ^ --- unsatisfied trait bound introduced here diff --git a/tests/ui/treat-err-as-bug/err.rs b/tests/ui/treat-err-as-bug/err.rs index 6f0e3c55fbb..f297a5773cb 100644 --- a/tests/ui/treat-err-as-bug/err.rs +++ b/tests/ui/treat-err-as-bug/err.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Ztreat-err-as-bug //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*:\n.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![crate_type = "rlib"] diff --git a/tests/ui/treat-err-as-bug/span_delayed_bug.rs b/tests/ui/treat-err-as-bug/span_delayed_bug.rs index 4681a8fc1ee..ff5a595899a 100644 --- a/tests/ui/treat-err-as-bug/span_delayed_bug.rs +++ b/tests/ui/treat-err-as-bug/span_delayed_bug.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Ztreat-err-as-bug -Zeagerly-emit-delayed-bugs //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*:\n.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*:\n.*\n" -> "" //@ rustc-env:RUST_BACKTRACE=0 #![feature(rustc_attrs)] diff --git a/tests/ui/issues/issue-51632-try-desugar-incompatible-types.rs b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.rs index 35402dff675..4b2081d14d0 100644 --- a/tests/ui/issues/issue-51632-try-desugar-incompatible-types.rs +++ b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/51632 #![allow(dead_code)] fn missing_discourses() -> Result<isize, ()> { diff --git a/tests/ui/issues/issue-51632-try-desugar-incompatible-types.stderr b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.stderr index 99fce1eeea6..c624605d76a 100644 --- a/tests/ui/issues/issue-51632-try-desugar-incompatible-types.stderr +++ b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.stderr @@ -1,5 +1,5 @@ error[E0308]: `?` operator has incompatible types - --> $DIR/issue-51632-try-desugar-incompatible-types.rs:8:5 + --> $DIR/incompatible-types-with-question-mark-51632.rs:9:5 | LL | fn forbidden_narratives() -> Result<isize, ()> { | ----------------- expected `Result<isize, ()>` because of return type diff --git a/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr b/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr index bf8829c0925..e8bbdaaacbf 100644 --- a/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr +++ b/tests/ui/type-inference/unbounded-type-param-in-fn-with-assoc-type.stderr @@ -13,7 +13,7 @@ error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0282`. Future incompatibility report: Future breakage diagnostic: -warning: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +warning: defaults for generic parameters are not allowed here --> $DIR/unbounded-type-param-in-fn-with-assoc-type.rs:3:11 | LL | fn foo<T, U = u64>() -> (T, U) { diff --git a/tests/ui/type/default_type_parameter_in_fn_or_impl.rs b/tests/ui/type/default_type_parameter_in_fn_or_impl.rs deleted file mode 100644 index 33038e24bc6..00000000000 --- a/tests/ui/type/default_type_parameter_in_fn_or_impl.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![allow(unused)] - -fn avg<T=i32>(_: T) {} -//~^ ERROR defaults for type parameters are only allowed -//~| WARN this was previously accepted - -struct S<T>(T); -impl<T=i32> S<T> {} -//~^ ERROR defaults for type parameters are only allowed -//~| WARN this was previously accepted - -fn main() {} diff --git a/tests/ui/type/default_type_parameter_in_fn_or_impl.stderr b/tests/ui/type/default_type_parameter_in_fn_or_impl.stderr deleted file mode 100644 index a3205cd3c29..00000000000 --- a/tests/ui/type/default_type_parameter_in_fn_or_impl.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8 - | -LL | fn avg<T=i32>(_: T) {} - | ^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6 - | -LL | impl<T=i32> S<T> {} - | ^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - -error: aborting due to 2 previous errors - -Future incompatibility report: Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default_type_parameter_in_fn_or_impl.rs:3:8 - | -LL | fn avg<T=i32>(_: T) {} - | ^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - -Future breakage diagnostic: -error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default_type_parameter_in_fn_or_impl.rs:8:6 - | -LL | impl<T=i32> S<T> {} - | ^^^^^ - | - = 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 #36887 <https://github.com/rust-lang/rust/issues/36887> - = note: `#[deny(invalid_type_param_default)]` on by default - diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs index c28fda6f91a..ff99ac98926 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs @@ -1,7 +1,7 @@ //@known-bug: #127972 //@ failure-status: 101 //@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "thread 'rustc'.*panicked.*\n" -> "" //@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " //@ rustc-env:RUST_BACKTRACE=0 diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs index ad7d972879f..072a699a6b5 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs @@ -4,7 +4,7 @@ trait Trait<const N: dyn Trait = bar> { fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait { //~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters //~| ERROR expected value, found builtin type `u32` - //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions + //~| ERROR defaults for generic parameters are not allowed here bar //~^ ERROR cannot find value `bar` in this scope } diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index dc5a1cf3485..47f3e83fae2 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -39,7 +39,7 @@ LL | trait Trait<const N: dyn Trait = bar> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions +error: defaults for generic parameters are not allowed here --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:12 | LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait { diff --git a/triagebot.toml b/triagebot.toml index fefff78d64e..e8c15bb9bfd 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -287,6 +287,11 @@ trigger_files = [ "compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs", ] +[autolabel."F-explicit_tail_calls"] +trigger_files = [ + "tests/ui/explicit-tail-calls", +] + [autolabel."T-rustdoc-frontend"] trigger_labels = [ "A-rustdoc-search", |
