11use rustc_errors:: ErrorGuaranteed ;
2- use rustc_hir:: def:: DefKind ;
32use rustc_hir:: LangItem ;
43use rustc_hir:: def_id:: DefId ;
54use rustc_infer:: infer:: TyCtxtInferExt ;
@@ -11,12 +10,11 @@ use rustc_middle::ty::{
1110} ;
1211use rustc_span:: sym;
1312use rustc_trait_selection:: traits;
14- use tracing:: { debug, instrument } ;
13+ use tracing:: debug;
1514use traits:: translate_args;
1615
1716use crate :: errors:: UnexpectedFnPtrAssociatedItem ;
1817
19- #[ instrument( level = "debug" , skip( tcx) , ret) ]
2018fn resolve_instance_raw < ' tcx > (
2119 tcx : TyCtxt < ' tcx > ,
2220 key : ty:: PseudoCanonicalInput < ' tcx , ( DefId , GenericArgsRef < ' tcx > ) > ,
@@ -92,32 +90,13 @@ fn resolve_instance_raw<'tcx>(
9290 let ty = args. type_at ( 0 ) ;
9391 ty:: InstanceKind :: AsyncDropGlue ( def_id, ty)
9492 } else {
95- debug ! ( " => free or inherent item" ) ;
93+ debug ! ( " => free item" ) ;
9694 ty:: InstanceKind :: Item ( def_id)
9795 } ;
9896
9997 Ok ( Some ( Instance { def, args } ) )
10098 } ;
101-
102- if let Ok ( Some ( Instance { def : ty:: InstanceKind :: Item ( def_id) , args } ) ) = result
103- && matches ! ( tcx. def_kind( def_id) , DefKind :: Const | DefKind :: AssocConst )
104- {
105- debug ! ( " => resolved to const item" ) ;
106- let ct = tcx. const_of_item ( def_id) . instantiate ( tcx, args) ;
107- debug ! ( "ct={ct:?}" ) ;
108- if let ty:: ConstKind :: Unevaluated ( uv) = ct. kind ( ) {
109- if tcx. def_kind ( uv. def ) == DefKind :: AnonConst {
110- return Ok ( Some ( ty:: Instance {
111- def : ty:: InstanceKind :: Item ( uv. def ) ,
112- args : uv. args ,
113- } ) ) ;
114- } else {
115- let input = PseudoCanonicalInput { typing_env, value : ( uv. def , uv. args ) } ;
116- return tcx. resolve_instance_raw ( input) ;
117- }
118- }
119- }
120-
99+ debug ! ( "resolve_instance: result={:?}" , result) ;
121100 result
122101}
123102
0 commit comments