8000 add `unused_braces` lint by lcnr · Pull Request #70081 · rust-lang/rust · GitHub
[go: up one dir, main page]

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
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix internal lint fallout
  • Loading branch information
lcnr committed Mar 31, 2020
commit 21c5ccab10b30085479a7189ee555f77c47c79e7
18 changes: 9 additions & 9 deletions src/libcore/array/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{
Expand Down Expand Up @@ -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,
{
Expand Down Expand Up @@ -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,
{
Expand Down Expand Up @@ -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,
{
Expand All @@ -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,
{
Expand All @@ -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,
{
Expand Down Expand Up @@ -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,
{
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_macros/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,11 @@ fn add_query_description_impl(
quote! { #t }
})
.unwrap_or(quote! { _ });
// expr is a `Block`, meaning that `{ #expr }` gets expanded
// to `{ { stmts... } }`, which triggers the `unused_braces` lint.
quote! {
#[inline]
#[allow(unused_variables)]
#[allow(unused_variables, unused_braces)]
fn cache_on_disk(
#tcx: TyCtxt<'tcx>,
#key: Self::Key,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2807,7 +2807,7 @@ impl<'a> Resolver<'a> {
ast::Path {
span,
segments: iter::once(Ident::with_dummy_span(kw::PathRoot))
.chain({ path_str.split("::").skip(1).map(Ident::from_str) })
.chain(path_str.split("::").skip(1).map(Ident::from_str))
.map(|i| self.new_ast_path_segment(i))
.collect(),
}
Expand Down
5 changes: 2 additions & 3 deletions src/libstd/sys/windows/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ impl RawHandle {
) -> io::Result<Option<usize>> {
let len = cmp::min(buf.len(), <c::DWORD>::max_value() as usize) as c::DWORD;
let mut amt = 0;
let res =
cvt({ c::ReadFile(self.0, buf.as_ptr() as c::LPVOID, len, &mut amt, overlapped) });
let res = cvt(c::ReadFile(self.0, buf.as_ptr() as c::LPVOID, len, &mut amt, overlapped));
match res {
Ok(_) => Ok(Some(amt as usize)),
Err(e) => {
Expand All @@ -139,7 +138,7 @@ impl RawHandle {
unsafe {
let mut bytes = 0;
let wait = if wait { c::TRUE } else { c::FALSE };
let res = cvt({ c::GetOverlappedResult(self.raw(), overlapped, &mut bytes, wait) });
let res = cvt(c::GetOverlappedResult(self.raw(), overlapped, &mut bytes, wait));
match res {
Ok(_) => Ok(bytes as usize),
Err(e) => {
Expand Down
0