forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#130541 - workingjubilee:rollup-26jmumi, r=wor…
…kingjubilee Rollup of 3 pull requests Successful merges: - rust-lang#129755 (test: cross-edition metavar fragment specifiers) - rust-lang#130511 (Support `char::encode_utf8` in const scenarios.) - rust-lang#130531 (Check params for unsafety in THIR) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
7 changed files
with
119 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//@ edition: 2018 | ||
#[macro_export] | ||
macro_rules! make_matcher { | ||
($name:ident, $fragment_type:ident, $d:tt) => { | ||
#[macro_export] | ||
macro_rules! $name { | ||
($d _:$fragment_type) => { true }; | ||
(const { 0 }) => { false }; | ||
(A | B) => { false }; | ||
} | ||
}; | ||
} | ||
make_matcher!(is_expr_from_2018, expr, $); | ||
make_matcher!(is_pat_from_2018, pat, $); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//@ compile-flags: --edition=2024 -Z unstable-options | ||
//@ aux-build: metavar_2018.rs | ||
//@ known-bug: #130484 | ||
//@ run-pass | ||
|
||
// This test captures the behavior of macro-generating-macros with fragment | ||
// specifiers across edition boundaries. | ||
|
||
#![feature(expr_fragment_specifier_2024)] | ||
#![feature(macro_metavar_expr)] | ||
#![allow(incomplete_features)] | ||
|
||
extern crate metavar_2018; | ||
|
||
use metavar_2018::{is_expr_from_2018, is_pat_from_2018, make_matcher}; | ||
|
||
make_matcher!(is_expr_from_2024, expr, $); | ||
make_matcher!(is_pat_from_2024, pat, $); | ||
|
||
fn main() { | ||
// Check expr | ||
let from_2018 = is_expr_from_2018!(const { 0 }); | ||
dbg!(from_2018); | ||
let from_2024 = is_expr_from_2024!(const { 0 }); | ||
dbg!(from_2024); | ||
|
||
assert!(!from_2018); | ||
assert!(!from_2024); // from_2024 will be true once #130484 is fixed | ||
|
||
// Check pat | ||
let from_2018 = is_pat_from_2018!(A | B); | ||
dbg!(from_2018); | ||
let from_2024 = is_pat_from_2024!(A | B); | ||
dbg!(from_2024); | ||
|
||
assert!(!from_2018); | ||
assert!(!from_2024); // from_2024 will be true once #130484 is fixed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
union U { | ||
a: &'static i32, | ||
b: usize, | ||
} | ||
|
||
fn fun(U { a }: U) { | ||
//~^ ERROR access to union field is unsafe | ||
dbg!(*a); | ||
} | ||
|
||
fn main() { | ||
fun(U { b: 0 }); | ||
|
||
let closure = |U { a }| { | ||
//~^ ERROR access to union field is unsafe | ||
dbg!(*a); | ||
}; | ||
closure(U { b: 0 }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0133]: access to union field is unsafe and requires unsafe function or block | ||
--> $DIR/union-pat-in-param.rs:6:12 | ||
| | ||
LL | fn fun(U { a }: U) { | ||
| ^ access to union field | ||
| | ||
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior | ||
|
||
error[E0133]: access to union field is unsafe and requires unsafe function or block | ||
--> $DIR/union-pat-in-param.rs:14:24 | ||
| | ||
LL | let closure = |U { a }| { | ||
| ^ access to union field | ||
| | ||
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0133`. |