Auto merge of #143233 - dianqk:rollup-lcx3278, r=dianqk
Rollup of 14 pull requests Successful merges: - rust-lang/rust#142429 (`tests/ui`: A New Order [13/N]) - rust-lang/rust#142514 (Miri: handling of SNaN inputs in `f*::pow` operations) - rust-lang/rust#143066 (Use let chains in the new solver) - rust-lang/rust#143090 (Workaround for memory unsafety in third party DLLs) - rust-lang/rust#143118 (`tests/ui`: A New Order [15/N]) - rust-lang/rust#143159 (Do not freshen `ReError`) - rust-lang/rust#143168 (`tests/ui`: A New Order [16/N]) - rust-lang/rust#143176 (fix typos and improve clarity in documentation) - rust-lang/rust#143187 (Add my work email to mailmap) - rust-lang/rust#143190 (Use the `new` method for `BasicBlockData` and `Statement`) - rust-lang/rust#143195 (`tests/ui`: A New Order [17/N]) - rust-lang/rust#143196 (Port #[link_section] to the new attribute parsing infrastructure) - rust-lang/rust#143199 (Re-disable `tests/run-make/short-ice` on Windows MSVC again) - rust-lang/rust#143219 (Show auto trait and blanket impls for `!`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
c65dccabac
125 changed files with 1360 additions and 1065 deletions
36
tests/ui/attributes/inner-attrs-impl-cfg.rs
Normal file
36
tests/ui/attributes/inner-attrs-impl-cfg.rs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
//! Test inner attributes (#![...]) behavior in impl blocks with cfg conditions.
|
||||
//!
|
||||
//! This test verifies that:
|
||||
//! - Inner attributes can conditionally exclude entire impl blocks
|
||||
//! - Regular attributes within impl blocks work independently
|
||||
//! - Attribute parsing doesn't consume too eagerly
|
||||
|
||||
//@ run-pass
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
#![cfg(false)]
|
||||
|
||||
fn method(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
#![cfg(not(FALSE))]
|
||||
|
||||
// Check that we don't eat attributes too eagerly.
|
||||
#[cfg(false)]
|
||||
fn method(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn method(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert!(Foo.method());
|
||||
}
|
||||
12
tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs
Normal file
12
tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
//! Test that -Z maximal-hir-to-mir-coverage flag is accepted.
|
||||
//!
|
||||
//! Original PR: https://github.com/rust-lang/rust/pull/105286
|
||||
|
||||
//@ compile-flags: -Zmaximal-hir-to-mir-coverage
|
||||
//@ run-pass
|
||||
|
||||
fn main() {
|
||||
let x = 1;
|
||||
let y = x + 1;
|
||||
println!("{y}");
|
||||
}
|
||||
37
tests/ui/codegen/mono-respects-abi-alignment.rs
Normal file
37
tests/ui/codegen/mono-respects-abi-alignment.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
//! Test that monomorphization correctly distinguishes types with different ABI alignment.
|
||||
//!
|
||||
//! On x86_64-linux-gnu and similar platforms, structs get 8-byte "preferred"
|
||||
//! alignment, but their "ABI" alignment (what actually matters for data layout)
|
||||
//! is the largest alignment of any field. If monomorphization incorrectly uses
|
||||
//! "preferred" alignment instead of "ABI" alignment, it might unify types `A`
|
||||
//! and `B` even though `S<A>` and `S<B>` have field `t` at different offsets,
|
||||
//! leading to incorrect method dispatch for `unwrap()`.
|
||||
|
||||
//@ run-pass
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct S<T> {
|
||||
#[allow(dead_code)]
|
||||
i: u8,
|
||||
t: T,
|
||||
}
|
||||
|
||||
impl<T> S<T> {
|
||||
fn unwrap(self) -> T {
|
||||
self.t
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
struct A((u32, u32)); // Different ABI alignment than B
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
struct B(u64); // Different ABI alignment than A
|
||||
|
||||
pub fn main() {
|
||||
static CA: S<A> = S { i: 0, t: A((13, 104)) };
|
||||
static CB: S<B> = S { i: 0, t: B(31337) };
|
||||
|
||||
assert_eq!(CA.unwrap(), A((13, 104)));
|
||||
assert_eq!(CB.unwrap(), B(31337));
|
||||
}
|
||||
37
tests/ui/codegen/msvc-opt-level-z-no-corruption.rs
Normal file
37
tests/ui/codegen/msvc-opt-level-z-no-corruption.rs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
//! Test that opt-level=z produces correct code on Windows MSVC targets.
|
||||
//!
|
||||
//! A previously outdated version of LLVM caused compilation failures and
|
||||
//! generated invalid code on Windows specifically with optimization level `z`.
|
||||
//! The bug manifested as corrupted base pointers due to incorrect register
|
||||
//! usage in the generated assembly (e.g., `popl %esi` corrupting local variables).
|
||||
//! After updating to a more recent LLVM version, this test ensures that
|
||||
//! compilation and execution both succeed with opt-level=z.
|
||||
//!
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/45034>.
|
||||
|
||||
//@ ignore-cross-compile
|
||||
// Reason: the compiled binary is executed
|
||||
//@ only-windows
|
||||
// Reason: the observed bug only occurred on Windows MSVC targets
|
||||
//@ run-pass
|
||||
//@ compile-flags: -C opt-level=z
|
||||
|
||||
#![feature(test)]
|
||||
extern crate test;
|
||||
|
||||
fn foo(x: i32, y: i32) -> i64 {
|
||||
(x + y) as i64
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn bar() {
|
||||
let _f = Box::new(0);
|
||||
// This call used to trigger an LLVM bug in opt-level=z where the base
|
||||
// pointer gets corrupted due to incorrect register allocation
|
||||
let y: fn(i32, i32) -> i64 = test::black_box(foo);
|
||||
test::black_box(y(1, 2));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
bar();
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
//! Regression test checks UI tests without error annotations are detected as failing.
|
||||
//!
|
||||
//! This tests that when we forget to use any `//~ ERROR` comments whatsoever,
|
||||
//! the test doesn't succeed
|
||||
//! Originally created in https://github.com/rust-lang/rust/pull/56244
|
||||
|
||||
//@ should-fail
|
||||
|
||||
fn main() {}
|
||||
30
tests/ui/derives/derive-Debug-enum-variants.rs
Normal file
30
tests/ui/derives/derive-Debug-enum-variants.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//! Test that `#[derive(Debug)]` for enums correctly formats variant names.
|
||||
|
||||
//@ run-pass
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Foo {
|
||||
A(usize),
|
||||
C,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Bar {
|
||||
D,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
// Test variant with data
|
||||
let foo_a = Foo::A(22);
|
||||
assert_eq!("A(22)".to_string(), format!("{:?}", foo_a));
|
||||
|
||||
if let Foo::A(value) = foo_a {
|
||||
println!("Value: {}", value); // This needs to remove #[allow(dead_code)]
|
||||
}
|
||||
|
||||
// Test unit variant
|
||||
assert_eq!("C".to_string(), format!("{:?}", Foo::C));
|
||||
|
||||
// Test unit variant from different enum
|
||||
assert_eq!("D".to_string(), format!("{:?}", Bar::D));
|
||||
}
|
||||
|
|
@ -387,14 +387,6 @@ LL | #![link()]
|
|||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
||||
warning: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1
|
||||
|
|
||||
LL | #![link_section = "1800"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
||||
warning: attribute should be applied to a function definition
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:62:1
|
||||
|
|
||||
|
|
@ -411,6 +403,14 @@ LL | #![link_name = "1900"]
|
|||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
||||
warning: attribute should be applied to a function or static
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:69:1
|
||||
|
|
||||
LL | #![link_section = "1800"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ not a function or static
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
||||
warning: `#[must_use]` has no effect when applied to a module
|
||||
--> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1
|
||||
|
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
//! Test that Debug::fmt is called exactly once during formatting.
|
||||
//!
|
||||
//! This is a regression test for PR https://github.com/rust-lang/rust/pull/10715
|
||||
|
||||
//@ run-pass
|
||||
//@ needs-threads
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::fmt;
|
||||
use std::thread;
|
||||
use std::{fmt, thread};
|
||||
|
||||
struct Foo(Cell<isize>);
|
||||
|
||||
|
|
@ -1,16 +1,20 @@
|
|||
//! Test that only usize can be used for indexing arrays and slices.
|
||||
|
||||
pub fn main() {
|
||||
let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5];
|
||||
let s: String = "abcdef".to_string();
|
||||
|
||||
// Valid indexing with usize
|
||||
v[3_usize];
|
||||
v[3];
|
||||
v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8`
|
||||
v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8`
|
||||
v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8`
|
||||
v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8`
|
||||
v[3u32]; //~ ERROR the type `[isize]` cannot be indexed by `u32`
|
||||
v[3i32]; //~ ERROR the type `[isize]` cannot be indexed by `i32`
|
||||
s.as_bytes()[3_usize];
|
||||
s.as_bytes()[3];
|
||||
s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8`
|
||||
s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8`
|
||||
s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8`
|
||||
s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8`
|
||||
s.as_bytes()[3u32]; //~ ERROR the type `[u8]` cannot be indexed by `u32`
|
||||
s.as_bytes()[3i32]; //~ ERROR the type `[u8]` cannot be indexed by `i32`
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: the type `[isize]` cannot be indexed by `u8`
|
||||
--> $DIR/integral-indexing.rs:6:7
|
||||
--> $DIR/indexing-integral-types.rs:10:7
|
||||
|
|
||||
LL | v[3u8];
|
||||
| ^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -11,7 +11,7 @@ LL | v[3u8];
|
|||
= note: required for `Vec<isize>` to implement `Index<u8>`
|
||||
|
||||
error[E0277]: the type `[isize]` cannot be indexed by `i8`
|
||||
--> $DIR/integral-indexing.rs:7:7
|
||||
--> $DIR/indexing-integral-types.rs:11:7
|
||||
|
|
||||
LL | v[3i8];
|
||||
| ^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -23,7 +23,7 @@ LL | v[3i8];
|
|||
= note: required for `Vec<isize>` to implement `Index<i8>`
|
||||
|
||||
error[E0277]: the type `[isize]` cannot be indexed by `u32`
|
||||
--> $DIR/integral-indexing.rs:8:7
|
||||
--> $DIR/indexing-integral-types.rs:12:7
|
||||
|
|
||||
LL | v[3u32];
|
||||
| ^^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -35,7 +35,7 @@ LL | v[3u32];
|
|||
= note: required for `Vec<isize>` to implement `Index<u32>`
|
||||
|
||||
error[E0277]: the type `[isize]` cannot be indexed by `i32`
|
||||
--> $DIR/integral-indexing.rs:9:7
|
||||
--> $DIR/indexing-integral-types.rs:13:7
|
||||
|
|
||||
LL | v[3i32];
|
||||
| ^^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -47,7 +47,7 @@ LL | v[3i32];
|
|||
= note: required for `Vec<isize>` to implement `Index<i32>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `u8`
|
||||
--> $DIR/integral-indexing.rs:12:18
|
||||
--> $DIR/indexing-integral-types.rs:16:18
|
||||
|
|
||||
LL | s.as_bytes()[3u8];
|
||||
| ^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -59,7 +59,7 @@ LL | s.as_bytes()[3u8];
|
|||
= note: required for `[u8]` to implement `Index<u8>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `i8`
|
||||
--> $DIR/integral-indexing.rs:13:18
|
||||
--> $DIR/indexing-integral-types.rs:17:18
|
||||
|
|
||||
LL | s.as_bytes()[3i8];
|
||||
| ^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -71,7 +71,7 @@ LL | s.as_bytes()[3i8];
|
|||
= note: required for `[u8]` to implement `Index<i8>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `u32`
|
||||
--> $DIR/integral-indexing.rs:14:18
|
||||
--> $DIR/indexing-integral-types.rs:18:18
|
||||
|
|
||||
LL | s.as_bytes()[3u32];
|
||||
| ^^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -83,7 +83,7 @@ LL | s.as_bytes()[3u32];
|
|||
= note: required for `[u8]` to implement `Index<u32>`
|
||||
|
||||
error[E0277]: the type `[u8]` cannot be indexed by `i32`
|
||||
--> $DIR/integral-indexing.rs:15:18
|
||||
--> $DIR/indexing-integral-types.rs:19:18
|
||||
|
|
||||
LL | s.as_bytes()[3i32];
|
||||
| ^^^^ slice indices are of type `usize` or ranges of `usize`
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
#![cfg(false)]
|
||||
|
||||
fn method(&self) -> bool { false }
|
||||
}
|
||||
|
||||
impl Foo {
|
||||
#![cfg(not(FALSE))]
|
||||
|
||||
// check that we don't eat attributes too eagerly.
|
||||
#[cfg(false)]
|
||||
fn method(&self) -> bool { false }
|
||||
|
||||
fn method(&self) -> bool { true }
|
||||
}
|
||||
|
||||
|
||||
pub fn main() {
|
||||
assert!(Foo.method());
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
mod inner {
|
||||
pub mod inner2 {
|
||||
pub fn hello() { println!("hello, modular world"); }
|
||||
}
|
||||
pub fn hello() { inner2::hello(); }
|
||||
}
|
||||
|
||||
pub fn main() { inner::hello(); inner::inner2::hello(); }
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// see #9186
|
||||
|
||||
enum Bar<T> { What } //~ ERROR parameter `T` is never used
|
||||
|
||||
fn foo<T>() {
|
||||
static a: Bar<T> = Bar::What;
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
//! Test placement of functions and statics in custom link sections
|
||||
|
||||
//@ run-pass
|
||||
|
||||
// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint
|
||||
#![allow(static_mut_refs)]
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
#[link_section = ".moretext"]
|
||||
18
tests/ui/linkage-attr/msvc-static-data-import.rs
Normal file
18
tests/ui/linkage-attr/msvc-static-data-import.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//! Test that static data from external crates can be imported on MSVC targets.
|
||||
//!
|
||||
//! On Windows MSVC targets, static data from external rlibs must be imported
|
||||
//! through `__imp_<symbol>` stubs to ensure proper linking. Without this,
|
||||
//! the linker would fail with "unresolved external symbol" errors when trying
|
||||
//! to reference static data from another crate.
|
||||
//!
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/26591>.
|
||||
//! Fixed in <https://github.com/rust-lang/rust/pull/28646>.
|
||||
|
||||
//@ run-pass
|
||||
//@ aux-build:msvc-static-data-import-lib.rs
|
||||
|
||||
extern crate msvc_static_data_import_lib;
|
||||
|
||||
fn main() {
|
||||
println!("The answer is {}!", msvc_static_data_import_lib::FOO);
|
||||
}
|
||||
|
|
@ -1,3 +1,7 @@
|
|||
//! Test the `missing_debug_implementations` lint that warns about public types without Debug.
|
||||
//!
|
||||
//! See https://github.com/rust-lang/rust/issues/20855
|
||||
|
||||
//@ compile-flags: --crate-type lib
|
||||
#![deny(missing_debug_implementations)]
|
||||
#![allow(unused)]
|
||||
|
|
@ -10,7 +14,6 @@ pub enum A {} //~ ERROR type does not implement `Debug`
|
|||
pub enum B {}
|
||||
|
||||
pub enum C {}
|
||||
|
||||
impl fmt::Debug for C {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
Ok(())
|
||||
|
|
@ -23,15 +26,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug`
|
|||
pub struct Bar;
|
||||
|
||||
pub struct Baz;
|
||||
|
||||
impl fmt::Debug for Baz {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Private types should not trigger the lint
|
||||
struct PrivateStruct;
|
||||
|
||||
enum PrivateEnum {}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
|
||||
--> $DIR/missing_debug_impls.rs:7:1
|
||||
--> $DIR/missing-debug-implementations-lint.rs:11:1
|
||||
|
|
||||
LL | pub enum A {}
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/missing_debug_impls.rs:2:9
|
||||
--> $DIR/missing-debug-implementations-lint.rs:6:9
|
||||
|
|
||||
LL | #![deny(missing_debug_implementations)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
|
||||
--> $DIR/missing_debug_impls.rs:20:1
|
||||
--> $DIR/missing-debug-implementations-lint.rs:23:1
|
||||
|
|
||||
LL | pub struct Foo;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -102,4 +102,10 @@ pub fn no_mangle_test() {}
|
|||
#[used] //~ ERROR unused attribute
|
||||
static FOO: u32 = 0;
|
||||
|
||||
#[link_section = ".text"]
|
||||
//~^ ERROR unused attribute
|
||||
//~| WARN this was previously accepted
|
||||
#[link_section = ".bss"]
|
||||
pub extern "C" fn example() {}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -289,5 +289,18 @@ note: attribute also specified here
|
|||
LL | #[used]
|
||||
| ^^^^^^^
|
||||
|
||||
error: aborting due to 23 previous errors
|
||||
error: unused attribute
|
||||
--> $DIR/unused-attr-duplicate.rs:105:1
|
||||
|
|
||||
LL | #[link_section = ".text"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
|
||||
|
|
||||
note: attribute also specified here
|
||||
--> $DIR/unused-attr-duplicate.rs:108:1
|
||||
|
|
||||
LL | #[link_section = ".bss"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
|
||||
error: aborting due to 24 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
if false {
|
||||
println!("{}", "foobar");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
#![allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
enum foo {
|
||||
a(usize),
|
||||
b(String),
|
||||
c,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum bar {
|
||||
d, e, f
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22)));
|
||||
assert_eq!("c".to_string(), format!("{:?}", foo::c));
|
||||
assert_eq!("d".to_string(), format!("{:?}", bar::d));
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
//@ should-fail
|
||||
|
||||
// this test ensures that when we forget to use
|
||||
// any `//~ ERROR` comments whatsoever, that the test doesn't succeed
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
//@ compile-flags: -Zmaximal-hir-to-mir-coverage
|
||||
//@ run-pass
|
||||
|
||||
// Just making sure this flag is accepted and doesn't crash the compiler
|
||||
|
||||
fn main() {
|
||||
let x = 1;
|
||||
let y = x + 1;
|
||||
println!("{y}");
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
trait Tr: ?Sized {}
|
||||
//~^ ERROR `?Trait` is not permitted in supertraits
|
||||
|
||||
type A1 = dyn Tr + (?Sized);
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
type A2 = dyn for<'a> Tr + (?Sized);
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fn bar() {}
|
||||
fn foo(x: i32) -> u32 {
|
||||
0
|
||||
}
|
||||
fn main() {
|
||||
let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308]
|
||||
let f: fn(i32) = foo; //~ ERROR mismatched types [E0308]
|
||||
}
|
||||
16
tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs
Normal file
16
tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//! This test checks that when there's a type mismatch between a function item and
|
||||
//! a function pointer, the error message focuses on the actual type difference
|
||||
//! (return types, argument types) rather than the confusing "pointer vs item" distinction.
|
||||
//!
|
||||
//! See https://github.com/rust-lang/rust/issues/127263
|
||||
|
||||
fn bar() {}
|
||||
|
||||
fn foo(x: i32) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308]
|
||||
let f: fn(i32) = foo; //~ ERROR mismatched types [E0308]
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/method-output-diff-issue-127263.rs:6:26
|
||||
--> $DIR/fn-pointer-mismatch-diagnostics.rs:14:26
|
||||
|
|
||||
LL | let b: fn() -> u32 = bar;
|
||||
| ----------- ^^^ expected fn pointer, found fn item
|
||||
|
|
@ -10,7 +10,7 @@ LL | let b: fn() -> u32 = bar;
|
|||
found fn item `fn() -> () {bar}`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/method-output-diff-issue-127263.rs:7:22
|
||||
--> $DIR/fn-pointer-mismatch-diagnostics.rs:15:22
|
||||
|
|
||||
LL | let f: fn(i32) = foo;
|
||||
| ------- ^^^ expected fn pointer, found fn item
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
//! Check that a type mismatch error is reported when trying
|
||||
//! to unify a {float} value assignment to an {integer} variable.
|
||||
|
||||
fn main() {
|
||||
let mut x //~ NOTE expected due to the type of this binding
|
||||
=
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0308]: mismatched types
|
||||
--> $DIR/integral-variable-unification-error.rs:5:9
|
||||
--> $DIR/int-float-type-mismatch.rs:8:9
|
||||
|
|
||||
LL | let mut x
|
||||
| ----- expected due to the type of this binding
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
mod Mod {
|
||||
pub struct FakeVariant<T>(pub T);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
Mod::FakeVariant::<i32>(0);
|
||||
Mod::<i32>::FakeVariant(0);
|
||||
//~^ ERROR type arguments are not allowed on module `Mod` [E0109]
|
||||
}
|
||||
19
tests/ui/modules/nested-modules-basic.rs
Normal file
19
tests/ui/modules/nested-modules-basic.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! Basic test for nested module functionality and path resolution
|
||||
|
||||
//@ run-pass
|
||||
|
||||
mod inner {
|
||||
pub mod inner2 {
|
||||
pub fn hello() {
|
||||
println!("hello, modular world");
|
||||
}
|
||||
}
|
||||
pub fn hello() {
|
||||
inner2::hello();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
inner::hello();
|
||||
inner::inner2::hello();
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(non_upper_case_globals)]
|
||||
#![allow(dead_code)]
|
||||
/*!
|
||||
* On x86_64-linux-gnu and possibly other platforms, structs get 8-byte "preferred" alignment,
|
||||
* but their "ABI" alignment (i.e., what actually matters for data layout) is the largest alignment
|
||||
* of any field. (Also, `u64` has 8-byte ABI alignment; this is not always true).
|
||||
*
|
||||
* On such platforms, if monomorphize uses the "preferred" alignment, then it will unify
|
||||
* `A` and `B`, even though `S<A>` and `S<B>` have the field `t` at different offsets,
|
||||
* and apply the wrong instance of the method `unwrap`.
|
||||
*/
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
struct S<T> { i:u8, t:T }
|
||||
|
||||
impl<T> S<T> {
|
||||
fn unwrap(self) -> T {
|
||||
self.t
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
struct A((u32, u32));
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
struct B(u64);
|
||||
|
||||
pub fn main() {
|
||||
static Ca: S<A> = S { i: 0, t: A((13, 104)) };
|
||||
static Cb: S<B> = S { i: 0, t: B(31337) };
|
||||
assert_eq!(Ca.unwrap(), A((13, 104)));
|
||||
assert_eq!(Cb.unwrap(), B(31337));
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
//@ run-pass
|
||||
//@ aux-build:msvc-data-only-lib.rs
|
||||
|
||||
extern crate msvc_data_only_lib;
|
||||
|
||||
fn main() {
|
||||
println!("The answer is {} !", msvc_data_only_lib::FOO);
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// A previously outdated version of LLVM caused compilation failures on Windows
|
||||
// specifically with optimization level `z`. After the update to a more recent LLVM
|
||||
// version, this test checks that compilation and execution both succeed.
|
||||
// See https://github.com/rust-lang/rust/issues/45034
|
||||
|
||||
//@ ignore-cross-compile
|
||||
// Reason: the compiled binary is executed
|
||||
//@ only-windows
|
||||
// Reason: the observed bug only occurs on Windows
|
||||
//@ run-pass
|
||||
//@ compile-flags: -C opt-level=z
|
||||
|
||||
#![feature(test)]
|
||||
extern crate test;
|
||||
|
||||
fn foo(x: i32, y: i32) -> i64 {
|
||||
(x + y) as i64
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn bar() {
|
||||
let _f = Box::new(0);
|
||||
// This call used to trigger an LLVM bug in opt-level z where the base
|
||||
// pointer gets corrupted, see issue #45034
|
||||
let y: fn(i32, i32) -> i64 = test::black_box(foo);
|
||||
test::black_box(y(1, 2));
|
||||
}
|
||||
|
||||
fn main() {
|
||||
bar();
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
//@ run-pass
|
||||
//
|
||||
|
||||
// Test that multibyte characters don't crash the compiler
|
||||
pub fn main() {
|
||||
println!("마이너스 사인이 없으면");
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
/*
|
||||
* This is a multi-line oldcomment.
|
||||
*/
|
||||
pub fn main() { }
|
||||
10
tests/ui/parser/multiline-comments-basic.rs
Normal file
10
tests/ui/parser/multiline-comments-basic.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//! Test that basic multiline comments are parsed correctly.
|
||||
//!
|
||||
//! Feature implementation test for <https://github.com/rust-lang/rust/issues/66>.
|
||||
|
||||
//@ run-pass
|
||||
|
||||
/*
|
||||
* This is a multi-line comment.
|
||||
*/
|
||||
pub fn main() {}
|
||||
9
tests/ui/parser/unicode-multibyte-chars-no-ice.rs
Normal file
9
tests/ui/parser/unicode-multibyte-chars-no-ice.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//! Test that multibyte Unicode characters don't crash the compiler.
|
||||
//!
|
||||
//! Regression test for <https://github.com/rust-lang/rust/issues/4780>.
|
||||
|
||||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
println!("마이너스 사인이 없으면");
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! Test that a struct and function can have the same name
|
||||
//!
|
||||
//@ run-pass
|
||||
|
||||
#![allow(non_snake_case)]
|
||||
|
|
@ -23,7 +25,7 @@ impl Product for Foo {
|
|||
}
|
||||
|
||||
fn Foo(x: isize, y: isize) -> Foo {
|
||||
Foo { x: x, y: y }
|
||||
Foo { x, y }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
@ -1,8 +1,13 @@
|
|||
//! Test that items in subscopes correctly shadow type parameters and local variables
|
||||
//!
|
||||
//! Regression test for https://github.com/rust-lang/rust/issues/23880
|
||||
|
||||
//@ run-pass
|
||||
// Tests that items in subscopes can shadow type parameters and local variables (see issue #23880).
|
||||
|
||||
#![allow(unused)]
|
||||
struct Foo<X> { x: Box<X> }
|
||||
struct Foo<X> {
|
||||
x: Box<X>,
|
||||
}
|
||||
impl<Bar> Foo<Bar> {
|
||||
fn foo(&self) {
|
||||
type Bar = i32;
|
||||
20
tests/ui/statics/static-generic-param-soundness.rs
Normal file
20
tests/ui/statics/static-generic-param-soundness.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
//! Originally, inner statics in generic functions were generated only once, causing the same
|
||||
//! static to be shared across all generic instantiations. This created a soundness hole where
|
||||
//! different types could be coerced through thread-local storage in safe code.
|
||||
//!
|
||||
//! This test checks that generic parameters from outer scopes cannot be used in inner statics,
|
||||
//! preventing this soundness issue.
|
||||
//!
|
||||
//! See https://github.com/rust-lang/rust/issues/9186
|
||||
|
||||
enum Bar<T> {
|
||||
//~^ ERROR parameter `T` is never used
|
||||
What,
|
||||
}
|
||||
|
||||
fn foo<T>() {
|
||||
static a: Bar<T> = Bar::What;
|
||||
//~^ ERROR can't use generic parameters from outer item
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0401]: can't use generic parameters from outer item
|
||||
--> $DIR/inner-static-type-parameter.rs:6:19
|
||||
--> $DIR/static-generic-param-soundness.rs:16:19
|
||||
|
|
||||
LL | fn foo<T>() {
|
||||
| - type parameter from outer item
|
||||
|
|
@ -9,9 +9,9 @@ LL | static a: Bar<T> = Bar::What;
|
|||
= note: a `static` is a separate item from the item that contains it
|
||||
|
||||
error[E0392]: type parameter `T` is never used
|
||||
--> $DIR/inner-static-type-parameter.rs:3:10
|
||||
--> $DIR/static-generic-param-soundness.rs:10:10
|
||||
|
|
||||
LL | enum Bar<T> { What }
|
||||
LL | enum Bar<T> {
|
||||
| ^ unused type parameter
|
||||
|
|
||||
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
|
||||
|
|
@ -1,20 +1,30 @@
|
|||
//! Test various invalid implementations of DispatchFromDyn trait.
|
||||
//!
|
||||
//! DispatchFromDyn is a special trait used by the compiler for dyn-compatible dynamic dispatch.
|
||||
//! This checks that the compiler correctly rejects invalid implementations:
|
||||
//! - Structs with extra non-coercible fields
|
||||
//! - Structs with multiple pointer fields
|
||||
//! - Structs with no coercible fields
|
||||
//! - Structs with repr(C) or other incompatible representations
|
||||
//! - Structs with over-aligned fields
|
||||
|
||||
#![feature(unsize, dispatch_from_dyn)]
|
||||
|
||||
use std::{
|
||||
ops::DispatchFromDyn,
|
||||
marker::{Unsize, PhantomData},
|
||||
};
|
||||
use std::marker::{PhantomData, Unsize};
|
||||
use std::ops::DispatchFromDyn;
|
||||
|
||||
// Extra field prevents DispatchFromDyn
|
||||
struct WrapperWithExtraField<T>(T, i32);
|
||||
|
||||
impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T>
|
||||
//~^ ERROR [E0378]
|
||||
where
|
||||
T: DispatchFromDyn<U>,
|
||||
{}
|
||||
T: DispatchFromDyn<U>
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
struct MultiplePointers<T: ?Sized>{
|
||||
// Multiple pointer fields create ambiguous coercion
|
||||
struct MultiplePointers<T: ?Sized> {
|
||||
ptr1: *const T,
|
||||
ptr2: *const T,
|
||||
}
|
||||
|
|
@ -22,10 +32,11 @@ struct MultiplePointers<T: ?Sized>{
|
|||
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T>
|
||||
//~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced
|
||||
where
|
||||
T: Unsize<U>,
|
||||
{}
|
||||
|
||||
T: Unsize<U>
|
||||
{
|
||||
}
|
||||
|
||||
// No coercible fields (only PhantomData)
|
||||
struct NothingToCoerce<T: ?Sized> {
|
||||
data: PhantomData<T>,
|
||||
}
|
||||
|
|
@ -33,23 +44,28 @@ struct NothingToCoerce<T: ?Sized> {
|
|||
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {}
|
||||
//~^ ERROR implementing `DispatchFromDyn` requires a field to be coerced
|
||||
|
||||
// repr(C) is incompatible with DispatchFromDyn
|
||||
#[repr(C)]
|
||||
struct HasReprC<T: ?Sized>(Box<T>);
|
||||
|
||||
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T>
|
||||
//~^ ERROR [E0378]
|
||||
where
|
||||
T: Unsize<U>,
|
||||
{}
|
||||
T: Unsize<U>
|
||||
{
|
||||
}
|
||||
|
||||
// Over-aligned fields are incompatible
|
||||
#[repr(align(64))]
|
||||
struct OverAlignedZst;
|
||||
|
||||
struct OverAligned<T: ?Sized>(Box<T>, OverAlignedZst);
|
||||
|
||||
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T>
|
||||
//~^ ERROR [E0378]
|
||||
where
|
||||
T: Unsize<U>,
|
||||
{}
|
||||
where
|
||||
T: Unsize<U>
|
||||
{
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,25 +1,25 @@
|
|||
error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else
|
||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:10:1
|
||||
--> $DIR/dispatch-from-dyn-invalid-impls.rs:19:1
|
||||
|
|
||||
LL | / impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T>
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | T: DispatchFromDyn<U>,
|
||||
| |__________________________^
|
||||
LL | | T: DispatchFromDyn<U>
|
||||
| |_________________________^
|
||||
|
|
||||
= note: extra field `1` of type `i32` is not allowed
|
||||
|
||||
error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced
|
||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:22:1
|
||||
--> $DIR/dispatch-from-dyn-invalid-impls.rs:32:1
|
||||
|
|
||||
LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T>
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | T: Unsize<U>,
|
||||
| |_________________^
|
||||
LL | | T: Unsize<U>
|
||||
| |________________^
|
||||
|
|
||||
note: the trait `DispatchFromDyn` may only be implemented when a single field is being coerced
|
||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:18:5
|
||||
--> $DIR/dispatch-from-dyn-invalid-impls.rs:28:5
|
||||
|
|
||||
LL | ptr1: *const T,
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
@ -27,7 +27,7 @@ LL | ptr2: *const T,
|
|||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error[E0374]: implementing `DispatchFromDyn` requires a field to be coerced
|
||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:33:1
|
||||
--> $DIR/dispatch-from-dyn-invalid-impls.rs:44:1
|
||||
|
|
||||
LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
@ -35,22 +35,22 @@ LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingT
|
|||
= note: expected a single field to be coerced, none found
|
||||
|
||||
error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]`
|
||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:39:1
|
||||
--> $DIR/dispatch-from-dyn-invalid-impls.rs:51:1
|
||||
|
|
||||
LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T>
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | T: Unsize<U>,
|
||||
| |_________________^
|
||||
LL | | T: Unsize<U>
|
||||
| |________________^
|
||||
|
||||
error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else
|
||||
--> $DIR/invalid_dispatch_from_dyn_impls.rs:49:1
|
||||
--> $DIR/dispatch-from-dyn-invalid-impls.rs:64:1
|
||||
|
|
||||
LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T>
|
||||
LL | |
|
||||
LL | | where
|
||||
LL | | T: Unsize<U>,
|
||||
| |_____________________^
|
||||
LL | | where
|
||||
LL | | T: Unsize<U>
|
||||
| |________________^
|
||||
|
|
||||
= note: extra field `1` of type `OverAlignedZst` is not allowed
|
||||
|
||||
|
|
@ -1,14 +1,23 @@
|
|||
//! Regression test for issue #11881
|
||||
//!
|
||||
//! Originally, the compiler would ICE when trying to parameterize on certain encoder types
|
||||
//! due to issues with higher-ranked trait bounds and lifetime inference. This test checks
|
||||
//! that various encoder patterns work correctly:
|
||||
//! - Generic encoders with associated error types
|
||||
//! - Higher-ranked trait bounds (for<'r> Encodable<JsonEncoder<'r>>)
|
||||
//! - Multiple encoder implementations for the same type
|
||||
//! - Polymorphic encoding functions
|
||||
|
||||
//@ run-pass
|
||||
|
||||
#![allow(unused_must_use)]
|
||||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
|
||||
use std::fmt;
|
||||
use std::io::prelude::*;
|
||||
use std::io::Cursor;
|
||||
use std::slice;
|
||||
use std::io::prelude::*;
|
||||
use std::marker::PhantomData;
|
||||
use std::{fmt, slice};
|
||||
|
||||
trait Encoder {
|
||||
type Error;
|
||||
|
|
@ -45,7 +54,6 @@ impl Encoder for OpaqueEncoder {
|
|||
type Error = ();
|
||||
}
|
||||
|
||||
|
||||
struct Foo {
|
||||
baz: bool,
|
||||
}
|
||||
|
|
@ -69,7 +77,6 @@ impl<S: Encoder> Encodable<S> for Bar {
|
|||
enum WireProtocol {
|
||||
JSON,
|
||||
Opaque,
|
||||
// ...
|
||||
}
|
||||
|
||||
fn encode_json<T: for<'a> Encodable<JsonEncoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) {
|
||||
23
tests/ui/traits/eval-caching-error-region.rs
Normal file
23
tests/ui/traits/eval-caching-error-region.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Regression test for #132882.
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
pub trait Numoid: Sized
|
||||
where
|
||||
&'missing Self: Add<Self>,
|
||||
//~^ ERROR use of undeclared lifetime name `'missing`
|
||||
{
|
||||
}
|
||||
|
||||
// Proving `N: Numoid`'s well-formedness causes us to have to prove `&'missing N: Add<N>`.
|
||||
// Since `'missing` is a region error, that will lead to us consider the predicate to hold,
|
||||
// since it references errors. Since the freshener turns error regions into fresh regions,
|
||||
// this means that subsequent lookups of `&'?0 N: Add<N>` will also hit this cache entry
|
||||
// even if candidate assembly can't assemble anything for `&'?0 N: Add<?1>` anyways. This
|
||||
// led to an ICE.
|
||||
pub fn compute<N: Numoid>(a: N) {
|
||||
let _ = &a + a;
|
||||
//~^ ERROR cannot add `N` to `&N`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
33
tests/ui/traits/eval-caching-error-region.stderr
Normal file
33
tests/ui/traits/eval-caching-error-region.stderr
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
error[E0261]: use of undeclared lifetime name `'missing`
|
||||
--> $DIR/eval-caching-error-region.rs:7:6
|
||||
|
|
||||
LL | &'missing Self: Add<Self>,
|
||||
| ^^^^^^^^ undeclared lifetime
|
||||
|
|
||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||
help: consider making the bound lifetime-generic with a new `'missing` lifetime
|
||||
|
|
||||
LL | for<'missing> &'missing Self: Add<Self>,
|
||||
| +++++++++++++
|
||||
help: consider introducing lifetime `'missing` here
|
||||
|
|
||||
LL | pub trait Numoid<'missing>: Sized
|
||||
| ++++++++++
|
||||
|
||||
error[E0369]: cannot add `N` to `&N`
|
||||
--> $DIR/eval-caching-error-region.rs:19:16
|
||||
|
|
||||
LL | let _ = &a + a;
|
||||
| -- ^ - N
|
||||
| |
|
||||
| &N
|
||||
|
|
||||
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
||||
|
|
||||
LL | pub fn compute<N: Numoid>(a: N) where &N: Add<N> {
|
||||
| ++++++++++++++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0261, E0369.
|
||||
For more information about an error, try `rustc --explain E0261`.
|
||||
18
tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs
Normal file
18
tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
//! Test that ?Trait bounds are forbidden in supertraits and trait object types.
|
||||
//!
|
||||
//! While `?Sized` and other maybe bounds are allowed in type parameter bounds and where clauses,
|
||||
//! they are explicitly forbidden in certain syntactic positions:
|
||||
//! - As supertraits in trait definitions
|
||||
//! - In trait object type expressions
|
||||
//!
|
||||
//! See https://github.com/rust-lang/rust/issues/20503
|
||||
|
||||
trait Tr: ?Sized {}
|
||||
//~^ ERROR `?Trait` is not permitted in supertraits
|
||||
|
||||
type A1 = dyn Tr + (?Sized);
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
type A2 = dyn for<'a> Tr + (?Sized);
|
||||
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0658]: `?Trait` is not permitted in supertraits
|
||||
--> $DIR/maybe-bounds.rs:1:11
|
||||
--> $DIR/maybe-trait-bounds-forbidden-locations.rs:10:11
|
||||
|
|
||||
LL | trait Tr: ?Sized {}
|
||||
| ^^^^^^
|
||||
|
|
@ -9,7 +9,7 @@ LL | trait Tr: ?Sized {}
|
|||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: `?Trait` is not permitted in trait object types
|
||||
--> $DIR/maybe-bounds.rs:4:20
|
||||
--> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20
|
||||
|
|
||||
LL | type A1 = dyn Tr + (?Sized);
|
||||
| ^^^^^^^^
|
||||
|
|
@ -18,7 +18,7 @@ LL | type A1 = dyn Tr + (?Sized);
|
|||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error[E0658]: `?Trait` is not permitted in trait object types
|
||||
--> $DIR/maybe-bounds.rs:6:28
|
||||
--> $DIR/maybe-trait-bounds-forbidden-locations.rs:15:28
|
||||
|
|
||||
LL | type A2 = dyn for<'a> Tr + (?Sized);
|
||||
| ^^^^^^^^
|
||||
16
tests/ui/type-alias-enum-variants/module-type-args-error.rs
Normal file
16
tests/ui/type-alias-enum-variants/module-type-args-error.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//! Test that type arguments are properly rejected on modules.
|
||||
//!
|
||||
//! Related PR: https://github.com/rust-lang/rust/pull/56225 (RFC 2338 implementation)
|
||||
|
||||
mod Mod {
|
||||
pub struct FakeVariant<T>(pub T);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// This should work fine - normal generic struct constructor
|
||||
Mod::FakeVariant::<i32>(0);
|
||||
|
||||
// This should error - type arguments not allowed on modules
|
||||
Mod::<i32>::FakeVariant(0);
|
||||
//~^ ERROR type arguments are not allowed on module `Mod` [E0109]
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0109]: type arguments are not allowed on module `Mod`
|
||||
--> $DIR/mod-subitem-as-enum-variant.rs:7:11
|
||||
--> $DIR/module-type-args-error.rs:14:11
|
||||
|
|
||||
LL | Mod::<i32>::FakeVariant(0);
|
||||
| --- ^^^ type argument not allowed
|
||||
Loading…
Add table
Add a link
Reference in a new issue