diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-09-04 18:26:48 +0400 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-09-04 20:04:51 +0400 |
| commit | fcd42d628cced5169ebbb791a992a8832d220ab6 (patch) | |
| tree | ed01e8b2ef371c3e2cabd340551d99aed730d40b | |
| parent | b11bf65e4aaa125952b6479a63f36e9e83efc32c (diff) | |
| download | rust-fcd42d628cced5169ebbb791a992a8832d220ab6.tar.gz rust-fcd42d628cced5169ebbb791a992a8832d220ab6.zip | |
Don't fire `rust_2021_incompatible_closure_captures` in edition = 2021
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_typeck/src/check/upvar.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/lint/issue-101284.rs | 15 |
3 files changed, 21 insertions, 2 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index ca01599acc8..2e3a06fcbb7 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -3407,7 +3407,7 @@ declare_lint! { /// /// ### Example of drop reorder /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_incompatible_closure_captures)] /// # #![allow(unused)] /// @@ -3443,7 +3443,7 @@ declare_lint! { /// /// ### Example of auto-trait /// - /// ```rust,compile_fail + /// ```rust,edition2018,compile_fail /// #![deny(rust_2021_incompatible_closure_captures)] /// use std::thread; /// diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 0afc153300b..0b207a6c0be 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -2024,6 +2024,10 @@ fn should_do_rust_2021_incompatible_closure_captures_analysis( tcx: TyCtxt<'_>, closure_id: hir::HirId, ) -> bool { + if tcx.sess.rust_2021() { + return false; + } + let (level, _) = tcx.lint_level_at_node(lint::builtin::RUST_2021_INCOMPATIBLE_CLOSURE_CAPTURES, closure_id); diff --git a/src/test/ui/lint/issue-101284.rs b/src/test/ui/lint/issue-101284.rs new file mode 100644 index 00000000000..1381d4f1727 --- /dev/null +++ b/src/test/ui/lint/issue-101284.rs @@ -0,0 +1,15 @@ +// check-pass +// edition:2021 +#![deny(rust_2021_compatibility)] + +pub struct Warns { + // `Arc` has significant drop + _significant_drop: std::sync::Arc<()>, + field: String, +} + +pub fn test(w: Warns) { + _ = || drop(w.field); +} + +fn main() {} |
