Use is_lang_item more aggressively
This commit is contained in:
parent
d5c48ebc71
commit
93ff86ed7c
44 changed files with 171 additions and 166 deletions
|
@ -4,6 +4,7 @@
|
|||
//! of MIR building, and only after this pass we think of the program has having the
|
||||
//! normal MIR semantics.
|
||||
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
||||
|
@ -27,7 +28,7 @@ fn may_contain_reference<'tcx>(ty: Ty<'tcx>, depth: u32, tcx: TyCtxt<'tcx>) -> b
|
|||
// References and Boxes (`noalias` sources)
|
||||
ty::Ref(..) => true,
|
||||
ty::Adt(..) if ty.is_box() => true,
|
||||
ty::Adt(adt, _) if Some(adt.did()) == tcx.lang_items().ptr_unique() => true,
|
||||
ty::Adt(adt, _) if tcx.is_lang_item(adt.did(), LangItem::PtrUnique) => true,
|
||||
// Compound types: recurse
|
||||
ty::Array(ty, _) | ty::Slice(ty) => {
|
||||
// This does not branch so we keep the depth the same.
|
||||
|
|
|
@ -561,7 +561,7 @@ impl<'tcx> AsyncDestructorCtorShimBuilder<'tcx> {
|
|||
|
||||
// If projection of Discriminant then compare with `Ty::discriminant_ty`
|
||||
if let ty::Alias(ty::Projection, ty::AliasTy { args, def_id, .. }) = expected_ty.kind()
|
||||
&& Some(*def_id) == self.tcx.lang_items().discriminant_type()
|
||||
&& self.tcx.is_lang_item(*def_id, LangItem::Discriminant)
|
||||
&& args.first().unwrap().as_type().unwrap().discriminant_ty(self.tcx) == operand_ty
|
||||
{
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_index::bit_set::{BitSet, GrowableBitSet};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::bug;
|
||||
|
@ -70,7 +71,7 @@ fn escaping_locals<'tcx>(
|
|||
// Exclude #[repr(simd)] types so that they are not de-optimized into an array
|
||||
return true;
|
||||
}
|
||||
if Some(def.did()) == tcx.lang_items().dyn_metadata() {
|
||||
if tcx.is_lang_item(def.did(), LangItem::DynMetadata) {
|
||||
// codegen wants to see the `DynMetadata<T>`,
|
||||
// not the inner reference-to-opaque-type.
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
//! Validates the MIR to ensure that invariants are upheld.
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_infer::traits::Reveal;
|
||||
|
@ -689,7 +690,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
|
|||
}
|
||||
ty::Adt(adt_def, args) => {
|
||||
// see <https://github.com/rust-lang/rust/blob/7601adcc764d42c9f2984082b49948af652df986/compiler/rustc_middle/src/ty/layout.rs#L861-L864>
|
||||
if Some(adt_def.did()) == self.tcx.lang_items().dyn_metadata() {
|
||||
if self.tcx.is_lang_item(adt_def.did(), LangItem::DynMetadata) {
|
||||
self.fail(
|
||||
location,
|
||||
format!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue