Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 2 Packages Projects Releases Wiki Activity
Files
55b6f649024b372af901b3412a6d36c4284ccf3d
rust/tests/ui/moves/move-of-addr-of-mut.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

13 lines
310 B
Rust
Raw Normal View History

Sanity check for move from an uninit variable whose address is taken
2021-11-11 14:55:58 -08:00
// Ensure that taking a mutable raw ptr to an uninitialized variable does not change its
// initializedness.
struct S;
fn main() {
let mut x: S;
On partial uninit error point at where we need init When a binding is declared without a value, borrowck verifies that all codepaths have *one* assignment to them to initialize them fully. If there are any cases where a condition can be met that leaves the binding uninitialized or we attempt to initialize a field of an unitialized binding, we emit E0381. We now look at all the statements that initialize the binding, and use them to explore branching code paths that *don't* and point at them. If we find *no* potential places where an assignment to the binding might be missing, we display the spans of all the existing initializers to provide some context.
2022-06-21 11:57:45 -07:00
std::ptr::addr_of_mut!(x); //~ ERROR E0381
Sanity check for move from an uninit variable whose address is taken
2021-11-11 14:55:58 -08:00
let y = x; // Should error here if `addr_of_mut` is ever allowed on uninitialized variables
drop(y);
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 897ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API