Skip to content

Commit e79b2a1

Browse files
committed
Auto merge of #61172 - matthewjasper:cleanup-implied-bounds-lint, r=varkor
Improve the explicit_outlives_requirements lint * Don't use Strings to compare parameters * Extend the lint to lifetime bounds * Extend the lint to enums and unions * Use the correct span for where clauses in tuple structs * Try to early-out where possible * Remove unnecessary bounds in rustc crates
2 parents 9cb052a + fdeb581 commit e79b2a1

20 files changed

+3429
-548
lines changed

src/librustc/hir/intravisit.rs

-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,6 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi
773773

774774
pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics) {
775775
walk_list!(visitor, visit_generic_param, &generics.params);
776-
visitor.visit_id(generics.where_clause.hir_id);
777776
walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates);
778777
}
779778

src/librustc/hir/lowering.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1755,8 +1755,8 @@ impl<'a> LoweringContext<'a> {
17551755
generics: hir::Generics {
17561756
params: lifetime_defs,
17571757
where_clause: hir::WhereClause {
1758-
hir_id: lctx.next_id(),
17591758
predicates: hir_vec![],
1759+
span,
17601760
},
17611761
span,
17621762
},
@@ -2647,8 +2647,8 @@ impl<'a> LoweringContext<'a> {
26472647
generics: hir::Generics {
26482648
params: generic_params,
26492649
where_clause: hir::WhereClause {
2650-
hir_id: this.next_id(),
26512650
predicates: hir_vec![],
2651+
span,
26522652
},
26532653
span,
26542654
},
@@ -3001,11 +3001,11 @@ impl<'a> LoweringContext<'a> {
30013001
AnonymousLifetimeMode::ReportError,
30023002
|this| {
30033003
hir::WhereClause {
3004-
hir_id: this.lower_node_id(wc.id),
30053004
predicates: wc.predicates
30063005
.iter()
30073006
.map(|predicate| this.lower_where_predicate(predicate))
30083007
.collect(),
3008+
span: wc.span,
30093009
}
30103010
},
30113011
)

src/librustc/hir/mod.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,8 @@ impl Generics {
592592
Generics {
593593
params: HirVec::new(),
594594
where_clause: WhereClause {
595-
hir_id: DUMMY_HIR_ID,
596595
predicates: HirVec::new(),
596+
span: DUMMY_SP,
597597
},
598598
span: DUMMY_SP,
599599
}
@@ -644,19 +644,18 @@ pub enum SyntheticTyParamKind {
644644
/// A where-clause in a definition.
645645
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
646646
pub struct WhereClause {
647-
pub hir_id: HirId,
648647
pub predicates: HirVec<WherePredicate>,
648+
// Only valid if predicates isn't empty.
649+
span: Span,
649650
}
650651

651652
impl WhereClause {
652653
pub fn span(&self) -> Option<Span> {
653-
self.predicates.iter().map(|predicate| predicate.span())
654-
.fold(None, |acc, i| match (acc, i) {
655-
(None, i) => Some(i),
656-
(Some(acc), i) => {
657-
Some(acc.to(i))
658-
}
659-
})
654+
if self.predicates.is_empty() {
655+
None
656+
} else {
657+
Some(self.span)
658+
}
660659
}
661660
}
662661

src/librustc/hir/print.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2202,8 +2202,8 @@ impl<'a> State<'a> {
22022202
let generics = hir::Generics {
22032203
params: hir::HirVec::new(),
22042204
where_clause: hir::WhereClause {
2205-
hir_id: hir::DUMMY_HIR_ID,
22062205
predicates: hir::HirVec::new(),
2206+
span: syntax_pos::DUMMY_SP,
22072207
},
22082208
span: syntax_pos::DUMMY_SP,
22092209
};

0 commit comments

Comments
 (0)