2019-11-24 16:39:05 -06:00
|
|
|
// Test that the borrow checker doesn't consider checking an exhaustive pattern
|
|
|
|
// as an access.
|
|
|
|
|
2024-02-16 14:02:50 -06:00
|
|
|
//@ check-pass
|
2019-11-24 16:39:05 -06:00
|
|
|
|
2023-05-19 04:25:35 -05:00
|
|
|
#![allow(dropping_references)]
|
2023-03-29 15:18:20 -05:00
|
|
|
|
2024-02-16 14:02:50 -06:00
|
|
|
//@ aux-build:monovariants.rs
|
2019-11-24 16:39:05 -06:00
|
|
|
extern crate monovariants;
|
|
|
|
|
|
|
|
use monovariants::ExhaustiveMonovariant;
|
|
|
|
|
|
|
|
enum Local {
|
|
|
|
Variant(u32),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[non_exhaustive]
|
|
|
|
enum LocalNonExhaustive {
|
|
|
|
Variant(u32),
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = ExhaustiveMonovariant::Variant(1);
|
|
|
|
let y = &mut x;
|
|
|
|
match x {
|
|
|
|
ExhaustiveMonovariant::Variant(_) => {},
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
drop(y);
|
|
|
|
let mut x = Local::Variant(1);
|
|
|
|
let y = &mut x;
|
|
|
|
match x {
|
|
|
|
Local::Variant(_) => {},
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
drop(y);
|
|
|
|
let mut x = LocalNonExhaustive::Variant(1);
|
|
|
|
let y = &mut x;
|
|
|
|
match x {
|
|
|
|
LocalNonExhaustive::Variant(_) => {},
|
|
|
|
_ => {},
|
|
|
|
}
|
|
|
|
drop(y);
|
|
|
|
}
|