Skip to content

Commit 5d2d11f

Browse files
committed
Rename ClearCrossCrate::assert_crate_local.
As `unwrap_crate_local`, because it follows exactly the standard form of an `unwrap` function.
1 parent 2f695dc commit 5d2d11f

File tree

12 files changed

+15
-15
lines changed

12 files changed

+15
-15
lines changed

compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ impl<T> ClearCrossCrate<T> {
780780
}
781781
}
782782

783-
pub fn assert_crate_local(self) -> T {
783+
pub fn unwrap_crate_local(self) -> T {
784784
match self {
785785
ClearCrossCrate::Clear => bug!("unwrapping cross-crate data"),
786786
ClearCrossCrate::Set(v) => v,
@@ -1094,7 +1094,7 @@ pub enum LocalInfo<'tcx> {
10941094

10951095
impl<'tcx> LocalDecl<'tcx> {
10961096
pub fn local_info(&self) -> &LocalInfo<'tcx> {
1097-
self.local_info.as_ref().assert_crate_local()
1097+
self.local_info.as_ref().unwrap_crate_local()
10981098
}
10991099

11001100
/// Returns `true` only if local is a binding that can itself be

compiler/rustc_mir_build/src/builder/expr/as_operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
142142
// Overwrite temp local info if we have something more interesting to record.
143143
if !matches!(local_info, LocalInfo::Boring) {
144144
let decl_info =
145-
this.local_decls[operand].local_info.as_mut().assert_crate_local();
145+
this.local_decls[operand].local_info.as_mut().unwrap_crate_local();
146146
if let LocalInfo::Boring | LocalInfo::BlockTailTemp(_) = **decl_info {
147147
**decl_info = local_info;
148148
}

compiler/rustc_mir_build/src/builder/expr/as_temp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
8585

8686
_ => LocalInfo::Boring,
8787
};
88-
**local_decl.local_info.as_mut().assert_crate_local() = local_info;
88+
**local_decl.local_info.as_mut().unwrap_crate_local() = local_info;
8989
this.local_decls.push(local_decl)
9090
};
9191
debug!(?temp);

compiler/rustc_mir_build/src/builder/matches/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
722722
if let LocalInfo::User(BindingForm::Var(VarBindingForm {
723723
opt_match_place: Some((ref mut match_place, _)),
724724
..
725-
})) = **self.local_decls[local].local_info.as_mut().assert_crate_local()
725+
})) = **self.local_decls[local].local_info.as_mut().unwrap_crate_local()
726726
{
727727
*match_place = Some(place);
728728
} else {

compiler/rustc_mir_build/src/builder/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
967967
} => {
968968
self.local_decls[local].mutability = mutability;
969969
self.local_decls[local].source_info.scope = self.source_scope;
970-
**self.local_decls[local].local_info.as_mut().assert_crate_local() =
970+
**self.local_decls[local].local_info.as_mut().unwrap_crate_local() =
971971
if let Some(kind) = param.self_kind {
972972
LocalInfo::User(BindingForm::ImplicitSelf(kind))
973973
} else {
@@ -1032,7 +1032,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
10321032
let parent_id = self.source_scopes[original_source_scope]
10331033
.local_data
10341034
.as_ref()
1035-
.assert_crate_local()
1035+
.unwrap_crate_local()
10361036
.lint_root;
10371037
self.maybe_new_source_scope(pattern_span, arg_hir_id, parent_id);
10381038
}

compiler/rustc_mir_build/src/builder/scope.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
604604
let source_scope = self.source_scope;
605605
if let LintLevel::Explicit(current_hir_id) = lint_level {
606606
let parent_id =
607-
self.source_scopes[source_scope].local_data.as_ref().assert_crate_local().lint_root;
607+
self.source_scopes[source_scope].local_data.as_ref().unwrap_crate_local().lint_root;
608608
self.maybe_new_source_scope(region_scope.1.span, current_hir_id, parent_id);
609609
}
610610
self.push_scope(region_scope);
@@ -992,7 +992,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
992992
lint_root: if let LintLevel::Explicit(lint_root) = lint_level {
993993
lint_root
994994
} else {
995-
self.source_scopes[parent].local_data.as_ref().assert_crate_local().lint_root
995+
self.source_scopes[parent].local_data.as_ref().unwrap_crate_local().lint_root
996996
},
997997
};
998998
self.source_scopes.push(SourceScopeData {

compiler/rustc_mir_transform/src/check_const_item_mutation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> {
7979
let lint_root = self.body.source_scopes[source_info.scope]
8080
.local_data
8181
.as_ref()
82-
.assert_crate_local()
82+
.unwrap_crate_local()
8383
.lint_root;
8484

8585
Some((lint_root, source_info.span, self.tcx.def_span(const_item)))

compiler/rustc_mir_transform/src/coroutine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ fn compute_layout<'tcx>(
945945
let decl = &body.local_decls[local];
946946
debug!(?decl);
947947

948-
// Do not `assert_crate_local` here, as post-borrowck cleanup may have already cleared
948+
// Do not `unwrap_crate_local` here, as post-borrowck cleanup may have already cleared
949949
// the information. This is alright, since `ignore_for_traits` is only relevant when
950950
// this code runs on pre-cleanup MIR, and `ignore_for_traits = false` is the safer
951951
// default.

compiler/rustc_mir_transform/src/ffi_unwind_calls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
8585
let lint_root = body.source_scopes[terminator.source_info.scope]
8686
.local_data
8787
.as_ref()
88-
.assert_crate_local()
88+
.unwrap_crate_local()
8989
.lint_root;
9090
let span = terminator.source_info.span;
9191

compiler/rustc_mir_transform/src/function_item_references.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
154154
let lint_root = self.body.source_scopes[source_info.scope]
155155
.local_data
156156
.as_ref()
157-
.assert_crate_local()
157+
.unwrap_crate_local()
158158
.lint_root;
159159
// FIXME: use existing printing routines to print the function signature
160160
let fn_sig = self.tcx.fn_sig(fn_id).instantiate(self.tcx, fn_args);

compiler/rustc_mir_transform/src/patch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl<'tcx> MirPatch<'tcx> {
158158
let index = self.next_local;
159159
self.next_local += 1;
160160
let mut new_decl = LocalDecl::new(ty, span);
161-
**new_decl.local_info.as_mut().assert_crate_local() = local_info;
161+
**new_decl.local_info.as_mut().unwrap_crate_local() = local_info;
162162
self.new_locals.push(new_decl);
163163
Local::new(index)
164164
}

src/tools/clippy/clippy_lints/src/redundant_clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
205205
let node = mir.source_scopes[scope]
206206
.local_data
207207
.as_ref()
208-
.assert_crate_local()
208+
.unwrap_crate_local()
209209
.lint_root;
210210

211211
if let Some(snip) = span.get_source_text(cx)

0 commit comments

Comments
 (0)