@@ -34,15 +34,15 @@ use crate::traits::query::normalize::NormalizationResult;
3434use crate :: traits:: query:: outlives_bounds:: OutlivesBound ;
3535use crate :: traits:: specialization_graph;
3636use crate :: traits:: Clauses ;
37- use crate :: ty:: { self , CrateInherentImpls , ParamEnvAnd , Ty , TyCtxt } ;
37+ use crate :: ty:: { self , CrateInherentImpls , ParamEnvAnd , Ty , TyCtxt , AdtSizedConstraint } ;
3838use crate :: ty:: steal:: Steal ;
3939use crate :: ty:: subst:: Substs ;
40+ use crate :: ty:: util:: NeedsDrop ;
4041use crate :: util:: nodemap:: { DefIdSet , DefIdMap , ItemLocalSet } ;
4142use crate :: util:: common:: { ErrorReported } ;
4243use crate :: util:: profiling:: ProfileCategory :: * ;
4344use crate :: session:: Session ;
4445
45- use errors:: DiagnosticBuilder ;
4646use rustc_data_structures:: svh:: Svh ;
4747use rustc_data_structures:: bit_set:: BitSet ;
4848use rustc_data_structures:: indexed_vec:: IndexVec ;
@@ -154,7 +154,16 @@ define_queries! { <'tcx>
154154 [ ] fn trait_def: TraitDefOfItem ( DefId ) -> & ' tcx ty:: TraitDef ,
155155 [ ] fn adt_def: AdtDefOfItem ( DefId ) -> & ' tcx ty:: AdtDef ,
156156 [ ] 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+
158167 [ ] fn adt_dtorck_constraint: DtorckConstraint (
159168 DefId
160169 ) -> Result <DtorckConstraint <' tcx>, NoSolution >,
@@ -411,7 +420,16 @@ define_queries! { <'tcx>
411420 [ ] fn is_copy_raw: is_copy_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>) -> bool ,
412421 [ ] fn is_sized_raw: is_sized_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>) -> bool ,
413422 [ ] 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+
415433 [ ] fn layout_raw: layout_dep_node( ty:: ParamEnvAnd <' tcx, Ty <' tcx>>)
416434 -> Result <& ' tcx ty:: layout:: LayoutDetails ,
417435 ty:: layout:: LayoutError <' tcx>>,
@@ -731,32 +749,6 @@ define_queries! { <'tcx>
731749 } ,
732750}
733751
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-
760752//////////////////////////////////////////////////////////////////////
761753// These functions are little shims used to find the dep-node for a
762754// given query when there is not a *direct* mapping:
0 commit comments