From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../auxiliary/static-function-pointer-aux.rs | 4 - .../ui/statics/auxiliary/static-methods-crate.rs | 29 ------- .../statics/auxiliary/static_fn_inline_xc_aux.rs | 12 --- .../ui/statics/auxiliary/static_fn_trait_xc_aux.rs | 11 --- src/test/ui/statics/auxiliary/static_mut_xc.rs | 1 - src/test/ui/statics/issue-14227.mir.stderr | 11 --- src/test/ui/statics/issue-14227.rs | 10 --- src/test/ui/statics/issue-14227.thir.stderr | 11 --- src/test/ui/statics/issue-15261.rs | 11 --- src/test/ui/statics/issue-17233.rs | 17 ---- src/test/ui/statics/issue-17718-static-sync.rs | 12 --- src/test/ui/statics/issue-17718-static-sync.stderr | 12 --- .../statics/issue-17718-static-unsafe-interior.rs | 52 ------------- src/test/ui/statics/issue-44373-2.rs | 11 --- src/test/ui/statics/issue-44373.rs | 5 -- src/test/ui/statics/issue-44373.stderr | 13 ---- src/test/ui/statics/issue-91050-1.rs | 34 -------- src/test/ui/statics/issue-91050-2.rs | 24 ------ src/test/ui/statics/static-fn-inline-xc.rs | 12 --- src/test/ui/statics/static-fn-trait-xc.rs | 12 --- src/test/ui/statics/static-function-pointer-xc.rs | 17 ---- src/test/ui/statics/static-function-pointer.rs | 16 ---- src/test/ui/statics/static-impl.rs | 66 ---------------- .../static-method-in-trait-with-tps-intracrate.rs | 28 ------- src/test/ui/statics/static-method-xcrate.rs | 13 ---- src/test/ui/statics/static-methods-in-traits.rs | 26 ------- src/test/ui/statics/static-methods-in-traits2.rs | 22 ------ src/test/ui/statics/static-mut-xc.rs | 39 ---------- src/test/ui/statics/static-promotion.rs | 34 -------- src/test/ui/statics/static-recursive.rs | 36 --------- src/test/ui/statics/uninhabited-static.rs | 21 ----- src/test/ui/statics/uninhabited-static.stderr | 91 ---------------------- 32 files changed, 713 deletions(-) delete mode 100644 src/test/ui/statics/auxiliary/static-function-pointer-aux.rs delete mode 100644 src/test/ui/statics/auxiliary/static-methods-crate.rs delete mode 100644 src/test/ui/statics/auxiliary/static_fn_inline_xc_aux.rs delete mode 100644 src/test/ui/statics/auxiliary/static_fn_trait_xc_aux.rs delete mode 100644 src/test/ui/statics/auxiliary/static_mut_xc.rs delete mode 100644 src/test/ui/statics/issue-14227.mir.stderr delete mode 100644 src/test/ui/statics/issue-14227.rs delete mode 100644 src/test/ui/statics/issue-14227.thir.stderr delete mode 100644 src/test/ui/statics/issue-15261.rs delete mode 100644 src/test/ui/statics/issue-17233.rs delete mode 100644 src/test/ui/statics/issue-17718-static-sync.rs delete mode 100644 src/test/ui/statics/issue-17718-static-sync.stderr delete mode 100644 src/test/ui/statics/issue-17718-static-unsafe-interior.rs delete mode 100644 src/test/ui/statics/issue-44373-2.rs delete mode 100644 src/test/ui/statics/issue-44373.rs delete mode 100644 src/test/ui/statics/issue-44373.stderr delete mode 100644 src/test/ui/statics/issue-91050-1.rs delete mode 100644 src/test/ui/statics/issue-91050-2.rs delete mode 100644 src/test/ui/statics/static-fn-inline-xc.rs delete mode 100644 src/test/ui/statics/static-fn-trait-xc.rs delete mode 100644 src/test/ui/statics/static-function-pointer-xc.rs delete mode 100644 src/test/ui/statics/static-function-pointer.rs delete mode 100644 src/test/ui/statics/static-impl.rs delete mode 100644 src/test/ui/statics/static-method-in-trait-with-tps-intracrate.rs delete mode 100644 src/test/ui/statics/static-method-xcrate.rs delete mode 100644 src/test/ui/statics/static-methods-in-traits.rs delete mode 100644 src/test/ui/statics/static-methods-in-traits2.rs delete mode 100644 src/test/ui/statics/static-mut-xc.rs delete mode 100644 src/test/ui/statics/static-promotion.rs delete mode 100644 src/test/ui/statics/static-recursive.rs delete mode 100644 src/test/ui/statics/uninhabited-static.rs delete mode 100644 src/test/ui/statics/uninhabited-static.stderr (limited to 'src/test/ui/statics') diff --git a/src/test/ui/statics/auxiliary/static-function-pointer-aux.rs b/src/test/ui/statics/auxiliary/static-function-pointer-aux.rs deleted file mode 100644 index 4dfc25764..000000000 --- a/src/test/ui/statics/auxiliary/static-function-pointer-aux.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub fn f(x: isize) -> isize { -x } - -pub static F: fn(isize) -> isize = f; -pub static mut MutF: fn(isize) -> isize = f; diff --git a/src/test/ui/statics/auxiliary/static-methods-crate.rs b/src/test/ui/statics/auxiliary/static-methods-crate.rs deleted file mode 100644 index 7ff3bc0dd..000000000 --- a/src/test/ui/statics/auxiliary/static-methods-crate.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![crate_name="static_methods_crate"] -#![crate_type = "lib"] - -pub trait read: Sized { - fn readMaybe(s: String) -> Option; -} - -impl read for isize { - fn readMaybe(s: String) -> Option { - s.parse().ok() - } -} - -impl read for bool { - fn readMaybe(s: String) -> Option { - match &*s { - "true" => Some(true), - "false" => Some(false), - _ => None - } - } -} - -pub fn read(s: String) -> T { - match read::readMaybe(s) { - Some(x) => x, - _ => panic!("read panicked!") - } -} diff --git a/src/test/ui/statics/auxiliary/static_fn_inline_xc_aux.rs b/src/test/ui/statics/auxiliary/static_fn_inline_xc_aux.rs deleted file mode 100644 index 8d0f7f61c..000000000 --- a/src/test/ui/statics/auxiliary/static_fn_inline_xc_aux.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub mod num { - pub trait Num2 { - fn from_int2(n: isize) -> Self; - } -} - -pub mod f64 { - impl ::num::Num2 for f64 { - #[inline] - fn from_int2(n: isize) -> f64 { return n as f64; } - } -} diff --git a/src/test/ui/statics/auxiliary/static_fn_trait_xc_aux.rs b/src/test/ui/statics/auxiliary/static_fn_trait_xc_aux.rs deleted file mode 100644 index b8aed2c5f..000000000 --- a/src/test/ui/statics/auxiliary/static_fn_trait_xc_aux.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub mod num { - pub trait Num2 { - fn from_int2(n: isize) -> Self; - } -} - -pub mod f64 { - impl ::num::Num2 for f64 { - fn from_int2(n: isize) -> f64 { return n as f64; } - } -} diff --git a/src/test/ui/statics/auxiliary/static_mut_xc.rs b/src/test/ui/statics/auxiliary/static_mut_xc.rs deleted file mode 100644 index 264a2243a..000000000 --- a/src/test/ui/statics/auxiliary/static_mut_xc.rs +++ /dev/null @@ -1 +0,0 @@ -pub static mut a: isize = 3; diff --git a/src/test/ui/statics/issue-14227.mir.stderr b/src/test/ui/statics/issue-14227.mir.stderr deleted file mode 100644 index 8e7a2514d..000000000 --- a/src/test/ui/statics/issue-14227.mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-14227.rs:7:21 - | -LL | static CRASH: u32 = symbol; - | ^^^^^^ use of extern static - | - = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/statics/issue-14227.rs b/src/test/ui/statics/issue-14227.rs deleted file mode 100644 index 5f866ec90..000000000 --- a/src/test/ui/statics/issue-14227.rs +++ /dev/null @@ -1,10 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -extern "C" { - pub static symbol: u32; -} -static CRASH: u32 = symbol; -//~^ ERROR use of extern static is unsafe and requires - -fn main() {} diff --git a/src/test/ui/statics/issue-14227.thir.stderr b/src/test/ui/statics/issue-14227.thir.stderr deleted file mode 100644 index 8e7a2514d..000000000 --- a/src/test/ui/statics/issue-14227.thir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-14227.rs:7:21 - | -LL | static CRASH: u32 = symbol; - | ^^^^^^ use of extern static - | - = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/statics/issue-15261.rs b/src/test/ui/statics/issue-15261.rs deleted file mode 100644 index ec413f6d1..000000000 --- a/src/test/ui/statics/issue-15261.rs +++ /dev/null @@ -1,11 +0,0 @@ -// build-pass -#![allow(dead_code)] -#![allow(non_upper_case_globals)] - -// pretty-expanded FIXME #23616 - -static mut n_mut: usize = 0; - -static n: &'static usize = unsafe{ &n_mut }; - -fn main() {} diff --git a/src/test/ui/statics/issue-17233.rs b/src/test/ui/statics/issue-17233.rs deleted file mode 100644 index 54a12fdf8..000000000 --- a/src/test/ui/statics/issue-17233.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass - -const X1: &'static [u8] = &[b'1']; -const X2: &'static [u8] = b"1"; -const X3: &'static [u8; 1] = &[b'1']; -const X4: &'static [u8; 1] = b"1"; - -static Y1: u8 = X1[0]; -static Y2: u8 = X2[0]; -static Y3: u8 = X3[0]; -static Y4: u8 = X4[0]; - -fn main() { - assert_eq!(Y1, Y2); - assert_eq!(Y1, Y3); - assert_eq!(Y1, Y4); -} diff --git a/src/test/ui/statics/issue-17718-static-sync.rs b/src/test/ui/statics/issue-17718-static-sync.rs deleted file mode 100644 index 6f278d76b..000000000 --- a/src/test/ui/statics/issue-17718-static-sync.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Sync; - -struct Foo; -impl !Sync for Foo {} - -static FOO: usize = 3; -static BAR: Foo = Foo; -//~^ ERROR: `Foo` cannot be shared between threads safely [E0277] - -fn main() {} diff --git a/src/test/ui/statics/issue-17718-static-sync.stderr b/src/test/ui/statics/issue-17718-static-sync.stderr deleted file mode 100644 index bc6e45e59..000000000 --- a/src/test/ui/statics/issue-17718-static-sync.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: `Foo` cannot be shared between threads safely - --> $DIR/issue-17718-static-sync.rs:9:13 - | -LL | static BAR: Foo = Foo; - | ^^^ `Foo` cannot be shared between threads safely - | - = help: the trait `Sync` is not implemented for `Foo` - = note: shared static variables must have a type that implements `Sync` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/statics/issue-17718-static-unsafe-interior.rs b/src/test/ui/statics/issue-17718-static-unsafe-interior.rs deleted file mode 100644 index 65a8713ba..000000000 --- a/src/test/ui/statics/issue-17718-static-unsafe-interior.rs +++ /dev/null @@ -1,52 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_variables)] -#![allow(unused_imports)] -// pretty-expanded FIXME #23616 - -use std::marker; -use std::cell::UnsafeCell; - -struct MyUnsafePack(UnsafeCell); - -unsafe impl Sync for MyUnsafePack {} - -struct MyUnsafe { - value: MyUnsafePack -} - -impl MyUnsafe { - fn forbidden(&self) {} -} - -unsafe impl Sync for MyUnsafe {} - -enum UnsafeEnum { - VariantSafe, - VariantUnsafe(UnsafeCell) -} - -unsafe impl Sync for UnsafeEnum {} - -static STATIC1: UnsafeEnum = UnsafeEnum::VariantSafe; - -static STATIC2: MyUnsafePack = MyUnsafePack(UnsafeCell::new(1)); -const CONST: MyUnsafePack = MyUnsafePack(UnsafeCell::new(1)); -static STATIC3: MyUnsafe = MyUnsafe{value: CONST}; - -static STATIC4: &'static MyUnsafePack = &STATIC2; - -struct Wrap { - value: T -} - -unsafe impl Sync for Wrap {} - -static UNSAFE: MyUnsafePack = MyUnsafePack(UnsafeCell::new(2)); -static WRAPPED_UNSAFE: Wrap<&'static MyUnsafePack> = Wrap { value: &UNSAFE }; - -fn main() { - let a = &STATIC1; - - STATIC3.forbidden() -} diff --git a/src/test/ui/statics/issue-44373-2.rs b/src/test/ui/statics/issue-44373-2.rs deleted file mode 100644 index 194ce1dca..000000000 --- a/src/test/ui/statics/issue-44373-2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -#![allow(dead_code)] - -struct Foo(bool); - -struct Container(&'static [&'static Foo]); - -static FOO: Foo = Foo(true); -static CONTAINER: Container = Container(&[&FOO]); - -fn main() {} diff --git a/src/test/ui/statics/issue-44373.rs b/src/test/ui/statics/issue-44373.rs deleted file mode 100644 index 0d011d096..000000000 --- a/src/test/ui/statics/issue-44373.rs +++ /dev/null @@ -1,5 +0,0 @@ -static FOO: u32 = 50; - -fn main() { - let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR temporary value dropped while borrowed -} diff --git a/src/test/ui/statics/issue-44373.stderr b/src/test/ui/statics/issue-44373.stderr deleted file mode 100644 index 2d29dec88..000000000 --- a/src/test/ui/statics/issue-44373.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-44373.rs:4:42 - | -LL | let _val: &'static [&'static u32] = &[&FOO]; - | ----------------------- ^^^^^^ creates a temporary value which is freed while still in use - | | - | type annotation requires that borrow lasts for `'static` -LL | } - | - temporary value is freed at the end of this statement - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0716`. diff --git a/src/test/ui/statics/issue-91050-1.rs b/src/test/ui/statics/issue-91050-1.rs deleted file mode 100644 index 403a41462..000000000 --- a/src/test/ui/statics/issue-91050-1.rs +++ /dev/null @@ -1,34 +0,0 @@ -// build-pass -// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes - -// This test declares globals by the same name with different types, which -// caused problems because Module::getOrInsertGlobal would return a Constant* -// bitcast instead of a GlobalVariable* that could access linkage/visibility. -// In alt builds with LLVM assertions this would fail: -// -// rustc: /checkout/src/llvm-project/llvm/include/llvm/Support/Casting.h:269: -// typename cast_retty::ret_type llvm::cast(Y *) [X = llvm::GlobalValue, Y = llvm::Value]: -// Assertion `isa(Val) && "cast() argument of incompatible type!"' failed. -// -// In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!" - -pub mod before { - #[no_mangle] - pub static GLOBAL1: [u8; 1] = [1]; -} - -pub mod inner { - extern "C" { - pub static GLOBAL1: u8; - pub static GLOBAL2: u8; - } - - pub fn call() { - drop(unsafe { (GLOBAL1, GLOBAL2) }); - } -} - -pub mod after { - #[no_mangle] - pub static GLOBAL2: [u8; 1] = [2]; -} diff --git a/src/test/ui/statics/issue-91050-2.rs b/src/test/ui/statics/issue-91050-2.rs deleted file mode 100644 index 2ff954d15..000000000 --- a/src/test/ui/statics/issue-91050-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// build-pass -// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes - -// This is a variant of issue-91050-1.rs -- see there for an explanation. - -pub mod before { - extern "C" { - pub static GLOBAL1: [u8; 1]; - } - - pub unsafe fn do_something_with_array() -> u8 { - GLOBAL1[0] - } -} - -pub mod inner { - extern "C" { - pub static GLOBAL1: u8; - } - - pub unsafe fn call() -> u8 { - GLOBAL1 + 42 - } -} diff --git a/src/test/ui/statics/static-fn-inline-xc.rs b/src/test/ui/statics/static-fn-inline-xc.rs deleted file mode 100644 index a400b9c8d..000000000 --- a/src/test/ui/statics/static-fn-inline-xc.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// aux-build:static_fn_inline_xc_aux.rs - -// pretty-expanded FIXME #23616 - -extern crate static_fn_inline_xc_aux as mycore; - -use mycore::num; - -pub fn main() { - let _1: f64 = num::Num2::from_int2(1); -} diff --git a/src/test/ui/statics/static-fn-trait-xc.rs b/src/test/ui/statics/static-fn-trait-xc.rs deleted file mode 100644 index 1d3126128..000000000 --- a/src/test/ui/statics/static-fn-trait-xc.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// aux-build:static_fn_trait_xc_aux.rs - -// pretty-expanded FIXME #23616 - -extern crate static_fn_trait_xc_aux as mycore; - -use mycore::num; - -pub fn main() { - let _1: f64 = num::Num2::from_int2(1); -} diff --git a/src/test/ui/statics/static-function-pointer-xc.rs b/src/test/ui/statics/static-function-pointer-xc.rs deleted file mode 100644 index 2d063a751..000000000 --- a/src/test/ui/statics/static-function-pointer-xc.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -// aux-build:static-function-pointer-aux.rs - -extern crate static_function_pointer_aux as aux; - -fn f(x: isize) -> isize { x } - -pub fn main() { - assert_eq!(aux::F(42), -42); - unsafe { - assert_eq!(aux::MutF(42), -42); - aux::MutF = f; - assert_eq!(aux::MutF(42), 42); - aux::MutF = aux::f; - assert_eq!(aux::MutF(42), -42); - } -} diff --git a/src/test/ui/statics/static-function-pointer.rs b/src/test/ui/statics/static-function-pointer.rs deleted file mode 100644 index 6c52dfecd..000000000 --- a/src/test/ui/statics/static-function-pointer.rs +++ /dev/null @@ -1,16 +0,0 @@ -// run-pass - -fn f(x: isize) -> isize { x } -fn g(x: isize) -> isize { 2 * x } - -static F: fn(isize) -> isize = f; -static mut G: fn(isize) -> isize = f; - -pub fn main() { - assert_eq!(F(42), 42); - unsafe { - assert_eq!(G(42), 42); - G = g; - assert_eq!(G(42), 84); - } -} diff --git a/src/test/ui/statics/static-impl.rs b/src/test/ui/statics/static-impl.rs deleted file mode 100644 index e7bdb38ee..000000000 --- a/src/test/ui/statics/static-impl.rs +++ /dev/null @@ -1,66 +0,0 @@ -// run-pass -#![allow(non_camel_case_types)] - - - - -pub trait plus { - fn plus(&self) -> isize; -} - -mod a { - use plus; - impl plus for usize { fn plus(&self) -> isize { *self as isize + 20 } } -} - -mod b { - use plus; - impl plus for String { fn plus(&self) -> isize { 200 } } -} - -trait uint_utils { - fn str(&self) -> String; - fn multi(&self, f: F) where F: FnMut(usize); -} - -impl uint_utils for usize { - fn str(&self) -> String { - self.to_string() - } - fn multi(&self, mut f: F) where F: FnMut(usize) { - let mut c = 0_usize; - while c < *self { f(c); c += 1_usize; } - } -} - -trait vec_utils { - fn length_(&self, ) -> usize; - fn iter_(&self, f: F) where F: FnMut(&T); - fn map_(&self, f: F) -> Vec where F: FnMut(&T) -> U; -} - -impl vec_utils for Vec { - fn length_(&self) -> usize { self.len() } - fn iter_(&self, mut f: F) where F: FnMut(&T) { for x in self { f(x); } } - fn map_(&self, mut f: F) -> Vec where F: FnMut(&T) -> U { - let mut r = Vec::new(); - for elt in self { - r.push(f(elt)); - } - r - } -} - -pub fn main() { - assert_eq!(10_usize.plus(), 30); - assert_eq!(("hi".to_string()).plus(), 200); - - assert_eq!((vec![1]).length_().str(), "1".to_string()); - let vect = vec![3, 4].map_(|a| *a + 4); - assert_eq!(vect[0], 7); - let vect = (vec![3, 4]).map_::(|a| *a as usize + 4_usize); - assert_eq!(vect[0], 7_usize); - let mut x = 0_usize; - 10_usize.multi(|_n| x += 2_usize ); - assert_eq!(x, 20_usize); -} diff --git a/src/test/ui/statics/static-method-in-trait-with-tps-intracrate.rs b/src/test/ui/statics/static-method-in-trait-with-tps-intracrate.rs deleted file mode 100644 index cd3ccfee0..000000000 --- a/src/test/ui/statics/static-method-in-trait-with-tps-intracrate.rs +++ /dev/null @@ -1,28 +0,0 @@ -// run-pass -#![allow(dead_code)] - -trait Deserializer { - fn read_int(&self) -> isize; -} - -trait Deserializable { - fn deserialize(d: &D) -> Self; -} - -impl Deserializable for isize { - fn deserialize(d: &D) -> isize { - return d.read_int(); - } -} - -struct FromThinAir { dummy: () } - -impl Deserializer for FromThinAir { - fn read_int(&self) -> isize { 22 } -} - -pub fn main() { - let d = FromThinAir { dummy: () }; - let i: isize = Deserializable::deserialize(&d); - assert_eq!(i, 22); -} diff --git a/src/test/ui/statics/static-method-xcrate.rs b/src/test/ui/statics/static-method-xcrate.rs deleted file mode 100644 index 1d1cb3810..000000000 --- a/src/test/ui/statics/static-method-xcrate.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass -// aux-build:static-methods-crate.rs - -extern crate static_methods_crate; - -use static_methods_crate::read; - -pub fn main() { - let result: isize = read("5".to_string()); - assert_eq!(result, 5); - assert_eq!(read::readMaybe("false".to_string()), Some(false)); - assert_eq!(read::readMaybe("foo".to_string()), None::); -} diff --git a/src/test/ui/statics/static-methods-in-traits.rs b/src/test/ui/statics/static-methods-in-traits.rs deleted file mode 100644 index ff76d4e4a..000000000 --- a/src/test/ui/statics/static-methods-in-traits.rs +++ /dev/null @@ -1,26 +0,0 @@ -// run-pass - -mod a { - pub trait Foo { - fn foo() -> Self; - } - - impl Foo for isize { - fn foo() -> isize { - 3 - } - } - - impl Foo for usize { - fn foo() -> usize { - 5 - } - } -} - -pub fn main() { - let x: isize = a::Foo::foo(); - let y: usize = a::Foo::foo(); - assert_eq!(x, 3); - assert_eq!(y, 5); -} diff --git a/src/test/ui/statics/static-methods-in-traits2.rs b/src/test/ui/statics/static-methods-in-traits2.rs deleted file mode 100644 index 2c43ff6a7..000000000 --- a/src/test/ui/statics/static-methods-in-traits2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// run-pass -// pretty-expanded FIXME #23616 - -pub trait Number: NumConv { - fn from(n: T) -> Self; -} - -impl Number for f64 { - fn from(n: T) -> f64 { n.to_float() } -} - -pub trait NumConv { - fn to_float(&self) -> f64; -} - -impl NumConv for f64 { - fn to_float(&self) -> f64 { *self } -} - -pub fn main() { - let _: f64 = Number::from(0.0f64); -} diff --git a/src/test/ui/statics/static-mut-xc.rs b/src/test/ui/statics/static-mut-xc.rs deleted file mode 100644 index 1d172d26a..000000000 --- a/src/test/ui/statics/static-mut-xc.rs +++ /dev/null @@ -1,39 +0,0 @@ -// run-pass -#![allow(non_upper_case_globals)] - -// Constants (static variables) can be used to match in patterns, but mutable -// statics cannot. This ensures that there's some form of error if this is -// attempted. - -// aux-build:static_mut_xc.rs - - -extern crate static_mut_xc; - -unsafe fn static_bound(_: &'static isize) {} - -fn static_bound_set(a: &'static mut isize) { - *a = 3; -} - -unsafe fn run() { - assert_eq!(static_mut_xc::a, 3); - static_mut_xc::a = 4; - assert_eq!(static_mut_xc::a, 4); - static_mut_xc::a += 1; - assert_eq!(static_mut_xc::a, 5); - static_mut_xc::a *= 3; - assert_eq!(static_mut_xc::a, 15); - static_mut_xc::a = -3; - assert_eq!(static_mut_xc::a, -3); - static_bound(&static_mut_xc::a); - static_bound_set(&mut static_mut_xc::a); -} - -pub fn main() { - unsafe { run() } -} - -pub mod inner { - pub static mut a: isize = 4; -} diff --git a/src/test/ui/statics/static-promotion.rs b/src/test/ui/statics/static-promotion.rs deleted file mode 100644 index b9eff4691..000000000 --- a/src/test/ui/statics/static-promotion.rs +++ /dev/null @@ -1,34 +0,0 @@ -// run-pass - -// Use of global static variables in literal values should be allowed for -// promotion. -// This test is to demonstrate the issue raised in -// https://github.com/rust-lang/rust/issues/70584 - -// Literal values were previously promoted into local static values when -// other global static variables are used. - -struct A(&'static T); -struct B { - x: &'static T, -} -static STR: &'static [u8] = b"hi"; -static C: A>> = { - A(&B { - x: &B { x: STR }, - }) -}; - -pub struct Slice(&'static [i32]); - -static CONTENT: i32 = 42; -pub static CONTENT_MAP: Slice = Slice(&[CONTENT]); - -pub static FOO: (i32, i32) = (42, 43); -pub static CONTENT_MAP2: Slice = Slice(&[FOO.0]); - -fn main() { - assert_eq!(b"hi", C.0.x.x); - assert_eq!(&[42], CONTENT_MAP.0); - assert_eq!(&[42], CONTENT_MAP2.0); -} diff --git a/src/test/ui/statics/static-recursive.rs b/src/test/ui/statics/static-recursive.rs deleted file mode 100644 index 95dadc81f..000000000 --- a/src/test/ui/statics/static-recursive.rs +++ /dev/null @@ -1,36 +0,0 @@ -// run-pass -static mut S: *const u8 = unsafe { &S as *const *const u8 as *const u8 }; - -struct StaticDoubleLinked { - prev: &'static StaticDoubleLinked, - next: &'static StaticDoubleLinked, - data: i32, - head: bool -} - -static L1: StaticDoubleLinked = StaticDoubleLinked{prev: &L3, next: &L2, data: 1, head: true}; -static L2: StaticDoubleLinked = StaticDoubleLinked{prev: &L1, next: &L3, data: 2, head: false}; -static L3: StaticDoubleLinked = StaticDoubleLinked{prev: &L2, next: &L1, data: 3, head: false}; - - -pub fn main() { - unsafe { assert_eq!(S, *(S as *const *const u8)); } - - let mut test_vec = Vec::new(); - let mut cur = &L1; - loop { - test_vec.push(cur.data); - cur = cur.next; - if cur.head { break } - } - assert_eq!(&test_vec, &[1,2,3]); - - let mut test_vec = Vec::new(); - let mut cur = &L1; - loop { - cur = cur.prev; - test_vec.push(cur.data); - if cur.head { break } - } - assert_eq!(&test_vec, &[3,2,1]); -} diff --git a/src/test/ui/statics/uninhabited-static.rs b/src/test/ui/statics/uninhabited-static.rs deleted file mode 100644 index f5c6f4443..000000000 --- a/src/test/ui/statics/uninhabited-static.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(never_type)] -#![deny(uninhabited_static)] - -enum Void {} -extern { - static VOID: Void; //~ ERROR static of uninhabited type - //~| WARN: previously accepted - static NEVER: !; //~ ERROR static of uninhabited type - //~| WARN: previously accepted -} - -static VOID2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type -//~| WARN: previously accepted -//~| ERROR could not evaluate static initializer -//~| WARN: type `Void` does not permit zero-initialization -static NEVER2: Void = unsafe { std::mem::transmute(()) }; //~ ERROR static of uninhabited type -//~| WARN: previously accepted -//~| ERROR could not evaluate static initializer -//~| WARN: type `Void` does not permit zero-initialization - -fn main() {} diff --git a/src/test/ui/statics/uninhabited-static.stderr b/src/test/ui/statics/uninhabited-static.stderr deleted file mode 100644 index ef794bb36..000000000 --- a/src/test/ui/statics/uninhabited-static.stderr +++ /dev/null @@ -1,91 +0,0 @@ -error: static of uninhabited type - --> $DIR/uninhabited-static.rs:6:5 - | -LL | static VOID: Void; - | ^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #74840 - = note: uninhabited statics cannot be initialized, and any access would be an immediate error -note: the lint level is defined here - --> $DIR/uninhabited-static.rs:2:9 - | -LL | #![deny(uninhabited_static)] - | ^^^^^^^^^^^^^^^^^^ - -error: static of uninhabited type - --> $DIR/uninhabited-static.rs:8:5 - | -LL | static NEVER: !; - | ^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #74840 - = note: uninhabited statics cannot be initialized, and any access would be an immediate error - -error: static of uninhabited type - --> $DIR/uninhabited-static.rs:12:1 - | -LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #74840 - = note: uninhabited statics cannot be initialized, and any access would be an immediate error - -error: static of uninhabited type - --> $DIR/uninhabited-static.rs:16:1 - | -LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #74840 - = note: uninhabited statics cannot be initialized, and any access would be an immediate error - -error[E0080]: could not evaluate static initializer - --> $DIR/uninhabited-static.rs:12:31 - | -LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type - -warning: the type `Void` does not permit zero-initialization - --> $DIR/uninhabited-static.rs:12:31 - | -LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | this code causes undefined behavior when executed - | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done - | -note: enums with no inhabited variants have no valid value - --> $DIR/uninhabited-static.rs:4:1 - | -LL | enum Void {} - | ^^^^^^^^^ - = note: `#[warn(invalid_value)]` on by default - -error[E0080]: could not evaluate static initializer - --> $DIR/uninhabited-static.rs:16:32 - | -LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type - -warning: the type `Void` does not permit zero-initialization - --> $DIR/uninhabited-static.rs:16:32 - | -LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ - | | - | this code causes undefined behavior when executed - | help: use `MaybeUninit` instead, and only call `assume_init` after initialization is done - | -note: enums with no inhabited variants have no valid value - --> $DIR/uninhabited-static.rs:4:1 - | -LL | enum Void {} - | ^^^^^^^^^ - -error: aborting due to 6 previous errors; 2 warnings emitted - -For more information about this error, try `rustc --explain E0080`. -- cgit v1.2.3