Auto merge of #127170 - bjorn3:no_specialize_index_borrowck, r=michaelwoerister

Stop using specialization in rustc_index and rustc_borrowck

For rustc_borrowck the version with specialization isn't much more readable anyway IMO. For rustc_index it probably doesn't affect perf in any noticeable way anyway.
This commit is contained in:
bors 2024-07-04 14:24:43 +00:00
commit 9f877c9cd2
6 changed files with 29 additions and 16 deletions

View File

@ -213,8 +213,32 @@ trait FactCell {
fn to_string(&self, location_table: &LocationTable) -> String; fn to_string(&self, location_table: &LocationTable) -> String;
} }
impl<A: Debug> FactCell for A { impl FactCell for BorrowIndex {
default fn to_string(&self, _location_table: &LocationTable) -> String { fn to_string(&self, _location_table: &LocationTable) -> String {
format!("{self:?}")
}
}
impl FactCell for Local {
fn to_string(&self, _location_table: &LocationTable) -> String {
format!("{self:?}")
}
}
impl FactCell for MovePathIndex {
fn to_string(&self, _location_table: &LocationTable) -> String {
format!("{self:?}")
}
}
impl FactCell for PoloniusRegionVid {
fn to_string(&self, _location_table: &LocationTable) -> String {
format!("{self:?}")
}
}
impl FactCell for RegionVid {
fn to_string(&self, _location_table: &LocationTable) -> String {
format!("{self:?}") format!("{self:?}")
} }
} }

View File

@ -7,7 +7,6 @@
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(control_flow_enum)] #![feature(control_flow_enum)]
#![feature(let_chains)] #![feature(let_chains)]
#![feature(min_specialization)]
#![feature(never_type)] #![feature(never_type)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]

View File

@ -1,10 +1,7 @@
// tidy-alphabetical-start // tidy-alphabetical-start
#![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))] #![cfg_attr(all(feature = "nightly", test), feature(stmt_expr_attributes))]
#![cfg_attr(
feature = "nightly",
feature(extend_one, min_specialization, new_uninit, step_trait, test)
)]
#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", allow(internal_features))]
#![cfg_attr(feature = "nightly", feature(extend_one, new_uninit, step_trait, test))]
// tidy-alphabetical-end // tidy-alphabetical-end
pub mod bit_set; pub mod bit_set;

View File

@ -34,10 +34,7 @@ mod newtype;
/// optimizations. The default max value is 0xFFFF_FF00. /// optimizations. The default max value is 0xFFFF_FF00.
/// - `#[gate_rustc_only]`: makes parts of the generated code nightly-only. /// - `#[gate_rustc_only]`: makes parts of the generated code nightly-only.
#[proc_macro] #[proc_macro]
#[cfg_attr( #[cfg_attr(feature = "nightly", allow_internal_unstable(step_trait, rustc_attrs, trusted_step))]
feature = "nightly",
allow_internal_unstable(step_trait, rustc_attrs, trusted_step, min_specialization)
)]
pub fn newtype_index(input: TokenStream) -> TokenStream { pub fn newtype_index(input: TokenStream) -> TokenStream {
newtype::newtype(input) newtype::newtype(input)
} }

View File

@ -139,10 +139,6 @@ impl Parse for Newtype {
Self::index(start).checked_sub(u).map(Self::from_usize) Self::index(start).checked_sub(u).map(Self::from_usize)
} }
} }
// Safety: The implementation of `Step` upholds all invariants.
#gate_rustc_only
unsafe impl ::std::iter::TrustedStep for #name {}
} }
} else { } else {
quote! {} quote! {}

View File

@ -2,7 +2,7 @@
#![allow(rustc::usage_of_ty_tykind)] #![allow(rustc::usage_of_ty_tykind)]
#![cfg_attr( #![cfg_attr(
feature = "nightly", feature = "nightly",
feature(associated_type_defaults, min_specialization, never_type, rustc_attrs, negative_impls) feature(associated_type_defaults, never_type, rustc_attrs, negative_impls)
)] )]
#![cfg_attr(feature = "nightly", allow(internal_features))] #![cfg_attr(feature = "nightly", allow(internal_features))]
// tidy-alphabetical-end // tidy-alphabetical-end