Skip to content
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

Rollup of 8 pull requests #123762

Merged
merged 19 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8923b58
Document restricted_std
adamgemmell Feb 28, 2024
8a24ddf
Be more specific when flagging imports that are redundant due to the …
fmease Mar 23, 2024
0ef49fe
Stabilize `cstr_count_bytes`
tgross35 Apr 9, 2024
796be88
Use `fn` ptr signature instead of `{closure@..}` in infer error
estebank Apr 10, 2024
c8490a0
skip `unused_parens`'s suggestion for `Paren` in macro.
surechen Apr 1, 2024
88bcc79
Revert "Put basic impls for f16 and f128 behind cfg(not(bootstrap))"
tgross35 Apr 5, 2024
454de78
Add basic library support for `f16` and `f128`
tgross35 Mar 6, 2024
143ecc3
Add basic f16 and f128 modules
tgross35 Mar 26, 2024
311ad55
Add primitive documentation for `f16` and `f128`
tgross35 Apr 6, 2024
f0fd5ad
clean up docs for `File::sync_*`
Apr 10, 2024
3764af6
Use suggest_impl_trait in return type suggestion
compiler-errors Apr 10, 2024
aac3f24
Rollup merge of #122470 - tgross35:f16-f128-step4-libs-min, r=Amanieu
fmease Apr 10, 2024
ccab2b1
Rollup merge of #122954 - fmease:defined-by-extern-prelude, r=petroch…
fmease Apr 10, 2024
82c6f18
Rollup merge of #123314 - surechen:fix_120642, r=Nadrieril
fmease Apr 10, 2024
084d27b
Rollup merge of #123360 - adamgemmell:dev/adagem01/restricted-std, r=…
fmease Apr 10, 2024
d7d5be0
Rollup merge of #123661 - tgross35:stabilize-cstr_count_bytes, r=dtolnay
fmease Apr 10, 2024
ae88766
Rollup merge of #123703 - estebank:diag-changes-2, r=Nadrieril
fmease Apr 10, 2024
b24d2ad
Rollup merge of #123756 - lukas-code:file-sync, r=jhpratt
fmease Apr 10, 2024
2930dce
Rollup merge of #123761 - compiler-errors:suggest-more-impl-trait, r=…
fmease Apr 10, 2024
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
24 changes: 15 additions & 9 deletions compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,10 +1074,14 @@ impl UnusedParens {
// Otherwise proceed with linting.
_ => {}
}
let spans = inner
.span
.find_ancestor_inside(value.span)
.map(|inner| (value.span.with_hi(inner.lo()), value.span.with_lo(inner.hi())));
let spans = if !value.span.from_expansion() {
inner
.span
.find_ancestor_inside(value.span)
.map(|inner| (value.span.with_hi(inner.lo()), value.span.with_lo(inner.hi())))
} else {
None
};
self.emit_unused_delims(cx, value.span, spans, "pattern", keep_space, false);
}
}
Expand Down Expand Up @@ -1233,11 +1237,13 @@ impl EarlyLintPass for UnusedParens {
if self.with_self_ty_parens && b.generic_params.len() > 0 => {}
ast::TyKind::ImplTrait(_, bounds) if bounds.len() > 1 => {}
_ => {
let spans = r
.span
.find_ancestor_inside(ty.span)
.map(|r| (ty.span.with_hi(r.lo()), ty.span.with_lo(r.hi())));

let spans = if !ty.span.from_expansion() {
r.span
.find_ancestor_inside(ty.span)
.map(|r| (ty.span.with_hi(r.lo()), ty.span.with_lo(r.hi())))
} else {
None
};
self.emit_unused_delims(cx, ty.span, spans, "type", (false, false), false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//@ run-pass

#![warn(unused_parens)]
#![allow(dead_code)]

trait Foo {
fn bar();
fn tar();
}

macro_rules! unused_parens {
($ty:ident) => {
impl<$ty: Foo> Foo for ($ty,) {
fn bar() { <$ty>::bar() }
fn tar() {}
}
};

($ty:ident $(, $rest:ident)*) => {
impl<$ty: Foo, $($rest: Foo),*> Foo for ($ty, $($rest),*) {
fn bar() {
<$ty>::bar();
<($($rest),*)>::bar() //~WARN unnecessary parentheses around type
}
fn tar() {
let (_t) = 1; //~WARN unnecessary parentheses around pattern
//~| WARN unnecessary parentheses around pattern
let (_t1,) = (1,);
let (_t2, _t3) = (1, 2);
}
}

unused_parens!($($rest),*);
}
}

unused_parens!(T1, T2, T3);

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
warning: unnecessary parentheses around pattern
--> $DIR/unused-parens-in-macro-issue-120642.rs:26:19
|
LL | let (_t) = 1;
| ^^^^
...
LL | unused_parens!(T1, T2, T3);
| -------------------------- in this macro invocation
|
note: the lint level is defined here
--> $DIR/unused-parens-in-macro-issue-120642.rs:3:9
|
LL | #![warn(unused_parens)]
| ^^^^^^^^^^^^^
= note: this warning originates in the macro `unused_parens` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unnecessary parentheses around type
--> $DIR/unused-parens-in-macro-issue-120642.rs:23:18
|
LL | <($($rest),*)>::bar()
| ^^^^^^^^^^^^
...
LL | unused_parens!(T1, T2, T3);
| -------------------------- in this macro invocation
|
= note: this warning originates in the macro `unused_parens` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: unnecessary parentheses around pattern
--> $DIR/unused-parens-in-macro-issue-120642.rs:26:19
|
LL | let (_t) = 1;
| ^^^^
...
LL | unused_parens!(T1, T2, T3);
| -------------------------- in this macro invocation
|
= note: this warning originates in the macro `unused_parens` (in Nightly builds, run with -Z macro-backtrace for more info)

warning: 3 warnings emitted