Skip to content

Commit 58af0c7

Browse files
authored
Rollup merge of rust-lang#48296 - ishitatsuyuki:exp-unblow, r=nikomatsakis
Fix exponential projection complexity on nested types This implements solution 1 from rust-lang#38528 (comment). The code quality is currently extremely poor, but we can improve them during review. Blocking issues: - we probably don't want a quadratic deduplication for obligations. - is there an alternative to deduplication? Based on rust-lang#48315. Needs changelog. Noticable improvement on compile time is expected. Fix rust-lang#38528 Close rust-lang#39684 Close rust-lang#43757
2 parents 0957572 + 5a2bec9 commit 58af0c7

File tree

6 files changed

+133
-151
lines changed

6 files changed

+133
-151
lines changed

src/librustc/traits/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub enum IntercrateMode {
7373
/// either identifying an `impl` (e.g., `impl Eq for int`) that
7474
/// provides the required vtable, or else finding a bound that is in
7575
/// scope. The eventual result is usually a `Selection` (defined below).
76-
#[derive(Clone, PartialEq, Eq)]
76+
#[derive(Clone, PartialEq, Eq, Hash)]
7777
pub struct Obligation<'tcx, T> {
7878
pub cause: ObligationCause<'tcx>,
7979
pub param_env: ty::ParamEnv<'tcx>,
@@ -85,7 +85,7 @@ pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
8585
pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
8686

8787
/// Why did we incur this obligation? Used for error reporting.
88-
#[derive(Clone, Debug, PartialEq, Eq)]
88+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
8989
pub struct ObligationCause<'tcx> {
9090
pub span: Span,
9191

@@ -113,7 +113,7 @@ impl<'tcx> ObligationCause<'tcx> {
113113
}
114114
}
115115

116-
#[derive(Clone, Debug, PartialEq, Eq)]
116+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
117117
pub enum ObligationCauseCode<'tcx> {
118118
/// Not well classified or should be obvious from span.
119119
MiscObligation,
@@ -215,7 +215,7 @@ pub enum ObligationCauseCode<'tcx> {
215215
BlockTailExpression(ast::NodeId),
216216
}
217217

218-
#[derive(Clone, Debug, PartialEq, Eq)]
218+
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
219219
pub struct DerivedObligationCause<'tcx> {
220220
/// The trait reference of the parent obligation that led to the
221221
/// current obligation. Note that only trait obligations lead to
@@ -304,7 +304,7 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
304304
/// ### The type parameter `N`
305305
///
306306
/// See explanation on `VtableImplData`.
307-
#[derive(Clone, RustcEncodable, RustcDecodable)]
307+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
308308
pub enum Vtable<'tcx, N> {
309309
/// Vtable identifying a particular impl.
310310
VtableImpl(VtableImplData<'tcx, N>),
@@ -374,13 +374,13 @@ pub struct VtableClosureData<'tcx, N> {
374374
pub nested: Vec<N>
375375
}
376376

377-
#[derive(Clone, RustcEncodable, RustcDecodable)]
377+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
378378
pub struct VtableAutoImplData<N> {
379379
pub trait_def_id: DefId,
380380
pub nested: Vec<N>
381381
}
382382

383-
#[derive(Clone, RustcEncodable, RustcDecodable)]
383+
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
384384
pub struct VtableBuiltinData<N> {
385385
pub nested: Vec<N>
386386
}

0 commit comments

Comments
 (0)