Adjust alias-uninit-value.rs

- Document and tidy up `alias-uninit-value.rs`
- Move `alias-uninit-value.rs` to `tests/ui/codegen/`
This commit is contained in:
Jieyou Xu 2024-12-05 07:32:05 +00:00 committed by 许杰友 Jieyou Xu (Joe)
parent 974ccc12e6
commit dd3b313b56
2 changed files with 26 additions and 19 deletions

View file

@ -1,19 +0,0 @@
//@ run-pass
#![allow(non_camel_case_types)]
#![allow(dead_code)]
// Regression test for issue #374
enum sty { ty_nil, }
struct RawT {struct_: sty, cname: Option<String>, hash: usize}
fn mk_raw_ty(st: sty, cname: Option<String>) -> RawT {
return RawT {struct_: st, cname: cname, hash: 0};
}
pub fn main() { mk_raw_ty(sty::ty_nil, None::<String>); }

View file

@ -0,0 +1,26 @@
//! Regression test for issue #374, where previously rustc performed conditional jumps or moves that
//! incorrectly depended on uninitialized values.
//!
//! Issue: <https://github.com/rust-lang/rust/issues/374>.
//@ run-pass
#![allow(dead_code)]
enum TyS {
Nil,
}
struct RawT {
struct_: TyS,
cname: Option<String>,
hash: usize,
}
fn mk_raw_ty(st: TyS, cname: Option<String>) -> RawT {
return RawT { struct_: st, cname: cname, hash: 0 };
}
pub fn main() {
mk_raw_ty(TyS::Nil, None::<String>);
}