@@ -34,15 +34,15 @@ use crate::traits::query::normalize::NormalizationResult;
34
34
use crate :: traits:: query:: outlives_bounds:: OutlivesBound ;
35
35
use crate :: traits:: specialization_graph;
36
36
use crate :: traits:: Clauses ;
37
- use crate :: ty:: { self , CrateInherentImpls , ParamEnvAnd , Ty , TyCtxt } ;
37
+ use crate :: ty:: { self , CrateInherentImpls , ParamEnvAnd , Ty , TyCtxt , AdtSizedConstraint } ;
38
38
use crate :: ty:: steal:: Steal ;
39
39
use crate :: ty:: subst:: Substs ;
40
+ use crate :: ty:: util:: NeedsDrop ;
40
41
use crate :: util:: nodemap:: { DefIdSet , DefIdMap , ItemLocalSet } ;
41
42
use crate :: util:: common:: { ErrorReported } ;
42
43
use crate :: util:: profiling:: ProfileCategory :: * ;
43
44
use crate :: session:: Session ;
44
45
45
- use errors:: DiagnosticBuilder ;
46
46
use rustc_data_structures:: svh:: Svh ;
47
47
use rustc_data_structures:: bit_set:: BitSet ;
48
48
use rustc_data_structures:: indexed_vec:: IndexVec ;
@@ -154,7 +154,16 @@ define_queries! { <'tcx>
154
154
[ ] fn trait_def: TraitDefOfItem ( DefId ) -> & ' tcx ty:: TraitDef ,
155
155
[ ] fn adt_def: AdtDefOfItem ( DefId ) -> & ' tcx ty:: AdtDef ,
156
156
[ ] fn adt_destructor: AdtDestructor ( DefId ) -> Option <ty:: Destructor >,
157
- [ ] fn adt_sized_constraint: SizedConstraint ( DefId ) -> & ' tcx [ Ty <' tcx>] ,
157
+
158
+ // The cycle error here should be reported as an error by `check_representable`.
159
+ // We consider the type as Sized in the meanwhile to avoid
160
+ // further errors (done in impl Value for AdtSizedConstraint).
161
+ // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
162
+ // in case we accidentally otherwise don't emit an error.
163
+ [ cycle_delay_bug] fn adt_sized_constraint: SizedConstraint (
164
+ DefId
165
+ ) -> AdtSizedConstraint <' tcx>,
166
+
158
167
[ ] fn adt_dtorck_constraint: DtorckConstraint (
159
168
DefId
160
169
) -> Result <DtorckConstraint <' tcx>, NoSolution >,
@@ -411,7 +420,16 @@ define_queries! { <'tcx>
411
420
[ ] fn is_copy_raw: is_copy_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>) -> bool ,
412
421
[ ] fn is_sized_raw: is_sized_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>) -> bool ,
413
422
[ ] fn is_freeze_raw: is_freeze_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>) -> bool ,
414
- [ ] fn needs_drop_raw: needs_drop_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>) -> bool ,
423
+
424
+ // The cycle error here should be reported as an error by `check_representable`.
425
+ // We consider the type as not needing drop in the meanwhile to avoid
426
+ // further errors (done in impl Value for NeedsDrop).
427
+ // Use `cycle_delay_bug` to delay the cycle error here to be emitted later
428
+ // in case we accidentally otherwise don't emit an error.
429
+ [ cycle_delay_bug] fn needs_drop_raw: needs_drop_dep_node(
430
+ ty:: ParamEnvAnd <' tcx, Ty <' tcx>>
431
+ ) -> NeedsDrop ,
432
+
415
433
[ ] fn layout_raw: layout_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>)
416
434
-> Result <& ' tcx ty:: layout:: LayoutDetails ,
417
435
ty:: layout:: LayoutError <' tcx>>,
@@ -731,32 +749,6 @@ define_queries! { <'tcx>
731
749
} ,
732
750
}
733
751
734
- // `try_get_query` can't be public because it uses the private query
735
- // implementation traits, so we provide access to it selectively.
736
- impl < ' a , ' tcx , ' lcx > TyCtxt < ' a , ' tcx , ' lcx > {
737
- pub fn try_adt_sized_constraint (
738
- self ,
739
- span : Span ,
740
- key : DefId ,
741
- ) -> Result < & ' tcx [ Ty < ' tcx > ] , Box < DiagnosticBuilder < ' a > > > {
742
- self . try_get_query :: < queries:: adt_sized_constraint < ' _ > > ( span, key)
743
- }
744
- pub fn try_needs_drop_raw (
745
- self ,
746
- span : Span ,
747
- key : ty:: ParamEnvAnd < ' tcx , Ty < ' tcx > > ,
748
- ) -> Result < bool , Box < DiagnosticBuilder < ' a > > > {
749
- self . try_get_query :: < queries:: needs_drop_raw < ' _ > > ( span, key)
750
- }
751
- pub fn try_optimized_mir (
752
- self ,
753
- span : Span ,
754
- key : DefId ,
755
- ) -> Result < & ' tcx mir:: Mir < ' tcx > , Box < DiagnosticBuilder < ' a > > > {
756
- self . try_get_query :: < queries:: optimized_mir < ' _ > > ( span, key)
757
- }
758
- }
759
-
760
752
//////////////////////////////////////////////////////////////////////
761
753
// These functions are little shims used to find the dep-node for a
762
754
// given query when there is not a *direct* mapping:
0 commit comments