Skip to content

tests/ui: A New Order [16/N] #143168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs
Original file line number Diff line number Diff line change
@@ -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}");
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
//! Test the `missing_debug_implementations` lint that warns about public types without Debug.
//!
//! This lint helps enforce the convention that public types should implement Debug
//! for better debugging experience, as recommended by RFC 504.
//!
//! See https://github.com/rust-lang/rust/issues/20855

//@ compile-flags: --crate-type lib
#![deny(missing_debug_implementations)]
#![allow(unused)]
Expand All @@ -10,7 +17,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(())
Expand All @@ -23,15 +29,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)]
Expand Down
Original file line number Diff line number Diff line change
@@ -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:14: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:9: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:26:1
|
LL | pub struct Foo;
| ^^^^^^^^^^^^^^^
Expand Down
10 changes: 0 additions & 10 deletions tests/ui/maximal_mir_to_hir_coverage.rs

This file was deleted.

9 changes: 0 additions & 9 deletions tests/ui/maybe-bounds.rs

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/method-output-diff-issue-127263.rs

This file was deleted.

16 changes: 16 additions & 0 deletions tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs
Original file line number Diff line number Diff line change
@@ -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]
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
9 changes: 0 additions & 9 deletions tests/ui/mod-subitem-as-enum-variant.rs

This file was deleted.

18 changes: 18 additions & 0 deletions tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs
Original file line number Diff line number Diff line change
@@ -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() {}
Original file line number Diff line number Diff line change
@@ -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 {}
| ^^^^^^
Expand All @@ -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);
| ^^^^^^^^
Expand All @@ -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);
| ^^^^^^^^
Expand Down
16 changes: 16 additions & 0 deletions tests/ui/type-alias-enum-variants/module-type-args-error.rs
Original file line number Diff line number Diff line change
@@ -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]
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading