1
Fork 0

Rollup merge of #104657 - hi-rustin:rustin-patch-check-transmute, r=compiler-errors

Do not check transmute if has non region infer

close https://github.com/rust-lang/rust/issues/104609

See: https://github.com/rust-lang/rust/issues/104609#issuecomment-1320956351

r? `@compiler-errors`
This commit is contained in:
Matthias Krüger 2022-11-22 00:01:10 +01:00 committed by GitHub
commit 9cefd9dd29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View file

@ -3,7 +3,7 @@ use rustc_errors::struct_span_err;
use rustc_hir as hir;
use rustc_index::vec::Idx;
use rustc_middle::ty::layout::{LayoutError, SizeSkeleton};
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitable};
use rustc_target::abi::{Pointer, VariantIdx};
use super::FnCtxt;
@ -46,7 +46,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let from = normalize(from);
let to = normalize(to);
trace!(?from, ?to);
if from.has_non_region_infer() || to.has_non_region_infer() {
tcx.sess.delay_span_bug(span, "argument to transmute has inference variables");
return;
}
// Transmutes that are only changing lifetimes are always ok.
if from == to {
return;