about summary refs log tree commit diff
path: root/compiler/rustc_target/src/lib.rs
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-03-04 13:46:56 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2022-03-07 13:41:47 +1100
commit4f008e06c33e1ef729bce839c0899154e71902b0 (patch)
tree1b1a3e1ba55bc10a31e66002693284c27620ad77 /compiler/rustc_target/src/lib.rs
parent8876ca3dd46b99fe7e6ad937f11493d37996231e (diff)
downloadrust-4f008e06c33e1ef729bce839c0899154e71902b0.tar.gz
rust-4f008e06c33e1ef729bce839c0899154e71902b0.zip
Clarify `Layout` interning.
`Layout` is another type that is sometimes interned, sometimes not, and
we always use references to refer to it so we can't take any advantage
of the uniqueness properties for hashing or equality checks.

This commit renames `Layout` as `LayoutS`, and then introduces a new
`Layout` that is a newtype around an `Interned<LayoutS>`. It also
interns more layouts than before. Previously layouts within layouts
(via the `variants` field) were never interned, but now they are. Hence
the lifetime on the new `Layout` type.

Unlike other interned types, these ones are in `rustc_target` instead of
`rustc_middle`. This reflects the existing structure of the code, which
does layout-specific stuff in `rustc_target` while `TyAndLayout` is
generic over the `Ty`, allowing the type-specific stuff to occur in
`rustc_middle`.

The commit also adds a `HashStable` impl for `Interned`, which was
needed. It hashes the contents, unlike the `Hash` impl which hashes the
pointer.
Diffstat (limited to 'compiler/rustc_target/src/lib.rs')
-rw-r--r--compiler/rustc_target/src/lib.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs
index 2919743e499..e9ef71ede51 100644
--- a/compiler/rustc_target/src/lib.rs
+++ b/compiler/rustc_target/src/lib.rs
@@ -8,13 +8,14 @@
 //! LLVM.
 
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
-#![feature(bool_to_option)]
-#![feature(let_else)]
-#![feature(nll)]
-#![feature(never_type)]
 #![feature(associated_type_bounds)]
+#![feature(bool_to_option)]
 #![feature(exhaustive_patterns)]
+#![feature(let_else)]
 #![feature(min_specialization)]
+#![feature(never_type)]
+#![feature(nll)]
+#![feature(rustc_attrs)]
 #![feature(step_trait)]
 
 use std::iter::FromIterator;