diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/crashes/120600-2.rs | 13 | ||||
| -rw-r--r-- | tests/crashes/120600.rs | 11 | ||||
| -rw-r--r-- | tests/mir-opt/building/eq_never_type._f.built.after.mir | 53 | ||||
| -rw-r--r-- | tests/mir-opt/building/eq_never_type.rs | 13 | ||||
| -rw-r--r-- | tests/run-make/cross-lang-lto-riscv-abi/rmake.rs | 61 | ||||
| -rw-r--r-- | tests/rustdoc/const-display.rs | 4 | ||||
| -rw-r--r-- | tests/rustdoc/deref/deref-const-fn.rs | 2 | ||||
| -rw-r--r-- | tests/rustdoc/ensure-src-link.rs | 2 | ||||
| -rw-r--r-- | tests/rustdoc/implementor-stable-version.rs | 2 | ||||
| -rw-r--r-- | tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs | 18 | ||||
| -rw-r--r-- | tests/ui/fmt/no-inline-literals-out-of-range.rs | 14 | ||||
| -rw-r--r-- | tests/ui/fmt/no-inline-literals-out-of-range.stderr | 56 | ||||
| -rw-r--r-- | tests/ui/lexer/emoji-literal-prefix.rs | 8 | ||||
| -rw-r--r-- | tests/ui/lexer/emoji-literal-prefix.stderr | 14 | ||||
| -rw-r--r-- | tests/ui/never_type/eq-never-types.rs | 13 | ||||
| -rw-r--r-- | tests/ui/numbers-arithmetic/f16-f128-lit.rs | 16 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/variance.rs | 24 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/variance.stderr | 56 |
18 files changed, 308 insertions, 72 deletions
diff --git a/tests/crashes/120600-2.rs b/tests/crashes/120600-2.rs deleted file mode 100644 index aa1785eea84..00000000000 --- a/tests/crashes/120600-2.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #120600 -#![feature(never_type, never_type_fallback)] - -enum E { Bar(!) } - -fn f(a: &E, b: &E) { - match (a, b) { - (E::Bar(a), E::Bar(b)) => { *a == *b; } - _ => {} - } -} - -pub fn main() {} diff --git a/tests/crashes/120600.rs b/tests/crashes/120600.rs deleted file mode 100644 index 1be51a8da16..00000000000 --- a/tests/crashes/120600.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #120600 -#![feature(never_type)] -#![feature(never_type_fallback)] - -#[derive(Ord, Eq, PartialOrd, PartialEq)] -enum E { - Foo, - Bar(!, i32, i32), -} - -fn main() {} diff --git a/tests/mir-opt/building/eq_never_type._f.built.after.mir b/tests/mir-opt/building/eq_never_type._f.built.after.mir new file mode 100644 index 00000000000..39438258c2e --- /dev/null +++ b/tests/mir-opt/building/eq_never_type._f.built.after.mir @@ -0,0 +1,53 @@ +// MIR for `_f` after built + +fn _f(_1: !, _2: !) -> () { + debug a => _1; + debug b => _2; + let mut _0: (); + let mut _3: !; + let _4: bool; + let mut _5: &(); + let mut _6: !; + let mut _7: &(); + let _8: (); + let mut _9: !; + + bb0: { + StorageLive(_4); + StorageLive(_5); + StorageLive(_6); + _6 = _1; + unreachable; + } + + bb1: { + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _2; + unreachable; + } + + bb2: { + _7 = &_8; + StorageDead(_9); + _4 = <() as PartialEq>::eq(move _5, move _7) -> [return: bb3, unwind: bb5]; + } + + bb3: { + StorageDead(_7); + StorageDead(_5); + StorageDead(_8); + StorageDead(_4); + unreachable; + } + + bb4: { + return; + } + + bb5 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/building/eq_never_type.rs b/tests/mir-opt/building/eq_never_type.rs new file mode 100644 index 00000000000..90e2e697535 --- /dev/null +++ b/tests/mir-opt/building/eq_never_type.rs @@ -0,0 +1,13 @@ +// skip-filecheck +#![feature(never_type)] +#![allow(unreachable_code)] + +// EMIT_MIR eq_never_type._f.built.after.mir +fn _f(a: !, b: !) { + // Both arguments must be references (i.e. == should auto-borrow/coerce-to-ref both arguments) + // (this previously was buggy due to `NeverToAny` coercion incorrectly throwing out other + // coercions) + a == b; +} + +fn main() {} diff --git a/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs b/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs index 2f13cf17169..b534a99f8cf 100644 --- a/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs +++ b/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs @@ -1,10 +1,10 @@ //! Make sure that cross-language LTO works on riscv targets, -//! which requires extra abi metadata to be emitted. +//! which requires extra `target-abi` metadata to be emitted. //@ needs-matching-clang //@ needs-llvm-components riscv extern crate run_make_support; -use run_make_support::{bin_name, rustc, tmp_dir}; +use run_make_support::{bin_name, clang, llvm_readobj, rustc, tmp_dir}; use std::{ env, path::PathBuf, @@ -12,13 +12,6 @@ use std::{ str, }; -fn handle_failed_output(output: Output) { - eprintln!("output status: `{}`", output.status); - eprintln!("=== STDOUT ===\n{}\n\n", String::from_utf8(output.stdout).unwrap()); - eprintln!("=== STDERR ===\n{}\n\n", String::from_utf8(output.stderr).unwrap()); - std::process::exit(1) -} - fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float: bool) { eprintln!("Checking target {target}"); // Rust part @@ -30,40 +23,24 @@ fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float: .linker_plugin_lto("on") .run(); // C part - let clang = env::var("CLANG").unwrap(); - let mut cmd = Command::new(clang); - let executable = tmp_dir().join("riscv-xlto"); - cmd.arg("-target") - .arg(clang_target) - .arg(format!("-march={carch}")) - .arg(format!("-flto=thin")) - .arg(format!("-fuse-ld=lld")) - .arg("-nostdlib") - .arg("-o") - .arg(&executable) - .arg("cstart.c") - .arg(tmp_dir().join("libriscv_xlto.rlib")); - eprintln!("{cmd:?}"); - let output = cmd.output().unwrap(); - if !output.status.success() { - handle_failed_output(output); - } + clang() + .target(clang_target) + .arch(carch) + .lto("thin") + .use_ld("lld") + .no_stdlib() + .out_exe("riscv-xlto") + .input("cstart.c") + .input(tmp_dir().join("libriscv_xlto.rlib")) + .run(); + // Check that the built binary has correct float abi - let llvm_readobj = - PathBuf::from(env::var("LLVM_BIN_DIR").unwrap()).join(bin_name("llvm-readobj")); - let mut cmd = Command::new(llvm_readobj); - cmd.arg("--file-header").arg(executable); - eprintln!("{cmd:?}"); - let output = cmd.output().unwrap(); - if output.status.success() { - assert!( - !(is_double_float - ^ dbg!(str::from_utf8(&output.stdout).unwrap()) - .contains("EF_RISCV_FLOAT_ABI_DOUBLE")) - ) - } else { - handle_failed_output(output); - } + let executable = tmp_dir().join(bin_name("riscv-xlto")); + let output = llvm_readobj().input(&executable).file_header().run(); + let stdout = String::from_utf8_lossy(&output.stdout); + eprintln!("obj:\n{}", stdout); + + assert!(!(is_double_float ^ stdout.contains("EF_RISCV_FLOAT_ABI_DOUBLE"))); } fn main() { diff --git a/tests/rustdoc/const-display.rs b/tests/rustdoc/const-display.rs index 594501b22b1..c8967f426f0 100644 --- a/tests/rustdoc/const-display.rs +++ b/tests/rustdoc/const-display.rs @@ -72,8 +72,8 @@ impl Foo { pub struct Bar; impl Bar { - // Do not show non-const stabilities that are the same as the enclosing item. - // @matches 'foo/struct.Bar.html' '//span[@class="since"]' '^const: 1.2.0$' + // Show non-const stabilities that are the same as the enclosing item. + // @has 'foo/struct.Bar.html' '//span[@class="since"]' '1.0.0 (const: 1.2.0)' #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_stable(feature = "const2", since = "1.2.0")] pub const fn stable_impl() -> u32 { 42 } diff --git a/tests/rustdoc/deref/deref-const-fn.rs b/tests/rustdoc/deref/deref-const-fn.rs index 8ecca6d12d2..85c2f2934e0 100644 --- a/tests/rustdoc/deref/deref-const-fn.rs +++ b/tests/rustdoc/deref/deref-const-fn.rs @@ -26,7 +26,7 @@ pub struct Foo { // @has 'foo/struct.Foo.html' // @has - '//*[@id="method.len"]' 'pub fn len(&self) -> usize' -// @!has - '//*[@id="method.len"]//span[@class="since"]' '1.0.0' +// @has - '//*[@id="method.len"]//span[@class="since"]' '1.0.0' // @!has - '//*[@id="method.len"]//span[@class="since"]' '(const: 1.0.0)' #[stable(feature = "rust1", since = "1.0.0")] impl std::ops::Deref for Foo { diff --git a/tests/rustdoc/ensure-src-link.rs b/tests/rustdoc/ensure-src-link.rs index f99c4c4d988..f95b5f2d424 100644 --- a/tests/rustdoc/ensure-src-link.rs +++ b/tests/rustdoc/ensure-src-link.rs @@ -2,5 +2,5 @@ // This test ensures that the [src] link is present on traits items. -// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src rightside"]' "source" +// @has foo/trait.Iterator.html '//*[@id="method.zip"]//a[@class="src"]' "source" pub use std::iter::Iterator; diff --git a/tests/rustdoc/implementor-stable-version.rs b/tests/rustdoc/implementor-stable-version.rs index 9c5b9b7e303..3674b9f2e48 100644 --- a/tests/rustdoc/implementor-stable-version.rs +++ b/tests/rustdoc/implementor-stable-version.rs @@ -16,6 +16,6 @@ pub struct Foo; #[stable(feature = "foobar", since = "4.4.4")] impl Bar for Foo {} -// @!has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' +// @has foo/trait.Baz.html '//div[@id="implementors-list"]//span[@class="since"]' '3.3.3' #[stable(feature = "foobaz", since = "3.3.3")] impl Baz for Foo {} diff --git a/tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs b/tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs new file mode 100644 index 00000000000..292733cd492 --- /dev/null +++ b/tests/ui/associated-inherent-types/constrain_opaque_types_during_projection.rs @@ -0,0 +1,18 @@ +//@ check-pass + +#![feature(inherent_associated_types, type_alias_impl_trait)] +#![allow(incomplete_features)] + +struct Foo<T>(T); + +impl Foo<i32> { + type Assoc = u32; +} + +type Tait = impl Sized; + +fn bar(_: Tait) { + let x: Foo<Tait>::Assoc = 42; +} + +fn main() {} diff --git a/tests/ui/fmt/no-inline-literals-out-of-range.rs b/tests/ui/fmt/no-inline-literals-out-of-range.rs new file mode 100644 index 00000000000..d2532cdfbff --- /dev/null +++ b/tests/ui/fmt/no-inline-literals-out-of-range.rs @@ -0,0 +1,14 @@ +//@ only-64bit + +fn main() { + format_args!("{}", 0x8f_i8); // issue #115423 + //~^ ERROR literal out of range for `i8` + format_args!("{}", 0xffff_ffff_u8); // issue #116633 + //~^ ERROR literal out of range for `u8` + format_args!("{}", 0xffff_ffff_ffff_ffff_ffff_usize); + //~^ ERROR literal out of range for `usize` + format_args!("{}", 0x8000_0000_0000_0000_isize); + //~^ ERROR literal out of range for `isize` + format_args!("{}", 0xffff_ffff); // treat unsuffixed literals as i32 + //~^ ERROR literal out of range for `i32` +} diff --git a/tests/ui/fmt/no-inline-literals-out-of-range.stderr b/tests/ui/fmt/no-inline-literals-out-of-range.stderr new file mode 100644 index 00000000000..78ec4888c27 --- /dev/null +++ b/tests/ui/fmt/no-inline-literals-out-of-range.stderr @@ -0,0 +1,56 @@ +error: literal out of range for `i8` + --> $DIR/no-inline-literals-out-of-range.rs:4:24 + | +LL | format_args!("{}", 0x8f_i8); // issue #115423 + | ^^^^^^^ + | + = note: the literal `0x8f_i8` (decimal `143`) does not fit into the type `i8` and will become `-113i8` + = note: `#[deny(overflowing_literals)]` on by default +help: consider using the type `u8` instead + | +LL | format_args!("{}", 0x8f_u8); // issue #115423 + | ~~~~~~~ +help: to use as a negative number (decimal `-113`), consider using the type `u8` for the literal and cast it to `i8` + | +LL | format_args!("{}", 0x8f_u8 as i8); // issue #115423 + | ~~~~~~~~~~~~~ + +error: literal out of range for `u8` + --> $DIR/no-inline-literals-out-of-range.rs:6:24 + | +LL | format_args!("{}", 0xffff_ffff_u8); // issue #116633 + | ^^^^^^^^^^^^^^ help: consider using the type `u32` instead: `0xffff_ffff_u32` + | + = note: the literal `0xffff_ffff_u8` (decimal `4294967295`) does not fit into the type `u8` and will become `255u8` + +error: literal out of range for `usize` + --> $DIR/no-inline-literals-out-of-range.rs:8:24 + | +LL | format_args!("{}", 0xffff_ffff_ffff_ffff_ffff_usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the literal `0xffff_ffff_ffff_ffff_ffff_usize` (decimal `1208925819614629174706175`) does not fit into the type `usize` and will become `18446744073709551615usize` + +error: literal out of range for `isize` + --> $DIR/no-inline-literals-out-of-range.rs:10:24 + | +LL | format_args!("{}", 0x8000_0000_0000_0000_isize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the literal `0x8000_0000_0000_0000_isize` (decimal `9223372036854775808`) does not fit into the type `isize` and will become `-9223372036854775808isize` + +error: literal out of range for `i32` + --> $DIR/no-inline-literals-out-of-range.rs:12:24 + | +LL | format_args!("{}", 0xffff_ffff); // treat unsuffixed literals as i32 + | ^^^^^^^^^^^ + | + = note: the literal `0xffff_ffff` (decimal `4294967295`) does not fit into the type `i32` and will become `-1i32` + = help: consider using the type `u32` instead +help: to use as a negative number (decimal `-1`), consider using the type `u32` for the literal and cast it to `i32` + | +LL | format_args!("{}", 0xffff_ffffu32 as i32); // treat unsuffixed literals as i32 + | ~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/lexer/emoji-literal-prefix.rs b/tests/ui/lexer/emoji-literal-prefix.rs new file mode 100644 index 00000000000..ccc8d48d4cc --- /dev/null +++ b/tests/ui/lexer/emoji-literal-prefix.rs @@ -0,0 +1,8 @@ +macro_rules! lexes {($($_:tt)*) => {}} + +lexes!(🐛#); //~ ERROR identifiers cannot contain emoji +lexes!(🐛"foo"); +lexes!(🐛'q'); +lexes!(🐛'q); + +fn main() {} diff --git a/tests/ui/lexer/emoji-literal-prefix.stderr b/tests/ui/lexer/emoji-literal-prefix.stderr new file mode 100644 index 00000000000..25aafed48ea --- /dev/null +++ b/tests/ui/lexer/emoji-literal-prefix.stderr @@ -0,0 +1,14 @@ +error: identifiers cannot contain emoji: `🐛` + --> $DIR/emoji-literal-prefix.rs:3:8 + | +LL | lexes!(🐛#); + | ^^ +LL | lexes!(🐛"foo"); + | ^^ +LL | lexes!(🐛'q'); + | ^^ +LL | lexes!(🐛'q); + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/never_type/eq-never-types.rs b/tests/ui/never_type/eq-never-types.rs new file mode 100644 index 00000000000..19717fcf443 --- /dev/null +++ b/tests/ui/never_type/eq-never-types.rs @@ -0,0 +1,13 @@ +//@ check-pass +// +// issue: rust-lang/rust#120600 + +#![allow(internal_features)] +#![feature(never_type, rustc_attrs)] +#![rustc_never_type_options(fallback = "never")] + +fn ice(a: !) { + a == a; +} + +fn main() {} diff --git a/tests/ui/numbers-arithmetic/f16-f128-lit.rs b/tests/ui/numbers-arithmetic/f16-f128-lit.rs new file mode 100644 index 00000000000..762436edb16 --- /dev/null +++ b/tests/ui/numbers-arithmetic/f16-f128-lit.rs @@ -0,0 +1,16 @@ +//@ run-pass + +#![feature(f16)] +#![feature(f128)] + +fn main() { + assert_eq!(0.0_f16.to_bits(), 0x0000); + assert_eq!((-0.0_f16).to_bits(), 0x8000); + assert_eq!(10.0_f16.to_bits(), 0x4900); + assert_eq!((-10.0_f16).to_bits(), 0xC900); + + assert_eq!(0.0_f128.to_bits(), 0x0000_0000_0000_0000_0000_0000_0000_0000); + assert_eq!((-0.0_f128).to_bits(), 0x8000_0000_0000_0000_0000_0000_0000_0000); + assert_eq!(10.0_f128.to_bits(), 0x4002_4000_0000_0000_0000_0000_0000_0000); + assert_eq!((-10.0_f128).to_bits(), 0xC002_4000_0000_0000_0000_0000_0000_0000); +} diff --git a/tests/ui/type-alias-impl-trait/variance.rs b/tests/ui/type-alias-impl-trait/variance.rs index 4b9fa67fd64..ba52eaa0359 100644 --- a/tests/ui/type-alias-impl-trait/variance.rs +++ b/tests/ui/type-alias-impl-trait/variance.rs @@ -52,4 +52,28 @@ impl<'i> Foo<'i> for () { //~^ ERROR: unconstrained opaque type } +trait Nesting<'a> { + type Output; +} +impl<'a> Nesting<'a> for &'a () { + type Output = &'a (); +} +type NestedDeeply<'a> = + impl Nesting< //~ [*, o] + 'a, + Output = impl Nesting< //~ [*, o] + 'a, + Output = impl Nesting< //~ [*, o] + 'a, + Output = impl Nesting< //~ [*, o] + 'a, + Output = impl Nesting<'a> //~ [*, o] + > + >, + >, + >; +fn test<'a>() -> NestedDeeply<'a> { + &() +} + fn main() {} diff --git a/tests/ui/type-alias-impl-trait/variance.stderr b/tests/ui/type-alias-impl-trait/variance.stderr index 1aaf36223b7..e5ced7a4981 100644 --- a/tests/ui/type-alias-impl-trait/variance.stderr +++ b/tests/ui/type-alias-impl-trait/variance.stderr @@ -176,6 +176,60 @@ error: [*, *, o, o] LL | type ExplicitCaptureFromGat<'a> = impl Sized + Captures<'a>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 24 previous errors +error: [*, o] + --> $DIR/variance.rs:62:5 + | +LL | / impl Nesting< +LL | | 'a, +LL | | Output = impl Nesting< +LL | | 'a, +... | +LL | | >, +LL | | >; + | |_____^ + +error: [*, o] + --> $DIR/variance.rs:64:18 + | +LL | Output = impl Nesting< + | __________________^ +LL | | 'a, +LL | | Output = impl Nesting< +LL | | 'a, +... | +LL | | >, +LL | | >, + | |_________^ + +error: [*, o] + --> $DIR/variance.rs:66:22 + | +LL | Output = impl Nesting< + | ______________________^ +LL | | 'a, +LL | | Output = impl Nesting< +LL | | 'a, +LL | | Output = impl Nesting<'a> +LL | | > +LL | | >, + | |_____________^ + +error: [*, o] + --> $DIR/variance.rs:68:26 + | +LL | Output = impl Nesting< + | __________________________^ +LL | | 'a, +LL | | Output = impl Nesting<'a> +LL | | > + | |_________________^ + +error: [*, o] + --> $DIR/variance.rs:70:30 + | +LL | Output = impl Nesting<'a> + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 29 previous errors For more information about this error, try `rustc --explain E0657`. |
