2025-01-04 01:38:17 -08:00
|
|
|
//@ edition: 2024
|
2025-01-15 01:21:35 -08:00
|
|
|
//@ revisions: classic2024 structural2024
|
|
|
|
|
//@[classic2024] run-pass
|
2025-01-04 01:38:17 -08:00
|
|
|
//! Tests for errors from binding with `ref x` under a by-ref default binding mode. These can't be
|
|
|
|
|
//! in the same body as tests for other errors, since they're emitted during THIR construction.
|
|
|
|
|
#![allow(incomplete_features)]
|
2025-01-15 01:21:35 -08:00
|
|
|
#![cfg_attr(classic2024, feature(ref_pat_eat_one_layer_2024))]
|
|
|
|
|
#![cfg_attr(structural2024, feature(ref_pat_eat_one_layer_2024_structural))]
|
2025-01-04 01:38:17 -08:00
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
|
let [&ref x] = &[&0];
|
2025-01-15 01:21:35 -08:00
|
|
|
//[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024
|
|
|
|
|
//[structural2024]~| cannot override to bind by-reference when that is the implicit default
|
|
|
|
|
#[cfg(classic2024)] let _: &&u32 = x;
|
2025-01-04 01:38:17 -08:00
|
|
|
|
|
|
|
|
let [&ref x] = &[&mut 0];
|
2025-01-15 01:21:35 -08:00
|
|
|
//[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024
|
|
|
|
|
//[structural2024]~| cannot override to bind by-reference when that is the implicit default
|
|
|
|
|
#[cfg(classic2024)] let _: &&mut u32 = x;
|
2025-01-04 01:38:17 -08:00
|
|
|
|
|
|
|
|
let [&ref x] = &mut [&0];
|
2025-01-15 01:21:35 -08:00
|
|
|
//[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024
|
|
|
|
|
//[structural2024]~| cannot override to bind by-reference when that is the implicit default
|
|
|
|
|
#[cfg(classic2024)] let _: &&u32 = x;
|
2025-01-04 01:38:17 -08:00
|
|
|
|
|
|
|
|
let [&ref x] = &mut [&mut 0];
|
2025-01-15 01:21:35 -08:00
|
|
|
//[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024
|
|
|
|
|
//[structural2024]~| cannot override to bind by-reference when that is the implicit default
|
|
|
|
|
#[cfg(classic2024)] let _: &&mut u32 = x;
|
2025-01-04 01:38:17 -08:00
|
|
|
|
|
|
|
|
let [&mut ref x] = &mut [&mut 0];
|
2025-01-15 01:21:35 -08:00
|
|
|
//[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024
|
|
|
|
|
//[structural2024]~| cannot override to bind by-reference when that is the implicit default
|
|
|
|
|
#[cfg(classic2024)] let _: &&mut u32 = x;
|
2025-01-04 01:38:17 -08:00
|
|
|
|
|
|
|
|
let [&mut ref mut x] = &mut [&mut 0];
|
2025-01-15 01:21:35 -08:00
|
|
|
//[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024
|
|
|
|
|
//[structural2024]~| cannot override to bind by-reference when that is the implicit default
|
|
|
|
|
#[cfg(classic2024)] let _: &mut &mut u32 = x;
|
2025-01-04 01:38:17 -08:00
|
|
|
}
|