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 d30c392

Browse files
committedOct 5, 2024
Auto merge of rust-lang#131275 - workingjubilee:rollup-4yxqio3, r=workingjubilee
Rollup of 9 pull requests Successful merges: - rust-lang#129517 (Compute array length from type for unconditional panic lint. ) - rust-lang#130367 (Check elaborated projections from dyn don't mention unconstrained late bound lifetimes) - rust-lang#130403 (Stabilize `const_slice_from_raw_parts_mut`) - rust-lang#130633 (Add support for reborrowing pinned method receivers) - rust-lang#131105 (update `Literal`'s intro) - rust-lang#131194 (Fix needless_lifetimes in stable_mir) - rust-lang#131260 (rustdoc: cleaner errors on disambiguator/namespace mismatches) - rust-lang#131267 (Stabilize `BufRead::skip_until`) - rust-lang#131273 (Account for `impl Trait {` when `impl Trait for Type {` was intended) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 495f75a + 08689af commit d30c392

Some content is hidden

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

43 files changed

+559
-94
lines changed
 

‎compiler/rustc_middle/src/ty/sty.rs

+10
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,16 @@ impl<'tcx> Ty<'tcx> {
584584
Ty::new_ref(tcx, r, ty, hir::Mutability::Not)
585585
}
586586

587+
pub fn new_pinned_ref(
588+
tcx: TyCtxt<'tcx>,
589+
r: Region<'tcx>,
590+
ty: Ty<'tcx>,
591+
mutbl: ty::Mutability,
592+
) -> Ty<'tcx> {
593+
let pin = tcx.adt_def(tcx.require_lang_item(LangItem::Pin, None));
594+
Ty::new_adt(tcx, pin, tcx.mk_args(&[Ty::new_ref(tcx, r, ty, mutbl).into()]))
595+
}
596+
587597
#[inline]
588598
pub fn new_ptr(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, mutbl: ty::Mutability) -> Ty<'tcx> {
589599
Ty::new(tcx, ty::RawPtr(ty, mutbl))

‎compiler/rustc_mir_transform/src/known_panics_lint.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -600,13 +600,15 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
600600
}
601601

602602
Len(place) => {
603-
let len = match self.get_const(place)? {
604-
Value::Immediate(src) => src.len(&self.ecx).discard_err()?,
605-
Value::Aggregate { fields, .. } => fields.len() as u64,
606-
Value::Uninit => match place.ty(self.local_decls(), self.tcx).ty.kind() {
607-
ty::Array(_, n) => n.try_eval_target_usize(self.tcx, self.param_env)?,
608-
_ => return None,
609-
},
603+
let len = if let ty::Array(_, n) = place.ty(self.local_decls(), self.tcx).ty.kind()
604+
{
605+
n.try_eval_target_usize(self.tcx, self.param_env)?
606+
} else {
607+
match self.get_const(place)? {
608+
Value::Immediate(src) => src.len(&self.ecx).discard_err()?,
609+
Value::Aggregate { fields, .. } => fields.len() as u64,
610+
Value::Uninit => return None,
611+
}
610612
};
611613
ImmTy::from_scalar(Scalar::from_target_usize(len, self), layout).into()
612614
}
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.