Skip to content

Commit f82ba3b

Browse files
authored
Rollup merge of rust-lang#62964 - RalfJung:ty-tests, r=Centril
clarify and unify some type test names * `is_mutable_pointer`: use `ptr` suffix for consistency with `is_region_ptr`, `is_fn_ptr`, `is_unsafe_ptr`. * `is_pointer_sized`: the name is misleading as this only tests for pointer-sized *integers*, so rename to `is_ptr_sized_integral`.
2 parents b8dadb0 + 0576062 commit f82ba3b

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/librustc/ty/sty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ impl<'tcx> TyS<'tcx> {
18471847
}
18481848

18491849
#[inline]
1850-
pub fn is_mutable_pointer(&self) -> bool {
1850+
pub fn is_mutable_ptr(&self) -> bool {
18511851
match self.sty {
18521852
RawPtr(TypeAndMut { mutbl: hir::Mutability::MutMutable, .. }) |
18531853
Ref(_, _, hir::Mutability::MutMutable) => true,
@@ -2002,7 +2002,7 @@ impl<'tcx> TyS<'tcx> {
20022002
}
20032003

20042004
#[inline]
2005-
pub fn is_pointer_sized(&self) -> bool {
2005+
pub fn is_ptr_sized_integral(&self) -> bool {
20062006
match self.sty {
20072007
Int(ast::IntTy::Isize) | Uint(ast::UintTy::Usize) => true,
20082008
_ => false,

src/librustc_mir/borrow_check/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
536536
let base_ty = Place::ty_from(deref_base.base, deref_base.projection, self.body, tcx).ty;
537537
if base_ty.is_unsafe_ptr() {
538538
BorrowedContentSource::DerefRawPointer
539-
} else if base_ty.is_mutable_pointer() {
539+
} else if base_ty.is_mutable_ptr() {
540540
BorrowedContentSource::DerefMutableRef
541541
} else {
542542
BorrowedContentSource::DerefSharedRef

src/librustc_mir/borrow_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13291329
base: PlaceBase::Local(local),
13301330
projection: None,
13311331
}) if self.body.local_decls[local].is_user_variable.is_none() => {
1332-
if self.body.local_decls[local].ty.is_mutable_pointer() {
1332+
if self.body.local_decls[local].ty.is_mutable_ptr() {
13331333
// The variable will be marked as mutable by the borrow.
13341334
return;
13351335
}

src/librustc_mir/hair/pattern/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ pub fn is_useful<'p, 'a, 'tcx>(
11711171
// For privately empty and non-exhaustive enums, we work as if there were an "extra"
11721172
// `_` constructor for the type, so we can never match over all constructors.
11731173
let is_non_exhaustive = is_privately_empty || is_declared_nonexhaustive ||
1174-
(pcx.ty.is_pointer_sized() && !cx.tcx.features().precise_pointer_size_matching);
1174+
(pcx.ty.is_ptr_sized_integral() && !cx.tcx.features().precise_pointer_size_matching);
11751175

11761176
if cheap_missing_ctors == MissingCtors::Empty && !is_non_exhaustive {
11771177
split_grouped_constructors(cx.tcx, all_ctors, matrix, pcx.ty).into_iter().map(|c| {
@@ -1488,7 +1488,7 @@ fn should_treat_range_exhaustively(tcx: TyCtxt<'tcx>, ctor: &Constructor<'tcx>)
14881488
_ => return false,
14891489
};
14901490
if let ty::Char | ty::Int(_) | ty::Uint(_) = ty.sty {
1491-
!ty.is_pointer_sized() || tcx.features().precise_pointer_size_matching
1491+
!ty.is_ptr_sized_integral() || tcx.features().precise_pointer_size_matching
14921492
} else {
14931493
false
14941494
}

src/librustc_typeck/check/method/suggest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
8686
trait_name,
8787
item_name,
8888
if rcvr_ty.is_region_ptr() && args.is_some() {
89-
if rcvr_ty.is_mutable_pointer() {
89+
if rcvr_ty.is_mutable_ptr() {
9090
"&mut "
9191
} else {
9292
"&"

0 commit comments

Comments
 (0)