Skip to content

Commit

Permalink
Rename variant AddrOfRegion of RegionVariableOrigin to Borrow
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gurry committed Sep 7, 2024
1 parent 59d4114 commit e593120
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// this time with enough precision to check that the value
// whose address was taken can actually be made to live as long
// as it needs to live.
let region = self.next_region_var(infer::AddrOfRegion(expr.span));
let region = self.next_region_var(infer::Borrow(expr.span));
Ty::new_ref(self.tcx, region, ty, mutbl)
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2270,7 +2270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

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

Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ pub enum RegionVariableOrigin {
MiscVariable(Span),

/// Regions created by a `&P` or `[...]` pattern.
PatternRegion(Span),
Pattern(Span),

/// Regions created by `&` operator.
///
AddrOfRegion(Span),
Borrow(Span),

/// Regions created as part of an autoref of a method receiver.
Autoref(Span),

Expand Down Expand Up @@ -1740,8 +1740,8 @@ impl RegionVariableOrigin {
pub fn span(&self) -> Span {
match *self {
MiscVariable(a)
| PatternRegion(a)
| AddrOfRegion(a)
| Pattern(a)
| Borrow(a)
| Autoref(a)
| Coercion(a)
| RegionParameterDefinition(a, ..)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,8 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
};
let var_description = match var_origin {
infer::MiscVariable(_) => String::new(),
infer::PatternRegion(_) => " for pattern".to_string(),
infer::AddrOfRegion(_) => " for borrow expression".to_string(),
infer::Pattern(_) => " for pattern".to_string(),
infer::Borrow(_) => " for borrow expression".to_string(),
infer::Autoref(_) => " for autoref".to_string(),
infer::Coercion(_) => " for automatic coercion".to_string(),
infer::BoundRegion(_, br, infer::FnCall) => {
Expand Down

0 comments on commit e593120

Please sign in to comment.