Skip to content

Commit 80bb3c0

Browse files
authored
Rollup merge of rust-lang#91148 - jhpratt:use-default-enum, r=petrochenkov
Use `derive_default_enum` in the compiler Let's get this feature some real-world love. `@rustbot` label: +C-cleanup +S-waiting-on-review
2 parents ccc53bb + 7b103e7 commit 80bb3c0

File tree

9 files changed

+17
-31
lines changed

9 files changed

+17
-31
lines changed

compiler/rustc_infer/src/infer/mod.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ pub(crate) type UnificationTable<'a, 'tcx, T> = ut::UnificationTable<
9595
/// This is used so that the region values inferred by HIR region solving are
9696
/// not exposed, and so that we can avoid doing work in HIR typeck that MIR
9797
/// typeck will also do.
98-
#[derive(Copy, Clone, Debug)]
98+
#[derive(Copy, Clone, Debug, Default)]
9999
pub enum RegionckMode {
100100
/// The default mode: report region errors, don't erase regions.
101+
#[default]
101102
Solve,
102103
/// Erase the results of region after solving.
103104
Erase {
@@ -108,12 +109,6 @@ pub enum RegionckMode {
108109
},
109110
}
110111

111-
impl Default for RegionckMode {
112-
fn default() -> Self {
113-
RegionckMode::Solve
114-
}
115-
}
116-
117112
impl RegionckMode {
118113
/// Indicates that the MIR borrowck will repeat these region
119114
/// checks, so we should ignore errors if NLL is (unconditionally)

compiler/rustc_infer/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1616
#![feature(bool_to_option)]
1717
#![feature(box_patterns)]
18+
#![feature(derive_default_enum)]
1819
#![feature(extend_one)]
1920
#![feature(iter_zip)]
2021
#![feature(let_else)]

compiler/rustc_middle/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#![feature(bool_to_option)]
3131
#![feature(box_patterns)]
3232
#![feature(core_intrinsics)]
33+
#![feature(derive_default_enum)]
3334
#![feature(discriminant_kind)]
3435
#![feature(exhaustive_patterns)]
3536
#![feature(if_let_guard)]

compiler/rustc_middle/src/ty/sty.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -2263,10 +2263,11 @@ impl<'tcx> TyS<'tcx> {
22632263
/// a miscompilation or unsoundness.
22642264
///
22652265
/// When in doubt, use `VarianceDiagInfo::default()`
2266-
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
2266+
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
22672267
pub enum VarianceDiagInfo<'tcx> {
22682268
/// No additional information - this is the default.
22692269
/// We will not add any additional information to error messages.
2270+
#[default]
22702271
None,
22712272
/// We switched our variance because a type occurs inside
22722273
/// the generic argument of a mutable reference or pointer
@@ -2301,9 +2302,3 @@ impl<'tcx> VarianceDiagInfo<'tcx> {
23012302
}
23022303
}
23032304
}
2304-
2305-
impl<'tcx> Default for VarianceDiagInfo<'tcx> {
2306-
fn default() -> Self {
2307-
Self::None
2308-
}
2309-
}

compiler/rustc_session/src/config.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -335,22 +335,17 @@ impl Default for ErrorOutputType {
335335
}
336336

337337
/// Parameter to control path trimming.
338-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
338+
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
339339
pub enum TrimmedDefPaths {
340340
/// `try_print_trimmed_def_path` never prints a trimmed path and never calls the expensive query
341+
#[default]
341342
Never,
342343
/// `try_print_trimmed_def_path` calls the expensive query, the query doesn't call `delay_good_path_bug`
343344
Always,
344345
/// `try_print_trimmed_def_path` calls the expensive query, the query calls `delay_good_path_bug`
345346
GoodPath,
346347
}
347348

348-
impl Default for TrimmedDefPaths {
349-
fn default() -> Self {
350-
Self::Never
351-
}
352-
}
353-
354349
/// Use tree-based collections to cheaply get a deterministic `Hash` implementation.
355350
/// *Do not* switch `BTreeMap` out for an unsorted container type! That would break
356351
/// dependency tracking for command-line arguments. Also only hash keys, since tracking

compiler/rustc_session/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![feature(crate_visibility_modifier)]
2+
#![feature(derive_default_enum)]
23
#![feature(min_specialization)]
34
#![feature(once_cell)]
45
#![recursion_limit = "256"]

compiler/rustc_trait_selection/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#![feature(bool_to_option)]
1515
#![feature(box_patterns)]
1616
#![feature(drain_filter)]
17+
#![feature(derive_default_enum)]
1718
#![feature(hash_drain_filter)]
1819
#![feature(in_band_lifetimes)]
1920
#![feature(iter_zip)]

compiler/rustc_trait_selection/src/traits/mod.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,14 @@ pub use self::chalk_fulfill::FulfillmentContext as ChalkFulfillmentContext;
8282
pub use rustc_infer::traits::*;
8383

8484
/// Whether to skip the leak check, as part of a future compatibility warning step.
85-
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
85+
///
86+
/// The "default" for skip-leak-check corresponds to the current
87+
/// behavior (do not skip the leak check) -- not the behavior we are
88+
/// transitioning into.
89+
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
8690
pub enum SkipLeakCheck {
8791
Yes,
92+
#[default]
8893
No,
8994
}
9095

@@ -94,15 +99,6 @@ impl SkipLeakCheck {
9499
}
95100
}
96101

97-
/// The "default" for skip-leak-check corresponds to the current
98-
/// behavior (do not skip the leak check) -- not the behavior we are
99-
/// transitioning into.
100-
impl Default for SkipLeakCheck {
101-
fn default() -> Self {
102-
SkipLeakCheck::No
103-
}
104-
}
105-
106102
/// The mode that trait queries run in.
107103
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
108104
pub enum TraitQueryMode {

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
#![cfg_attr(bootstrap, feature(const_raw_ptr_deref))]
164164
#![feature(const_refs_to_cell)]
165165
#![feature(decl_macro)]
166+
#![feature(derive_default_enum)]
166167
#![feature(doc_cfg)]
167168
#![feature(doc_notable_trait)]
168169
#![feature(doc_primitive)]

0 commit comments

Comments
 (0)