Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b1674a7

Browse files
committedMay 10, 2024
Make builtin_deref just return a Ty
1 parent 8c7c151 commit b1674a7

File tree

42 files changed

+91
-115
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+91
-115
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,10 +1483,9 @@ fn suggest_ampmut<'tcx>(
14831483
} else {
14841484
// otherwise, suggest that the user annotates the binding; we provide the
14851485
// type of the local.
1486-
let ty_mut = decl_ty.builtin_deref(true).unwrap();
1487-
assert_eq!(ty_mut.mutbl, hir::Mutability::Not);
1486+
let ty = decl_ty.builtin_deref(true).unwrap();
14881487

1489-
(false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty_mut.ty))
1488+
(false, span, format!("{}mut {}", if decl_ty.is_ref() { "&" } else { "*" }, ty))
14901489
}
14911490
}
14921491

‎compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
401401
} else if let Some(static_def_id) = constant.check_static_ptr(tcx) {
402402
let unnormalized_ty = tcx.type_of(static_def_id).instantiate_identity();
403403
let normalized_ty = self.cx.normalize(unnormalized_ty, locations);
404-
let literal_ty = constant.const_.ty().builtin_deref(true).unwrap().ty;
404+
let literal_ty = constant.const_.ty().builtin_deref(true).unwrap();
405405

406406
if let Err(terr) = self.cx.eq_types(
407407
literal_ty,
@@ -638,7 +638,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
638638
match pi {
639639
ProjectionElem::Deref => {
640640
let deref_ty = base_ty.builtin_deref(true);
641-
PlaceTy::from_ty(deref_ty.map(|t| t.ty).unwrap_or_else(|| {
641+
PlaceTy::from_ty(deref_ty.unwrap_or_else(|| {
642642
span_mirbug_and_err!(self, place, "deref of non-pointer {:?}", base_ty)
643643
}))
644644
}

0 commit comments

Comments
 (0)
Please sign in to comment.