Skip to content

Commit fcd42d6

Browse files
committed
Don't fire rust_2021_incompatible_closure_captures in edition = 2021
1 parent b11bf65 commit fcd42d6

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3407,7 +3407,7 @@ declare_lint! {
34073407
///
34083408
/// ### Example of drop reorder
34093409
///
3410-
/// ```rust,compile_fail
3410+
/// ```rust,edition2018,compile_fail
34113411
/// #![deny(rust_2021_incompatible_closure_captures)]
34123412
/// # #![allow(unused)]
34133413
///
@@ -3443,7 +3443,7 @@ declare_lint! {
34433443
///
34443444
/// ### Example of auto-trait
34453445
///
3446-
/// ```rust,compile_fail
3446+
/// ```rust,edition2018,compile_fail
34473447
/// #![deny(rust_2021_incompatible_closure_captures)]
34483448
/// use std::thread;
34493449
///

compiler/rustc_typeck/src/check/upvar.rs

+4
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,10 @@ fn should_do_rust_2021_incompatible_closure_captures_analysis(
20242024
tcx: TyCtxt<'_>,
20252025
closure_id: hir::HirId,
20262026
) -> bool {
2027+
if tcx.sess.rust_2021() {
2028+
return false;
2029+
}
2030+
20272031
let (level, _) =
20282032
tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id);
20292033

src/test/ui/lint/issue-101284.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
// edition:2021
3+
#![deny(rust_2021_compatibility)]
4+
5+
pub struct Warns {
6+
// `Arc` has significant drop
7+
_significant_drop: std::sync::Arc<()>,
8+
field: String,
9+
}
10+
11+
pub fn test(w: Warns) {
12+
_ = || drop(w.field);
13+
}
14+
15+
fn main() {}

0 commit comments

Comments
 (0)