-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #130547 - workingjubilee:rollup-tw30khz, r=workingjubilee
Rollup of 3 pull requests Successful merges: - #130531 (Check params for unsafety in THIR) - #130533 (Never patterns constitute a read for unsafety) - #130542 (Stabilize const `MaybeUninit::as_mut_ptr`) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
9 changed files
with
98 additions
and
9 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
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
16 changes: 16 additions & 0 deletions
16
tests/ui/rfcs/rfc-0000-never_patterns/never-pattern-is-a-read.rs
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,16 @@ | ||
// Make sure we consider `!` to be a union read. | ||
|
||
#![feature(never_type, never_patterns)] | ||
//~^ WARN the feature `never_patterns` is incomplete | ||
|
||
union U { | ||
a: !, | ||
b: usize, | ||
} | ||
|
||
fn foo<T>(u: U) -> ! { | ||
let U { a: ! } = u; | ||
//~^ ERROR access to union field is unsafe | ||
} | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
tests/ui/rfcs/rfc-0000-never_patterns/never-pattern-is-a-read.stderr
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,20 @@ | ||
warning: the feature `never_patterns` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/never-pattern-is-a-read.rs:3:24 | ||
| | ||
LL | #![feature(never_type, never_patterns)] | ||
| ^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #118155 <https://github.com/rust-lang/rust/issues/118155> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error[E0133]: access to union field is unsafe and requires unsafe function or block | ||
--> $DIR/never-pattern-is-a-read.rs:12:16 | ||
| | ||
LL | let U { a: ! } = u; | ||
| ^ access to union field | ||
| | ||
= note: the field may not be properly initialized: using uninitialized data will cause undefined behavior | ||
|
||
error: aborting due to 1 previous error; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0133`. |
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`. |