Skip to content

Commit fdeb581

Browse files
committed
Address review comments
1 parent d5f80c8 commit fdeb581

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

src/librustc_lint/builtin.rs

+20-19
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ impl ExplicitOutlivesRequirements {
16181618
let mut from_start = true;
16191619
for (i, bound_span) in bound_spans {
16201620
match last_merged_i {
1621-
// If the first bound is inferable, our span should also eat the leading `+`
1621+
// If the first bound is inferable, our span should also eat the leading `+`.
16221622
None if i == 0 => {
16231623
merged.push(bound_span.to(bounds[1].span().shrink_to_lo()));
16241624
last_merged_i = Some(0);
@@ -1732,15 +1732,17 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
17321732
hir::TyKind::Path(hir::QPath::Resolved(
17331733
None,
17341734
ref path,
1735-
)) => if let Res::Def(DefKind::TyParam, def_id) = path.res {
1736-
let index = ty_generics.param_def_id_to_index[&def_id];
1737-
(
1738-
Self::lifetimes_outliving_type(inferred_outlives, index),
1739-
&predicate.bounds,
1740-
predicate.span,
1741-
)
1742-
} else {
1743-
continue
1735+
)) => {
1736+
if let Res::Def(DefKind::TyParam, def_id) = path.res {
1737+
let index = ty_generics.param_def_id_to_index[&def_id];
1738+
(
1739+
Self::lifetimes_outliving_type(inferred_outlives, index),
1740+
&predicate.bounds,
1741+
predicate.span,
1742+
)
1743+
} else {
1744+
continue;
1745+
}
17441746
},
17451747
_ => { continue; }
17461748
}
@@ -1762,9 +1764,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
17621764
}
17631765

17641766
// If all the bounds on a predicate were inferable and there are
1765-
// further predicates, we want to eat the trailing comma
1767+
// further predicates, we want to eat the trailing comma.
17661768
if drop_predicate && i + 1 < num_predicates {
1767-
let next_predicate_span = hir_generics.where_clause.predicates[i+1].span();
1769+
let next_predicate_span = hir_generics.where_clause.predicates[i + 1].span();
17681770
where_lint_spans.push(
17691771
span.to(next_predicate_span.shrink_to_lo())
17701772
);
@@ -1787,13 +1789,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitOutlivesRequirements {
17871789
// Extend the where clause back to the closing `>` of the
17881790
// generics, except for tuple struct, which have the `where`
17891791
// after the fields of the struct.
1790-
let full_where_span = match item.node {
1791-
hir::ItemKind::Struct(hir::VariantData::Tuple(..), _) => {
1792-
where_span
1793-
}
1794-
_ => {
1795-
hir_generics.span.shrink_to_hi().to(where_span)
1796-
}
1792+
let full_where_span = if let hir::ItemKind::Struct(hir::VariantData::Tuple(..), _)
1793+
= item.node
1794+
{
1795+
where_span
1796+
} else {
1797+
hir_generics.span.shrink_to_hi().to(where_span)
17971798
};
17981799
lint_spans.push(
17991800
full_where_span

0 commit comments

Comments
 (0)