Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk

Improve syntax of `newtype_index`

This makes it more like proper Rust and also makes the implementation a lot simpler.

Mostly just turns weird flags in the body into proper attributes.

It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
This commit is contained in:
bors 2022-12-20 07:27:01 +00:00
commit eb9e5e711d
37 changed files with 182 additions and 268 deletions

View file

@ -115,13 +115,11 @@ impl<'tcx> fmt::Debug for OutlivesConstraint<'tcx> {
}
rustc_index::newtype_index! {
pub struct OutlivesConstraintIndex {
DEBUG_FORMAT = "OutlivesConstraintIndex({})"
}
#[debug_format = "OutlivesConstraintIndex({})"]
pub struct OutlivesConstraintIndex {}
}
rustc_index::newtype_index! {
pub struct ConstraintSccIndex {
DEBUG_FORMAT = "ConstraintSccIndex({})"
}
#[debug_format = "ConstraintSccIndex({})"]
pub struct ConstraintSccIndex {}
}

View file

@ -108,9 +108,8 @@ impl_visitable! {
}
rustc_index::newtype_index! {
pub struct BorrowIndex {
DEBUG_FORMAT = "bw{}"
}
#[debug_format = "bw{}"]
pub struct BorrowIndex {}
}
/// `Borrows` stores the data used in the analyses that track the flow

View file

@ -20,9 +20,8 @@ pub struct LocationTable {
}
rustc_index::newtype_index! {
pub struct LocationIndex {
DEBUG_FORMAT = "LocationIndex({})"
}
#[debug_format = "LocationIndex({})"]
pub struct LocationIndex {}
}
#[derive(Copy, Clone, Debug)]

View file

@ -55,9 +55,8 @@ pub(crate) struct NllMemberConstraint<'tcx> {
}
rustc_index::newtype_index! {
pub(crate) struct NllMemberConstraintIndex {
DEBUG_FORMAT = "MemberConstraintIndex({})"
}
#[debug_format = "MemberConstraintIndex({})"]
pub(crate) struct NllMemberConstraintIndex {}
}
impl Default for MemberConstraintSet<'_, ty::RegionVid> {

View file

@ -90,12 +90,14 @@ impl RegionValueElements {
rustc_index::newtype_index! {
/// A single integer representing a `Location` in the MIR control-flow
/// graph. Constructed efficiently from `RegionValueElements`.
pub struct PointIndex { DEBUG_FORMAT = "PointIndex({})" }
#[debug_format = "PointIndex({})"]
pub struct PointIndex {}
}
rustc_index::newtype_index! {
/// A single integer representing a `ty::Placeholder`.
pub struct PlaceholderIndex { DEBUG_FORMAT = "PlaceholderIndex({})" }
#[debug_format = "PlaceholderIndex({})"]
pub struct PlaceholderIndex {}
}
/// An individual element in a region value -- the value of a

View file

@ -46,7 +46,7 @@ struct Appearance {
}
rustc_index::newtype_index! {
pub struct AppearanceIndex { .. }
pub struct AppearanceIndex {}
}
impl vll::LinkElem for Appearance {