Skip to content

Commit 8993358

Browse files
authored
Rollup merge of #70081 - lcnr:issue68387, r=varkor
add `unused_braces` lint Add the lint `unused_braces` which is warn by default. `unused_parens` is also extended and now checks anon consts. closes #68387 r? @varkor
2 parents 718ba0d + bab327c commit 8993358

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+559
-176
lines changed

src/libcore/array/iter.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ where
3939
alive: Range<usize>,
4040
}
4141

42-
impl<T, const N: usize> IntoIter<T, { N }>
42+
impl<T, const N: usize> IntoIter<T, N>
4343
where
4444
[T; N]: LengthAtMost32,
4545
{
@@ -99,7 +99,7 @@ where
9999
}
100100

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

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

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

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

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

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

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

251251
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
252-
impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, { N }>
252+
impl<T: fmt::Debug, const N: usize> fmt::Debug for IntoIter<T, N>
253253
where
254254
[T; N]: LengthAtMost32,
255255
{

src/librustc_lint/early.rs

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
104104
run_early_pass!(self, check_pat_post, p);
105105
}
106106

107+
fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
108+
run_early_pass!(self, check_anon_const, c);
109+
ast_visit::walk_anon_const(self, c);
110+
}
111+
107112
fn visit_expr(&mut self, e: &'a ast::Expr) {
108113
self.with_lint_attrs(e.id, &e.attrs, |cx| {
109114
run_early_pass!(cx, check_expr, e);

src/librustc_lint/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ macro_rules! early_lint_passes {
104104
$args,
105105
[
106106
UnusedParens: UnusedParens,
107+
UnusedBraces: UnusedBraces,
107108
UnusedImportBraces: UnusedImportBraces,
108109
UnsafeCode: UnsafeCode,
109110
AnonymousParameters: AnonymousParameters,
@@ -275,6 +276,7 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
275276
UNUSED_FEATURES,
276277
UNUSED_LABELS,
277278
UNUSED_PARENS,
279+
UNUSED_BRACES,
278280
REDUNDANT_SEMICOLONS
279281
);
280282

src/librustc_lint/passes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ macro_rules! early_lint_methods {
170170
fn check_stmt(a: &ast::Stmt);
171171
fn check_arm(a: &ast::Arm);
172172
fn check_pat(a: &ast::Pat);
173+
fn check_anon_const(a: &ast::AnonConst);
173174
fn check_pat_post(a: &ast::Pat);
174175
fn check_expr(a: &ast::Expr);
175176
fn check_expr_post(a: &ast::Expr);

0 commit comments

Comments
 (0)