@@ -19,6 +19,7 @@ use rustc_infer::infer::{
1919 BoundRegionConversionTime , InferCtxt , NllRegionVariableOrigin , RegionVariableOrigin ,
2020} ;
2121use rustc_infer:: traits:: PredicateObligations ;
22+ use rustc_middle:: bug;
2223use rustc_middle:: mir:: visit:: { NonMutatingUseContext , PlaceContext , Visitor } ;
2324use rustc_middle:: mir:: * ;
2425use rustc_middle:: traits:: query:: NoSolution ;
@@ -28,7 +29,6 @@ use rustc_middle::ty::{
2829 self , CanonicalUserTypeAnnotation , CanonicalUserTypeAnnotations , CoroutineArgsExt ,
2930 GenericArgsRef , Ty , TyCtxt , TypeVisitableExt , UserArgs , UserTypeAnnotationIndex , fold_regions,
3031} ;
31- use rustc_middle:: { bug, span_bug} ;
3232use rustc_mir_dataflow:: move_paths:: MoveData ;
3333use rustc_mir_dataflow:: points:: DenseLocationMap ;
3434use rustc_span:: def_id:: CRATE_DEF_ID ;
@@ -387,18 +387,10 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
387387 #[ instrument( skip( self ) , level = "debug" ) ]
388388 fn check_user_type_annotations ( & mut self ) {
389389 debug ! ( ?self . user_type_annotations) ;
390- let tcx = self . tcx ( ) ;
391390 for user_annotation in self . user_type_annotations {
392391 let CanonicalUserTypeAnnotation { span, ref user_ty, inferred_ty } = * user_annotation;
393392 let annotation = self . instantiate_canonical ( span, user_ty) ;
394- if let ty:: UserTypeKind :: TypeOf ( def, args) = annotation. kind
395- && let DefKind :: InlineConst = tcx. def_kind ( def)
396- {
397- assert ! ( annotation. bounds. is_empty( ) ) ;
398- self . check_inline_const ( inferred_ty, def. expect_local ( ) , args, span) ;
399- } else {
400- self . ascribe_user_type ( inferred_ty, annotation, span) ;
401- }
393+ self . ascribe_user_type ( inferred_ty, annotation, span) ;
402394 }
403395 }
404396
@@ -560,36 +552,6 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
560552 self . constraints . liveness_constraints . add_location ( region, location) ;
561553 }
562554 }
563-
564- fn check_inline_const (
565- & mut self ,
566- inferred_ty : Ty < ' tcx > ,
567- def_id : LocalDefId ,
568- args : UserArgs < ' tcx > ,
569- span : Span ,
570- ) {
571- assert ! ( args. user_self_ty. is_none( ) ) ;
572- let tcx = self . tcx ( ) ;
573- let const_ty = tcx. type_of ( def_id) . instantiate ( tcx, args. args ) ;
574- if let Err ( terr) =
575- self . eq_types ( const_ty, inferred_ty, Locations :: All ( span) , ConstraintCategory :: Boring )
576- {
577- span_bug ! (
578- span,
579- "bad inline const pattern: ({:?} = {:?}) {:?}" ,
580- const_ty,
581- inferred_ty,
582- terr
583- ) ;
584- }
585- let args = self . infcx . resolve_vars_if_possible ( args. args ) ;
586- let predicates = self . prove_closure_bounds ( tcx, def_id, args, Locations :: All ( span) ) ;
587- self . normalize_and_prove_instantiated_predicates (
588- def_id. to_def_id ( ) ,
589- predicates,
590- Locations :: All ( span) ,
591- ) ;
592- }
593555}
594556
595557impl < ' a , ' tcx > Visitor < ' tcx > for TypeChecker < ' a , ' tcx > {
@@ -1731,12 +1693,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
17311693 let def_id = uv. def ;
17321694 if tcx. def_kind ( def_id) == DefKind :: InlineConst {
17331695 let def_id = def_id. expect_local ( ) ;
1734- let predicates = self . prove_closure_bounds (
1735- tcx,
1736- def_id,
1737- uv. args ,
1738- location. to_locations ( ) ,
1739- ) ;
1696+ let predicates = self . prove_closure_bounds ( tcx, def_id, uv. args , location) ;
17401697 self . normalize_and_prove_instantiated_predicates (
17411698 def_id. to_def_id ( ) ,
17421699 predicates,
@@ -2519,15 +2476,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25192476 // clauses on the struct.
25202477 AggregateKind :: Closure ( def_id, args)
25212478 | AggregateKind :: CoroutineClosure ( def_id, args)
2522- | AggregateKind :: Coroutine ( def_id, args) => (
2523- def_id,
2524- self . prove_closure_bounds (
2525- tcx,
2526- def_id. expect_local ( ) ,
2527- args,
2528- location. to_locations ( ) ,
2529- ) ,
2530- ) ,
2479+ | AggregateKind :: Coroutine ( def_id, args) => {
2480+ ( def_id, self . prove_closure_bounds ( tcx, def_id. expect_local ( ) , args, location) )
2481+ }
25312482
25322483 AggregateKind :: Array ( _) | AggregateKind :: Tuple | AggregateKind :: RawPtr ( ..) => {
25332484 ( CRATE_DEF_ID . to_def_id ( ) , ty:: InstantiatedPredicates :: empty ( ) )
@@ -2546,12 +2497,12 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25462497 tcx : TyCtxt < ' tcx > ,
25472498 def_id : LocalDefId ,
25482499 args : GenericArgsRef < ' tcx > ,
2549- locations : Locations ,
2500+ location : Location ,
25502501 ) -> ty:: InstantiatedPredicates < ' tcx > {
25512502 let root_def_id = self . root_cx . root_def_id ( ) ;
25522503 // We will have to handle propagated closure requirements for this closure,
25532504 // but need to defer this until the nested body has been fully borrow checked.
2554- self . deferred_closure_requirements . push ( ( def_id, args, locations ) ) ;
2505+ self . deferred_closure_requirements . push ( ( def_id, args, location . to_locations ( ) ) ) ;
25552506
25562507 // Equate closure args to regions inherited from `root_def_id`. Fixes #98589.
25572508 let typeck_root_args = ty:: GenericArgs :: identity_for_item ( tcx, root_def_id) ;
@@ -2575,7 +2526,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
25752526 if let Err ( _) = self . eq_args (
25762527 typeck_root_args,
25772528 parent_args,
2578- locations ,
2529+ location . to_locations ( ) ,
25792530 ConstraintCategory :: BoringNoLocation ,
25802531 ) {
25812532 span_mirbug ! (
0 commit comments