1
Fork 0

Remove BorrowKind glob, make names longer

This commit is contained in:
Michael Goulet 2024-11-03 22:02:31 +00:00
parent be4b0261c2
commit 883f8705d4
68 changed files with 289 additions and 288 deletions

View file

@ -10,7 +10,6 @@ use rustc_span::def_id::LocalDefIdMap;
use rustc_span::symbol::Ident;
use rustc_span::{Span, Symbol};
use self::BorrowKind::*;
use super::TyCtxt;
use crate::hir::place::{
Place as HirPlace, PlaceBase as HirPlaceBase, ProjectionKind as HirProjectionKind,
@ -334,7 +333,7 @@ pub fn place_to_string_for_capture<'tcx>(tcx: TyCtxt<'tcx>, place: &HirPlace<'tc
#[derive(TypeFoldable, TypeVisitable)]
pub enum BorrowKind {
/// Data must be immutable and is aliasable.
ImmBorrow,
Immutable,
/// Data must be immutable but not aliasable. This kind of borrow
/// cannot currently be expressed by the user and is used only in
@ -382,17 +381,17 @@ pub enum BorrowKind {
/// borrow, it's just used when translating closures.
///
/// FIXME: Rename this to indicate the borrow is actually not immutable.
UniqueImmBorrow,
UniqueImmutable,
/// Data is mutable and not aliasable.
MutBorrow,
Mutable,
}
impl BorrowKind {
pub fn from_mutbl(m: hir::Mutability) -> BorrowKind {
match m {
hir::Mutability::Mut => MutBorrow,
hir::Mutability::Not => ImmBorrow,
hir::Mutability::Mut => BorrowKind::Mutable,
hir::Mutability::Not => BorrowKind::Immutable,
}
}
@ -402,13 +401,13 @@ impl BorrowKind {
/// question.
pub fn to_mutbl_lossy(self) -> hir::Mutability {
match self {
MutBorrow => hir::Mutability::Mut,
ImmBorrow => hir::Mutability::Not,
BorrowKind::Mutable => hir::Mutability::Mut,
BorrowKind::Immutable => hir::Mutability::Not,
// We have no type corresponding to a unique imm borrow, so
// use `&mut`. It gives all the capabilities of a `&uniq`
// and hence is a safe "over approximation".
UniqueImmBorrow => hir::Mutability::Mut,
BorrowKind::UniqueImmutable => hir::Mutability::Mut,
}
}
}

View file

@ -55,7 +55,6 @@ use tracing::{debug, instrument};
pub use vtable::*;
use {rustc_ast as ast, rustc_attr as attr, rustc_hir as hir};
pub use self::BorrowKind::*;
pub use self::closure::{
BorrowKind, CAPTURE_STRUCT_LOCAL, CaptureInfo, CapturedPlace, ClosureTypeInfo,
MinCaptureInformationMap, MinCaptureList, RootVariableMinCaptureList, UpvarCapture, UpvarId,