Rename ClearCrossCrate::assert_crate_local
.
As `unwrap_crate_local`, because it follows exactly the standard form of an `unwrap` function.
This commit is contained in:
parent
2f695dc64e
commit
5d2d11fd5d
12 changed files with 15 additions and 15 deletions
|
@ -780,7 +780,7 @@ impl<T> ClearCrossCrate<T> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn assert_crate_local(self) -> T {
|
||||
pub fn unwrap_crate_local(self) -> T {
|
||||
match self {
|
||||
ClearCrossCrate::Clear => bug!("unwrapping cross-crate data"),
|
||||
ClearCrossCrate::Set(v) => v,
|
||||
|
@ -1094,7 +1094,7 @@ pub enum LocalInfo<'tcx> {
|
|||
|
||||
impl<'tcx> LocalDecl<'tcx> {
|
||||
pub fn local_info(&self) -> &LocalInfo<'tcx> {
|
||||
self.local_info.as_ref().assert_crate_local()
|
||||
self.local_info.as_ref().unwrap_crate_local()
|
||||
}
|
||||
|
||||
/// Returns `true` only if local is a binding that can itself be
|
||||
|
|
|
@ -142,7 +142,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// Overwrite temp local info if we have something more interesting to record.
|
||||
if !matches!(local_info, LocalInfo::Boring) {
|
||||
let decl_info =
|
||||
this.local_decls[operand].local_info.as_mut().assert_crate_local();
|
||||
this.local_decls[operand].local_info.as_mut().unwrap_crate_local();
|
||||
if let LocalInfo::Boring | LocalInfo::BlockTailTemp(_) = **decl_info {
|
||||
**decl_info = local_info;
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
|
||||
_ => LocalInfo::Boring,
|
||||
};
|
||||
**local_decl.local_info.as_mut().assert_crate_local() = local_info;
|
||||
**local_decl.local_info.as_mut().unwrap_crate_local() = local_info;
|
||||
this.local_decls.push(local_decl)
|
||||
};
|
||||
debug!(?temp);
|
||||
|
|
|
@ -722,7 +722,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
if let LocalInfo::User(BindingForm::Var(VarBindingForm {
|
||||
opt_match_place: Some((ref mut match_place, _)),
|
||||
..
|
||||
})) = **self.local_decls[local].local_info.as_mut().assert_crate_local()
|
||||
})) = **self.local_decls[local].local_info.as_mut().unwrap_crate_local()
|
||||
{
|
||||
*match_place = Some(place);
|
||||
} else {
|
||||
|
|
|
@ -967,7 +967,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
} => {
|
||||
self.local_decls[local].mutability = mutability;
|
||||
self.local_decls[local].source_info.scope = self.source_scope;
|
||||
**self.local_decls[local].local_info.as_mut().assert_crate_local() =
|
||||
**self.local_decls[local].local_info.as_mut().unwrap_crate_local() =
|
||||
if let Some(kind) = param.self_kind {
|
||||
LocalInfo::User(BindingForm::ImplicitSelf(kind))
|
||||
} else {
|
||||
|
@ -1032,7 +1032,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let parent_id = self.source_scopes[original_source_scope]
|
||||
.local_data
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.unwrap_crate_local()
|
||||
.lint_root;
|
||||
self.maybe_new_source_scope(pattern_span, arg_hir_id, parent_id);
|
||||
}
|
||||
|
|
|
@ -604,7 +604,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let source_scope = self.source_scope;
|
||||
if let LintLevel::Explicit(current_hir_id) = lint_level {
|
||||
let parent_id =
|
||||
self.source_scopes[source_scope].local_data.as_ref().assert_crate_local().lint_root;
|
||||
self.source_scopes[source_scope].local_data.as_ref().unwrap_crate_local().lint_root;
|
||||
self.maybe_new_source_scope(region_scope.1.span, current_hir_id, parent_id);
|
||||
}
|
||||
self.push_scope(region_scope);
|
||||
|
@ -992,7 +992,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
lint_root: if let LintLevel::Explicit(lint_root) = lint_level {
|
||||
lint_root
|
||||
} else {
|
||||
self.source_scopes[parent].local_data.as_ref().assert_crate_local().lint_root
|
||||
self.source_scopes[parent].local_data.as_ref().unwrap_crate_local().lint_root
|
||||
},
|
||||
};
|
||||
self.source_scopes.push(SourceScopeData {
|
||||
|
|
|
@ -79,7 +79,7 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> {
|
|||
let lint_root = self.body.source_scopes[source_info.scope]
|
||||
.local_data
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.unwrap_crate_local()
|
||||
.lint_root;
|
||||
|
||||
Some((lint_root, source_info.span, self.tcx.def_span(const_item)))
|
||||
|
|
|
@ -945,7 +945,7 @@ fn compute_layout<'tcx>(
|
|||
let decl = &body.local_decls[local];
|
||||
debug!(?decl);
|
||||
|
||||
// Do not `assert_crate_local` here, as post-borrowck cleanup may have already cleared
|
||||
// Do not `unwrap_crate_local` here, as post-borrowck cleanup may have already cleared
|
||||
// the information. This is alright, since `ignore_for_traits` is only relevant when
|
||||
// this code runs on pre-cleanup MIR, and `ignore_for_traits = false` is the safer
|
||||
// default.
|
||||
|
|
|
@ -85,7 +85,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
|
|||
let lint_root = body.source_scopes[terminator.source_info.scope]
|
||||
.local_data
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.unwrap_crate_local()
|
||||
.lint_root;
|
||||
let span = terminator.source_info.span;
|
||||
|
||||
|
|
|
@ -154,7 +154,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
|
|||
let lint_root = self.body.source_scopes[source_info.scope]
|
||||
.local_data
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.unwrap_crate_local()
|
||||
.lint_root;
|
||||
// FIXME: use existing printing routines to print the function signature
|
||||
let fn_sig = self.tcx.fn_sig(fn_id).instantiate(self.tcx, fn_args);
|
||||
|
|
|
@ -158,7 +158,7 @@ impl<'tcx> MirPatch<'tcx> {
|
|||
let index = self.next_local;
|
||||
self.next_local += 1;
|
||||
let mut new_decl = LocalDecl::new(ty, span);
|
||||
**new_decl.local_info.as_mut().assert_crate_local() = local_info;
|
||||
**new_decl.local_info.as_mut().unwrap_crate_local() = local_info;
|
||||
self.new_locals.push(new_decl);
|
||||
Local::new(index)
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
|
|||
let node = mir.source_scopes[scope]
|
||||
.local_data
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.unwrap_crate_local()
|
||||
.lint_root;
|
||||
|
||||
if let Some(snip) = span.get_source_text(cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue