Skip to content

Commit 70a11c7

Browse files
committed
rustc_next_trait_solver: derivative -> derive-where
1 parent 35ba700 commit 70a11c7

File tree

7 files changed

+19
-26
lines changed

7 files changed

+19
-26
lines changed

Diff for: Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -4488,7 +4488,7 @@ name = "rustc_next_trait_solver"
44884488
version = "0.0.0"
44894489
dependencies = [
44904490
"bitflags 2.5.0",
4491-
"derivative",
4491+
"derive-where",
44924492
"rustc_ast_ir",
44934493
"rustc_data_structures",
44944494
"rustc_index",

Diff for: compiler/rustc_next_trait_solver/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66
[dependencies]
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
9-
derivative = "2.2.0"
9+
derive-where = "1.2.7"
1010
rustc_ast_ir = { path = "../rustc_ast_ir", default-features = false }
1111
rustc_data_structures = { path = "../rustc_data_structures", optional = true }
1212
rustc_index = { path = "../rustc_index", default-features = false }

Diff for: compiler/rustc_next_trait_solver/src/coherence.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use std::fmt::Debug;
22
use std::ops::ControlFlow;
33

4+
use derive_where::derive_where;
45
use rustc_type_ir::inherent::*;
56
use rustc_type_ir::visit::{TypeVisitable, TypeVisitableExt, TypeVisitor};
67
use rustc_type_ir::{self as ty, InferCtxtLike, Interner};
@@ -108,15 +109,13 @@ impl From<bool> for IsFirstInputType {
108109
}
109110
}
110111

111-
#[derive(derivative::Derivative)]
112-
#[derivative(Debug(bound = "T: Debug"))]
112+
#[derive_where(Debug; I: Interner, T: Debug)]
113113
pub enum OrphanCheckErr<I: Interner, T> {
114114
NonLocalInputType(Vec<(I::Ty, IsFirstInputType)>),
115115
UncoveredTyParams(UncoveredTyParams<I, T>),
116116
}
117117

118-
#[derive(derivative::Derivative)]
119-
#[derivative(Debug(bound = "T: Debug"))]
118+
#[derive_where(Debug; I: Interner, T: Debug)]
120119
pub struct UncoveredTyParams<I: Interner, T> {
121120
pub uncovered: T,
122121
pub local_ty: Option<I::Ty>,

Diff for: compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
pub(super) mod structural_traits;
44

5+
use derive_where::derive_where;
56
use rustc_type_ir::elaborate;
67
use rustc_type_ir::fold::TypeFoldable;
78
use rustc_type_ir::inherent::*;
@@ -21,8 +22,7 @@ use crate::solve::{
2122
///
2223
/// It consists of both the `source`, which describes how that goal would be proven,
2324
/// and the `result` when using the given `source`.
24-
#[derive(derivative::Derivative)]
25-
#[derivative(Debug(bound = ""), Clone(bound = ""))]
25+
#[derive_where(Clone, Debug; I: Interner)]
2626
pub(super) struct Candidate<I: Interner> {
2727
pub(super) source: CandidateSource<I>,
2828
pub(super) result: CanonicalResponse<I>,

Diff for: compiler/rustc_next_trait_solver/src/solve/assembly/structural_traits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Code which is used by built-in goals that match "structurally", such a auto
22
//! traits, `Copy`/`Clone`.
33
4+
use derive_where::derive_where;
45
use rustc_ast_ir::{Movability, Mutability};
56
use rustc_type_ir::data_structures::HashMap;
67
use rustc_type_ir::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
@@ -384,8 +385,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_callable<I: Intern
384385

385386
/// Relevant types for an async callable, including its inputs, output,
386387
/// and the return type you get from awaiting the output.
387-
#[derive(derivative::Derivative)]
388-
#[derivative(Clone(bound = ""), Copy(bound = ""), Debug(bound = ""))]
388+
#[derive_where(Clone, Copy, Debug; I: Interner)]
389389
#[derive(TypeVisitable_Generic, TypeFoldable_Generic)]
390390
pub(in crate::solve) struct AsyncCallableRelevantTypes<I: Interner> {
391391
pub tupled_inputs_ty: I::Ty,

Diff for: compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::ops::ControlFlow;
22

3+
use derive_where::derive_where;
34
#[cfg(feature = "nightly")]
45
use rustc_macros::{HashStable_NoContext, TyDecodable, TyEncodable};
56
use rustc_type_ir::data_structures::ensure_sufficient_stack;
@@ -87,8 +88,7 @@ where
8788
pub(super) inspect: ProofTreeBuilder<D>,
8889
}
8990

90-
#[derive(derivative::Derivative)]
91-
#[derivative(Clone(bound = ""), Debug(bound = ""), Default(bound = ""))]
91+
#[derive_where(Clone, Debug, Default; I: Interner)]
9292
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
9393
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
9494
// FIXME: This can be made crate-private once `EvalCtxt` also lives in this crate.

Diff for: compiler/rustc_next_trait_solver/src/solve/inspect/build.rs

+8-14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use std::marker::PhantomData;
88
use std::mem;
99

10+
use derive_where::derive_where;
1011
use rustc_type_ir::inherent::*;
1112
use rustc_type_ir::{self as ty, search_graph, Interner};
1213

@@ -51,8 +52,7 @@ where
5152
/// in the code, only one or two variants are actually possible.
5253
///
5354
/// We simply ICE in case that assumption is broken.
54-
#[derive(derivative::Derivative)]
55-
#[derivative(Debug(bound = ""))]
55+
#[derive_where(Debug; I: Interner)]
5656
enum DebugSolver<I: Interner> {
5757
Root,
5858
GoalEvaluation(WipGoalEvaluation<I>),
@@ -78,8 +78,7 @@ impl<I: Interner> From<WipCanonicalGoalEvaluationStep<I>> for DebugSolver<I> {
7878
}
7979
}
8080

81-
#[derive(derivative::Derivative)]
82-
#[derivative(PartialEq(bound = ""), Eq(bound = ""), Debug(bound = ""))]
81+
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
8382
struct WipGoalEvaluation<I: Interner> {
8483
pub uncanonicalized_goal: Goal<I, I::Predicate>,
8584
pub orig_values: Vec<I::GenericArg>,
@@ -96,8 +95,7 @@ impl<I: Interner> WipGoalEvaluation<I> {
9695
}
9796
}
9897

99-
#[derive(derivative::Derivative)]
100-
#[derivative(PartialEq(bound = ""), Eq(bound = ""))]
98+
#[derive_where(PartialEq, Eq; I: Interner)]
10199
pub(in crate::solve) enum WipCanonicalGoalEvaluationKind<I: Interner> {
102100
Overflow,
103101
CycleInStack,
@@ -118,8 +116,7 @@ impl<I: Interner> std::fmt::Debug for WipCanonicalGoalEvaluationKind<I> {
118116
}
119117
}
120118

121-
#[derive(derivative::Derivative)]
122-
#[derivative(PartialEq(bound = ""), Eq(bound = ""), Debug(bound = ""))]
119+
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
123120
struct WipCanonicalGoalEvaluation<I: Interner> {
124121
goal: CanonicalInput<I>,
125122
kind: Option<WipCanonicalGoalEvaluationKind<I>>,
@@ -153,8 +150,7 @@ impl<I: Interner> WipCanonicalGoalEvaluation<I> {
153150
}
154151
}
155152

156-
#[derive(derivative::Derivative)]
157-
#[derivative(PartialEq(bound = ""), Eq(bound = ""), Debug(bound = ""))]
153+
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
158154
struct WipCanonicalGoalEvaluationStep<I: Interner> {
159155
/// Unlike `EvalCtxt::var_values`, we append a new
160156
/// generic arg here whenever we create a new inference
@@ -193,8 +189,7 @@ impl<I: Interner> WipCanonicalGoalEvaluationStep<I> {
193189
}
194190
}
195191

196-
#[derive(derivative::Derivative)]
197-
#[derivative(PartialEq(bound = ""), Eq(bound = ""), Debug(bound = ""))]
192+
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
198193
struct WipProbe<I: Interner> {
199194
initial_num_var_values: usize,
200195
steps: Vec<WipProbeStep<I>>,
@@ -212,8 +207,7 @@ impl<I: Interner> WipProbe<I> {
212207
}
213208
}
214209

215-
#[derive(derivative::Derivative)]
216-
#[derivative(PartialEq(bound = ""), Eq(bound = ""), Debug(bound = ""))]
210+
#[derive_where(PartialEq, Eq, Debug; I: Interner)]
217211
enum WipProbeStep<I: Interner> {
218212
AddGoal(GoalSource, inspect::CanonicalState<I, Goal<I, I::Predicate>>),
219213
NestedProbe(WipProbe<I>),

0 commit comments

Comments
 (0)