about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_hir_typeck/src/pat.rs4
-rw-r--r--compiler/rustc_monomorphize/src/collector.rs4
-rw-r--r--compiler/rustc_monomorphize/src/partitioning.rs44
-rw-r--r--compiler/rustc_smir/src/rustc_smir/mod.rs36
-rw-r--r--compiler/rustc_smir/src/stable_mir/ty.rs36
-rw-r--r--compiler/rustc_trait_selection/src/solve/normalize.rs4
6 files changed, 90 insertions, 38 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index 19f82fbd3bf..42f4531c0ef 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -394,8 +394,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         let mut pat_ty = ty;
         if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
             let expected = self.structurally_resolve_type(span, expected);
-            if let ty::Ref(_, inner_ty, _) = expected.kind()
-                && matches!(inner_ty.kind(), ty::Slice(_))
+            if let ty::Ref(_, inner_ty, _) = *expected.kind()
+                && self.try_structurally_resolve_type(span, inner_ty).is_slice()
             {
                 let tcx = self.tcx;
                 trace!(?lt.hir_id.local_id, "polymorphic byte string lit");
diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs
index 12be4d842dd..242269e9d1a 100644
--- a/compiler/rustc_monomorphize/src/collector.rs
+++ b/compiler/rustc_monomorphize/src/collector.rs
@@ -231,8 +231,8 @@ impl<'tcx> UsageMap<'tcx> {
         assert!(self.used_map.insert(user_item, used_items).is_none());
     }
 
-    pub fn get_user_items(&self, item: MonoItem<'tcx>) -> Option<&[MonoItem<'tcx>]> {
-        self.user_map.get(&item).map(|items| items.as_slice())
+    pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
+        self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[])
     }
 
     /// Internally iterate over all inlined items used by `item`.
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs
index f4535fbd58f..da76cf2236c 100644
--- a/compiler/rustc_monomorphize/src/partitioning.rs
+++ b/compiler/rustc_monomorphize/src/partitioning.rs
@@ -427,9 +427,9 @@ fn merge_codegen_units<'tcx>(
         // zero-padded suffixes, which means they are automatically sorted by
         // names. The numeric suffix width depends on the number of CGUs, which
         // is always greater than zero:
-        // - [1,9]     CGUS: `0`, `1`, `2`, ...
-        // - [10,99]   CGUS: `00`, `01`, `02`, ...
-        // - [100,999] CGUS: `000`, `001`, `002`, ...
+        // - [1,9]     CGUs: `0`, `1`, `2`, ...
+        // - [10,99]   CGUs: `00`, `01`, `02`, ...
+        // - [100,999] CGUs: `000`, `001`, `002`, ...
         // - etc.
         //
         // If we didn't zero-pad the sorted-by-name order would be `XYZ-cgu.0`,
@@ -458,7 +458,7 @@ fn internalize_symbols<'tcx>(
     /// used to keep track of that.
     #[derive(Clone, PartialEq, Eq, Debug)]
     enum MonoItemPlacement {
-        SingleCgu { cgu_name: Symbol },
+        SingleCgu(Symbol),
         MultipleCgus,
     }
 
@@ -466,7 +466,7 @@ fn internalize_symbols<'tcx>(
     let single_codegen_unit = codegen_units.len() == 1;
 
     if !single_codegen_unit {
-        for cgu in codegen_units.iter_mut() {
+        for cgu in codegen_units.iter() {
             for item in cgu.items().keys() {
                 // If there is more than one codegen unit, we need to keep track
                 // in which codegen units each monomorphization is placed.
@@ -474,13 +474,13 @@ fn internalize_symbols<'tcx>(
                     Entry::Occupied(e) => {
                         let placement = e.into_mut();
                         debug_assert!(match *placement {
-                            MonoItemPlacement::SingleCgu { cgu_name } => cgu_name != cgu.name(),
+                            MonoItemPlacement::SingleCgu(cgu_name) => cgu_name != cgu.name(),
                             MonoItemPlacement::MultipleCgus => true,
                         });
                         *placement = MonoItemPlacement::MultipleCgus;
                     }
                     Entry::Vacant(e) => {
-                        e.insert(MonoItemPlacement::SingleCgu { cgu_name: cgu.name() });
+                        e.insert(MonoItemPlacement::SingleCgu(cgu.name()));
                     }
                 }
             }
@@ -490,7 +490,7 @@ fn internalize_symbols<'tcx>(
     // For each internalization candidates in each codegen unit, check if it is
     // used from outside its defining codegen unit.
     for cgu in codegen_units {
-        let home_cgu = MonoItemPlacement::SingleCgu { cgu_name: cgu.name() };
+        let home_cgu = MonoItemPlacement::SingleCgu(cgu.name());
 
         for (item, linkage_and_visibility) in cgu.items_mut() {
             if !internalization_candidates.contains(item) {
@@ -501,20 +501,20 @@ fn internalize_symbols<'tcx>(
             if !single_codegen_unit {
                 debug_assert_eq!(mono_item_placements[item], home_cgu);
 
-                if let Some(user_items) = cx.usage_map.get_user_items(*item) {
-                    if user_items
-                        .iter()
-                        .filter_map(|user_item| {
-                            // Some user mono items might not have been
-                            // instantiated. We can safely ignore those.
-                            mono_item_placements.get(user_item)
-                        })
-                        .any(|placement| *placement != home_cgu)
-                    {
-                        // Found a user from another CGU, so skip to the next item
-                        // without marking this one as internal.
-                        continue;
-                    }
+                if cx
+                    .usage_map
+                    .get_user_items(*item)
+                    .iter()
+                    .filter_map(|user_item| {
+                        // Some user mono items might not have been
+                        // instantiated. We can safely ignore those.
+                        mono_item_placements.get(user_item)
+                    })
+                    .any(|placement| *placement != home_cgu)
+                {
+                    // Found a user from another CGU, so skip to the next item
+                    // without marking this one as internal.
+                    continue;
                 }
             }
 
diff --git a/compiler/rustc_smir/src/rustc_smir/mod.rs b/compiler/rustc_smir/src/rustc_smir/mod.rs
index 874e34bef60..85d5bb00c4e 100644
--- a/compiler/rustc_smir/src/rustc_smir/mod.rs
+++ b/compiler/rustc_smir/src/rustc_smir/mod.rs
@@ -7,7 +7,8 @@
 //!
 //! For now, we are developing everything inside `rustc`, thus, we keep this module private.
 
-use crate::stable_mir::{self, ty::TyKind, Context};
+use crate::stable_mir::ty::{FloatTy, IntTy, RigidTy, TyKind, UintTy};
+use crate::stable_mir::{self, Context};
 use rustc_middle::mir;
 use rustc_middle::ty::{self, Ty, TyCtxt};
 use rustc_span::def_id::{CrateNum, DefId, LOCAL_CRATE};
@@ -69,11 +70,28 @@ pub struct Tables<'tcx> {
 impl<'tcx> Tables<'tcx> {
     fn rustc_ty_to_ty(&mut self, ty: Ty<'tcx>) -> TyKind {
         match ty.kind() {
-            ty::Bool => TyKind::Bool,
-            ty::Char => todo!(),
-            ty::Int(_) => todo!(),
-            ty::Uint(_) => todo!(),
-            ty::Float(_) => todo!(),
+            ty::Bool => TyKind::RigidTy(RigidTy::Bool),
+            ty::Char => TyKind::RigidTy(RigidTy::Char),
+            ty::Int(int_ty) => match int_ty {
+                ty::IntTy::Isize => TyKind::RigidTy(RigidTy::Int(IntTy::Isize)),
+                ty::IntTy::I8 => TyKind::RigidTy(RigidTy::Int(IntTy::I8)),
+                ty::IntTy::I16 => TyKind::RigidTy(RigidTy::Int(IntTy::I16)),
+                ty::IntTy::I32 => TyKind::RigidTy(RigidTy::Int(IntTy::I32)),
+                ty::IntTy::I64 => TyKind::RigidTy(RigidTy::Int(IntTy::I64)),
+                ty::IntTy::I128 => TyKind::RigidTy(RigidTy::Int(IntTy::I128)),
+            },
+            ty::Uint(uint_ty) => match uint_ty {
+                ty::UintTy::Usize => TyKind::RigidTy(RigidTy::Uint(UintTy::Usize)),
+                ty::UintTy::U8 => TyKind::RigidTy(RigidTy::Uint(UintTy::U8)),
+                ty::UintTy::U16 => TyKind::RigidTy(RigidTy::Uint(UintTy::U16)),
+                ty::UintTy::U32 => TyKind::RigidTy(RigidTy::Uint(UintTy::U32)),
+                ty::UintTy::U64 => TyKind::RigidTy(RigidTy::Uint(UintTy::U64)),
+                ty::UintTy::U128 => TyKind::RigidTy(RigidTy::Uint(UintTy::U128)),
+            },
+            ty::Float(float_ty) => match float_ty {
+                ty::FloatTy::F32 => TyKind::RigidTy(RigidTy::Float(FloatTy::F32)),
+                ty::FloatTy::F64 => TyKind::RigidTy(RigidTy::Float(FloatTy::F64)),
+            },
             ty::Adt(_, _) => todo!(),
             ty::Foreign(_) => todo!(),
             ty::Str => todo!(),
@@ -90,9 +108,9 @@ impl<'tcx> Tables<'tcx> {
             ty::GeneratorWitness(_) => todo!(),
             ty::GeneratorWitnessMIR(_, _) => todo!(),
             ty::Never => todo!(),
-            ty::Tuple(fields) => {
-                TyKind::Tuple(fields.iter().map(|ty| self.intern_ty(ty)).collect())
-            }
+            ty::Tuple(fields) => TyKind::RigidTy(RigidTy::Tuple(
+                fields.iter().map(|ty| self.intern_ty(ty)).collect(),
+            )),
             ty::Alias(_, _) => todo!(),
             ty::Param(_) => todo!(),
             ty::Bound(_, _) => todo!(),
diff --git a/compiler/rustc_smir/src/stable_mir/ty.rs b/compiler/rustc_smir/src/stable_mir/ty.rs
index f27801b0f6c..3181af46e9c 100644
--- a/compiler/rustc_smir/src/stable_mir/ty.rs
+++ b/compiler/rustc_smir/src/stable_mir/ty.rs
@@ -9,7 +9,43 @@ impl Ty {
     }
 }
 
+#[derive(Clone, Debug)]
 pub enum TyKind {
+    RigidTy(RigidTy),
+}
+
+#[derive(Clone, Debug)]
+pub enum RigidTy {
     Bool,
+    Char,
+    Int(IntTy),
+    Uint(UintTy),
+    Float(FloatTy),
     Tuple(Vec<Ty>),
 }
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum IntTy {
+    Isize,
+    I8,
+    I16,
+    I32,
+    I64,
+    I128,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum UintTy {
+    Usize,
+    U8,
+    U16,
+    U32,
+    U64,
+    U128,
+}
+
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum FloatTy {
+    F32,
+    F64,
+}
diff --git a/compiler/rustc_trait_selection/src/solve/normalize.rs b/compiler/rustc_trait_selection/src/solve/normalize.rs
index c0ee1a576e5..c388850d831 100644
--- a/compiler/rustc_trait_selection/src/solve/normalize.rs
+++ b/compiler/rustc_trait_selection/src/solve/normalize.rs
@@ -167,9 +167,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
         // We don't normalize opaque types unless we have
         // `Reveal::All`, even if we're in the defining scope.
         let data = match *ty.kind() {
-            ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::UserFacing => {
-                alias_ty
-            }
+            ty::Alias(kind, alias_ty) if kind != ty::Opaque || reveal == Reveal::All => alias_ty,
             _ => return ty.try_super_fold_with(self),
         };