Skip to content

Commit

Permalink
Rollup merge of #91148 - jhpratt:use-default-enum, r=petrochenkov
Browse files Browse the repository at this point in the history
Use `derive_default_enum` in the compiler

Let's get this feature some real-world love.

``@rustbot`` label: +C-cleanup +S-waiting-on-review
  • Loading branch information
matthiaskrgr authored Nov 23, 2021
2 parents a26c2c7 + 7b103e7 commit e52e3a4
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 31 deletions.
9 changes: 2 additions & 7 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
/// This is used so that the region values inferred by HIR region solving are
/// not exposed, and so that we can avoid doing work in HIR typeck that MIR
/// typeck will also do.
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, Default)]
pub enum RegionckMode {
/// The default mode: report region errors, don't erase regions.
#[default]
Solve,
/// Erase the results of region after solving.
Erase {
Expand All @@ -108,12 +109,6 @@ pub enum RegionckMode {
},
}

impl Default for RegionckMode {
fn default() -> Self {
RegionckMode::Solve
}
}

impl RegionckMode {
/// Indicates that the MIR borrowck will repeat these region
/// checks, so we should ignore errors if NLL is (unconditionally)
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_infer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(derive_default_enum)]
#![feature(extend_one)]
#![feature(iter_zip)]
#![feature(let_else)]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(core_intrinsics)]
#![feature(derive_default_enum)]
#![feature(discriminant_kind)]
#![feature(exhaustive_patterns)]
#![feature(if_let_guard)]
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2263,10 +2263,11 @@ impl<'tcx> TyS<'tcx> {
/// a miscompilation or unsoundness.
///
/// When in doubt, use `VarianceDiagInfo::default()`
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
pub enum VarianceDiagInfo<'tcx> {
/// No additional information - this is the default.
/// We will not add any additional information to error messages.
#[default]
None,
/// We switched our variance because a type occurs inside
/// the generic argument of a mutable reference or pointer
Expand Down Expand Up @@ -2301,9 +2302,3 @@ impl<'tcx> VarianceDiagInfo<'tcx> {
}
}
}

impl<'tcx> Default for VarianceDiagInfo<'tcx> {
fn default() -> Self {
Self::None
}
}
9 changes: 2 additions & 7 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,22 +335,17 @@ impl Default for ErrorOutputType {
}

/// Parameter to control path trimming.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
pub enum TrimmedDefPaths {
/// `try_print_trimmed_def_path` never prints a trimmed path and never calls the expensive query
#[default]
Never,
/// `try_print_trimmed_def_path` calls the expensive query, the query doesn't call `delay_good_path_bug`
Always,
/// `try_print_trimmed_def_path` calls the expensive query, the query calls `delay_good_path_bug`
GoodPath,
}

impl Default for TrimmedDefPaths {
fn default() -> Self {
Self::Never
}
}

/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
/// dependency tracking for command-line arguments. Also only hash keys, since tracking
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_session/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![feature(crate_visibility_modifier)]
#![feature(derive_default_enum)]
#![feature(min_specialization)]
#![feature(once_cell)]
#![recursion_limit = "256"]
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![feature(bool_to_option)]
#![feature(box_patterns)]
#![feature(drain_filter)]
#![feature(derive_default_enum)]
#![feature(hash_drain_filter)]
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
Expand Down
16 changes: 6 additions & 10 deletions compiler/rustc_trait_selection/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,14 @@ pub use self::chalk_fulfill::FulfillmentContext as ChalkFulfillmentContext;
pub use rustc_infer::traits::*;

/// Whether to skip the leak check, as part of a future compatibility warning step.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
///
/// The "default" for skip-leak-check corresponds to the current
/// behavior (do not skip the leak check) -- not the behavior we are
/// transitioning into.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
pub enum SkipLeakCheck {
Yes,
#[default]
No,
}

Expand All @@ -94,15 +99,6 @@ impl SkipLeakCheck {
}
}

/// The "default" for skip-leak-check corresponds to the current
/// behavior (do not skip the leak check) -- not the behavior we are
/// transitioning into.
impl Default for SkipLeakCheck {
fn default() -> Self {
SkipLeakCheck::No
}
}

/// The mode that trait queries run in.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum TraitQueryMode {
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
#![cfg_attr(bootstrap, feature(const_raw_ptr_deref))]
#![feature(const_refs_to_cell)]
#![feature(decl_macro)]
#![feature(derive_default_enum)]
#![feature(doc_cfg)]
#![feature(doc_notable_trait)]
#![feature(doc_primitive)]
Expand Down

0 comments on commit e52e3a4

Please sign in to comment.