rust/tests/ui/lint/non-local-defs/exhaustive.rs
Urgau 0c0dfb88ee Switch back non_local_definitions lint to allow-by-default
as request T-lang is requesting some major changes in the lint inner
workings in #126768#issuecomment-2192634762
2024-06-27 08:05:07 +02:00

87 lines
2.0 KiB
Rust

//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Display;
trait Trait {}
struct Test;
fn main() {
impl Test {
//~^ WARN non-local `impl` definition
fn foo() {}
}
impl Display for Test {
//~^ WARN non-local `impl` definition
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
impl dyn Trait {}
//~^ WARN non-local `impl` definition
impl<T: Trait> Trait for Vec<T> { }
//~^ WARN non-local `impl` definition
impl Trait for &dyn Trait {}
//~^ WARN non-local `impl` definition
impl Trait for *mut Test {}
//~^ WARN non-local `impl` definition
impl Trait for *mut [Test] {}
//~^ WARN non-local `impl` definition
impl Trait for [Test; 8] {}
//~^ WARN non-local `impl` definition
impl Trait for (Test,) {}
//~^ WARN non-local `impl` definition
impl Trait for fn(Test) -> () {}
//~^ WARN non-local `impl` definition
impl Trait for fn() -> Test {}
//~^ WARN non-local `impl` definition
let _a = || {
impl Trait for Test {}
//~^ WARN non-local `impl` definition
1
};
struct InsideMain;
impl Trait for *mut InsideMain {}
//~^ WARN non-local `impl` definition
impl Trait for *mut [InsideMain] {}
//~^ WARN non-local `impl` definition
impl Trait for [InsideMain; 8] {}
//~^ WARN non-local `impl` definition
impl Trait for (InsideMain,) {}
//~^ WARN non-local `impl` definition
impl Trait for fn(InsideMain) -> () {}
//~^ WARN non-local `impl` definition
impl Trait for fn() -> InsideMain {}
//~^ WARN non-local `impl` definition
fn inside_inside() {
impl Display for InsideMain {
//~^ WARN non-local `impl` definition
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
impl InsideMain {
//~^ WARN non-local `impl` definition
fn bar() {}
}
}
}