Skip to content

Commit e593120

Browse files
committed
Rename variant AddrOfRegion of RegionVariableOrigin to Borrow
because "Borrow" is the more idiomatic Rust term in Rust than "AddrOff". Also rename `PatternRegion` to just `Pattern` as the suffix "Region" is redundant (since the enum already has "Region" in it) as well inconsistent with other variants which don't have it in them
1 parent 59d4114 commit e593120

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
447447
// this time with enough precision to check that the value
448448
// whose address was taken can actually be made to live as long
449449
// as it needs to live.
450-
let region = self.next_region_var(infer::AddrOfRegion(expr.span));
450+
let region = self.next_region_var(infer::Borrow(expr.span));
451451
Ty::new_ref(self.tcx, region, ty, mutbl)
452452
}
453453
}

compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2270,7 +2270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22702270

22712271
/// Create a reference type with a fresh region variable.
22722272
fn new_ref_ty(&self, span: Span, mutbl: Mutability, ty: Ty<'tcx>) -> Ty<'tcx> {
2273-
let region = self.next_region_var(infer::PatternRegion(span));
2273+
let region = self.next_region_var(infer::Pattern(span));
22742274
Ty::new_ref(self.tcx, region, ty, mutbl)
22752275
}
22762276

compiler/rustc_infer/src/infer/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -455,11 +455,11 @@ pub enum RegionVariableOrigin {
455455
MiscVariable(Span),
456456

457457
/// Regions created by a `&P` or `[...]` pattern.
458-
PatternRegion(Span),
458+
Pattern(Span),
459459

460460
/// Regions created by `&` operator.
461-
///
462-
AddrOfRegion(Span),
461+
Borrow(Span),
462+
463463
/// Regions created as part of an autoref of a method receiver.
464464
Autoref(Span),
465465

@@ -1740,8 +1740,8 @@ impl RegionVariableOrigin {
17401740
pub fn span(&self) -> Span {
17411741
match *self {
17421742
MiscVariable(a)
1743-
| PatternRegion(a)
1744-
| AddrOfRegion(a)
1743+
| Pattern(a)
1744+
| Borrow(a)
17451745
| Autoref(a)
17461746
| Coercion(a)
17471747
| RegionParameterDefinition(a, ..)

compiler/rustc_trait_selection/src/error_reporting/infer/region.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
10171017
};
10181018
let var_description = match var_origin {
10191019
infer::MiscVariable(_) => String::new(),
1020-
infer::PatternRegion(_) => " for pattern".to_string(),
1021-
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
1020+
infer::Pattern(_) => " for pattern".to_string(),
1021+
infer::Borrow(_) => " for borrow expression".to_string(),
10221022
infer::Autoref(_) => " for autoref".to_string(),
10231023
infer::Coercion(_) => " for automatic coercion".to_string(),
10241024
infer::BoundRegion(_, br, infer::FnCall) => {

0 commit comments

Comments
 (0)