Skip to content

Commit

Permalink
Auto merge of #127170 - bjorn3:no_specialize_index_borrowck, r=michae…
Browse files Browse the repository at this point in the history
…lwoerister

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.
  • Loading branch information
bors committed Jul 4, 2024
2 parents e2cf31a + 449581d commit 9f877c9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 16 deletions.
28 changes: 26 additions & 2 deletions compiler/rustc_borrowck/src/facts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,32 @@ trait FactCell {
fn to_string(&self, location_table: &LocationTable) -> String;
}

impl<A: Debug> FactCell for A {
default fn to_string(&self, _location_table: &LocationTable) -> String {
impl FactCell for BorrowIndex {
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:?}")
}
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#![feature(box_patterns)]
#![feature(control_flow_enum)]
#![feature(let_chains)]
#![feature(min_specialization)]
#![feature(never_type)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_index/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// tidy-alphabetical-start
#![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", feature(extend_one, new_uninit, step_trait, test))]
// tidy-alphabetical-end

pub mod bit_set;
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_index_macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ mod newtype;
/// optimizations. The default max value is 0xFFFF_FF00.
/// - `#[gate_rustc_only]`: makes parts of the generated code nightly-only.
#[proc_macro]
#[cfg_attr(
feature = "nightly",
allow_internal_unstable(step_trait, rustc_attrs, trusted_step, min_specialization)
)]
#[cfg_attr(feature = "nightly", allow_internal_unstable(step_trait, rustc_attrs, trusted_step))]
pub fn newtype_index(input: TokenStream) -> TokenStream {
newtype::newtype(input)
}
4 changes: 0 additions & 4 deletions compiler/rustc_index_macros/src/newtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ impl Parse for Newtype {
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 {
quote! {}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![allow(rustc::usage_of_ty_tykind)]
#![cfg_attr(
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))]
// tidy-alphabetical-end
Expand Down

0 comments on commit 9f877c9

Please sign in to comment.