Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generating CTFE backtrace on optimized MIR #66203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ pub struct Body<'tcx> {

/// Crate-local information for each source scope, that can't (and
/// needn't) be tracked across crates.
///
/// Before optimizations run, every scope in `source_scopes` is guarnateed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*guaranteed

/// to have an entry in `source_scope_local_data` (assuming it is `ClearCrossCrate::Set`).
///
/// However, after optimizations are run, there may be some scopes with no entry
/// in `source_scope_local_data:`. This is due to the fact that MIR inlining can
/// cause scopes from a different crate to be inlined into this `Body`, which
/// cannot have crate-local data.
pub source_scope_local_data: ClearCrossCrate<IndexVec<SourceScope, SourceScopeLocalData>>,

/// The yield type of the function, if it is a generator.
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,12 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
block.terminator().source_info
};
match body.source_scope_local_data {
mir::ClearCrossCrate::Set(ref ivs) => Some(ivs[source_info.scope].lint_root),
// The scope may have been inlined from a different crate, in which
// case we will not have crate-local data for it. If that is the case,
// we just use our root lint level.
mir::ClearCrossCrate::Set(ref ivs) => {
ivs.get(source_info.scope).map(|d| d.lint_root)
}
mir::ClearCrossCrate::Clear => None,
}
});
Expand Down