Skip to content

add unused_braces lint #70081

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 6 commits into from
Apr 1, 2020
Merged
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
18 changes: 9 additions & 9 deletions src/libcore/array/iter.rs
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ where
alive: Range<usize>,
}

impl<T, const N: usize> IntoIter<T, { N }>
impl<T, const N: usize> IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
@@ -99,7 +99,7 @@ where
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T, const N: usize> Iterator for IntoIter<T, { N }>
impl<T, const N: usize> Iterator for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
@@ -146,7 +146,7 @@ where
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, { N }>
impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
@@ -182,7 +182,7 @@ where
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T, const N: usize> Drop for IntoIter<T, { N }>
impl<T, const N: usize> Drop for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
@@ -195,7 +195,7 @@ where
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T, const N: usize> ExactSizeIterator for IntoIter<T, { N }>
impl<T, const N: usize> ExactSizeIterator for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
@@ -210,17 +210,17 @@ where
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T, const N: usize> FusedIterator for IntoIter<T, { N }> where [T; N]: LengthAtMost32 {}
impl<T, const N: usize> FusedIterator for IntoIter<T, N> where [T; N]: LengthAtMost32 {}

// The iterator indeed reports the correct length. The number of "alive"
// elements (that will still be yielded) is the length of the range `alive`.
// This range is decremented in length in either `next` or `next_back`. It is
// always decremented by 1 in those methods, but only if `Some(_)` is returned.
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, { N }> where [T; N]: LengthAtMost32 {}
unsafe impl<T, const N: usize> TrustedLen for IntoIter<T, N> where [T; N]: LengthAtMost32 {}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T: Clone, const N: usize> Clone for IntoIter<T, { N }>
impl<T: Clone, const N: usize> Clone for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
@@ -249,7 +249,7 @@ where
}

#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, { N }>
impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, N>
where
[T; N]: LengthAtMost32,
{
5 changes: 5 additions & 0 deletions src/librustc_lint/early.rs
Original file line number Diff line number Diff line change
@@ -104,6 +104,11 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
run_early_pass!(self, check_pat_post, p);
}

fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
run_early_pass!(self, check_anon_const, c);
ast_visit::walk_anon_const(self, c);
}

fn visit_expr(&mut self, e: &'a ast::Expr) {
self.with_lint_attrs(e.id, &e.attrs, |cx| {
run_early_pass!(cx, check_expr, e);
2 changes: 2 additions & 0 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@ macro_rules! early_lint_passes {
$args,
[
UnusedParens: UnusedParens,
UnusedBraces: UnusedBraces,
UnusedImportBraces: UnusedImportBraces,
UnsafeCode: UnsafeCode,
AnonymousParameters: AnonymousParameters,
@@ -275,6 +276,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
UNUSED_FEATURES,
UNUSED_LABELS,
UNUSED_PARENS,
UNUSED_BRACES,
REDUNDANT_SEMICOLONS
);

1 change: 1 addition & 0 deletions src/librustc_lint/passes.rs
Original file line number Diff line number Diff line change
@@ -170,6 +170,7 @@ macro_rules! early_lint_methods {
fn check_stmt(a: &ast::Stmt);
fn check_arm(a: &ast::Arm);
fn check_pat(a: &ast::Pat);
fn check_anon_const(a: &ast::AnonConst);
fn check_pat_post(a: &ast::Pat);
fn check_expr(a: &ast::Expr);
fn check_expr_post(a: &ast::Expr);
Loading