rust/tests/ui/lint/non-local-defs/local.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

56 lines
849 B
Rust

//@ check-pass
//@ edition:2021
#![warn(non_local_definitions)]
use std::fmt::Debug;
trait GlobalTrait {}
fn main() {
struct InsideMain;
impl InsideMain {
fn foo() {}
}
impl GlobalTrait for InsideMain {}
impl Debug for InsideMain {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
impl PartialEq<()> for InsideMain {
fn eq(&self, _: &()) -> bool {
todo!()
}
}
}
fn dyn_weirdness() {
trait LocalTrait {}
impl dyn LocalTrait {}
impl GlobalTrait for dyn LocalTrait {}
}
struct Test;
mod do_not_lint_mod {
pub trait Tait {}
impl super::Test {
fn hugo() {}
}
impl Tait for super::Test {}
}
fn bitflags() {
struct Flags;
const _: () = {
impl Flags {}
};
}