File tree Expand file tree Collapse file tree 1 file changed +16
-5
lines changed
frontend/exporter/src/traits Expand file tree Collapse file tree 1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change 2727//! benefit of reducing the size of signatures. Moreover, the rules on which bounds are required vs
2828//! implied are subtle. We may change this if this proves to be a problem.
2929use rustc_hir:: def:: DefKind ;
30+ use rustc_hir:: LangItem ;
3031use rustc_middle:: ty:: * ;
3132use rustc_span:: def_id:: DefId ;
3233use rustc_span:: { Span , DUMMY_SP } ;
@@ -92,11 +93,21 @@ pub fn required_predicates<'tcx>(
9293 predicates. to_mut ( ) . insert ( 0 , ( self_clause, DUMMY_SP ) ) ;
9394 }
9495 if add_drop {
95- // Add a `T: Drop` bound for every generic, unless the current trait is `Drop` itself, or
96- // `Sized`.
97- let drop_trait = tcx. lang_items ( ) . drop_trait ( ) . unwrap ( ) ;
98- let sized_trait = tcx. lang_items ( ) . sized_trait ( ) . unwrap ( ) ;
99- if def_id != drop_trait && def_id != sized_trait {
96+ // Add a `T: Drop` bound for every generic, unless the current trait is `Drop` itself, or a
97+ // built-in marker trait that we know doesn't need the bound.
98+ let lang_item = tcx. as_lang_item ( def_id) ;
99+ if !matches ! (
100+ lang_item,
101+ Some (
102+ LangItem :: Drop
103+ | LangItem :: Sized
104+ | LangItem :: MetaSized
105+ | LangItem :: PointeeSized
106+ | LangItem :: DiscriminantKind
107+ | LangItem :: PointeeTrait
108+ )
109+ ) {
110+ let drop_trait = tcx. lang_items ( ) . drop_trait ( ) . unwrap ( ) ;
100111 let extra_bounds = tcx
101112 . generics_of ( def_id)
102113 . own_params
You can’t perform that action at this time.
0 commit comments