diff --git a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs index c8cbd955acc5e..6ad79541bdbea 100644 --- a/compiler/rustc_const_eval/src/const_eval/eval_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/eval_queries.rs @@ -109,6 +109,19 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>( cid.promoted.map_or_else(String::new, |p| format!("::{p:?}")) ); + // We are about to initialize a frame without any arguments, + // and without `#[track_caller]` support. + // Make sure that the body expects this. + // Note: Promoteds don't require a caller location, + // even when inside an `Instance` with `#[track_caller]` + assert_eq!(body.arg_count, 0); + if cid.promoted.is_none() && cid.instance.def.requires_caller_location(tcx) { + // FIXME: Once #131787 is fixed, turn this delayed bug into an assertion. + throw_inval!(AlreadyReported(ReportedErrorInfo::non_const_eval_error( + tcx.dcx().span_delayed_bug(body.span, "can't evaluate body with `#[track_caller]`") + ))); + } + // This can't use `init_stack_frame` since `body` is not a function, // so computing its ABI would fail. It's also not worth it since there are no arguments to pass. ecx.push_stack_frame_raw( diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs index 876759b9ab41e..cb9432f9832e5 100644 --- a/compiler/rustc_const_eval/src/const_eval/machine.rs +++ b/compiler/rustc_const_eval/src/const_eval/machine.rs @@ -252,7 +252,7 @@ impl<'tcx> CompileTimeInterpCx<'tcx> { } let msg = Symbol::intern(self.read_str(&msg_place)?); - let span = self.find_closest_untracked_caller_location(); + let span = self.caller_location(); let (file, line, col) = self.location_triple_for_span(span); return Err(ConstEvalErrKind::Panic { msg, file, line, col }).into(); } else if self.tcx.is_lang_item(def_id, LangItem::PanicFmt) { @@ -469,7 +469,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> { fn panic_nounwind(ecx: &mut InterpCx<'tcx, Self>, msg: &str) -> InterpResult<'tcx> { let msg = Symbol::intern(msg); - let span = ecx.find_closest_untracked_caller_location(); + let span = ecx.caller_location(); let (file, line, col) = ecx.location_triple_for_span(span); Err(ConstEvalErrKind::Panic { msg, file, line, col }).into() } diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 3658982002e60..b5c3eceab9b4b 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -462,6 +462,21 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { let _trace = enter_trace_span!(M, step::init_stack_frame, %instance, tracing_separate_thread = Empty); let def_id = instance.def_id(); + match (instance.def.requires_caller_location(*self.tcx), with_caller_location) { + (false, true) => { + throw_ub_format!( + "calling a non-`#[track_caller]` function from a `#[track_caller]` declaration" + ) + } + (true, false) => { + throw_ub_format!( + "calling a `#[track_caller]` function from a non-`#[track_caller]` declaration" + ) + } + _ => {} + } + let caller_location = with_caller_location.then(|| self.caller_location()); + // The first order of business is to figure out the callee signature. // However, that requires the list of variadic arguments. // We use the *caller* information to determine where to split the list of arguments, @@ -542,6 +557,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { .collect::>() ); + // Initialize special caller_location "local", if this function has it. + self.frame_mut().track_caller_arg = caller_location; + // Determine whether there is a special VaList argument. This is always the // last argument, and since arguments start at index 1 that's `arg_count`. let va_list_arg = callee_fn_abi.c_variadic.then(|| mir::Local::from_usize(body.arg_count)); @@ -563,7 +581,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { // The "where they come from" part is easy, we expect the caller to do any special handling // that might be required here (e.g. for untupling). // If `with_caller_location` is set we pretend there is an extra argument (that - // we will not pass; our `caller_location` intrinsic implementation walks the stack instead). + // we will not pass normally; our `caller_location` intrinsic implementation handles + // that separately). assert_eq!( args.len() + if with_caller_location { 1 } else { 0 }, caller_fn_abi.args.len(), @@ -760,6 +779,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { match instance.def { ty::InstanceKind::Intrinsic(def_id) => { assert!(self.tcx.intrinsic(def_id).is_some()); + assert!(!with_caller_location); // FIXME: Should `InPlace` arguments be reset to uninit? if let Some(fallback) = M::call_intrinsic( self, @@ -771,11 +791,16 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { )? { assert!(!self.tcx.intrinsic(fallback.def_id()).unwrap().must_be_overridden); assert_matches!(fallback.def, ty::InstanceKind::Item(_)); + // For `#[rustc_intrinsic] fn`, two `Instance`s are involved: + // the original `InstanceKind::Intrinsic` (no caller location arg), and + // the fallback `InstanceKind::Item` (has caller location arg if + // it's `#[track_caller]`). + // We replace the former with the latter. return self.init_fn_call( FnVal::Instance(fallback), (caller_abi, caller_fn_abi), args, - with_caller_location, + fallback.def.requires_caller_location(*self.tcx), destination, target, unwind, diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 94b73a830503e..4307019c6cf27 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -1,5 +1,6 @@ use std::cell::RefCell; use std::collections::hash_map::Entry; +use std::convert::identity; use either::{Left, Right}; use rustc_abi::{Align, HasDataLayout, Size, TargetDataLayout}; @@ -18,7 +19,7 @@ use rustc_middle::ty::{ use rustc_span::{Span, span_bug}; use rustc_structures::Limit; use rustc_target::callconv::FnAbi; -use tracing::{debug, trace}; +use tracing::trace; use super::{ Frame, FrameInfo, GlobalId, InterpErrorKind, InterpResult, MPlaceTy, Machine, MemPlaceMeta, @@ -376,49 +377,41 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } } - /// Walks up the callstack from the intrinsic's callsite, searching for the first callsite in a - /// frame which is not `#[track_caller]`. This matches the `caller_location` intrinsic, + /// Grabs the implicit caller location argument, if there is one, + /// or falls back to the "current" span. This matches the `caller_location` intrinsic, /// and is primarily intended for the panic machinery. - pub(crate) fn find_closest_untracked_caller_location(&self) -> Span { - for frame in self.stack().iter().rev() { - debug!("find_closest_untracked_caller_location: checking frame {:?}", frame.instance); - - // Assert that the frame we look at is actually executing code currently - // (`loc` is `Right` when we are unwinding and the frame does not require cleanup). - let loc = frame.loc.left().unwrap(); - - // This could be a non-`Call` terminator (such as `Drop`), or not a terminator at all - // (such as `box`). Use the normal span by default. - let mut source_info = *frame.body.source_info(loc); - - // If this is a `Call` terminator, use the `fn_span` instead. - let block = &frame.body.basic_blocks[loc.block]; - if loc.statement_index == block.statements.len() { - debug!( - "find_closest_untracked_caller_location: got terminator {:?} ({:?})", - block.terminator(), - block.terminator().kind, - ); - if let mir::TerminatorKind::Call { fn_span, .. } = block.terminator().kind { - source_info.span = fn_span; - } - } - - let caller_location = if frame.instance.def.requires_caller_location(*self.tcx) { - // We use `Err(())` as indication that we should continue up the call stack since - // this is a `#[track_caller]` function. - Some(Err(())) - } else { - None - }; - if let Ok(span) = - frame.body.caller_location_span(source_info, caller_location, *self.tcx, Ok) - { - return span; - } + pub(crate) fn caller_location(&self) -> Span { + let frame = self.frame(); + + // Assert that the frame we look at is actually executing code currently + // (`loc` is `Right` when we are unwinding and the frame does not require cleanup). + let loc = frame.loc.left().unwrap(); + + // FIXME: It would be nice to have the following redundant sanity check. + // However, `requires_caller_location` would return true on a promoted that's + // inside a `#[track_caller]` function, and we currently don't keep track of + // enough information to identify such cases happening. + // assert_eq!( + // frame.track_caller_arg.is_some(), + // frame.instance.def.requires_caller_location(*self.tcx) + // ); + + // This could be a non-`Call` terminator (such as `Drop`), or not a terminator at all + // (such as `box`). Use the normal span by default. + let mut source_info = *frame.body.source_info(loc); + + // If this is a `Call` terminator, use the `fn_span` instead. + let block = &frame.body.basic_blocks[loc.block]; + if loc.statement_index == block.statements.len() + && let mir::TerminatorKind::Call { fn_span, .. } = block.terminator().kind + { + source_info.span = fn_span; } - span_bug!(self.cur_span(), "no non-`#[track_caller]` frame found") + // Directly returning `frame.track_caller_arg` would be wrong if we are + // in code that got inlined from another function. `caller_location_span` + // handles that for us. + frame.body.caller_location_span(source_info, frame.track_caller_arg, *self.tcx, identity) } /// Returns the actual dynamic size and alignment of the place at the given type. diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index b8b372ad1dab1..d66f4cf900eca 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -293,7 +293,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } sym::caller_location => { - let span = self.find_closest_untracked_caller_location(); + let span = self.caller_location(); let val = self.tcx.span_as_caller_location(span); let val = self.const_val_to_op(val, self.tcx.caller_location_ty(), Some(dest.layout))?; diff --git a/compiler/rustc_const_eval/src/interpret/stack.rs b/compiler/rustc_const_eval/src/interpret/stack.rs index 61cc31479b652..1bc6d43aa6dfb 100644 --- a/compiler/rustc_const_eval/src/interpret/stack.rs +++ b/compiler/rustc_const_eval/src/interpret/stack.rs @@ -66,6 +66,8 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> { pub(super) body: &'tcx mir::Body<'tcx>, /// The def_id and args of the current function. + /// Note that if this is the body of a promoted, the `instance` points + /// to the surrounding body! pub(super) instance: ty::Instance<'tcx>, /// Extra data for the machine. @@ -96,6 +98,10 @@ pub struct Frame<'tcx, Prov: Provenance = CtfeProvenance, Extra = ()> { /// frame is popped. pub(super) va_list: Vec>, + /// The implicit caller location argument that is passed by this function's caller, if any. + /// This is `Some` if and only if `instance.def.requires_caller_location` returns `true`. + pub(super) track_caller_arg: Option, + /// The span of the `tracing` crate is stored here. /// When the guard is dropped, the span is exited. This gives us /// a full stack trace on all tracing statements. @@ -258,13 +264,14 @@ impl<'tcx, Prov: Provenance> Frame<'tcx, Prov> { Frame { body: self.body, instance: self.instance, + extra, return_cont: self.return_cont, return_place: self.return_place, locals: self.locals, va_list: self.va_list, - loc: self.loc, - extra, + track_caller_arg: self.track_caller_arg, tracing_span: self.tracing_span, + loc: self.loc, } } } @@ -400,6 +407,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { return_place: return_place.clone(), locals, va_list: vec![], + track_caller_arg: None, instance, tracing_span: SpanGuard::new(), extra: (), diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index b647cc624bc04..a3e972f3b1ac1 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -496,15 +496,33 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } ty::FnDef(def_id, args) => { let instance = self.resolve(def_id, args.no_bound_vars().unwrap())?; - // Don't compute FnAbi for LLVM intrinsics. Trying to do that would panic. - // Rust intrinsics however *do* need a FnAbi as we may invoke the - // fallback body like a regular function. - let has_fn_abi = !matches!(instance.def, ty::InstanceKind::LlvmIntrinsic(_)); + let fn_abi = + match instance.def { + // Don't compute FnAbi for LLVM intrinsics. Trying to do that would panic. + ty::InstanceKind::LlvmIntrinsic(_) => None, + // Rust intrinsics don't really have a normal ABI, except for the case + // where we call the fallback body like a regular function. + // So, we compute the ABI based on the fallback body. + // We can't compute the ABI based on the `instance` directly, + // because `#[track_caller]` affects the ABI of the fallback body, + // but not affect the "ABI" of the intrinsic itself. + // Even if there is no fallback body, this computes a valid ABI + // (that we then mostly ignore). + ty::InstanceKind::Intrinsic(def_id) => { + let fallback_instance = ty::Instance { + def: ty::InstanceKind::Item(def_id), + args: instance.args, + }; + Some(self.fn_abi_of_instance_no_deduced_attrs( + fallback_instance, + extra_args, + )?) + } + _ => Some(self.fn_abi_of_instance_no_deduced_attrs(instance, extra_args)?), + }; ( FnVal::Instance(instance), - has_fn_abi - .then(|| self.fn_abi_of_instance_no_deduced_attrs(instance, extra_args)) - .transpose()?, + fn_abi, instance.def.requires_caller_location(*self.tcx), ) } diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index 4efef90581080..416207371e51c 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -25,7 +25,7 @@ pub(crate) fn type_implements_dyn_trait<'tcx, M: Machine<'tcx>>( let ty::Dynamic(preds, _) = trait_ty.kind() else { span_bug!( - ecx.find_closest_untracked_caller_location(), + ecx.cur_span(), "Invalid type provided to type_implements_predicates. U must be dyn Trait, got {trait_ty}." ); }; diff --git a/compiler/rustc_type_ir/src/binder.rs b/compiler/rustc_type_ir/src/binder.rs index 7f67435428b6c..d9b5ec7356e3e 100644 --- a/compiler/rustc_type_ir/src/binder.rs +++ b/compiler/rustc_type_ir/src/binder.rs @@ -136,6 +136,7 @@ impl Binder { self.as_ref().map_bound(f) } + #[inline] pub fn map_bound>(self, f: F) -> Binder where F: FnOnce(T) -> U, @@ -152,6 +153,7 @@ impl Binder { /// There are some uses of `map_bound` which are incredibly hot and trivially /// correct. Only use this if this significantly improves the performance of /// builds with debug assertions. + #[inline] pub fn map_bound_no_validate_bound_vars>(self, f: F) -> Binder where F: FnOnce(T) -> U, diff --git a/library/alloc/src/bstr.rs b/library/alloc/src/byte_str.rs similarity index 81% rename from library/alloc/src/bstr.rs rename to library/alloc/src/byte_str.rs index 59909ed1db9b2..55caf4012b21c 100644 --- a/library/alloc/src/bstr.rs +++ b/library/alloc/src/byte_str.rs @@ -4,9 +4,9 @@ #![cfg(not(no_global_oom_handling))] use core::borrow::{Borrow, BorrowMut}; -#[unstable(feature = "bstr", issue = "134915")] -pub use core::bstr::ByteStr; -use core::bstr::{impl_partial_eq, impl_partial_eq_n, impl_partial_eq_ord}; +#[unstable(feature = "byte_str", issue = "134915")] +pub use core::byte_str::ByteStr; +use core::byte_str::{impl_partial_eq, impl_partial_eq_n, impl_partial_eq_ord}; use core::cmp::Ordering; use core::ops::{ Deref, DerefMut, DerefPure, Index, IndexMut, Range, RangeFrom, RangeFull, RangeInclusive, @@ -33,7 +33,7 @@ use crate::vec::Vec; /// need to round-trip whatever data the user provides. /// /// A `ByteString` owns its contents and can grow and shrink, like a `Vec` or `String`. For a -/// borrowed byte string, see [`ByteStr`](../../std/bstr/struct.ByteStr.html). +/// borrowed byte string, see [`ByteStr`](../../std/byte_str/struct.ByteStr.html). /// /// `ByteString` implements `Deref` to `&Vec`, so all methods available on `&Vec` are /// available on `ByteString`. Similarly, `ByteString` implements `DerefMut` to `&mut Vec`, @@ -41,7 +41,7 @@ use crate::vec::Vec; /// /// The `Debug` and `Display` implementations for `ByteString` are the same as those for `ByteStr`, /// showing invalid UTF-8 as hex escapes or the Unicode replacement character, respectively. -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[repr(transparent)] #[derive(Clone, Default)] #[doc(alias = "BString")] @@ -70,7 +70,7 @@ impl ByteString { /// implementation for types that implement `Display`, and the trait version /// will use the Unicode replacement character rather than returning a /// `Result` and allowing for the possibility of the content not being UTF-8. - #[unstable(feature = "bstr_to_string", issue = "134915")] + #[unstable(feature = "byte_str_to_string", issue = "134915")] #[rustc_allow_incoherent_impl] pub fn to_string(&self) -> Result { // Avoid allocating a copy of the contents for invalid UTF-8 @@ -82,7 +82,7 @@ impl ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Deref for ByteString { type Target = Vec; @@ -92,7 +92,7 @@ impl Deref for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl DerefMut for ByteString { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { @@ -103,7 +103,7 @@ impl DerefMut for ByteString { #[unstable(feature = "deref_pure_trait", issue = "87121")] unsafe impl DerefPure for ByteString {} -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl fmt::Debug for ByteString { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -111,7 +111,7 @@ impl fmt::Debug for ByteString { } } -#[unstable(feature = "bstr_to_string", issue = "134915")] +#[unstable(feature = "byte_str_to_string", issue = "134915")] impl fmt::Display for ByteString { #[inline] fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -119,7 +119,7 @@ impl fmt::Display for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl AsRef<[u8]> for ByteString { #[inline] fn as_ref(&self) -> &[u8] { @@ -127,7 +127,7 @@ impl AsRef<[u8]> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl AsRef for ByteString { #[inline] fn as_ref(&self) -> &ByteStr { @@ -135,7 +135,7 @@ impl AsRef for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl AsMut<[u8]> for ByteString { #[inline] fn as_mut(&mut self) -> &mut [u8] { @@ -143,7 +143,7 @@ impl AsMut<[u8]> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl AsMut for ByteString { #[inline] fn as_mut(&mut self) -> &mut ByteStr { @@ -151,7 +151,7 @@ impl AsMut for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Borrow<[u8]> for ByteString { #[inline] fn borrow(&self) -> &[u8] { @@ -159,7 +159,7 @@ impl Borrow<[u8]> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Borrow for ByteString { #[inline] fn borrow(&self) -> &ByteStr { @@ -170,7 +170,7 @@ impl Borrow for ByteString { // `impl Borrow for Vec` omitted to avoid inference failures // `impl Borrow for String` omitted to avoid inference failures -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl BorrowMut<[u8]> for ByteString { #[inline] fn borrow_mut(&mut self) -> &mut [u8] { @@ -178,7 +178,7 @@ impl BorrowMut<[u8]> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl BorrowMut for ByteString { #[inline] fn borrow_mut(&mut self) -> &mut ByteStr { @@ -190,7 +190,7 @@ impl BorrowMut for ByteString { // Omitted due to inference failures // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a, const N: usize> From<&'a [u8; N]> for ByteString { // #[inline] // fn from(s: &'a [u8; N]) -> Self { @@ -198,7 +198,7 @@ impl BorrowMut for ByteString { // } // } // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl From<[u8; N]> for ByteString { // #[inline] // fn from(s: [u8; N]) -> Self { @@ -206,7 +206,7 @@ impl BorrowMut for ByteString { // } // } // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a> From<&'a [u8]> for ByteString { // #[inline] // fn from(s: &'a [u8]) -> Self { @@ -214,7 +214,7 @@ impl BorrowMut for ByteString { // } // } // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl From> for ByteString { // #[inline] // fn from(s: Vec) -> Self { @@ -222,7 +222,7 @@ impl BorrowMut for ByteString { // } // } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl From for Vec { #[inline] fn from(s: ByteString) -> Self { @@ -232,7 +232,7 @@ impl From for Vec { // Omitted due to inference failures // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a> From<&'a str> for ByteString { // #[inline] // fn from(s: &'a str) -> Self { @@ -240,7 +240,7 @@ impl From for Vec { // } // } // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl From for ByteString { // #[inline] // fn from(s: String) -> Self { @@ -248,7 +248,7 @@ impl From for Vec { // } // } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> From<&'a ByteStr> for ByteString { #[inline] fn from(s: &'a ByteStr) -> Self { @@ -256,7 +256,7 @@ impl<'a> From<&'a ByteStr> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> From for Cow<'a, ByteStr> { #[inline] fn from(s: ByteString) -> Self { @@ -264,7 +264,7 @@ impl<'a> From for Cow<'a, ByteStr> { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> { #[inline] fn from(s: &'a ByteString) -> Self { @@ -272,7 +272,7 @@ impl<'a> From<&'a ByteString> for Cow<'a, ByteStr> { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl FromIterator for ByteString { #[inline] fn from_iter>(iter: I) -> Self { @@ -280,7 +280,7 @@ impl FromIterator for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl FromIterator for ByteString { #[inline] fn from_iter>(iter: I) -> Self { @@ -288,7 +288,7 @@ impl FromIterator for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> FromIterator<&'a str> for ByteString { #[inline] fn from_iter>(iter: I) -> Self { @@ -296,7 +296,7 @@ impl<'a> FromIterator<&'a str> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> FromIterator<&'a [u8]> for ByteString { #[inline] fn from_iter>(iter: I) -> Self { @@ -308,7 +308,7 @@ impl<'a> FromIterator<&'a [u8]> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> FromIterator<&'a ByteStr> for ByteString { #[inline] fn from_iter>(iter: I) -> Self { @@ -320,7 +320,7 @@ impl<'a> FromIterator<&'a ByteStr> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl FromIterator for ByteString { #[inline] fn from_iter>(iter: I) -> Self { @@ -332,7 +332,7 @@ impl FromIterator for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl FromStr for ByteString { type Err = !; @@ -342,7 +342,7 @@ impl FromStr for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index for ByteString { type Output = u8; @@ -352,7 +352,7 @@ impl Index for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index for ByteString { type Output = ByteStr; @@ -362,7 +362,7 @@ impl Index for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index> for ByteString { type Output = ByteStr; @@ -372,7 +372,7 @@ impl Index> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index> for ByteString { type Output = ByteStr; @@ -382,7 +382,7 @@ impl Index> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index> for ByteString { type Output = ByteStr; @@ -392,7 +392,7 @@ impl Index> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index> for ByteString { type Output = ByteStr; @@ -402,7 +402,7 @@ impl Index> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Index> for ByteString { type Output = ByteStr; @@ -412,7 +412,7 @@ impl Index> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut for ByteString { #[inline] fn index_mut(&mut self, idx: usize) -> &mut u8 { @@ -420,7 +420,7 @@ impl IndexMut for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut for ByteString { #[inline] fn index_mut(&mut self, _: RangeFull) -> &mut ByteStr { @@ -428,7 +428,7 @@ impl IndexMut for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut> for ByteString { #[inline] fn index_mut(&mut self, r: Range) -> &mut ByteStr { @@ -436,7 +436,7 @@ impl IndexMut> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut> for ByteString { #[inline] fn index_mut(&mut self, r: RangeInclusive) -> &mut ByteStr { @@ -444,7 +444,7 @@ impl IndexMut> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut> for ByteString { #[inline] fn index_mut(&mut self, r: RangeFrom) -> &mut ByteStr { @@ -452,7 +452,7 @@ impl IndexMut> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut> for ByteString { #[inline] fn index_mut(&mut self, r: RangeTo) -> &mut ByteStr { @@ -460,7 +460,7 @@ impl IndexMut> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl IndexMut> for ByteString { #[inline] fn index_mut(&mut self, r: RangeToInclusive) -> &mut ByteStr { @@ -468,7 +468,7 @@ impl IndexMut> for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl hash::Hash for ByteString { #[inline] fn hash(&self, state: &mut H) { @@ -476,10 +476,10 @@ impl hash::Hash for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Eq for ByteString {} -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl PartialEq for ByteString { #[inline] fn eq(&self, other: &ByteString) -> bool { @@ -489,7 +489,7 @@ impl PartialEq for ByteString { macro_rules! impl_partial_eq_ord_cow { ($lhs:ty, $rhs:ty) => { - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialEq<$rhs> for $lhs { #[inline] fn eq(&self, other: &$rhs) -> bool { @@ -498,7 +498,7 @@ macro_rules! impl_partial_eq_ord_cow { } } - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialEq<$lhs> for $rhs { #[inline] fn eq(&self, other: &$lhs) -> bool { @@ -507,7 +507,7 @@ macro_rules! impl_partial_eq_ord_cow { } } - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialOrd<$rhs> for $lhs { #[inline] fn partial_cmp(&self, other: &$rhs) -> Option { @@ -516,7 +516,7 @@ macro_rules! impl_partial_eq_ord_cow { } } - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialOrd<$lhs> for $rhs { #[inline] fn partial_cmp(&self, other: &$lhs) -> Option { @@ -549,7 +549,7 @@ impl_partial_eq_ord_cow!(ByteString, Cow<'_, ByteStr>); impl_partial_eq_ord_cow!(ByteString, Cow<'_, str>); impl_partial_eq_ord_cow!(ByteString, Cow<'_, [u8]>); -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Ord for ByteString { #[inline] fn cmp(&self, other: &ByteString) -> Ordering { @@ -557,7 +557,7 @@ impl Ord for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl PartialOrd for ByteString { #[inline] fn partial_cmp(&self, other: &ByteString) -> Option { @@ -565,7 +565,7 @@ impl PartialOrd for ByteString { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl ToOwned for ByteStr { type Owned = ByteString; @@ -575,7 +575,7 @@ impl ToOwned for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl TryFrom for String { type Error = crate::string::FromUtf8Error; @@ -585,7 +585,7 @@ impl TryFrom for String { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> TryFrom<&'a ByteString> for &'a str { type Error = crate::str::Utf8Error; @@ -597,7 +597,7 @@ impl<'a> TryFrom<&'a ByteString> for &'a str { // Additional impls for `ByteStr` that require types from `alloc`: -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl Clone for Box { #[inline] fn clone(&self) -> Self { @@ -605,7 +605,7 @@ impl Clone for Box { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> { #[inline] fn from(s: &'a ByteStr) -> Self { @@ -613,7 +613,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl From> for Box { #[inline] fn from(s: Box<[u8]>) -> Box { @@ -622,7 +622,7 @@ impl From> for Box { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl From> for Box<[u8]> { #[inline] fn from(s: Box) -> Box<[u8]> { @@ -631,7 +631,7 @@ impl From> for Box<[u8]> { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[cfg(not(no_rc))] impl From> for Rc { #[inline] @@ -641,7 +641,7 @@ impl From> for Rc { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[cfg(not(no_rc))] impl From> for Rc<[u8]> { #[inline] @@ -651,7 +651,7 @@ impl From> for Rc<[u8]> { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] impl From> for Arc { #[inline] @@ -661,7 +661,7 @@ impl From> for Arc { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))] impl From> for Arc<[u8]> { #[inline] @@ -679,7 +679,7 @@ impl_partial_eq_ord_cow!(&ByteStr, Cow<'_, ByteStr>); impl_partial_eq_ord_cow!(&ByteStr, Cow<'_, str>); impl_partial_eq_ord_cow!(&ByteStr, Cow<'_, [u8]>); -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> TryFrom<&'a ByteStr> for String { type Error = core::str::Utf8Error; @@ -698,7 +698,7 @@ impl ByteStr { /// implementation for types that implement `Display`, and the trait version /// will use the Unicode replacement character rather than returning a /// `Result` and allowing for the possibility of the content not being UTF-8. - #[unstable(feature = "bstr_to_string", issue = "134915")] + #[unstable(feature = "byte_str_to_string", issue = "134915")] #[rustc_allow_incoherent_impl] pub fn to_string(&self) -> Result { // Avoid allocating a copy of the contents for invalid UTF-8 diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index f95cb5c58eaeb..3c24cf7a6c102 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -95,8 +95,8 @@ #![feature(async_fn_traits)] #![feature(async_iterator)] #![feature(borrowed_buf_init)] -#![feature(bstr)] -#![feature(bstr_internals)] +#![feature(byte_str)] +#![feature(byte_str_internals)] #![feature(can_vector)] #![feature(case_ignorable)] #![feature(cast_maybe_uninit)] @@ -256,8 +256,8 @@ pub mod alloc; // to allow code to have `use boxed::Box;` declarations. pub mod borrow; pub mod boxed; -#[unstable(feature = "bstr", issue = "134915")] -pub mod bstr; +#[unstable(feature = "byte_str", issue = "134915")] +pub mod byte_str; pub mod collections; #[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))] pub mod ffi; diff --git a/library/alloctests/tests/bstr.rs b/library/alloctests/tests/byte_str.rs similarity index 99% rename from library/alloctests/tests/bstr.rs rename to library/alloctests/tests/byte_str.rs index 64a1b901f1300..f8484985d84fe 100644 --- a/library/alloctests/tests/bstr.rs +++ b/library/alloctests/tests/byte_str.rs @@ -1,4 +1,4 @@ -use alloc::bstr::ByteString; +use alloc::byte_str::ByteString; use core::assert_matches; #[test] diff --git a/library/alloctests/tests/lib.rs b/library/alloctests/tests/lib.rs index 5c8ee92388dd0..291ee9ddff3ff 100644 --- a/library/alloctests/tests/lib.rs +++ b/library/alloctests/tests/lib.rs @@ -8,9 +8,9 @@ #![feature(binary_heap_into_iter_sorted)] #![feature(binary_heap_pop_if)] #![feature(borrowed_buf_init)] -#![feature(bstr)] -#![feature(bstr_to_string)] #![feature(buf_read_has_data_left)] +#![feature(byte_str)] +#![feature(byte_str_to_string)] #![feature(can_vector)] #![feature(casefold)] #![feature(const_btree_len)] @@ -72,8 +72,8 @@ mod arc; mod autotraits; mod borrow; mod boxed; -mod bstr; mod btree_set_hash; +mod byte_str; mod c_str; mod c_str2; mod collections; diff --git a/library/core/src/arch.rs b/library/core/src/arch.rs index 92ff55ecc75c0..570427f508554 100644 --- a/library/core/src/arch.rs +++ b/library/core/src/arch.rs @@ -80,6 +80,8 @@ pub macro global_asm("assembly template", $(operands,)* $(options($(option),*))? /// - On aarch64 targets, this produces a `brk #0xf000` instruction. // When adding more items above, also add cases to the test in `tests/assembly-llvm/breakpoint.rs`. // When stabilizing this, update the comment on `core::intrinsics::breakpoint`. +// NOTE: there is an alternative in `process::resumable_breakpoint`. We may or may not +// actually want to stabilize both of them. #[unstable(feature = "breakpoint", issue = "133724")] #[inline(always)] pub fn breakpoint() { diff --git a/library/core/src/bstr/mod.rs b/library/core/src/byte_str/mod.rs similarity index 85% rename from library/core/src/bstr/mod.rs rename to library/core/src/byte_str/mod.rs index 0530ddc292a99..9ce00b813b6d8 100644 --- a/library/core/src/bstr/mod.rs +++ b/library/core/src/byte_str/mod.rs @@ -2,7 +2,7 @@ mod traits; -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] pub use traits::{impl_partial_eq, impl_partial_eq_n, impl_partial_eq_ord}; use crate::borrow::{Borrow, BorrowMut}; @@ -17,7 +17,7 @@ use crate::ops::{Deref, DerefMut, DerefPure}; /// need to round-trip whatever data the user provides. /// /// For an owned, growable byte string buffer, use -/// [`ByteString`](../../std/bstr/struct.ByteString.html). +/// [`ByteString`](../../std/byte_str/struct.ByteString.html). /// /// `ByteStr` implements `Deref` to `[u8]`, so all methods available on `[u8]` are available on /// `ByteStr`. @@ -37,7 +37,7 @@ use crate::ops::{Deref, DerefMut, DerefPure}; /// /// The `Display` implementation behaves as if the `ByteStr` were first lossily converted to a /// `str`, with invalid UTF-8 presented as the Unicode replacement character (�). -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_has_incoherent_inherent_impls] #[repr(transparent)] #[doc(alias = "BStr")] @@ -53,8 +53,8 @@ impl ByteStr { /// You can create a `ByteStr` from a byte array, a byte slice or a string slice: /// /// ``` - /// # #![feature(bstr)] - /// # use std::bstr::ByteStr; + /// # #![feature(byte_str)] + /// # use std::byte_str::ByteStr; /// let a = ByteStr::new(b"abc"); /// let b = ByteStr::new(&b"abc"[..]); /// let c = ByteStr::new("abc"); @@ -63,7 +63,7 @@ impl ByteStr { /// assert_eq!(a, c); /// ``` #[inline] - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] pub const fn new>(bytes: &B) -> &Self { ByteStr::from_bytes(bytes.as_ref()) @@ -76,7 +76,7 @@ impl ByteStr { /// for example `Box` or `Arc`. #[inline] // #[unstable(feature = "str_as_str", issue = "130366")] - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] pub const fn as_byte_str(&self) -> &ByteStr { self } @@ -88,15 +88,15 @@ impl ByteStr { /// for example `Box` or `MutexGuard`. #[inline] // #[unstable(feature = "str_as_str", issue = "130366")] - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] pub const fn as_mut_byte_str(&mut self) -> &mut ByteStr { self } #[doc(hidden)] - #[unstable(feature = "bstr_internals", issue = "none")] + #[unstable(feature = "byte_str_internals", issue = "none")] #[inline] - #[rustc_const_unstable(feature = "bstr_internals", issue = "none")] + #[rustc_const_unstable(feature = "byte_str_internals", issue = "none")] pub const fn from_bytes(slice: &[u8]) -> &Self { // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to // the wrapped type into a reference to the wrapper type. @@ -104,9 +104,9 @@ impl ByteStr { } #[doc(hidden)] - #[unstable(feature = "bstr_internals", issue = "none")] + #[unstable(feature = "byte_str_internals", issue = "none")] #[inline] - #[rustc_const_unstable(feature = "bstr_internals", issue = "none")] + #[rustc_const_unstable(feature = "byte_str_internals", issue = "none")] pub const fn from_bytes_mut(slice: &mut [u8]) -> &mut Self { // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`, so we can turn a reference to // the wrapped type into a reference to the wrapper type. @@ -114,23 +114,23 @@ impl ByteStr { } #[doc(hidden)] - #[unstable(feature = "bstr_internals", issue = "none")] + #[unstable(feature = "byte_str_internals", issue = "none")] #[inline] - #[rustc_const_unstable(feature = "bstr_internals", issue = "none")] + #[rustc_const_unstable(feature = "byte_str_internals", issue = "none")] pub const fn as_bytes(&self) -> &[u8] { &self.0 } #[doc(hidden)] - #[unstable(feature = "bstr_internals", issue = "none")] + #[unstable(feature = "byte_str_internals", issue = "none")] #[inline] - #[rustc_const_unstable(feature = "bstr_internals", issue = "none")] + #[rustc_const_unstable(feature = "byte_str_internals", issue = "none")] pub const fn as_bytes_mut(&mut self) -> &mut [u8] { &mut self.0 } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl Deref for ByteStr { type Target = [u8]; @@ -141,7 +141,7 @@ const impl Deref for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl DerefMut for ByteStr { #[inline] @@ -153,7 +153,7 @@ const impl DerefMut for ByteStr { #[unstable(feature = "deref_pure_trait", issue = "87121")] unsafe impl DerefPure for ByteStr {} -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl fmt::Debug for ByteStr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "\"")?; @@ -172,7 +172,7 @@ impl fmt::Debug for ByteStr { } } -#[unstable(feature = "bstr_to_string", issue = "134915")] +#[unstable(feature = "byte_str_to_string", issue = "134915")] impl fmt::Display for ByteStr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn emit(byte_str: &ByteStr, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -257,7 +257,7 @@ impl fmt::Display for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl AsRef<[u8]> for ByteStr { #[inline] @@ -266,7 +266,7 @@ const impl AsRef<[u8]> for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl AsRef for ByteStr { #[inline] @@ -277,7 +277,7 @@ const impl AsRef for ByteStr { // `impl AsRef for [u8]` omitted to avoid widespread inference failures -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl AsRef for str { #[inline] @@ -286,7 +286,7 @@ const impl AsRef for str { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl AsMut<[u8]> for ByteStr { #[inline] @@ -301,7 +301,7 @@ const impl AsMut<[u8]> for ByteStr { // `impl Borrow for str` omitted to avoid widespread inference failures -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl Borrow<[u8]> for ByteStr { #[inline] @@ -312,7 +312,7 @@ const impl Borrow<[u8]> for ByteStr { // `impl BorrowMut for [u8]` omitted to avoid widespread inference failures -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl BorrowMut<[u8]> for ByteStr { #[inline] @@ -321,14 +321,14 @@ const impl BorrowMut<[u8]> for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> Default for &'a ByteStr { fn default() -> Self { ByteStr::from_bytes(b"") } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl<'a> Default for &'a mut ByteStr { fn default() -> Self { ByteStr::from_bytes_mut(&mut []) @@ -337,7 +337,7 @@ impl<'a> Default for &'a mut ByteStr { // Omitted due to inference failures // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a, const N: usize> From<&'a [u8; N]> for &'a ByteStr { // #[inline] // fn from(s: &'a [u8; N]) -> Self { @@ -345,7 +345,7 @@ impl<'a> Default for &'a mut ByteStr { // } // } // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a> From<&'a [u8]> for &'a ByteStr { // #[inline] // fn from(s: &'a [u8]) -> Self { @@ -355,7 +355,7 @@ impl<'a> Default for &'a mut ByteStr { // Omitted due to slice-from-array-issue-113238: // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a> From<&'a ByteStr> for &'a [u8] { // #[inline] // fn from(s: &'a ByteStr) -> Self { @@ -363,7 +363,7 @@ impl<'a> Default for &'a mut ByteStr { // } // } // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a> From<&'a mut ByteStr> for &'a mut [u8] { // #[inline] // fn from(s: &'a mut ByteStr) -> Self { @@ -373,7 +373,7 @@ impl<'a> Default for &'a mut ByteStr { // Omitted due to inference failures // -// #[unstable(feature = "bstr", issue = "134915")] +// #[unstable(feature = "byte_str", issue = "134915")] // impl<'a> From<&'a str> for &'a ByteStr { // #[inline] // fn from(s: &'a str) -> Self { @@ -381,7 +381,7 @@ impl<'a> Default for &'a mut ByteStr { // } // } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl<'a> TryFrom<&'a ByteStr> for &'a str { type Error = crate::str::Utf8Error; @@ -392,7 +392,7 @@ const impl<'a> TryFrom<&'a ByteStr> for &'a str { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_convert", issue = "143773")] const impl<'a> TryFrom<&'a mut ByteStr> for &'a mut str { type Error = crate::str::Utf8Error; diff --git a/library/core/src/bstr/traits.rs b/library/core/src/byte_str/traits.rs similarity index 86% rename from library/core/src/bstr/traits.rs rename to library/core/src/byte_str/traits.rs index 6e9d836f1a1ff..93370ed7b0346 100644 --- a/library/core/src/bstr/traits.rs +++ b/library/core/src/byte_str/traits.rs @@ -1,11 +1,11 @@ //! Trait implementations for `ByteStr`. -use crate::bstr::ByteStr; +use crate::byte_str::ByteStr; use crate::cmp::Ordering; use crate::slice::SliceIndex; use crate::{hash, ops, range}; -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl Ord for ByteStr { #[inline] @@ -14,7 +14,7 @@ const impl Ord for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl PartialOrd for ByteStr { #[inline] @@ -23,7 +23,7 @@ const impl PartialOrd for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl PartialEq for ByteStr { #[inline] @@ -32,11 +32,11 @@ const impl PartialEq for ByteStr { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] #[rustc_const_unstable(feature = "const_cmp", issue = "143800")] const impl Eq for ByteStr {} -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl hash::Hash for ByteStr { #[inline] fn hash(&self, state: &mut H) { @@ -46,7 +46,7 @@ impl hash::Hash for ByteStr { #[doc(hidden)] #[macro_export] -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] macro_rules! impl_partial_eq { ($lhs:ty, $rhs:ty) => { impl PartialEq<$rhs> for $lhs { @@ -68,17 +68,17 @@ macro_rules! impl_partial_eq { } #[doc(hidden)] -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] pub use impl_partial_eq; #[doc(hidden)] #[macro_export] -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] macro_rules! impl_partial_eq_ord { ($lhs:ty, $rhs:ty) => { - $crate::bstr::impl_partial_eq!($lhs, $rhs); + $crate::byte_str::impl_partial_eq!($lhs, $rhs); - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialOrd<$rhs> for $lhs { #[inline] fn partial_cmp(&self, other: &$rhs) -> Option { @@ -87,7 +87,7 @@ macro_rules! impl_partial_eq_ord { } } - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialOrd<$lhs> for $rhs { #[inline] fn partial_cmp(&self, other: &$lhs) -> Option { @@ -99,15 +99,15 @@ macro_rules! impl_partial_eq_ord { } #[doc(hidden)] -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] pub use impl_partial_eq_ord; #[doc(hidden)] #[macro_export] -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] macro_rules! impl_partial_eq_n { ($lhs:ty, $rhs:ty) => { - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialEq<$rhs> for $lhs { #[inline] fn eq(&self, other: &$rhs) -> bool { @@ -116,7 +116,7 @@ macro_rules! impl_partial_eq_n { } } - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] impl PartialEq<$lhs> for $rhs { #[inline] fn eq(&self, other: &$lhs) -> bool { @@ -128,7 +128,7 @@ macro_rules! impl_partial_eq_n { } #[doc(hidden)] -#[unstable(feature = "bstr_internals", issue = "none")] +#[unstable(feature = "byte_str_internals", issue = "none")] pub use impl_partial_eq_n; // PartialOrd with `[u8]` omitted to avoid inference failures @@ -144,7 +144,7 @@ impl_partial_eq_n!(ByteStr, [u8; N]); // PartialOrd with `[u8; N]` omitted to avoid inference failures impl_partial_eq_n!(ByteStr, &[u8; N]); -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl ops::Index for ByteStr where I: SliceIndex, @@ -157,7 +157,7 @@ where } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] impl ops::IndexMut for ByteStr where I: SliceIndex, @@ -168,7 +168,7 @@ where } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] unsafe impl SliceIndex for ops::RangeFull { type Output = ByteStr; #[inline] @@ -197,7 +197,7 @@ unsafe impl SliceIndex for ops::RangeFull { } } -#[unstable(feature = "bstr", issue = "134915")] +#[unstable(feature = "byte_str", issue = "134915")] unsafe impl SliceIndex for usize { type Output = u8; #[inline] @@ -230,7 +230,7 @@ unsafe impl SliceIndex for usize { macro_rules! impl_slice_index { ($index:ty) => { - #[unstable(feature = "bstr", issue = "134915")] + #[unstable(feature = "byte_str", issue = "134915")] unsafe impl SliceIndex for $index { type Output = ByteStr; #[inline] diff --git a/library/core/src/clone.rs b/library/core/src/clone.rs index bd6d929c6d2b0..61528873a38c7 100644 --- a/library/core/src/clone.rs +++ b/library/core/src/clone.rs @@ -686,8 +686,8 @@ unsafe impl CloneToUninit for crate::ffi::CStr { } } -#[unstable(feature = "bstr", issue = "134915")] -unsafe impl CloneToUninit for crate::bstr::ByteStr { +#[unstable(feature = "byte_str", issue = "134915")] +unsafe impl CloneToUninit for crate::byte_str::ByteStr { #[inline] #[cfg_attr(debug_assertions, track_caller)] unsafe fn clone_to_uninit(&self, dst: *mut u8) { diff --git a/library/core/src/ffi/c_str.rs b/library/core/src/ffi/c_str.rs index daa68e885d893..8dcabacd2c7fd 100644 --- a/library/core/src/ffi/c_str.rs +++ b/library/core/src/ffi/c_str.rs @@ -173,7 +173,7 @@ impl fmt::Display for FromBytesUntilNulError { #[stable(feature = "cstr_debug", since = "1.3.0")] impl fmt::Debug for CStr { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(crate::bstr::ByteStr::from_bytes(self.to_bytes()), f) + fmt::Debug::fmt(crate::byte_str::ByteStr::from_bytes(self.to_bytes()), f) } } @@ -889,6 +889,6 @@ impl fmt::Debug for Display<'_> { #[stable(feature = "cstr_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(crate::bstr::ByteStr::from_bytes(self.c_str.to_bytes()), f) + fmt::Display::fmt(crate::byte_str::ByteStr::from_bytes(self.c_str.to_bytes()), f) } } diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index ff63e10a67d58..4974f62f15bcd 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -86,7 +86,7 @@ // Library features: // tidy-alphabetical-start #![feature(asm_experimental_arch)] -#![feature(bstr_internals)] +#![feature(byte_str_internals)] #![feature(cfg_target_has_reliable_f16_f128)] #![feature(const_carrying_mul_add)] #![feature(const_cmp)] @@ -295,8 +295,8 @@ pub mod ascii; pub mod asserting; #[unstable(feature = "async_iterator", issue = "79024")] pub mod async_iter; -#[unstable(feature = "bstr", issue = "134915")] -pub mod bstr; +#[unstable(feature = "byte_str", issue = "134915")] +pub mod byte_str; pub mod cell; pub mod char; pub mod ffi; diff --git a/library/core/src/process.rs b/library/core/src/process.rs index 1c2769f07895b..e92339f34d68e 100644 --- a/library/core/src/process.rs +++ b/library/core/src/process.rs @@ -42,3 +42,22 @@ pub const fn abort_immediate() -> ! { crate::intrinsics::abort_immediate() } + +/// Triggers a debugger breakpoint, pausing execution if possible. +/// +/// This signals the environment to pause execution if a debugger is attached, and pass control to +/// the debugger. Execution may then be aborted or continued by the user controlling the debugger. +/// +/// If possible, this will produce an instruction sequence that allows a debugger to resume *after* +/// the breakpoint, rather than resuming *at* the breakpoint; however, the exact behavior is +/// target-specific and debugger-specific, and not guaranteed. +/// +/// If no debugger is attached, this will typically abort the process but may also continue +/// execution. +// NOTE: this is meant to discuss alternatives to `arch::breakpoint`. We may or may not +// actually want to stabilize both of them. +#[unstable(feature = "breakpoint", issue = "133724")] +#[inline(always)] +pub fn resumable_breakpoint() { + crate::intrinsics::breakpoint(); +} diff --git a/library/coretests/tests/bstr.rs b/library/coretests/tests/byte_str.rs similarity index 99% rename from library/coretests/tests/bstr.rs rename to library/coretests/tests/byte_str.rs index dffc7e3f03494..bc90b348446bf 100644 --- a/library/coretests/tests/bstr.rs +++ b/library/coretests/tests/byte_str.rs @@ -1,4 +1,4 @@ -use core::bstr::ByteStr; +use core::byte_str::ByteStr; #[test] fn test_debug() { diff --git a/library/coretests/tests/lib.rs b/library/coretests/tests/lib.rs index 1fdb0c820d662..9054f9331f7bf 100644 --- a/library/coretests/tests/lib.rs +++ b/library/coretests/tests/lib.rs @@ -10,7 +10,7 @@ #![feature(async_iterator)] #![feature(atomic_volatile)] #![feature(borrowed_buf_init)] -#![feature(bstr)] +#![feature(byte_str)] #![feature(casefold)] #![feature(cfg_overflow_checks)] #![feature(cfg_target_has_reliable_f16_f128)] @@ -179,7 +179,7 @@ mod asserting; mod async_iter; mod atomic; mod bool; -mod bstr; +mod byte_str; mod cell; mod char; mod clone; diff --git a/library/std/src/bstr.rs b/library/std/src/bstr.rs deleted file mode 100644 index dd49177162833..0000000000000 --- a/library/std/src/bstr.rs +++ /dev/null @@ -1,4 +0,0 @@ -//! The `ByteStr` and `ByteString` types and trait implementations. - -#[unstable(feature = "bstr", issue = "134915")] -pub use alloc::bstr::{ByteStr, ByteString}; diff --git a/library/std/src/byte_str.rs b/library/std/src/byte_str.rs new file mode 100644 index 0000000000000..48703b52ece21 --- /dev/null +++ b/library/std/src/byte_str.rs @@ -0,0 +1,4 @@ +//! The `ByteStr` and `ByteString` types and trait implementations. + +#[unstable(feature = "byte_str", issue = "134915")] +pub use alloc::byte_str::{ByteStr, ByteString}; diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 773049d0ff6c4..0d0d9e0759d82 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -317,8 +317,8 @@ // Library features (core): // tidy-alphabetical-start #![feature(borrowed_buf_init)] -#![feature(bstr)] -#![feature(bstr_internals)] +#![feature(byte_str)] +#![feature(byte_str_internals)] #![feature(c_size_t)] #![feature(can_vector)] #![feature(cast_maybe_uninit)] @@ -625,8 +625,8 @@ pub mod f64; pub mod thread; pub mod ascii; pub mod backtrace; -#[unstable(feature = "bstr", issue = "134915")] -pub mod bstr; +#[unstable(feature = "byte_str", issue = "134915")] +pub mod byte_str; pub mod collections; pub mod env; pub mod error; diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index 0520da62ffae9..b03b359cdea91 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -1,4 +1,4 @@ -use crate::bstr::ByteStr; +use crate::byte_str::ByteStr; use crate::ffi::OsStr; #[cfg(any(doc, target_os = "android", target_os = "linux", target_os = "cygwin"))] use crate::os::net::linux_ext; diff --git a/library/std/src/os/windows/net/addr.rs b/library/std/src/os/windows/net/addr.rs index c330432039a8f..5f6b93e56e723 100644 --- a/library/std/src/os/windows/net/addr.rs +++ b/library/std/src/os/windows/net/addr.rs @@ -1,5 +1,5 @@ #![unstable(feature = "windows_unix_domain_sockets", issue = "150487")] -use crate::bstr::ByteStr; +use crate::byte_str::ByteStr; use crate::ffi::OsStr; use crate::path::Path; #[cfg(not(doc))] diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs index 048e5def1369b..040a9568ca1f6 100644 --- a/library/std/src/sys/os_str/bytes.rs +++ b/library/std/src/sys/os_str/bytes.rs @@ -4,7 +4,7 @@ use core::clone::CloneToUninit; use crate::borrow::Cow; -use crate::bstr::ByteStr; +use crate::byte_str::ByteStr; use crate::collections::TryReserveError; use crate::rc::Rc; use crate::sync::Arc; diff --git a/library/std/src/sys/platform_version/darwin/mod.rs b/library/std/src/sys/platform_version/darwin/mod.rs index 4756716452c88..7e82c04fce76c 100644 --- a/library/std/src/sys/platform_version/darwin/mod.rs +++ b/library/std/src/sys/platform_version/darwin/mod.rs @@ -3,7 +3,7 @@ use self::core_foundation::{ kCFPropertyListImmutable, kCFStringEncodingUTF8, }; use crate::borrow::Cow; -use crate::bstr::ByteStr; +use crate::byte_str::ByteStr; use crate::ffi::{CStr, c_char}; use crate::num::{NonZero, ParseIntError}; use crate::path::{Path, PathBuf}; diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 0d3870f456a07..e5187f7655940 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -51,7 +51,7 @@ const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[ ("alloc/slice/trait.Concat.html", &["#method.concat"]), ("alloc/slice/index.html", &["#method.concat", "#method.join"]), ("alloc/vec/struct.Vec.html", &["#method.sort_by_key", "#method.sort_by_cached_key"]), - ("alloc/bstr/struct.ByteStr.html", &[ + ("alloc/byte_str/struct.ByteStr.html", &[ "#method.to_ascii_uppercase", "#method.to_ascii_lowercase", "core/slice::sort_by_key", @@ -59,7 +59,7 @@ const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[ "#method.sort_by_cached_key", "#method.sort_by_key" ]), - ("alloc/bstr/struct.ByteString.html", &[ + ("alloc/byte_str/struct.ByteString.html", &[ "#method.to_ascii_uppercase", "#method.to_ascii_lowercase", "core/slice::sort_by_key", @@ -67,11 +67,11 @@ const LINKCHECK_EXCEPTIONS: &[(&str, &[&str])] = &[ "#method.sort_by_cached_key", "#method.sort_by_key" ]), - ("core/bstr/struct.ByteStr.html", &[ + ("core/byte_str/struct.ByteStr.html", &[ "#method.to_ascii_uppercase", "#method.to_ascii_lowercase", - "core/bstr/slice::sort_by_key", - "core\\bstr\\slice::sort_by_key", + "core/byte_str/slice::sort_by_key", + "core\\byte_str\\slice::sort_by_key", "#method.sort_by_cached_key" ]), ("core/primitive.str.html", &["#method.to_ascii_uppercase", "#method.to_ascii_lowercase"]), diff --git a/src/tools/miri/src/helpers.rs b/src/tools/miri/src/helpers.rs index f923d5529c6b9..26f2a8a459f79 100644 --- a/src/tools/miri/src/helpers.rs +++ b/src/tools/miri/src/helpers.rs @@ -421,9 +421,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { None => MPlaceTy::fake_alloc_zst(this.machine.layouts.unit), }; + let with_caller_location = f.def.requires_caller_location(*this.tcx); + // Construct a function pointer type representing the caller perspective. let sig = this.tcx.mk_fn_sig( - args.iter().map(|a| a.layout.ty), + args.iter() + .map(|a| a.layout.ty) + .chain(with_caller_location.then(|| this.tcx.caller_location_ty())), dest.layout.ty, // FIXME(splat): Do we need to set splatted here? // (Currently this also ignores c_variadic) @@ -437,7 +441,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { mir, caller_fn_abi, &args.iter().map(|a| FnArg::Copy(a.clone().into())).collect::>(), - /*with_caller_location*/ false, + with_caller_location, &dest.into(), cont, ) diff --git a/src/tools/miri/tests/fail/extern-extra-track-caller.rs b/src/tools/miri/tests/fail/extern-extra-track-caller.rs new file mode 100644 index 0000000000000..0396399f9d825 --- /dev/null +++ b/src/tools/miri/tests/fail/extern-extra-track-caller.rs @@ -0,0 +1,15 @@ +unsafe extern "Rust" { + #[track_caller] + safe fn foo(); +} + +fn main() { + foo(); //~ERROR: calling a non-`#[track_caller]` function from a `#[track_caller]` declaration +} + +mod module { + #[unsafe(no_mangle)] + fn foo() { + panic!(); + } +} diff --git a/src/tools/miri/tests/fail/extern-extra-track-caller.stderr b/src/tools/miri/tests/fail/extern-extra-track-caller.stderr new file mode 100644 index 0000000000000..c5c45a2ddca58 --- /dev/null +++ b/src/tools/miri/tests/fail/extern-extra-track-caller.stderr @@ -0,0 +1,13 @@ +error: Undefined Behavior: calling a non-`#[track_caller]` function from a `#[track_caller]` declaration + --> tests/fail/extern-extra-track-caller.rs:LL:CC + | +LL | foo(); + | ^^^^^ Undefined Behavior occurred here + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/src/tools/miri/tests/fail/extern-missing-track-caller.rs b/src/tools/miri/tests/fail/extern-missing-track-caller.rs new file mode 100644 index 0000000000000..a10bb03670ec1 --- /dev/null +++ b/src/tools/miri/tests/fail/extern-missing-track-caller.rs @@ -0,0 +1,15 @@ +unsafe extern "Rust" { + safe fn foo(); +} + +fn main() { + foo(); //~ERROR: calling a `#[track_caller]` function from a non-`#[track_caller]` declaration +} + +mod module { + #[unsafe(no_mangle)] + #[track_caller] + fn foo() { + panic!(); + } +} diff --git a/src/tools/miri/tests/fail/extern-missing-track-caller.stderr b/src/tools/miri/tests/fail/extern-missing-track-caller.stderr new file mode 100644 index 0000000000000..40d0c8165728f --- /dev/null +++ b/src/tools/miri/tests/fail/extern-missing-track-caller.stderr @@ -0,0 +1,13 @@ +error: Undefined Behavior: calling a `#[track_caller]` function from a non-`#[track_caller]` declaration + --> tests/fail/extern-missing-track-caller.rs:LL:CC + | +LL | foo(); + | ^^^^^ Undefined Behavior occurred here + | + = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior + = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information + +note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace + +error: aborting due to 1 previous error + diff --git a/tests/crashes/131787.rs b/tests/crashes/131787.rs deleted file mode 100644 index 5c24ff8c14303..0000000000000 --- a/tests/crashes/131787.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ known-bug: #131787 -#[track_caller] -static no_mangle: u32 = { - unimplemented!(); -}; diff --git a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs index f9e01cd1507ec..4f3f4993648cb 100644 --- a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs +++ b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs @@ -4,4 +4,4 @@ fn main() {} #[track_caller] //~ ERROR attribute cannot be used on -static _A: () = (); +static _A: () = panic!(); diff --git a/tests/ui/indexing/index-help.stderr b/tests/ui/indexing/index-help.stderr index 65faaec41258e..d40d511ab5a2f 100644 --- a/tests/ui/indexing/index-help.stderr +++ b/tests/ui/indexing/index-help.stderr @@ -9,7 +9,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `Vec<{integer}>` to implement `Index` diff --git a/tests/ui/indexing/indexing-integral-types.stderr b/tests/ui/indexing/indexing-integral-types.stderr index 604161325afcb..9577444703f83 100644 --- a/tests/ui/indexing/indexing-integral-types.stderr +++ b/tests/ui/indexing/indexing-integral-types.stderr @@ -9,7 +9,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `Vec` to implement `Index` @@ -25,7 +25,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `Vec` to implement `Index` @@ -41,7 +41,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `Vec` to implement `Index` @@ -57,7 +57,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `Vec` to implement `Index` @@ -73,7 +73,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[u8]` to implement `Index` @@ -89,7 +89,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[u8]` to implement `Index` @@ -105,7 +105,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[u8]` to implement `Index` @@ -121,7 +121,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[u8]` to implement `Index` diff --git a/tests/ui/indexing/indexing-requires-a-uint.stderr b/tests/ui/indexing/indexing-requires-a-uint.stderr index 9e974c8c9bbcc..5c93fcd948a24 100644 --- a/tests/ui/indexing/indexing-requires-a-uint.stderr +++ b/tests/ui/indexing/indexing-requires-a-uint.stderr @@ -9,7 +9,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[{integer}]` to implement `Index` diff --git a/tests/ui/on-unimplemented/slice-index.stderr b/tests/ui/on-unimplemented/slice-index.stderr index 61d4866f5618b..a5a3d8c000e76 100644 --- a/tests/ui/on-unimplemented/slice-index.stderr +++ b/tests/ui/on-unimplemented/slice-index.stderr @@ -9,7 +9,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[i32]` to implement `Index` @@ -25,10 +25,10 @@ help: `RangeTo` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` - ::: $SRC_DIR/core/src/bstr/traits.rs:LL:COL + ::: $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: in this macro invocation --> $SRC_DIR/core/src/str/traits.rs:LL:COL diff --git a/tests/ui/str/str-idx.stderr b/tests/ui/str/str-idx.stderr index 84f698a6e6625..b515a2e9dfb76 100644 --- a/tests/ui/str/str-idx.stderr +++ b/tests/ui/str/str-idx.stderr @@ -11,7 +11,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `str` to implement `Index<{integer}>` @@ -31,7 +31,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` note: required by a bound in `core::str::::get` @@ -52,7 +52,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` note: required by a bound in `core::str::::get_unchecked` diff --git a/tests/ui/str/str-mut-idx.stderr b/tests/ui/str/str-mut-idx.stderr index 87b78915075d2..89582c437c917 100644 --- a/tests/ui/str/str-mut-idx.stderr +++ b/tests/ui/str/str-mut-idx.stderr @@ -35,7 +35,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `str` to implement `Index` @@ -55,7 +55,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` note: required by a bound in `core::str::::get_mut` @@ -76,7 +76,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` note: required by a bound in `core::str::::get_unchecked_mut` diff --git a/tests/ui/suggestions/suggest-dereferencing-index.stderr b/tests/ui/suggestions/suggest-dereferencing-index.stderr index cee5ffcb2ae8c..7bf3b4ffaf275 100644 --- a/tests/ui/suggestions/suggest-dereferencing-index.stderr +++ b/tests/ui/suggestions/suggest-dereferencing-index.stderr @@ -9,7 +9,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[{integer}]` to implement `Index<&usize>` diff --git a/tests/ui/suggestions/suggest-remove-reference-index.stderr b/tests/ui/suggestions/suggest-remove-reference-index.stderr index 4f396fe529508..f435dfa54db06 100644 --- a/tests/ui/suggestions/suggest-remove-reference-index.stderr +++ b/tests/ui/suggestions/suggest-remove-reference-index.stderr @@ -9,7 +9,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[bool]` to implement `Index<&usize>` @@ -30,7 +30,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[bool]` to implement `Index<&usize>` @@ -51,7 +51,7 @@ help: `usize` implements trait `SliceIndex` --> $SRC_DIR/core/src/slice/index.rs:LL:COL | = note: `SliceIndex<[T]>` - --> $SRC_DIR/core/src/bstr/traits.rs:LL:COL + --> $SRC_DIR/core/src/byte_str/traits.rs:LL:COL | = note: `SliceIndex` = note: required for `[bool]` to implement `Index<&usize>`