diff options
| author | bors <bors@rust-lang.org> | 2024-04-17 19:21:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-17 19:21:44 +0000 |
| commit | d261b5308111fa95427fcfdfd53a8331dd44a2b6 (patch) | |
| tree | 8a985a2ac605d07089841ac906e13601c9d06390 /tests | |
| parent | 9776f647e67cadaa8c5f56a04c933c72fe27ccbc (diff) | |
| parent | 7c3c2716ff46fb3276c16bdaea226e5a5abc08c0 (diff) | |
| download | rust-d261b5308111fa95427fcfdfd53a8331dd44a2b6.tar.gz rust-d261b5308111fa95427fcfdfd53a8331dd44a2b6.zip | |
Auto merge of #3481 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'tests')
23 files changed, 151 insertions, 161 deletions
diff --git a/tests/run-make/issue-107495-archive-permissions/foo.rs b/tests/run-make/issue-107495-archive-permissions/foo.rs new file mode 100644 index 00000000000..d15abba5976 --- /dev/null +++ b/tests/run-make/issue-107495-archive-permissions/foo.rs @@ -0,0 +1 @@ +// Empty diff --git a/tests/run-make/issue-107495-archive-permissions/rmake.rs b/tests/run-make/issue-107495-archive-permissions/rmake.rs new file mode 100644 index 00000000000..40deabe15b7 --- /dev/null +++ b/tests/run-make/issue-107495-archive-permissions/rmake.rs @@ -0,0 +1,31 @@ +#![feature(rustc_private)] + +#[cfg(unix)] +extern crate libc; +extern crate run_make_support; + +use run_make_support::{aux_build, tmp_dir}; +use std::fs; +#[cfg(unix)] +use std::os::unix::fs::PermissionsExt; +use std::path::Path; + +fn main() { + #[cfg(unix)] + unsafe { + libc::umask(0o002); + } + + aux_build().arg("foo.rs").run(); + verify(&tmp_dir().join("libfoo.rlib")); +} + +fn verify(path: &Path) { + let perm = fs::metadata(path).unwrap().permissions(); + + assert!(!perm.readonly()); + + // Check that the file is readable for everyone + #[cfg(unix)] + assert_eq!(perm.mode(), 0o100664); +} diff --git a/tests/ui/abi/anon-extern-mod.rs b/tests/ui/abi/anon-extern-mod.rs index a424f93f637..bb3739bc4af 100644 --- a/tests/ui/abi/anon-extern-mod.rs +++ b/tests/ui/abi/anon-extern-mod.rs @@ -1,13 +1,9 @@ //@ run-pass //@ pretty-expanded FIXME #23616 -#![feature(rustc_private)] - -extern crate libc; - #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - fn rust_get_test_int() -> libc::intptr_t; + fn rust_get_test_int() -> isize; } pub fn main() { diff --git a/tests/ui/abi/c-stack-as-value.rs b/tests/ui/abi/c-stack-as-value.rs index 6ea2051b05b..401bc132b6e 100644 --- a/tests/ui/abi/c-stack-as-value.rs +++ b/tests/ui/abi/c-stack-as-value.rs @@ -1,14 +1,10 @@ //@ run-pass //@ pretty-expanded FIXME #23616 -#![feature(rustc_private)] - mod rustrt { - extern crate libc; - #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } diff --git a/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs b/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs index 5cbf8093c5c..559c40546a8 100644 --- a/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -1,9 +1,6 @@ #![crate_name = "anonexternmod"] -#![feature(rustc_private)] - -extern crate libc; #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } diff --git a/tests/ui/abi/foreign/auxiliary/foreign_lib.rs b/tests/ui/abi/foreign/auxiliary/foreign_lib.rs index 3c649b778bd..74a95b96e9f 100644 --- a/tests/ui/abi/foreign/auxiliary/foreign_lib.rs +++ b/tests/ui/abi/foreign/auxiliary/foreign_lib.rs @@ -1,28 +1,28 @@ #![crate_name = "foreign_lib"] -#![feature(rustc_private)] pub mod rustrt { - extern crate libc; - #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } pub mod rustrt2 { - extern crate libc; - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } pub mod rustrt3 { - // Different type, but same ABI (on all supported platforms). - // Ensures that we don't ICE or trigger LLVM asserts when - // importing the same symbol under different types. - // See https://github.com/rust-lang/rust/issues/32740. + // The point of this test is to ensure that we don't ICE or trigger LLVM asserts when importing + // the same symbol with different types. This is not really possible to test portably; there is + // no different signature we can come up with that is different to LLVM but which for sure has + // the same behavior on all platforms. The signed-ness of integers is ignored by LLVM as well + // as pointee types. So the only ways to make our signatures differ are to use + // differently-sized integers which is definitely an ABI mismatch, or to rely on pointers and + // isize/usize having the same ABI, which is wrong on CHERI and probably other niche platforms. + // If this test causes you trouble, please file an issue. + // See https://github.com/rust-lang/rust/issues/32740 for the bug that prompted this test. extern "C" { pub fn rust_get_test_int() -> *const u8; } @@ -32,6 +32,6 @@ pub fn local_uses() { unsafe { let x = rustrt::rust_get_test_int(); assert_eq!(x, rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, rustrt3::rust_get_test_int()); + assert_eq!(x as *const u8, rustrt3::rust_get_test_int()); } } diff --git a/tests/ui/abi/foreign/foreign-dupe.rs b/tests/ui/abi/foreign/foreign-dupe.rs index 1b6df0892c7..3473d436cb4 100644 --- a/tests/ui/abi/foreign/foreign-dupe.rs +++ b/tests/ui/abi/foreign/foreign-dupe.rs @@ -4,13 +4,12 @@ // Check that we can still call duplicated extern (imported) functions // which were declared in another crate. See issues #32740 and #32783. - extern crate foreign_lib; pub fn main() { unsafe { let x = foreign_lib::rustrt::rust_get_test_int(); assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int()); + assert_eq!(x as *const u8, foreign_lib::rustrt3::rust_get_test_int()); } } diff --git a/tests/ui/abi/foreign/foreign-no-abi.rs b/tests/ui/abi/foreign/foreign-no-abi.rs deleted file mode 100644 index 4ac47df29a7..00000000000 --- a/tests/ui/abi/foreign/foreign-no-abi.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass -// ABI is cdecl by default - -//@ pretty-expanded FIXME #23616 - -#![feature(rustc_private)] - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub fn main() { - unsafe { - rustrt::rust_get_test_int(); - } -} diff --git a/tests/ui/attributes/item-attributes.rs b/tests/ui/attributes/item-attributes.rs index 7fe7fdd9758..daab1bccb2c 100644 --- a/tests/ui/attributes/item-attributes.rs +++ b/tests/ui/attributes/item-attributes.rs @@ -148,7 +148,7 @@ mod test_foreign_items { #![rustc_dummy] #[rustc_dummy] - fn rust_get_test_int() -> u32; + fn rust_get_test_int() -> isize; } } } diff --git a/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs b/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs index 8426748fd52..fd54fe2b0e8 100644 --- a/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs +++ b/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.rs @@ -22,8 +22,7 @@ struct MyType { impl MyTrait<MyType> for MyType { //~^ ERROR E0119 fn get(&self) -> usize { (*self).clone() } - //~^ ERROR incompatible type - //~| ERROR mismatched types + //~^ ERROR mismatched types } fn main() { } diff --git a/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr b/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr index 0653009409c..fc6250dfa02 100644 --- a/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr +++ b/tests/ui/coherence/coherence-blanket-conflicts-with-specific-multidispatch.stderr @@ -7,23 +7,6 @@ LL | impl<T> MyTrait<T> for T { LL | impl MyTrait<MyType> for MyType { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `MyType` -error[E0053]: method `get` has an incompatible type for trait - --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:24:22 - | -LL | fn get(&self) -> usize { (*self).clone() } - | ^^^^^ - | | - | expected `MyType`, found `usize` - | help: change the output type to match the trait: `MyType` - | -note: type in trait - --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:8:22 - | -LL | fn get(&self) -> T; - | ^ - = note: expected signature `fn(&MyType) -> MyType` - found signature `fn(&MyType) -> usize` - error[E0308]: mismatched types --> $DIR/coherence-blanket-conflicts-with-specific-multidispatch.rs:24:30 | @@ -32,7 +15,7 @@ LL | fn get(&self) -> usize { (*self).clone() } | | | expected `usize` because of return type -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0053, E0119, E0308. -For more information about an error, try `rustc --explain E0053`. +Some errors have detailed explanations: E0119, E0308. +For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/coherence/coherence-orphan.rs b/tests/ui/coherence/coherence-orphan.rs index 9c96958f21a..aee6647a788 100644 --- a/tests/ui/coherence/coherence-orphan.rs +++ b/tests/ui/coherence/coherence-orphan.rs @@ -9,13 +9,10 @@ struct TheType; impl TheTrait<usize> for isize {} //~^ ERROR E0117 -//~| ERROR not all trait items implemented impl TheTrait<TheType> for isize {} -//~^ ERROR not all trait items implemented impl TheTrait<isize> for TheType {} -//~^ ERROR not all trait items implemented impl !Send for Vec<isize> {} //~ ERROR E0117 diff --git a/tests/ui/coherence/coherence-orphan.stderr b/tests/ui/coherence/coherence-orphan.stderr index 48843f7cd18..f6ffae34290 100644 --- a/tests/ui/coherence/coherence-orphan.stderr +++ b/tests/ui/coherence/coherence-orphan.stderr @@ -10,32 +10,8 @@ LL | impl TheTrait<usize> for isize {} | = note: define and implement a trait or new type instead -error[E0046]: not all trait items implemented, missing: `the_fn` - --> $DIR/coherence-orphan.rs:10:1 - | -LL | impl TheTrait<usize> for isize {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation - | - = help: implement the missing item: `fn the_fn(&self) { todo!() }` - -error[E0046]: not all trait items implemented, missing: `the_fn` - --> $DIR/coherence-orphan.rs:14:1 - | -LL | impl TheTrait<TheType> for isize {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation - | - = help: implement the missing item: `fn the_fn(&self) { todo!() }` - -error[E0046]: not all trait items implemented, missing: `the_fn` - --> $DIR/coherence-orphan.rs:17:1 - | -LL | impl TheTrait<isize> for TheType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `the_fn` in implementation - | - = help: implement the missing item: `fn the_fn(&self) { todo!() }` - error[E0117]: only traits defined in the current crate can be implemented for types defined outside of the crate - --> $DIR/coherence-orphan.rs:20:1 + --> $DIR/coherence-orphan.rs:17:1 | LL | impl !Send for Vec<isize> {} | ^^^^^^^^^^^^^^^---------- @@ -45,7 +21,6 @@ LL | impl !Send for Vec<isize> {} | = note: define and implement a trait or new type instead -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0046, E0117. -For more information about an error, try `rustc --explain E0046`. +For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/error-codes/E0117.rs b/tests/ui/error-codes/E0117.rs index 32b9863806c..406d24e3666 100644 --- a/tests/ui/error-codes/E0117.rs +++ b/tests/ui/error-codes/E0117.rs @@ -1,5 +1,4 @@ impl Drop for u32 {} //~ ERROR E0117 //~| ERROR the `Drop` trait may only be implemented for local structs, enums, and unions -//~| ERROR not all trait items implemented fn main() {} diff --git a/tests/ui/error-codes/E0117.stderr b/tests/ui/error-codes/E0117.stderr index 058a64b20d1..f144aa9f72c 100644 --- a/tests/ui/error-codes/E0117.stderr +++ b/tests/ui/error-codes/E0117.stderr @@ -15,15 +15,7 @@ error[E0120]: the `Drop` trait may only be implemented for local structs, enums, LL | impl Drop for u32 {} | ^^^ must be a struct, enum, or union in the current crate -error[E0046]: not all trait items implemented, missing: `drop` - --> $DIR/E0117.rs:1:1 - | -LL | impl Drop for u32 {} - | ^^^^^^^^^^^^^^^^^ missing `drop` in implementation - | - = help: implement the missing item: `fn drop(&mut self) { todo!() }` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0046, E0117, E0120. -For more information about an error, try `rustc --explain E0046`. +Some errors have detailed explanations: E0117, E0120. +For more information about an error, try `rustc --explain E0117`. diff --git a/tests/ui/extern/issue-1251.rs b/tests/ui/extern/issue-1251.rs index da2b8be7bc1..5581bddaddc 100644 --- a/tests/ui/extern/issue-1251.rs +++ b/tests/ui/extern/issue-1251.rs @@ -2,13 +2,10 @@ #![allow(unused_attributes)] #![allow(dead_code)] //@ pretty-expanded FIXME #23616 -#![feature(rustc_private)] mod rustrt { - extern crate libc; - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } diff --git a/tests/ui/inference/dont-collect-stmts-from-parent-body.rs b/tests/ui/inference/dont-collect-stmts-from-parent-body.rs new file mode 100644 index 00000000000..635fe74b867 --- /dev/null +++ b/tests/ui/inference/dont-collect-stmts-from-parent-body.rs @@ -0,0 +1,15 @@ +// issue: rust-lang/rust#124022 + +struct Type<T>; +//~^ ERROR type parameter `T` is never used + +fn main() { + { + impl<T> Type<T> { + fn new() -> Type<T> { + Type + //~^ ERROR type annotations needed + } + } + }; +} diff --git a/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr b/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr new file mode 100644 index 00000000000..f82527273fb --- /dev/null +++ b/tests/ui/inference/dont-collect-stmts-from-parent-body.stderr @@ -0,0 +1,24 @@ +error[E0392]: type parameter `T` is never used + --> $DIR/dont-collect-stmts-from-parent-body.rs:3:13 + | +LL | struct Type<T>; + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead + +error[E0282]: type annotations needed + --> $DIR/dont-collect-stmts-from-parent-body.rs:10:17 + | +LL | Type + | ^^^^ cannot infer type of the type parameter `T` declared on the struct `Type` + | +help: consider specifying the generic argument + | +LL | Type::<T> + | +++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0282, E0392. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-67535.rs b/tests/ui/issues/issue-67535.rs index 153b95a1674..24f50621310 100644 --- a/tests/ui/issues/issue-67535.rs +++ b/tests/ui/issues/issue-67535.rs @@ -2,21 +2,21 @@ fn main() {} impl std::ops::AddAssign for () { //~^ ERROR only traits defined in the current crate can be implemented for arbitrary types - fn add_assign(&self, other: ()) -> () { //~ ERROR incompatible type + fn add_assign(&self, other: ()) -> () { () } } impl std::ops::AddAssign for [(); 1] { //~^ ERROR only traits defined in the current crate can be implemented for arbitrary types - fn add_assign(&self, other: [(); 1]) -> [(); 1] { //~ ERROR incompatible type + fn add_assign(&self, other: [(); 1]) -> [(); 1] { [()] } } impl std::ops::AddAssign for &[u8] { //~^ ERROR only traits defined in the current crate can be implemented for arbitrary types - fn add_assign(&self, other: &[u8]) -> &[u8] { //~ ERROR incompatible type + fn add_assign(&self, other: &[u8]) -> &[u8] { self } } diff --git a/tests/ui/issues/issue-67535.stderr b/tests/ui/issues/issue-67535.stderr index c8bde2cb88c..4d7a02a5096 100644 --- a/tests/ui/issues/issue-67535.stderr +++ b/tests/ui/issues/issue-67535.stderr @@ -34,43 +34,6 @@ LL | impl std::ops::AddAssign for &[u8] { | = note: define and implement a trait or new type instead -error[E0053]: method `add_assign` has an incompatible type for trait - --> $DIR/issue-67535.rs:5:19 - | -LL | fn add_assign(&self, other: ()) -> () { - | ^^^^^ - | | - | types differ in mutability - | help: change the self-receiver type to match the trait: `&mut self` - | - = note: expected signature `fn(&mut (), ())` - found signature `fn(&(), ())` - -error[E0053]: method `add_assign` has an incompatible type for trait - --> $DIR/issue-67535.rs:12:19 - | -LL | fn add_assign(&self, other: [(); 1]) -> [(); 1] { - | ^^^^^ - | | - | types differ in mutability - | help: change the self-receiver type to match the trait: `&mut self` - | - = note: expected signature `fn(&mut _, _)` - found signature `fn(&_, _) -> [(); 1]` - -error[E0053]: method `add_assign` has an incompatible type for trait - --> $DIR/issue-67535.rs:19:19 - | -LL | fn add_assign(&self, other: &[u8]) -> &[u8] { - | ^^^^^ - | | - | types differ in mutability - | help: change the self-receiver type to match the trait: `&mut self` - | - = note: expected signature `fn(&mut &_, &_)` - found signature `fn(&&_, &_) -> &[u8]` - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0053, E0117. -For more information about an error, try `rustc --explain E0053`. +For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs index d856b06e260..0009ed0e34c 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/weird-exprs.rs @@ -256,6 +256,20 @@ fn fake_macros() -> impl std::fmt::Debug { } } +fn fish_fight() { + trait Rope { + fn _____________<U>(_: Self, _: U) where Self: Sized {} + } + + struct T; + + impl Rope for T {} + + fn tug_o_war(_: impl Fn(T, T)) {} + + tug_o_war(<T>::_____________::<T>); +} + pub fn main() { strange(); funny(); @@ -284,4 +298,5 @@ pub fn main() { infcx(); return_already(); fake_macros(); + fish_fight(); } diff --git a/tests/ui/wf/conflicting-impls.rs b/tests/ui/wf/conflicting-impls.rs new file mode 100644 index 00000000000..8054eb7c594 --- /dev/null +++ b/tests/ui/wf/conflicting-impls.rs @@ -0,0 +1,20 @@ +//@ edition: 2021 + +struct Ty; + +impl TryFrom<Ty> for u8 { + type Error = Ty; + fn try_from(_: Ty) -> Result<Self, Self::Error> { + loop {} + } +} + +impl TryFrom<Ty> for u8 { + //~^ ERROR conflicting implementations of trait + type Error = Ty; + fn try_from(_: Ty) -> Result<Self, Self::Error> { + loop {} + } +} + +fn main() {} diff --git a/tests/ui/wf/conflicting-impls.stderr b/tests/ui/wf/conflicting-impls.stderr new file mode 100644 index 00000000000..d31ae17aa8f --- /dev/null +++ b/tests/ui/wf/conflicting-impls.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `TryFrom<Ty>` for type `u8` + --> $DIR/conflicting-impls.rs:12:1 + | +LL | impl TryFrom<Ty> for u8 { + | ----------------------- first implementation here +... +LL | impl TryFrom<Ty> for u8 { + | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `u8` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. |
