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 9 pull requests #88584

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
af1b65c
Path remapping: Make behavior of diagnostics output dependent on pres…
michaelwoerister Aug 26, 2021
8436fe1
Add test for showing remapped path in diagnostics
cbeuw Aug 20, 2021
c296c89
Fix remap-path-prefix UI test case.
michaelwoerister Aug 27, 2021
c6d800d
Point at unclosed delimiters as part of the primary MultiSpan
estebank Aug 27, 2021
d7da82a
expand: Treat more macro calls as statement macro calls
petrochenkov Aug 26, 2021
b99038f
use `unwrap_unchecked` where possible
ibraheemdev Aug 30, 2021
99a3d64
Remove single use variables
ptrojahn Aug 31, 2021
ffc43b8
add safety annotation to `LinkedList::detach_all_nodes`
ibraheemdev Aug 31, 2021
7189c85
Improve closure dummy capture suggestion in macros.
m-ou-se Aug 31, 2021
7d18052
Add test for closure migration where body is a block fragment.
m-ou-se Aug 31, 2021
59b245e
fix(rustc_lint): better detect when parens are necessary
notriddle Aug 31, 2021
6c9e708
`fmt::Formatter::pad`: don't call chars().count() more than one time
klensy Sep 1, 2021
f5f489b
fix clippy lints
klensy Sep 1, 2021
a5fd955
add regression test for issue 83190
lqd Sep 1, 2021
d9047db
Rollup merge of #88363 - michaelwoerister:remapped-diagnostics, r=est…
GuillaumeGomez Sep 2, 2021
2693e12
Rollup merge of #88386 - estebank:unmatched-delims, r=jackh726
GuillaumeGomez Sep 2, 2021
2f22cad
Rollup merge of #88428 - petrochenkov:stmtid, r=Aaron1011
GuillaumeGomez Sep 2, 2021
c892775
Rollup merge of #88505 - ibraheemdev:use-unwrap-unchecked, r=kennytm
GuillaumeGomez Sep 2, 2021
1d1e931
Rollup merge of #88532 - ptrojahn:single_use, r=davidtwco
GuillaumeGomez Sep 2, 2021
b341e56
Rollup merge of #88543 - m-ou-se:closure-migration-macro-block-fragme…
GuillaumeGomez Sep 2, 2021
60eb925
Rollup merge of #88547 - notriddle:notriddle/is-expr-delims-necessary…
GuillaumeGomez Sep 2, 2021
a90fff6
Rollup merge of #88560 - klensy:formatter-pad-shrink, r=m-ou-se
GuillaumeGomez Sep 2, 2021
7e3855b
Rollup merge of #88565 - lqd:issue-83190, r=spastorino
GuillaumeGomez Sep 2, 2021
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
Add test for closure migration where body is a block fragment.
  • Loading branch information
m-ou-se committed Aug 31, 2021
commit 7d18052b1bfc31a96c2482e8919ba824c0e4100c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// run-rustfix
// edition:2018
// check-pass
#![warn(rust_2021_compatibility)]

macro_rules! m {
(@ $body:expr) => {{
let f = || $body;
//~^ WARNING: drop order
f();
}};
($body:block) => {{
m!(@ $body);
}};
}

fn main() {
let a = (1.to_string(), 2.to_string());
m!({
let _ = &a;
//~^ HELP: add a dummy
let x = a.0;
println!("{}", x);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// run-rustfix
// edition:2018
// check-pass
#![warn(rust_2021_compatibility)]

macro_rules! m {
(@ $body:expr) => {{
let f = || $body;
//~^ WARNING: drop order
f();
}};
($body:block) => {{
m!(@ $body);
}};
}

fn main() {
let a = (1.to_string(), 2.to_string());
m!({
//~^ HELP: add a dummy
let x = a.0;
println!("{}", x);
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
warning: changes to closure capture in Rust 2021 will affect drop order
--> $DIR/closure-body-macro-fragment.rs:8:17
|
LL | let f = || $body;
| _________________^
LL | |
LL | | f();
LL | | }};
| | - in Rust 2018, `a` is dropped here, but in Rust 2021, only `a.0` will be dropped here as part of the closure
LL | | ($body:block) => {{
LL | | m!(@ $body);
| |__________________^
...
LL | / m!({
LL | |
LL | | let x = a.0;
| | --- in Rust 2018, this closure captures all of `a`, but in Rust 2021, it will only capture `a.0`
LL | | println!("{}", x);
LL | | });
| |_______- in this macro invocation
|
note: the lint level is defined here
--> $DIR/closure-body-macro-fragment.rs:4:9
|
LL | #![warn(rust_2021_compatibility)]
| ^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[warn(rust_2021_incompatible_closure_captures)]` implied by `#[warn(rust_2021_compatibility)]`
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
help: add a dummy let to cause `a` to be fully captured
|
LL ~ m!({
LL + let _ = &a;
|

warning: 1 warning emitted