Rollup merge of #87000 - m-ou-se:const-panic-track-caller, r=oli-obk
Use #[track_caller] in const panic diagnostics. This change stops const panic diagnostics from reporting inside #[track_caller] functions by skipping over them.
This commit is contained in:
commit
2152c145d3
5 changed files with 53 additions and 17 deletions
|
@ -398,7 +398,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
|
||||
#[inline(always)]
|
||||
pub fn cur_span(&self) -> Span {
|
||||
self.stack().last().map_or(self.tcx.span, |f| f.current_span())
|
||||
self.stack()
|
||||
.iter()
|
||||
.rev()
|
||||
.find(|frame| !frame.instance.def.requires_caller_location(*self.tcx))
|
||||
.map_or(self.tcx.span, |f| f.current_span())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -927,7 +931,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
#[must_use]
|
||||
pub fn generate_stacktrace(&self) -> Vec<FrameInfo<'tcx>> {
|
||||
let mut frames = Vec::new();
|
||||
for frame in self.stack().iter().rev() {
|
||||
for frame in self
|
||||
.stack()
|
||||
.iter()
|
||||
.rev()
|
||||
.skip_while(|frame| frame.instance.def.requires_caller_location(*self.tcx))
|
||||
{
|
||||
let lint_root = frame.current_source_info().and_then(|source_info| {
|
||||
match &frame.body.source_scopes[source_info.scope].local_data {
|
||||
mir::ClearCrossCrate::Set(data) => Some(data.lint_root),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue