@@ -22,7 +22,6 @@ use rustc_middle::ty::{
2222} ;
2323use rustc_span:: Span ;
2424use rustc_target:: abi:: { HasDataLayout , Size , TargetDataLayout } ;
25- use rustc_trait_selection:: traits;
2625
2726use crate :: const_prop:: CanConstProp ;
2827use crate :: const_prop:: ConstPropMachine ;
@@ -67,42 +66,6 @@ impl<'tcx> MirLint<'tcx> for ConstProp {
6766 return ;
6867 }
6968
70- // Check if it's even possible to satisfy the 'where' clauses
71- // for this item.
72- // This branch will never be taken for any normal function.
73- // However, it's possible to `#!feature(trivial_bounds)]` to write
74- // a function with impossible to satisfy clauses, e.g.:
75- // `fn foo() where String: Copy {}`
76- //
77- // We don't usually need to worry about this kind of case,
78- // since we would get a compilation error if the user tried
79- // to call it. However, since we can do const propagation
80- // even without any calls to the function, we need to make
81- // sure that it even makes sense to try to evaluate the body.
82- // If there are unsatisfiable where clauses, then all bets are
83- // off, and we just give up.
84- //
85- // We manually filter the predicates, skipping anything that's not
86- // "global". We are in a potentially generic context
87- // (e.g. we are evaluating a function without substituting generic
88- // parameters, so this filtering serves two purposes:
89- //
90- // 1. We skip evaluating any predicates that we would
91- // never be able prove are unsatisfiable (e.g. `<T as Foo>`
92- // 2. We avoid trying to normalize predicates involving generic
93- // parameters (e.g. `<T as Foo>::MyItem`). This can confuse
94- // the normalization code (leading to cycle errors), since
95- // it's usually never invoked in this way.
96- let predicates = tcx
97- . predicates_of ( def_id. to_def_id ( ) )
98- . predicates
99- . iter ( )
100- . filter_map ( |( p, _) | if p. is_global ( ) { Some ( * p) } else { None } ) ;
101- if traits:: impossible_predicates ( tcx, traits:: elaborate ( tcx, predicates) . collect ( ) ) {
102- trace ! ( "ConstProp skipped for {:?}: found unsatisfiable predicates" , def_id) ;
103- return ;
104- }
105-
10669 trace ! ( "ConstProp starting for {:?}" , def_id) ;
10770
10871 // FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold
0 commit comments