Skip to content

Improve the explicit_outlives_requirements lint #61172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ pub fn walk_generic_param<'v, V: Visitor<'v>>(visitor: &mut V, param: &'v Generi

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

Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1727,8 +1727,8 @@ impl<'a> LoweringContext<'a> {
generics: hir::Generics {
params: lifetime_defs,
where_clause: hir::WhereClause {
hir_id: lctx.next_id(),
predicates: hir_vec![],
span,
},
span,
},
Expand Down Expand Up @@ -2619,8 +2619,8 @@ impl<'a> LoweringContext<'a> {
generics: hir::Generics {
params: generic_params,
where_clause: hir::WhereClause {
hir_id: this.next_id(),
predicates: hir_vec![],
span,
},
span,
},
Expand Down Expand Up @@ -2973,11 +2973,11 @@ impl<'a> LoweringContext<'a> {
AnonymousLifetimeMode::ReportError,
|this| {
hir::WhereClause {
hir_id: this.lower_node_id(wc.id),
predicates: wc.predicates
.iter()
.map(|predicate| this.lower_where_predicate(predicate))
.collect(),
span: wc.span,
}
},
)
Expand Down
17 changes: 8 additions & 9 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ impl Generics {
Generics {
params: HirVec::new(),
where_clause: WhereClause {
hir_id: DUMMY_HIR_ID,
predicates: HirVec::new(),
span: DUMMY_SP,
},
span: DUMMY_SP,
}
Expand Down Expand Up @@ -644,19 +644,18 @@ pub enum SyntheticTyParamKind {
/// A where-clause in a definition.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct WhereClause {
pub hir_id: HirId,
pub predicates: HirVec<WherePredicate>,
// Only valid if predicates isn't empty.
span: Span,
}

impl WhereClause {
pub fn span(&self) -> Option<Span> {
self.predicates.iter().map(|predicate| predicate.span())
.fold(None, |acc, i| match (acc, i) {
(None, i) => Some(i),
(Some(acc), i) => {
Some(acc.to(i))
}
})
if self.predicates.is_empty() {
None
} else {
Some(self.span)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2202,8 +2202,8 @@ impl<'a> State<'a> {
let generics = hir::Generics {
params: hir::HirVec::new(),
where_clause: hir::WhereClause {
hir_id: hir::DUMMY_HIR_ID,
predicates: hir::HirVec::new(),
span: syntax_pos::DUMMY_SP,
},
span: syntax_pos::DUMMY_SP,
};
Expand Down
Loading