File: edition-gate-macro-error.rs

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 934,128 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; lisp: 29; perl: 29; ruby: 19; sql: 11
file content (30 lines) | stat: -rw-r--r-- 1,384 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//@ revisions: edition2021 edition2024
//@ compile-flags: -Z lint-mir -Z validate-mir
//@ [edition2021] edition: 2021
//@ [edition2024] edition: 2024
//@ aux-build:macro-in-2021.rs
//@ aux-build:macro-in-2024.rs

use std::unreachable as never;

// Compiletest doesn't specify the needed --extern flags to make `extern crate` unneccessary
extern crate macro_in_2021;
extern crate macro_in_2024;

fn main() {
    // Gated on both 2021 and 2024 if the `if` comes from a 2021 macro
    // Gated only on 2021 if the `if` comes from a 2024 macro
    // No gating if both the `if` and the chain are from a 2024 macro

    macro_in_2021::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() });
    //~^ ERROR `let` expressions in this position are unstable
    //~| ERROR `let` expressions in this position are unstable
    macro_in_2021::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() });
    //~^ ERROR `let` expressions in this position are unstable
    //~| ERROR `let` expressions in this position are unstable

    macro_in_2024::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() });
    //[edition2021]~^ ERROR `let` expressions in this position are unstable
    //[edition2021]~| ERROR `let` expressions in this position are unstable
    macro_in_2024::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() });
}