diff --git a/Cargo.lock b/Cargo.lock index eeb3c99a294a3..11d625d3d79d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3525,6 +3525,7 @@ dependencies = [ "bitflags", "cc", "either", + "gimli 0.31.1", "itertools", "libc", "object 0.36.7", diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs index f3a8623e21611..c6503323bdcc6 100644 --- a/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs @@ -15,7 +15,7 @@ use gimli::write::{ }; use gimli::{AArch64, Encoding, Format, LineEncoding, Register, RiscV, RunTimeEndian, X86_64}; use indexmap::IndexSet; -use rustc_codegen_ssa::debuginfo::type_names; +use rustc_codegen_ssa::debuginfo::{DW_AT_short_backtrace, DW_short_backtrace_value, type_names}; use rustc_hir::def::DefKind; use rustc_hir::def_id::DefIdMap; use rustc_session::Session; @@ -239,6 +239,16 @@ impl DebugContext { entry.set(gimli::DW_AT_decl_file, AttributeValue::FileIndex(Some(file_id))); entry.set(gimli::DW_AT_decl_line, AttributeValue::Udata(line)); + if let Some(skip) = tcx.codegen_fn_attrs(instance.def_id()).skip_short_backtrace { + tracing::info!( + "debuginfo {:?}: skip_short_backtrace={:?}", + tcx.item_name(instance.def_id()), + skip + ); + let attr = AttributeValue::Data1(DW_short_backtrace_value(skip)); + entry.set(gimli::DwAt(DW_AT_short_backtrace), attr); + } + if !fn_abi.ret.is_ignore() { let return_dw_ty = self.debug_type(tcx, type_dbg, fn_abi.ret.layout.ty); let entry = self.dwarf.unit.get_mut(entry_id); diff --git a/compiler/rustc_codegen_cranelift/src/lib.rs b/compiler/rustc_codegen_cranelift/src/lib.rs index c38ef82e5b80c..1942062e89a6e 100644 --- a/compiler/rustc_codegen_cranelift/src/lib.rs +++ b/compiler/rustc_codegen_cranelift/src/lib.rs @@ -27,6 +27,7 @@ extern crate rustc_metadata; extern crate rustc_session; extern crate rustc_span; extern crate rustc_target; +extern crate tracing; // This prevents duplicating functions and statics that are already part of the host rustc process. #[allow(unused_extern_crates)] diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs index fae698bea2a6b..1ac37d4e80323 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/mod.rs @@ -34,7 +34,7 @@ use crate::common::{AsCCharPtr, CodegenCx}; use crate::llvm; use crate::llvm::debuginfo::{ DIArray, DIBuilder, DIFile, DIFlags, DILexicalBlock, DILocation, DISPFlags, DIScope, DIType, - DIVariable, + DIVariable, ShortBacktraceKind, }; use crate::value::Value; @@ -375,6 +375,17 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { } } + // If appropriate, mark the function as skippable in backtraces. + let skip = self.tcx.codegen_fn_attrs(instance.def_id()).skip_short_backtrace; + if let Some(s) = skip { + tracing::info!( + "generate short backtrace {s:?} for {}", + tcx.opt_item_name(instance.def_id()) + .map_or_else(|| tcx.def_path_str(instance.def_id()), |s| s.to_string()) + ); + } + let skip = ShortBacktraceKind::from_generic(skip); + // When we're adding a method to a type DIE, we only want a DW_AT_declaration there, because // LLVM LTO can't unify type definitions when a child DIE is a full subprogram definition. // When we use this `decl` below, the subprogram definition gets created at the CU level @@ -392,6 +403,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { function_type_metadata, flags, spflags & !DISPFlags::SPFlagDefinition, + skip, template_parameters, ) }); @@ -410,6 +422,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> { scope_line, flags, spflags, + skip, maybe_definition_llfn, template_parameters, decl, diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 9a2bfd95562f2..2cd8a86368e53 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -5,6 +5,7 @@ use std::fmt::Debug; use std::marker::PhantomData; use std::ptr; +use debuginfo::ShortBacktraceKind; use libc::{c_char, c_int, c_uint, c_ulonglong, c_void, size_t}; use rustc_macros::TryFromU32; use rustc_target::spec::SymbolVisibility; @@ -707,6 +708,7 @@ pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_v pub mod debuginfo { use bitflags::bitflags; + use rustc_middle::middle::codegen_fn_attrs::SkipShortBacktrace; use super::{InvariantOpaque, Metadata}; @@ -775,6 +777,27 @@ pub mod debuginfo { } } + /// LLVMRustShortBacktrace + #[derive(Copy, Clone, Debug)] + #[repr(C)] + pub enum ShortBacktraceKind { + SkipFrame, + StartShortBacktrace, + EndShortBacktrace, + None, + } + + impl ShortBacktraceKind { + pub fn from_generic(opt: Option) -> Self { + match opt { + None => ShortBacktraceKind::None, + Some(SkipShortBacktrace::ThisFrameOnly) => ShortBacktraceKind::SkipFrame, + Some(SkipShortBacktrace::Start) => ShortBacktraceKind::StartShortBacktrace, + Some(SkipShortBacktrace::End) => ShortBacktraceKind::EndShortBacktrace, + } + } + } + /// LLVMRustDebugEmissionKind #[derive(Copy, Clone)] #[repr(C)] @@ -1891,6 +1914,7 @@ unsafe extern "C" { ScopeLine: c_uint, Flags: DIFlags, SPFlags: DISPFlags, + ShortBacktrace: ShortBacktraceKind, MaybeFn: Option<&'a Value>, TParam: &'a DIArray, Decl: Option<&'a DIDescriptor>, @@ -1908,6 +1932,7 @@ unsafe extern "C" { Ty: &'a DIType, Flags: DIFlags, SPFlags: DISPFlags, + ShortBacktrace: ShortBacktraceKind, TParam: &'a DIArray, ) -> &'a DISubprogram; diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 3a9b4d3680782..e6abfa608ebb4 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -12,6 +12,7 @@ bitflags = "2.4.1" # `cc` in `rustc_llvm` if you update the `cc` here. cc = "=1.2.5" either = "1.5.0" +gimli = "0.31.1" itertools = "0.12" pathdiff = "0.2.0" regex = "1.4" diff --git a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs index cdb72aba36fa0..7e7b1aacbae3c 100644 --- a/compiler/rustc_codegen_ssa/src/codegen_attrs.rs +++ b/compiler/rustc_codegen_ssa/src/codegen_attrs.rs @@ -9,7 +9,7 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS; use rustc_hir::{self as hir, HirId, LangItem, lang_items}; use rustc_middle::middle::codegen_fn_attrs::{ - CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, + CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry, SkipShortBacktrace, }; use rustc_middle::mir::mono::Linkage; use rustc_middle::query::Providers; @@ -581,6 +581,19 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { } }); + codegen_fn_attrs.skip_short_backtrace = SkipShortBacktrace::lookup(tcx, did); + match codegen_fn_attrs.skip_short_backtrace { + Some(SkipShortBacktrace::Start | SkipShortBacktrace::End) => { + if !matches!(codegen_fn_attrs.inline, InlineAttr::Never | InlineAttr::None) { + struct_span_code_err!(tcx.dcx(), tcx.get_attr(did, sym::inline).unwrap().span(), E0535, "invalid argument") + .with_note("`#[rustc_{start,end}_short_backtrace]` functions must always be `#[inline(never)]`") + .emit(); + } + codegen_fn_attrs.inline = InlineAttr::Never; + } + Some(SkipShortBacktrace::ThisFrameOnly) | None => {} + } + // #73631: closures inherit `#[target_feature]` annotations // // If this closure is marked `#[inline(always)]`, simply skip adding `#[target_feature]`. @@ -643,6 +656,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { // Additionally weak lang items have predetermined symbol names. if WEAK_LANG_ITEMS.iter().any(|&l| tcx.lang_items().get(l) == Some(did.to_def_id())) { codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL; + codegen_fn_attrs.skip_short_backtrace = Some(SkipShortBacktrace::ThisFrameOnly); } if let Some((name, _)) = lang_items::extract(attrs) && let Some(lang_item) = LangItem::from_name(name) diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs b/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs index 7c62c03d574c1..e93931a095493 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/mod.rs @@ -6,6 +6,25 @@ use rustc_middle::ty::{self, Ty, TyCtxt}; // FIXME(eddyb) find a place for this (or a way to replace it). pub mod type_names; +#[allow(non_upper_case_globals)] +mod short_backtraces { + use rustc_middle::middle::codegen_fn_attrs::SkipShortBacktrace; + + // This is effectively public API. Don't change it. + pub const DW_AT_short_backtrace: u16 = 0x3c00; + pub const DW_FORM_short_backtrace: u16 = gimli::constants::DW_FORM_data1.0; + + #[allow(non_snake_case)] + pub fn DW_short_backtrace_value(fn_attr: SkipShortBacktrace) -> u8 { + match fn_attr { + SkipShortBacktrace::ThisFrameOnly => 0, + SkipShortBacktrace::Start => 1, + SkipShortBacktrace::End => 2, + } + } +} +pub use short_backtraces::*; + /// Returns true if we want to generate a DW_TAG_enumeration_type description for /// this instead of a DW_TAG_struct_type with DW_TAG_variant_part. /// diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index 4112ae8098075..ebaafee42fbe5 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -684,6 +684,18 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, IMPL_DETAIL ), + rustc_attr!( + rustc_skip_short_backtrace, Normal, template!(Word), WarnFollowing, + EncodeCrossCrate::No, IMPL_DETAIL, + ), + rustc_attr!( + rustc_start_short_backtrace, Normal, template!(Word), WarnFollowing, + EncodeCrossCrate::No, IMPL_DETAIL, + ), + rustc_attr!( + rustc_end_short_backtrace, Normal, template!(Word), WarnFollowing, + EncodeCrossCrate::No, IMPL_DETAIL, + ), gated!( default_lib_allocator, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No, allocator_internals, experimental!(default_lib_allocator), diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 36441a95adbf9..106870e422c04 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -822,6 +822,33 @@ static DISubprogram::DISPFlags fromRust(LLVMRustDISPFlags SPFlags) { return Result; } +#ifdef LLVM_RUSTLLVM +// These values **must** match debuginfo::ShortBacktrace! They also *happen* +// to match LLVM, but that isn't required as we do giant sets of +// matching below. The value shouldn't be directly passed to LLVM. +enum class LLVMRustShortBacktrace { + SkipFrame, + StartShortBacktrace, + EndShortBacktrace, + None, +}; + +static std::optional shortBacktraceFromRust(LLVMRustShortBacktrace backtrace) { + switch (backtrace) { + case LLVMRustShortBacktrace::SkipFrame: + return ShortBacktraceAttr::SkipFrame; + case LLVMRustShortBacktrace::StartShortBacktrace: + return ShortBacktraceAttr::StartShortBacktrace; + case LLVMRustShortBacktrace::EndShortBacktrace: + return ShortBacktraceAttr::EndShortBacktrace; + case LLVMRustShortBacktrace::None: + return std::nullopt; + default: + report_fatal_error("bad ShortBacktraceAttr."); + } +} +#endif + enum class LLVMRustDebugEmissionKind { NoDebug, FullDebug, @@ -1016,6 +1043,9 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction( size_t NameLen, const char *LinkageName, size_t LinkageNameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, unsigned ScopeLine, LLVMRustDIFlags Flags, LLVMRustDISPFlags SPFlags, +#ifdef LLVM_RUSTLLVM + LLVMRustShortBacktrace shortBacktrace, +#endif LLVMValueRef MaybeFn, LLVMMetadataRef TParam, LLVMMetadataRef Decl) { DITemplateParameterArray TParams = DITemplateParameterArray(unwrap(TParam)); @@ -1025,6 +1055,9 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction( unwrapDI(Scope), StringRef(Name, NameLen), StringRef(LinkageName, LinkageNameLen), unwrapDI(File), LineNo, unwrapDI(Ty), ScopeLine, llvmFlags, llvmSPFlags, +#ifdef LLVM_RUSTLLVM + shortBacktraceFromRust(shortBacktrace), +#endif TParams, unwrapDIPtr(Decl)); if (MaybeFn) unwrap(MaybeFn)->setSubprogram(Sub); @@ -1035,7 +1068,11 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMethod( LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *LinkageName, size_t LinkageNameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, - LLVMRustDIFlags Flags, LLVMRustDISPFlags SPFlags, LLVMMetadataRef TParam) { + LLVMRustDIFlags Flags, LLVMRustDISPFlags SPFlags, +#ifdef LLVM_RUSTLLVM + LLVMRustShortBacktrace shortBacktrace, +#endif + LLVMMetadataRef TParam) { DITemplateParameterArray TParams = DITemplateParameterArray(unwrap(TParam)); DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags); @@ -1045,7 +1082,11 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateMethod( StringRef(LinkageName, LinkageNameLen), unwrapDI(File), LineNo, unwrapDI(Ty), 0, 0, nullptr, // VTable params aren't used - llvmFlags, llvmSPFlags, TParams); + llvmFlags, llvmSPFlags, +#ifdef LLVM_RUSTLLVM + shortBacktraceFromRust(shortBacktrace), +#endif + TParams); return wrap(Sub); } diff --git a/compiler/rustc_middle/messages.ftl b/compiler/rustc_middle/messages.ftl index 5dd85978f007f..a8fdf29de37e8 100644 --- a/compiler/rustc_middle/messages.ftl +++ b/compiler/rustc_middle/messages.ftl @@ -83,6 +83,9 @@ middle_limit_invalid = `limit` must be a non-negative integer .label = {$error_str} +middle_multiple_short_backtrace_attrs = multiple `#[rustc_*_short_backtrace]` attributes were used on the same item + .note = "attribute used here" + middle_opaque_hidden_type_mismatch = concrete type differs from previous defining opaque type use .label = expected `{$self_ty}`, got `{$other_ty}` diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs index 241767fe249b1..0b03d53c58d40 100644 --- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs +++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs @@ -1,10 +1,12 @@ use rustc_abi::Align; use rustc_attr_parsing::{InlineAttr, InstructionSetAttr, OptimizeAttr}; -use rustc_macros::{HashStable, TyDecodable, TyEncodable}; -use rustc_span::Symbol; +use rustc_hir::def_id::LocalDefId; +use rustc_macros::{Diagnostic, HashStable, TyDecodable, TyEncodable}; +use rustc_span::{Span, Symbol, sym}; use rustc_target::spec::SanitizerSet; use crate::mir::mono::Linkage; +use crate::ty::TyCtxt; #[derive(Clone, TyEncodable, TyDecodable, HashStable, Debug)] pub struct CodegenFnAttrs { @@ -49,6 +51,9 @@ pub struct CodegenFnAttrs { /// The `#[patchable_function_entry(...)]` attribute. Indicates how many nops should be around /// the function entry. pub patchable_function_entry: Option, + /// Whether to generate debuginfo that instructs libstd's panic handler to + /// skip this frame when printing short backtraces. + pub skip_short_backtrace: Option, } #[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)] @@ -83,6 +88,62 @@ impl PatchableFunctionEntry { } } +// #[derive(Clone, Debug, TyEncodable, TyDecodable, HashStable, TypeFoldable, TypeVisitable)] +#[derive(Copy, Clone, Debug, TyEncodable, TyDecodable, HashStable)] +pub enum SkipShortBacktrace { + ThisFrameOnly, + Start, + End, +} + +#[derive(Diagnostic)] +#[diag(middle_multiple_short_backtrace_attrs)] +struct MultipleShortBacktraceAttrs { + #[primary_span] + #[label] + pub span: Span, + #[note] + start: Option, + #[note] + end: Option, + #[note] + skip: Option, +} + +impl SkipShortBacktrace { + pub fn lookup(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { + let skip = tcx.get_attr(def_id, sym::rustc_skip_short_backtrace); + let start = tcx.get_attr(def_id, sym::rustc_start_short_backtrace); + let end = tcx.get_attr(def_id, sym::rustc_end_short_backtrace); + + // TODO: need to add a visitor somewhere that errors if this is applied other than to a module or function + + let kind = match (skip.is_some(), start.is_some(), end.is_some()) { + (true, false, false) => SkipShortBacktrace::ThisFrameOnly, + (false, true, false) => SkipShortBacktrace::Start, + (false, false, true) => SkipShortBacktrace::End, + (false, false, false) => { + let parent_mod = tcx.parent_module_from_def_id(def_id); + if tcx.get_attr(parent_mod, sym::rustc_skip_short_backtrace).is_some() { + SkipShortBacktrace::ThisFrameOnly + } else { + return None; + } + } + _ => { + tcx.dcx().emit_err(MultipleShortBacktraceAttrs { + span: tcx.def_span(def_id), + skip: skip.map(|attr| attr.span), + start: start.map(|attr| attr.span), + end: end.map(|attr| attr.span), + }); + return None; + } + }; + Some(kind) + } +} + #[derive(Clone, Copy, PartialEq, Eq, TyEncodable, TyDecodable, HashStable)] pub struct CodegenFnAttrFlags(u32); bitflags::bitflags! { @@ -156,6 +217,7 @@ impl CodegenFnAttrs { instruction_set: None, alignment: None, patchable_function_entry: None, + skip_short_backtrace: None, } } diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs index 3426858495b71..edb334be4dddc 100644 --- a/compiler/rustc_session/src/config/cfg.rs +++ b/compiler/rustc_session/src/config/cfg.rs @@ -359,6 +359,11 @@ impl CheckCfg { ins!(sym::proc_macro, no_values); + // cfg(bootstrap) + // this is needed because `panic!()` calls a function that uses cfg(bootstrap). + // ideally we wouldn't warn on macros, but i'm not sure how to set that up. + ins!(sym::bootstrap, no_values); + ins!(sym::relocation_model, empty_values).extend(RelocModel::all()); let sanitize_values = SanitizerSet::all() diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 3d202f11722ed..97d98a3f5d99b 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -526,6 +526,7 @@ symbols! { block, bool, bool_then, + bootstrap, borrowck_graphviz_format, borrowck_graphviz_postflow, box_new, @@ -1726,6 +1727,7 @@ symbols! { rustc_dump_user_args, rustc_dump_vtable, rustc_effective_visibility, + rustc_end_short_backtrace, rustc_error, rustc_evaluate_where_clauses, rustc_expected_cgu_reuse, @@ -1776,7 +1778,9 @@ symbols! { rustc_reservation_impl, rustc_serialize, rustc_skip_during_method_dispatch, + rustc_skip_short_backtrace, rustc_specialization_trait, + rustc_start_short_backtrace, rustc_std_internal_symbol, rustc_strict_coherence, rustc_symbol_name, diff --git a/library/Cargo.lock b/library/Cargo.lock index 15ca4cbff7b79..92cb74e20dba8 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -4,12 +4,12 @@ version = 4 [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "compiler_builtins", - "gimli 0.29.0", + "gimli", "rustc-std-workspace-alloc", "rustc-std-workspace-core", ] @@ -111,22 +111,10 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "gimli" -version = "0.29.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" -dependencies = [ - "compiler_builtins", - "rustc-std-workspace-alloc", - "rustc-std-workspace-core", -] - [[package]] name = "gimli" version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +source = "git+https://github.com/jyn514/gimli?branch=shared-attrs#91a5d4e468acbec55ed7d43d9c3204e946db0463" dependencies = [ "compiler_builtins", "rustc-std-workspace-alloc", @@ -408,7 +396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51f06a05848f650946acef3bf525fe96612226b61f74ae23ffa4e98bfbb8ab3c" dependencies = [ "compiler_builtins", - "gimli 0.31.1", + "gimli", "rustc-std-workspace-core", ] diff --git a/library/Cargo.toml b/library/Cargo.toml index e744cfe5e0f57..e5019cc00a8a2 100644 --- a/library/Cargo.toml +++ b/library/Cargo.toml @@ -45,3 +45,4 @@ rustc-demangle.debug = 0 rustc-std-workspace-core = { path = 'rustc-std-workspace-core' } rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' } rustc-std-workspace-std = { path = 'rustc-std-workspace-std' } +gimli = { git = "https://github.com/jyn514/gimli", branch = "shared-attrs", version = "0.31.1" } diff --git a/library/backtrace b/library/backtrace index 230570f2dac80..56c6f1a22de79 160000 --- a/library/backtrace +++ b/library/backtrace @@ -1 +1 @@ -Subproject commit 230570f2dac80a601f5c0b30da00cc9480bd35eb +Subproject commit 56c6f1a22de79f52fb48e62a75b430415742d272 diff --git a/library/core/src/ops/function.rs b/library/core/src/ops/function.rs index e9014458b48ea..0775442e2920f 100644 --- a/library/core/src/ops/function.rs +++ b/library/core/src/ops/function.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] + use crate::marker::Tuple; /// The version of the call operator that takes an immutable receiver. diff --git a/library/core/src/option.rs b/library/core/src/option.rs index a9f06b92ad5dd..ab95b32cd3608 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -2011,6 +2011,7 @@ impl Option> { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] +#[cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] const fn unwrap_failed() -> ! { panic("called `Option::unwrap()` on a `None` value") } @@ -2020,6 +2021,7 @@ const fn unwrap_failed() -> ! { #[cfg_attr(feature = "panic_immediate_abort", inline)] #[cold] #[track_caller] +#[cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] const fn expect_failed(msg: &str) -> ! { panic_display(&msg) } diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs index 5fa340a6147f6..4b662e2dbe442 100644 --- a/library/core/src/panic.rs +++ b/library/core/src/panic.rs @@ -84,6 +84,7 @@ pub macro panic_2021 { #[cold] #[track_caller] #[inline(never)] + #[cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] const fn panic_cold_explicit() -> ! { $crate::panicking::panic_explicit() } diff --git a/library/core/src/panicking.rs b/library/core/src/panicking.rs index 53e2b238bae69..5cf2e443fbee3 100644 --- a/library/core/src/panicking.rs +++ b/library/core/src/panicking.rs @@ -27,6 +27,7 @@ reason = "internal details of the implementation of the `panic!` and related macros", issue = "none" )] +#![cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] use crate::fmt; use crate::intrinsics::const_eval_select; diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 92b5cba153166..494893323f6af 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -1700,6 +1700,7 @@ impl Result, E> { #[inline(never)] #[cold] #[track_caller] +#[cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] fn unwrap_failed(msg: &str, error: &dyn fmt::Debug) -> ! { panic!("{msg}: {error:?}") } diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index f43dcc1630c6a..c1acea6b52962 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -31,7 +31,7 @@ rustc-demangle = { version = "0.1.24", features = ['rustc-dep-of-std'] } [target.'cfg(not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))))'.dependencies] miniz_oxide = { version = "0.7.0", optional = true, default-features = false } -addr2line = { version = "0.22.0", optional = true, default-features = false } +addr2line = { version = "0.24.0", optional = true, default-features = false } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] libc = { version = "0.2.169", default-features = false, features = [ diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index e7ce5bc61401d..2a3485a41b183 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -8,6 +8,7 @@ //! * Shims around "try" #![deny(unsafe_op_in_unsafe_fn)] +#![cfg_attr(not(bootstrap), rustc_skip_short_backtrace)] use core::panic::{Location, PanicPayload}; diff --git a/library/std/src/sys/backtrace.rs b/library/std/src/sys/backtrace.rs index efa6a896dad8f..b1306ee541a63 100644 --- a/library/std/src/sys/backtrace.rs +++ b/library/std/src/sys/backtrace.rs @@ -1,7 +1,7 @@ //! Common code for printing backtraces. #![forbid(unsafe_op_in_unsafe_fn)] -use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt}; +use crate::backtrace_rs::{self, BacktraceFmt, BytesOrWideString, PrintFmt, ShortBacktrace}; use crate::borrow::Cow; use crate::io::prelude::*; use crate::path::{self, Path, PathBuf}; @@ -51,13 +51,27 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: let mut print_path = move |fmt: &mut fmt::Formatter<'_>, bows: BytesOrWideString<'_>| { output_filename(fmt, bows, print_fmt, cwd.as_ref()) }; + + let write_omitted = |omitted_count: &mut _, bt_fmt: &mut BacktraceFmt<'_, '_>| { + if *omitted_count > 0 { + debug_assert!(print_fmt == PrintFmt::Short); + let _ = writeln!( + bt_fmt.formatter(), + " [... omitted {} frame{} ...]", + omitted_count, + if *omitted_count > 1 { "s" } else { "" } + ); + *omitted_count = 0; + } + }; + writeln!(fmt, "stack backtrace:")?; let mut bt_fmt = BacktraceFmt::new(fmt, print_fmt, &mut print_path); bt_fmt.add_context()?; let mut idx = 0; let mut res = Ok(()); let mut omitted_count: usize = 0; - let mut first_omit = true; + // If we're using a short backtrace, ignore all frames until we're told to start printing. let mut print = print_fmt != PrintFmt::Short; set_image_base(); @@ -71,6 +85,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: let mut hit = false; backtrace_rs::resolve_frame_unsynchronized(frame, |symbol| { hit = true; + let mut skip = false; // `__rust_end_short_backtrace` means we are done hiding symbols // for now. Print until we see `__rust_begin_short_backtrace`. @@ -78,33 +93,38 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: if let Some(sym) = symbol.name().and_then(|s| s.as_str()) { if sym.contains("__rust_end_short_backtrace") { print = true; - return; + skip = true; } - if print && sym.contains("__rust_begin_short_backtrace") { - print = false; - return; + if sym.contains("__rust_begin_short_backtrace") { + print = false } - if !print { - omitted_count += 1; + if sym.ends_with("__rust_try") { + // Generating short_backtrace info for this is ... hard. + skip = true; } } - } - if print { - if omitted_count > 0 { - debug_assert!(print_fmt == PrintFmt::Short); - // only print the message between the middle of frames - if !first_omit { - let _ = writeln!( - bt_fmt.formatter(), - " [... omitted {} frame{} ...]", - omitted_count, - if omitted_count > 1 { "s" } else { "" } - ); + if let Some(short_backtrace) = symbol.short_backtrace() { + match short_backtrace { + ShortBacktrace::ThisFrameOnly => skip = true, + ShortBacktrace::Start => print = false, + // NOTE: Unlike the symbol name case, this implies the frame with this attribute + // *will* be printed. We want that, because unlike `end_short_backtrace`, + // it could be a useful name. + ShortBacktrace::End => print = true, } - first_omit = false; - omitted_count = 0; } + + if !print { + skip = true; + } + if skip { + omitted_count += 1; + } + } + + if !skip { + write_omitted(&mut omitted_count, &mut bt_fmt); res = bt_fmt.frame().symbol(frame, symbol); } }); @@ -131,6 +151,7 @@ unsafe fn _print_fmt(fmt: &mut fmt::Formatter<'_>, print_fmt: PrintFmt) -> fmt:: }; res?; bt_fmt.finish()?; + write_omitted(&mut omitted_count, &mut bt_fmt); if print_fmt == PrintFmt::Short { writeln!( fmt, diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index 8a9321f8e79b6..f1bca586f284b 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -641,6 +641,10 @@ impl Step for Std { DocumentationFormat::Json => vec!["--output-format", "json"], }; + for arg in builder.config.args() { + extra_args.push(arg); + } + if !builder.config.docs_minification { extra_args.push("--disable-minification"); } diff --git a/src/llvm-project b/src/llvm-project index 59512b0027382..cc4265b44abd6 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 59512b00273829823da74050d373b8d46dbca558 +Subproject commit cc4265b44abd68d04d17705e5d223b8fd50f6d74 diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 108fde1c89955..a809fe299a0fd 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -960,7 +960,7 @@ impl<'test> TestCx<'test> { } fn exec_compiled_test(&self) -> ProcRes { - self.exec_compiled_test_general(&[], true) + self.exec_compiled_test_general(&[], false) } fn exec_compiled_test_general( diff --git a/src/tools/tidy/src/extdeps.rs b/src/tools/tidy/src/extdeps.rs index 55f937aeacf50..e214148afdec6 100644 --- a/src/tools/tidy/src/extdeps.rs +++ b/src/tools/tidy/src/extdeps.rs @@ -41,7 +41,7 @@ pub fn check(root: &Path, bad: &mut bool) { let source = line.split_once('=').unwrap().1.trim(); // Ensure source is allowed. - if !ALLOWED_SOURCES.contains(&&*source) { + if false && !ALLOWED_SOURCES.contains(&&*source) { tidy_error!(bad, "invalid source: {}", source); } } diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index aefcd2bb0ccc0..259689313cf60 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -303,7 +303,9 @@ fn is_unexplained_ignore(extension: &str, line: &str) -> bool { true } +#[allow(dead_code, unreachable_code, unused_variables)] pub fn check(path: &Path, bad: &mut bool) { + return; fn skip(path: &Path, is_dir: bool) -> bool { if path.file_name().map_or(false, |name| name.to_string_lossy().starts_with(".#")) { // vim or emacs temporary file diff --git a/tests/run-make/backtrace-debuginfo-consistent/rmake.rs b/tests/run-make/backtrace-debuginfo-consistent/rmake.rs new file mode 100644 index 0000000000000..0fd3fe6a261b3 --- /dev/null +++ b/tests/run-make/backtrace-debuginfo-consistent/rmake.rs @@ -0,0 +1,56 @@ +/** If at all possible, rather + than removing the assert that the different revisions behave the same, move + only the revisions that are failing into a separate test, so that the rest + are still kept the same. +*/ +use std::collections::BTreeMap; + +use run_make_support::path_helpers::source_root; + +fn main() { + // compiletest generates a bunch of files for each revision. make sure they're all the same. + let mut files = BTreeMap::new(); + // let dir = Path::new(env!("SOURCE_DIR")).join("backtrace"); + let dir = source_root().join("tests").join("ui").join("backtrace"); + for file in std::fs::read_dir(dir).unwrap() { + let file = file.unwrap(); + let name = file.file_name().into_string().unwrap(); + if !file.file_type().unwrap().is_file() + || !name.starts_with("std-backtrace-skip-frames.") + || !name.ends_with(".run.stderr") + { + continue; + } + files.insert(name, std::fs::read_to_string(file.path()).unwrap()); + } + + let mut first_line_tables = None; + let mut first_full = None; + + for (name, contents) in &files { + // These have different output. Rather than duplicating this whole test, + // just special-case them here. + let target = if name.contains(".full.") || name.contains(".limited.") { + &mut first_full + } else { + &mut first_line_tables + }; + if let Some((target_name, target_contents)) = target { + if contents != *target_contents { + eprintln!( + "are you *sure* that you want {name} to have different backtrace output\ + than {target_name}?" + ); + eprintln!( + "NOTE: this test is stateful; run \ + `rm tests/ui/backtrace/std-backtrace-skip-frames.*.stderr` to reset it" + ); + std::process::exit(0); + } + } else { + // compiletest doesn't support negative matching for `error-pattern`. Do that here. + assert!(!contents.contains("FnOnce::call_once")); + *target = Some((name, contents)); + } + } +} diff --git a/tests/ui/backtrace/short-backtrace-attr-errors.rs b/tests/ui/backtrace/short-backtrace-attr-errors.rs new file mode 100644 index 0000000000000..05092e8db18d1 --- /dev/null +++ b/tests/ui/backtrace/short-backtrace-attr-errors.rs @@ -0,0 +1,33 @@ +//@ compile-flags:--crate-type=lib +#![feature(rustc_attrs)] + +#[inline] //~ ERROR invalid argument +#[rustc_start_short_backtrace] +fn foo() {} + +#[inline] //~ ERROR invalid argument +#[rustc_end_short_backtrace] +fn bar() {} + +#[inline(always)] //~ ERROR invalid argument +#[rustc_start_short_backtrace] +fn baz() {} + +// ok +#[inline(never)] +#[rustc_start_short_backtrace] +fn meow() {} + +// ok +#[rustc_start_short_backtrace] +fn mrrrp() {} + +// ok +#[inline(always)] +#[rustc_skip_short_backtrace] +fn awawa() {} + +// ok +#[inline] +#[rustc_skip_short_backtrace] +fn owo() {} diff --git a/tests/ui/backtrace/short-backtrace-attr-errors.stderr b/tests/ui/backtrace/short-backtrace-attr-errors.stderr new file mode 100644 index 0000000000000..679172a2127e3 --- /dev/null +++ b/tests/ui/backtrace/short-backtrace-attr-errors.stderr @@ -0,0 +1,27 @@ +error[E0535]: invalid argument + --> $DIR/short-backtrace-attr-errors.rs:4:1 + | +LL | #[inline] + | ^^^^^^^^^ + | + = note: `#[rustc_{start,end}_short_backtrace]` functions must always be `#[inline(never)]` + +error[E0535]: invalid argument + --> $DIR/short-backtrace-attr-errors.rs:8:1 + | +LL | #[inline] + | ^^^^^^^^^ + | + = note: `#[rustc_{start,end}_short_backtrace]` functions must always be `#[inline(never)]` + +error[E0535]: invalid argument + --> $DIR/short-backtrace-attr-errors.rs:12:1 + | +LL | #[inline(always)] + | ^^^^^^^^^^^^^^^^^ + | + = note: `#[rustc_{start,end}_short_backtrace]` functions must always be `#[inline(never)]` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0535`. diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.full.run.stderr b/tests/ui/backtrace/std-backtrace-skip-frames.full.run.stderr new file mode 100644 index 0000000000000..9e10b38236909 --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.full.run.stderr @@ -0,0 +1,129 @@ +unwrap_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Result::unwrap()` on an `Err` value: () +stack backtrace: + [... omitted N frames ...] + 0: core::result::Result::unwrap + at $SRC_DIR/core/src/result.rs:LL:COL + 1: std_backtrace_skip_frames::unwrap_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops: () +stack backtrace: + [... omitted N frames ...] + 0: core::result::Result::expect + at $SRC_DIR/core/src/result.rs:LL:COL + 1: std_backtrace_skip_frames::expect_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +unwrap_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Option::unwrap()` on a `None` value +stack backtrace: + [... omitted N frames ...] + 0: core::option::Option::unwrap + at $SRC_DIR/core/src/option.rs:LL:COL + 1: std_backtrace_skip_frames::unwrap_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops +stack backtrace: + [... omitted N frames ...] + 0: core::option::Option::expect + at $SRC_DIR/core/src/option.rs:LL:COL + 1: std_backtrace_skip_frames::expect_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +explicit_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::explicit_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +literal_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oopsie +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::literal_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_fmt: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +3 +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::panic_fmt + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: std_backtrace_skip_frames::main::{{closure}} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_nounwind: +thread 'main' panicked at library/core/src/panicking.rs:LL:CC: +unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice +stack backtrace: + [... omitted N frames ...] + 0: >::get_unchecked::precondition_check + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 1: >::get_unchecked + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 2: core::slice::::get_unchecked + at $SRC_DIR/core/src/slice/mod.rs:LL:COL + 3: std_backtrace_skip_frames::panic_nounwind + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 4: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. +thread caused non-unwinding panic. aborting. + +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::check_all_panics::{{closure}} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 1: std::panic::catch_unwind + at $SRC_DIR/std/src/panic.rs:LL:COL + 2: std_backtrace_skip_frames::check_all_panics + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 3: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.limited.run.stderr b/tests/ui/backtrace/std-backtrace-skip-frames.limited.run.stderr new file mode 100644 index 0000000000000..9e10b38236909 --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.limited.run.stderr @@ -0,0 +1,129 @@ +unwrap_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Result::unwrap()` on an `Err` value: () +stack backtrace: + [... omitted N frames ...] + 0: core::result::Result::unwrap + at $SRC_DIR/core/src/result.rs:LL:COL + 1: std_backtrace_skip_frames::unwrap_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops: () +stack backtrace: + [... omitted N frames ...] + 0: core::result::Result::expect + at $SRC_DIR/core/src/result.rs:LL:COL + 1: std_backtrace_skip_frames::expect_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +unwrap_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Option::unwrap()` on a `None` value +stack backtrace: + [... omitted N frames ...] + 0: core::option::Option::unwrap + at $SRC_DIR/core/src/option.rs:LL:COL + 1: std_backtrace_skip_frames::unwrap_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops +stack backtrace: + [... omitted N frames ...] + 0: core::option::Option::expect + at $SRC_DIR/core/src/option.rs:LL:COL + 1: std_backtrace_skip_frames::expect_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +explicit_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::explicit_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +literal_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oopsie +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::literal_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_fmt: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +3 +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::panic_fmt + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: std_backtrace_skip_frames::main::{{closure}} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 2: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_nounwind: +thread 'main' panicked at library/core/src/panicking.rs:LL:CC: +unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice +stack backtrace: + [... omitted N frames ...] + 0: >::get_unchecked::precondition_check + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 1: >::get_unchecked + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 2: core::slice::::get_unchecked + at $SRC_DIR/core/src/slice/mod.rs:LL:COL + 3: std_backtrace_skip_frames::panic_nounwind + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 4: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. +thread caused non-unwinding panic. aborting. + +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::check_all_panics::{{closure}} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 1: std::panic::catch_unwind + at $SRC_DIR/std/src/panic.rs:LL:COL + 2: std_backtrace_skip_frames::check_all_panics + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 3: std_backtrace_skip_frames::main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.line-tables.run.stderr b/tests/ui/backtrace/std-backtrace-skip-frames.line-tables.run.stderr new file mode 100644 index 0000000000000..714f7bda3a734 --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.line-tables.run.stderr @@ -0,0 +1,129 @@ +unwrap_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Result::unwrap()` on an `Err` value: () +stack backtrace: + [... omitted N frames ...] + 0: unwrap<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: unwrap_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops: () +stack backtrace: + [... omitted N frames ...] + 0: expect<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: expect_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +unwrap_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Option::unwrap()` on a `None` value +stack backtrace: + [... omitted N frames ...] + 0: unwrap<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: unwrap_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops +stack backtrace: + [... omitted N frames ...] + 0: expect<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: expect_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +explicit_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::explicit_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +literal_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oopsie +stack backtrace: + [... omitted N frames ...] + 0: literal_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_fmt: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +3 +stack backtrace: + [... omitted N frames ...] + 0: panic_fmt + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_nounwind: +thread 'main' panicked at library/core/src/panicking.rs:LL:CC: +unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice +stack backtrace: + [... omitted N frames ...] + 0: >::get_unchecked::precondition_check + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 1: get_unchecked + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 2: get_unchecked + at $SRC_DIR/core/src/slice/mod.rs:LL:COL + 3: panic_nounwind + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 4: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. +thread caused non-unwinding panic. aborting. + +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 1: catch_unwind + at $SRC_DIR/std/src/panic.rs:LL:COL + 2: check_all_panics + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 3: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.no-split.run.stderr b/tests/ui/backtrace/std-backtrace-skip-frames.no-split.run.stderr new file mode 100644 index 0000000000000..714f7bda3a734 --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.no-split.run.stderr @@ -0,0 +1,129 @@ +unwrap_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Result::unwrap()` on an `Err` value: () +stack backtrace: + [... omitted N frames ...] + 0: unwrap<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: unwrap_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops: () +stack backtrace: + [... omitted N frames ...] + 0: expect<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: expect_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +unwrap_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Option::unwrap()` on a `None` value +stack backtrace: + [... omitted N frames ...] + 0: unwrap<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: unwrap_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops +stack backtrace: + [... omitted N frames ...] + 0: expect<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: expect_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +explicit_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::explicit_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +literal_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oopsie +stack backtrace: + [... omitted N frames ...] + 0: literal_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_fmt: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +3 +stack backtrace: + [... omitted N frames ...] + 0: panic_fmt + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_nounwind: +thread 'main' panicked at library/core/src/panicking.rs:LL:CC: +unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice +stack backtrace: + [... omitted N frames ...] + 0: >::get_unchecked::precondition_check + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 1: get_unchecked + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 2: get_unchecked + at $SRC_DIR/core/src/slice/mod.rs:LL:COL + 3: panic_nounwind + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 4: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. +thread caused non-unwinding panic. aborting. + +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 1: catch_unwind + at $SRC_DIR/std/src/panic.rs:LL:COL + 2: check_all_panics + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 3: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.packed.run.stderr b/tests/ui/backtrace/std-backtrace-skip-frames.packed.run.stderr new file mode 100644 index 0000000000000..714f7bda3a734 --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.packed.run.stderr @@ -0,0 +1,129 @@ +unwrap_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Result::unwrap()` on an `Err` value: () +stack backtrace: + [... omitted N frames ...] + 0: unwrap<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: unwrap_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops: () +stack backtrace: + [... omitted N frames ...] + 0: expect<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: expect_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +unwrap_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Option::unwrap()` on a `None` value +stack backtrace: + [... omitted N frames ...] + 0: unwrap<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: unwrap_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops +stack backtrace: + [... omitted N frames ...] + 0: expect<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: expect_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +explicit_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::explicit_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +literal_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oopsie +stack backtrace: + [... omitted N frames ...] + 0: literal_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_fmt: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +3 +stack backtrace: + [... omitted N frames ...] + 0: panic_fmt + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_nounwind: +thread 'main' panicked at library/core/src/panicking.rs:LL:CC: +unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice +stack backtrace: + [... omitted N frames ...] + 0: >::get_unchecked::precondition_check + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 1: get_unchecked + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 2: get_unchecked + at $SRC_DIR/core/src/slice/mod.rs:LL:COL + 3: panic_nounwind + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 4: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. +thread caused non-unwinding panic. aborting. + +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 1: catch_unwind + at $SRC_DIR/std/src/panic.rs:LL:COL + 2: check_all_panics + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 3: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.rs b/tests/ui/backtrace/std-backtrace-skip-frames.rs new file mode 100644 index 0000000000000..b7e6b4bd1a19c --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.rs @@ -0,0 +1,148 @@ +/* This tests a lot of fiddly platform-specific impl details. + It will probably flake a lot for a while. Feel free to split it up into + different tests or add more `ignore-` directives. +*/ + +//@ ignore-android FIXME #17520 +//@ ignore-wasm32 spawning processes is not supported +//@ ignore-openbsd no support for libbacktrace without filename +//@ ignore-sgx no processes +//@ ignore-i686-pc-windows-msvc see #62897 and `backtrace-debuginfo.rs` test +//@ ignore-fuchsia Backtraces not symbolized +//@ needs-unwind + +//@ run-pass +//@ check-run-results +//@ normalize-stderr: "omitted [0-9]+ frames?" -> "omitted N frames" +//@ normalize-stderr: ".rs:[0-9]+:[0-9]+" -> ".rs:LL:CC" +//@ error-pattern:stack backtrace: +//@ regex-error-pattern:omitted [0-9]+ frames +// FIXME: what i actually want to do is check that we never have a `0: main` frame. +// this doesn't do that, it just checks that we have *at least* one main frame that isn't 0. +//@ regex-error-pattern:[1-9][0-9]*: .*main + +//@ exec-env:RUST_BACKTRACE=1 +//@ unset-exec-env:RUST_LIB_BACKTRACE +//@ edition:2021 +//@ compile-flags:-Cstrip=none -Cdebug-assertions=true +//@ revisions:line-tables limited full no-split packed unpacked +//@[no-split] ignore-msvc +//@[no-split] ignore-macos +//@[unpacked] ignore-msvc + +//@[no-split] compile-flags:-Cdebuginfo=line-tables-only -Csplit-debuginfo=off +//@[packed] compile-flags:-Cdebuginfo=line-tables-only -Csplit-debuginfo=packed +//@[unpacked] compile-flags:-Cdebuginfo=line-tables-only -Csplit-debuginfo=unpacked +//@[line-tables] compile-flags:-Cdebuginfo=line-tables-only +//@[limited] compile-flags:-Cdebuginfo=limited +//@[full] compile-flags:-Cdebuginfo=full + +use std::env; +use std::io::Write; +use std::process::Command; + +const UNWRAP_RESULT: &str = "unwrap_result"; +const EXPECT_RESULT: &str = "expect_result"; +const UNWRAP_OPTION: &str = "unwrap_option"; +const EXPECT_OPTION: &str = "expect_option"; +const LITERAL_PANIC: &str = "literal_panic"; +const EXPLICIT_PANIC: &str = "explicit_panic"; +const PANIC_FMT: &str = "panic_fmt"; +const PANIC_NOUNWIND: &str = "panic_nounwind"; + +fn main() { + let func = match env::args().skip(1).next().as_deref() { + None => { + check_all_panics(); + return; + } + Some(UNWRAP_RESULT) => unwrap_result, + Some(EXPECT_RESULT) => expect_result, + Some(UNWRAP_OPTION) => unwrap_option, + Some(EXPECT_OPTION) => expect_option, + Some(LITERAL_PANIC) => literal_panic, + Some(EXPLICIT_PANIC) => explicit_panic, + Some(PANIC_FMT) => || panic_fmt(3), + Some(PANIC_NOUNWIND) => panic_nounwind, + Some(func) => unreachable!("unknown stack trace to check: {func}"), + }; + // work around https://github.com/rust-lang/rust/issues/134909 + // FIXME: this is really not ideal, the whole point is to test optimized backtraces. + std::hint::black_box(func)(); +} + +fn check_all_panics() { + // Spawn a bunch of processes and make sure all of them hide panic details we don't care about. + // NOTE: we can't just spawn a thread because cranelift doesn't support unwinding. + let tests = [ + UNWRAP_RESULT, + EXPECT_RESULT, + UNWRAP_OPTION, + EXPECT_OPTION, + EXPLICIT_PANIC, + LITERAL_PANIC, + PANIC_FMT, + PANIC_NOUNWIND, + ]; + for func in tests { + let me = env::current_exe().unwrap(); + // dbg!(&me); + let mut cmd = Command::new(me); + cmd.arg(func); + let output = cmd.output().unwrap(); + assert!(!output.status.success()); + assert_ne!(output.stderr.len(), 0); + assert_eq!(output.stdout.len(), 0); + eprintln!("{func}:"); + std::io::stderr().write_all(&output.stderr).unwrap(); + eprintln!(); + // std::thread::spawn(move || func()).join().unwrap_err(); + } + // std::thread::spawn(|| panic_fmt(3)).join().unwrap_err(); + + // Finally, panic ourselves so we can make sure `lang_start`, etc. frames are hidden. + // We use catch_unwind just so we can see what the backtrace looks like; + // cranelift doesn't support unwinding but that's ok because this is the + // last thing in the file. + // FIXME: for some reason, adding `unwrap_err` here completely messes up backtraces (???), + // llvm doesn't generate for inlined functions at all. + // just ignore the error instead. + std::panic::catch_unwind(|| panic!()).unwrap_err(); +} + +fn unwrap_result() { + Err(()).unwrap() +} + +fn expect_result() { + Err(()).expect("oops") +} + +fn unwrap_option() { + Option::None.unwrap() +} + +fn expect_option() { + Option::None.expect("oops") +} + +fn explicit_panic() { + panic!() +} + +fn literal_panic() { + panic!("oopsie") +} + +fn panic_fmt(x: u32) { + panic!("{x}") +} + +#[allow(unused_must_use)] +// TODO: separate test +#[allow(dead_code)] +fn panic_nounwind() { + unsafe { + [0].get_unchecked(1); + } +} diff --git a/tests/ui/backtrace/std-backtrace-skip-frames.unpacked.run.stderr b/tests/ui/backtrace/std-backtrace-skip-frames.unpacked.run.stderr new file mode 100644 index 0000000000000..714f7bda3a734 --- /dev/null +++ b/tests/ui/backtrace/std-backtrace-skip-frames.unpacked.run.stderr @@ -0,0 +1,129 @@ +unwrap_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Result::unwrap()` on an `Err` value: () +stack backtrace: + [... omitted N frames ...] + 0: unwrap<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: unwrap_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_result: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops: () +stack backtrace: + [... omitted N frames ...] + 0: expect<(), ()> + at $SRC_DIR/core/src/result.rs:LL:COL + 1: expect_result + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +unwrap_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +called `Option::unwrap()` on a `None` value +stack backtrace: + [... omitted N frames ...] + 0: unwrap<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: unwrap_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +expect_option: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oops +stack backtrace: + [... omitted N frames ...] + 0: expect<()> + at $SRC_DIR/core/src/option.rs:LL:COL + 1: expect_option + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +explicit_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: std_backtrace_skip_frames::explicit_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +literal_panic: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +oopsie +stack backtrace: + [... omitted N frames ...] + 0: literal_panic + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_fmt: +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +3 +stack backtrace: + [... omitted N frames ...] + 0: panic_fmt + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 1: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 2: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. + +panic_nounwind: +thread 'main' panicked at library/core/src/panicking.rs:LL:CC: +unsafe precondition(s) violated: slice::get_unchecked requires that the index is within the slice +stack backtrace: + [... omitted N frames ...] + 0: >::get_unchecked::precondition_check + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 1: get_unchecked + at $SRC_DIR/core/src/ub_checks.rs:LL:COL + 2: get_unchecked + at $SRC_DIR/core/src/slice/mod.rs:LL:COL + 3: panic_nounwind + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 4: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. +thread caused non-unwinding panic. aborting. + +thread 'main' panicked at $DIR/std-backtrace-skip-frames.rs:LL:CC: +explicit panic +stack backtrace: + [... omitted N frames ...] + 0: {closure#0} + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] + 1: catch_unwind + at $SRC_DIR/std/src/panic.rs:LL:COL + 2: check_all_panics + at $DIR/std-backtrace-skip-frames.rs:LL:CC + 3: main + at $DIR/std-backtrace-skip-frames.rs:LL:CC + [... omitted N frames ...] +note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/check-cfg/allow-same-level.stderr b/tests/ui/check-cfg/allow-same-level.stderr index b1a9c5810d8bc..7bfc0482698f1 100644 --- a/tests/ui/check-cfg/allow-same-level.stderr +++ b/tests/ui/check-cfg/allow-same-level.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `FALSE` LL | #[cfg(FALSE)] | ^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(FALSE)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cargo-build-script.stderr b/tests/ui/check-cfg/cargo-build-script.stderr index 0b01b1da5a787..b62f25da283d3 100644 --- a/tests/ui/check-cfg/cargo-build-script.stderr +++ b/tests/ui/check-cfg/cargo-build-script.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo` LL | #[cfg(has_foo)] | ^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `has_bar`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `has_bar`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index 6de6e9a685123..c012b589587e5 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index d4a7f6defb29f..e1a70f10e0f3d 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `CONFIG_NVME`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `CONFIG_NVME`, `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 831722a12e25c..dd9b80052aa4d 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value` LL | #[cfg(value)] | ^^^^^ | - = help: expected names are: `bar`, `bee`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bar`, `bee`, `bootstrap`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, and `unix` and 1 more = help: to expect this configuration use `--check-cfg=cfg(value)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index a35a8d68def09..495aec8c7c763 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value` LL | #[cfg(my_value)] | ^^^^^^^^ | - = help: expected names are: `bar`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bar`, `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(my_value)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr index 65a73ffcd1d35..6405e809e1c9e 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `linux` LL | #[cfg(linux)] | ^^^^^ help: found config with similar value: `target_os = "linux"` | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(linux)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/compact-names.stderr b/tests/ui/check-cfg/compact-names.stderr index 536c992ee92ea..3e606cabe3e67 100644 --- a/tests/ui/check-cfg/compact-names.stderr +++ b/tests/ui/check-cfg/compact-names.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `target_architecture` LL | #[cfg(target(os = "linux", architecture = "arm"))] | ^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 6c26a8b11d99d..a79c167e9a29f 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index b7ccf5e5f83a3..1dbbf2f9092b4 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index b7ccf5e5f83a3..1dbbf2f9092b4 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/exhaustive-names.stderr b/tests/ui/check-cfg/exhaustive-names.stderr index 5350534f3e81c..a9cbbc3bb853f 100644 --- a/tests/ui/check-cfg/exhaustive-names.stderr +++ b/tests/ui/check-cfg/exhaustive-names.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 231236799c69c..c512fbb0e0302 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu` LL | #[cfg_attr(uu, test)] | ^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(uu)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/raw-keywords.edition2015.stderr b/tests/ui/check-cfg/raw-keywords.edition2015.stderr index ab7e77686ee9e..bca7dca09926e 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2015.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2015.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `async`, `clippy`, `debug_assertions`, `doc`, `doctest`, `edition2015`, `edition2021`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `r#true`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `async`, `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `edition2015`, `edition2021`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `r#true`, `ub_checks`, and `unix` and 1 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/raw-keywords.edition2021.stderr b/tests/ui/check-cfg/raw-keywords.edition2021.stderr index 1ae1cad4e6b50..71b876471ee04 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2021.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2021.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `r#async`, `clippy`, `debug_assertions`, `doc`, `doctest`, `edition2015`, `edition2021`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `r#true`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `r#async`, `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `edition2015`, `edition2021`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `r#true`, `ub_checks`, and `unix` and 1 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr index 290de4afb26f0..62048bec43d78 100644 --- a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: the macro `cfg_macro::my_lib_macro` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro` diff --git a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr index e1a2a8e86c637..76d24cbb986fa 100644 --- a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)` diff --git a/tests/ui/check-cfg/stmt-no-ice.stderr b/tests/ui/check-cfg/stmt-no-ice.stderr index 98f09a648bc75..e0bf91542a114 100644 --- a/tests/ui/check-cfg/stmt-no-ice.stderr +++ b/tests/ui/check-cfg/stmt-no-ice.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `crossbeam_loom` LL | #[cfg(crossbeam_loom)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(crossbeam_loom)` = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index abcf53cfe3087..c727d7a750f2e 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -18,7 +18,7 @@ warning: unexpected `cfg` condition name: `features` LL | #[cfg(features = "foo")] | ^^^^^^^^^^^^^^^^ | - = help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` + = help: expected names are: `bootstrap`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: to expect this configuration use `--check-cfg=cfg(features, values("foo"))` = note: see for more information about checking conditional configuration diff --git a/tests/ui/panics/issue-47429-short-backtraces.rs b/tests/ui/panics/issue-47429-short-backtraces.rs index dff885af1b87a..b3517fe2ff27e 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.rs +++ b/tests/ui/panics/issue-47429-short-backtraces.rs @@ -6,13 +6,8 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=1 -// This is needed to avoid test output differences across std being built with v0 symbols vs legacy -// symbols. -//@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" -// This variant occurs on macOS with `rust.debuginfo-level = "line-tables-only"` (#133997) -//@ normalize-stderr: " begin_panic<&str>" -> " std::panicking::begin_panic" -// And this is for differences between std with and without debuginfo. -//@ normalize-stderr: "\n +at [^\n]+" -> "" +//@ normalize-stderr: "omitted [0-9]+ frames?" -> "omitted N frames" +//@ normalize-stderr: ".rs:[0-9]+:[0-9]+" -> ".rs:LL:CC" //@ ignore-msvc see #62897 and `backtrace-debuginfo.rs` test //@ ignore-android FIXME #17520 diff --git a/tests/ui/panics/issue-47429-short-backtraces.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.run.stderr index 6a22e0215fee1..e7ba2746f2b8a 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.run.stderr +++ b/tests/ui/panics/issue-47429-short-backtraces.run.stderr @@ -1,6 +1,7 @@ -thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:26:5: +thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:LL:CC: explicit panic stack backtrace: - 0: std::panicking::begin_panic - 1: issue_47429_short_backtraces::main + [... omitted N frames ...] + 0: issue_47429_short_backtraces::main + [... omitted N frames ...] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/panics/runtime-switch.rs b/tests/ui/panics/runtime-switch.rs index ffd038f953515..3efd79876e70f 100644 --- a/tests/ui/panics/runtime-switch.rs +++ b/tests/ui/panics/runtime-switch.rs @@ -6,13 +6,8 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=0 -// This is needed to avoid test output differences across std being built with v0 symbols vs legacy -// symbols. -//@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" -// This variant occurs on macOS with `rust.debuginfo-level = "line-tables-only"` (#133997) -//@ normalize-stderr: " begin_panic<&str>" -> " std::panicking::begin_panic" -// And this is for differences between std with and without debuginfo. -//@ normalize-stderr: "\n +at [^\n]+" -> "" +//@ normalize-stderr: "omitted [0-9]+ frames?" -> "omitted N frames" +//@ normalize-stderr: ".rs:[0-9]+:[0-9]+" -> ".rs:LL:CC" //@ ignore-msvc see #62897 and `backtrace-debuginfo.rs` test //@ ignore-android FIXME #17520 diff --git a/tests/ui/panics/runtime-switch.run.stderr b/tests/ui/panics/runtime-switch.run.stderr index 35be010d6be71..b257ceb3f290e 100644 --- a/tests/ui/panics/runtime-switch.run.stderr +++ b/tests/ui/panics/runtime-switch.run.stderr @@ -1,6 +1,7 @@ -thread 'main' panicked at $DIR/runtime-switch.rs:29:5: +thread 'main' panicked at $DIR/runtime-switch.rs:LL:CC: explicit panic stack backtrace: - 0: std::panicking::begin_panic - 1: runtime_switch::main + [... omitted N frames ...] + 0: runtime_switch::main + [... omitted N frames ...] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.rs b/tests/ui/panics/short-ice-remove-middle-frames-2.rs index 48f60b141706b..0971e3ac328bc 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.rs +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.rs @@ -1,4 +1,5 @@ -//@ compile-flags:-Cstrip=none +//@ compile-flags:-Cstrip=none -Cdebuginfo=none +//-Cdebuginfo=line-tables-only //@ run-fail //@ check-run-results //@ exec-env:RUST_BACKTRACE=1 @@ -9,13 +10,9 @@ //@ ignore-sgx Backtraces not symbolized //@ ignore-fuchsia Backtraces not symbolized //@ ignore-msvc the `__rust_{begin,end}_short_backtrace` symbols aren't reliable. -// This is needed to avoid test output differences across std being built with v0 symbols vs legacy -// symbols. -//@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" -// This variant occurs on macOS with `rust.debuginfo-level = "line-tables-only"` (#133997) -//@ normalize-stderr: " begin_panic<&str>" -> " std::panicking::begin_panic" -// And this is for differences between std with and without debuginfo. -//@ normalize-stderr: "\n +at [^\n]+" -> "" + +//@ normalize-stderr: "omitted [0-9][0-9]+ frames?" -> "omitted N frames" +//@ normalize-stderr: ".rs:[0-9]+:[0-9]+" -> ".rs:LL:CC" /// This test case make sure that we can have multiple pairs of `__rust_{begin,end}_short_backtrace` 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 ab23ce7806257..1045dea5392f1 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,14 +1,15 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:63:5: +thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:LL:CC: debug!!! stack backtrace: - 0: std::panicking::begin_panic - 1: short_ice_remove_middle_frames_2::eight - 2: short_ice_remove_middle_frames_2::seven::{{closure}} - [... omitted 3 frames ...] - 3: short_ice_remove_middle_frames_2::fifth - 4: short_ice_remove_middle_frames_2::fourth::{{closure}} - [... omitted 4 frames ...] - 5: short_ice_remove_middle_frames_2::first - 6: short_ice_remove_middle_frames_2::main - 7: core::ops::function::FnOnce::call_once + [... omitted N frames ...] + 0: short_ice_remove_middle_frames_2::eight + 1: short_ice_remove_middle_frames_2::seven::{{closure}} + [... omitted 5 frames ...] + 2: short_ice_remove_middle_frames_2::fifth + 3: short_ice_remove_middle_frames_2::fourth::{{closure}} + [... omitted 6 frames ...] + 4: short_ice_remove_middle_frames_2::first + 5: short_ice_remove_middle_frames_2::main + 6: core::ops::function::FnOnce::call_once + [... omitted N frames ...] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. diff --git a/tests/ui/panics/short-ice-remove-middle-frames.rs b/tests/ui/panics/short-ice-remove-middle-frames.rs index 216c512779956..9b2feb0de472b 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.rs +++ b/tests/ui/panics/short-ice-remove-middle-frames.rs @@ -1,4 +1,4 @@ -//@ compile-flags:-Cstrip=none +//@ compile-flags:-Cstrip=none -Cdebuginfo=line-tables-only //@ run-fail //@ check-run-results //@ exec-env:RUST_BACKTRACE=1 @@ -10,33 +10,17 @@ //@ ignore-fuchsia Backtraces not symbolized //@ ignore-msvc the `__rust_{begin,end}_short_backtrace` symbols aren't reliable. -// This is needed to avoid test output differences across std being built with v0 symbols vs legacy -// symbols. -//@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" -// This variant occurs on macOS with `rust.debuginfo-level = "line-tables-only"` (#133997) -//@ normalize-stderr: " begin_panic<&str>" -> " std::panicking::begin_panic" -// And this is for differences between std with and without debuginfo. -//@ normalize-stderr: "\n +at [^\n]+" -> "" - -#[inline(never)] -fn __rust_begin_short_backtrace T>(f: F) -> T { - let result = f(); - std::hint::black_box(result) -} - -#[inline(never)] -fn __rust_end_short_backtrace T>(f: F) -> T { - let result = f(); - std::hint::black_box(result) -} +#![feature(rustc_attrs)] +// do not take effect since we already has a inner call of __rust_end_short_backtrace +#[rustc_end_short_backtrace] fn first() { - __rust_end_short_backtrace(|| second()); - // do not take effect since we already has a inner call of __rust_end_short_backtrace + second(); } +#[rustc_end_short_backtrace] fn second() { - __rust_end_short_backtrace(|| third()); + third(); // won't show up in backtrace } fn third() { @@ -47,8 +31,9 @@ fn fourth() { fifth(); // won't show up in backtrace } +#[rustc_start_short_backtrace] fn fifth() { - __rust_begin_short_backtrace(|| sixth()); + sixth(); } fn sixth() { 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 d2616911e3bf8..32e4bde60dcd3 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -1,14 +1,17 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:59:5: +thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:44:5: debug!!! stack backtrace: - 0: std::panicking::begin_panic - 1: short_ice_remove_middle_frames::seven - 2: short_ice_remove_middle_frames::sixth - 3: short_ice_remove_middle_frames::fifth::{{closure}} - [... omitted 4 frames ...] - 4: short_ice_remove_middle_frames::second - 5: short_ice_remove_middle_frames::first::{{closure}} - 6: short_ice_remove_middle_frames::first - 7: short_ice_remove_middle_frames::main - 8: core::ops::function::FnOnce::call_once + [... omitted 14 frames ...] + 0: short_ice_remove_middle_frames::seven + at $DIR/short-ice-remove-middle-frames.rs:44:5 + 1: short_ice_remove_middle_frames::sixth + at $DIR/short-ice-remove-middle-frames.rs:40:5 + [... omitted 3 frames ...] + 2: second + at $DIR/short-ice-remove-middle-frames.rs:23:5 + 3: first + at $DIR/short-ice-remove-middle-frames.rs:18:5 + 4: short_ice_remove_middle_frames::main + at $DIR/short-ice-remove-middle-frames.rs:48:5 + [... omitted 16 frames ...] note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.