rust/tests/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
1.2 KiB
Rust
Raw Normal View History

2021-09-21 03:05:11 -05:00
// run-pass
2021-04-01 15:32:25 -05:00
// run-rustfix
#![deny(rust_2021_incompatible_closure_captures)]
2021-09-21 03:05:11 -05:00
#![allow(unused)]
2021-04-01 15:32:25 -05:00
2021-09-21 03:05:11 -05:00
// Test cases for types that implement an insignificant drop (stlib defined)
2021-04-01 15:32:25 -05:00
2021-09-21 03:05:11 -05:00
macro_rules! test_insig_dtor_for_type {
($t: ty, $disambiguator: ident) => {
mod $disambiguator {
use std::collections::*;
use std::rc::Rc;
use std::sync::Mutex;
2021-04-01 15:32:25 -05:00
2021-09-22 04:17:30 -05:00
fn test_for_type(t: $t) {
2021-09-21 03:05:11 -05:00
let tup = (Mutex::new(0), t);
2021-04-01 15:32:25 -05:00
2021-09-21 03:05:11 -05:00
let _c = || tup.0;
}
}
};
2021-04-01 15:32:25 -05:00
}
2021-09-21 03:05:11 -05:00
test_insig_dtor_for_type!(i32, prim_i32);
test_insig_dtor_for_type!(Vec<i32>, vec_i32);
test_insig_dtor_for_type!(String, string);
test_insig_dtor_for_type!(Vec<String>, vec_string);
2021-09-22 04:17:30 -05:00
test_insig_dtor_for_type!(HashMap<String, String>, hash_map);
2021-09-21 03:05:11 -05:00
test_insig_dtor_for_type!(BTreeMap<String, i32>, btree_map);
test_insig_dtor_for_type!(LinkedList<String>, linked_list);
test_insig_dtor_for_type!(Rc<i32>, rc_i32);
test_insig_dtor_for_type!(Rc<String>, rc_string);
test_insig_dtor_for_type!(std::vec::IntoIter<String>, vec_into_iter);
test_insig_dtor_for_type!(btree_map::IntoIter<String, String>, btree_map_into_iter);
test_insig_dtor_for_type!(std::array::IntoIter<String, 5>, array_into_iter);
fn main() {}