Skip to content

Rollup of 7 pull requests #131581

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 18 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
3743618
Support clobber_abi in MSP430 inline assembly
taiki-e Oct 5, 2024
f2d1edf
Change a few `&Option<T>` into `Option<&T>`
nyurik Sep 28, 2024
d2f93c9
Update library/std/src/sys/pal/unix/process/process_unix.rs
nyurik Oct 2, 2024
442d766
fix ref in process_vxworks.rs
nyurik Oct 9, 2024
a278f15
Update library/std/src/sys/pal/unix/process/process_vxworks.rs
nyurik Oct 9, 2024
181e667
stabilize duration_consts_float
RalfJung Oct 5, 2024
77b3065
Remove deprecation note in the `non_local_definitions` warning
Urgau Oct 11, 2024
0d8a978
intrinsics.fmuladdf{16,32,64,128}: expose llvm.fmuladd.* semantics
jedbrown Jan 6, 2024
395b078
Flatten redundant test module `run_make_support::diff::tests::tests`
Zalathar Aug 17, 2024
f4376c4
Avoid cross-file glob import
Zalathar Oct 12, 2024
1e8d6d1
Make unused_parens's suggestion considering expr's attributes
surechen Oct 11, 2024
3f9aa50
Rollup merge of #124874 - jedbrown:float-mul-add-fast, r=saethlin
tgross35 Oct 12, 2024
02cf62c
Rollup merge of #130962 - nyurik:opts-libs, r=cuviper
tgross35 Oct 12, 2024
3e16b77
Rollup merge of #131289 - RalfJung:duration_consts_float, r=tgross35
tgross35 Oct 12, 2024
9e72070
Rollup merge of #131310 - taiki-e:msp430-clobber-abi, r=Amanieu
tgross35 Oct 12, 2024
fcbf4ac
Rollup merge of #131546 - surechen:fix_129833, r=jieyouxu
tgross35 Oct 12, 2024
1f31925
Rollup merge of #131565 - Urgau:non_local_def-rm-deprecate, r=compile…
tgross35 Oct 12, 2024
5e477c9
Rollup merge of #131576 - Zalathar:tests-tests, r=jieyouxu
tgross35 Oct 12, 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
10 changes: 9 additions & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,15 @@ trait UnusedDelimLint {
.find_ancestor_inside(value.span)
.map(|span| (value.span.with_hi(span.lo()), value.span.with_lo(span.hi()))),
ast::ExprKind::Paren(ref expr) => {
expr.span.find_ancestor_inside(value.span).map(|expr_span| {
// For the expr with attributes, like `let _ = (#[inline] || println!("Hello!"));`,
// the span should contains the attributes, or the suggestion will remove them.
let expr_span_with_attrs =
if let Some(attr_lo) = expr.attrs.iter().map(|attr| attr.span.lo()).min() {
expr.span.with_lo(attr_lo)
} else {
expr.span
};
expr_span_with_attrs.find_ancestor_inside(value.span).map(|expr_span| {
(value.span.with_hi(expr_span.lo()), value.span.with_lo(expr_span.hi()))
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ run-rustfix
// Check the `unused_parens` suggestion for paren_expr with attributes.
// The suggestion should retain attributes in the front.

#![feature(stmt_expr_attributes)]
#![deny(unused_parens)]

pub fn foo() -> impl Fn() {
let _ = #[inline] #[allow(dead_code)] || println!("Hello!"); //~ERROR unnecessary parentheses
#[inline] #[allow(dead_code)] || println!("Hello!") //~ERROR unnecessary parentheses
}

fn main() {
let _ = foo();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ run-rustfix
// Check the `unused_parens` suggestion for paren_expr with attributes.
// The suggestion should retain attributes in the front.

#![feature(stmt_expr_attributes)]
#![deny(unused_parens)]

pub fn foo() -> impl Fn() {
let _ = (#[inline] #[allow(dead_code)] || println!("Hello!")); //~ERROR unnecessary parentheses
(#[inline] #[allow(dead_code)] || println!("Hello!")) //~ERROR unnecessary parentheses
}

fn main() {
let _ = foo();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error: unnecessary parentheses around assigned value
--> $DIR/unused-parens-for-stmt-expr-attributes-issue-129833.rs:9:13
|
LL | let _ = (#[inline] #[allow(dead_code)] || println!("Hello!"));
| ^ ^
|
note: the lint level is defined here
--> $DIR/unused-parens-for-stmt-expr-attributes-issue-129833.rs:6:9
|
LL | #![deny(unused_parens)]
| ^^^^^^^^^^^^^
help: remove these parentheses
|
LL - let _ = (#[inline] #[allow(dead_code)] || println!("Hello!"));
LL + let _ = #[inline] #[allow(dead_code)] || println!("Hello!");
|

error: unnecessary parentheses around block return value
--> $DIR/unused-parens-for-stmt-expr-attributes-issue-129833.rs:10:5
|
LL | (#[inline] #[allow(dead_code)] || println!("Hello!"))
| ^ ^
|
help: remove these parentheses
|
LL - (#[inline] #[allow(dead_code)] || println!("Hello!"))
LL + #[inline] #[allow(dead_code)] || println!("Hello!")
|

error: aborting due to 2 previous errors