Skip to content

Commit

Permalink
invalidate the mir instead
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertdev committed Sep 2, 2024
1 parent f449f71 commit 3805bdc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
9 changes: 1 addition & 8 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
} else if let Some(static_def_id) = constant.check_static_ptr(tcx) {
let unnormalized_ty = tcx.type_of(static_def_id).instantiate_identity();
let normalized_ty = self.cx.normalize(unnormalized_ty, locations);
let literal_ty = constant.const_.ty().builtin_deref(true).unwrap_or_else(|| {
span_mirbug_and_err!(
self,
constant,
"bad static type {:?}",
constant.const_.ty()
)
});
let literal_ty = constant.const_.ty().builtin_deref(true).unwrap();

if let Err(terr) = self.cx.eq_types(
literal_ty,
Expand Down
46 changes: 28 additions & 18 deletions compiler/rustc_mir_build/src/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
vec![destination_block]
};

let mut has_type_error = false;

let operands = operands
.into_iter()
.map(|op| match *op {
Expand Down Expand Up @@ -441,6 +443,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}
thir::InlineAsmOperand::Const { value, span } => {
has_type_error |=
matches!(value.ty().kind(), rustc_middle::ty::Error(_));

mir::InlineAsmOperand::Const {
value: Box::new(ConstOperand {
span,
Expand Down Expand Up @@ -484,26 +489,31 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
this.cfg.push_assign_unit(block, source_info, destination, this.tcx);
}

this.cfg.terminate(
block,
source_info,
TerminatorKind::InlineAsm {
template,
operands,
options,
line_spans,
targets: targets.into_boxed_slice(),
unwind: if options.contains(InlineAsmOptions::MAY_UNWIND) {
UnwindAction::Continue
} else {
UnwindAction::Unreachable
if has_type_error {
this.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
destination_block.unit()
} else {
this.cfg.terminate(
block,
source_info,
TerminatorKind::InlineAsm {
template,
operands,
options,
line_spans,
targets: targets.into_boxed_slice(),
unwind: if options.contains(InlineAsmOptions::MAY_UNWIND) {
UnwindAction::Continue
} else {
UnwindAction::Unreachable
},
},
},
);
if options.contains(InlineAsmOptions::MAY_UNWIND) {
this.diverge_from(block);
);
if options.contains(InlineAsmOptions::MAY_UNWIND) {
this.diverge_from(block);
}
destination_block.unit()
}
destination_block.unit()
}

// These cases don't actually need a destination
Expand Down

0 comments on commit 3805bdc

Please sign in to comment.