Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e5da71f

Browse files
committedJul 6, 2024
Auto merge of #127377 - cuviper:beta-next, r=cuviper
[beta] backports - Properly gate `safe` keyword in pre-expansion #126757 - Switch back `non_local_definitions` lint to allow-by-default #127015 - Stall computing instance for drop shim until it has no unsubstituted const params #127068 - Update LLVM submodule #127190 - Change to the NetBSD archive URL rather than the CDN #127232 r? cuviper
2 parents 64a1fe6 + c822bf2 commit e5da71f

35 files changed

+268
-110
lines changed
 

‎compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
562562
gate_all!(precise_capturing, "precise captures on `impl Trait` are experimental");
563563
gate_all!(global_registration, "global registration is experimental");
564564
gate_all!(unsafe_attributes, "`#[unsafe()]` markers for attributes are experimental");
565+
gate_all!(
566+
unsafe_extern_blocks,
567+
"`unsafe extern {}` blocks and `safe` keyword are experimental"
568+
);
565569

566570
if !visitor.features.never_patterns {
567571
if let Some(spans) = spans.get(&sym::never_patterns) {

‎compiler/rustc_lint/src/non_local_def.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ declare_lint! {
5050
/// All nested bodies (functions, enum discriminant, array length, consts) (expect for
5151
/// `const _: Ty = { ... }` in top-level module, which is still undecided) are checked.
5252
pub NON_LOCAL_DEFINITIONS,
53-
Warn,
53+
Allow,
5454
"checks for non-local definitions",
5555
report_in_external_macro
5656
}

‎compiler/rustc_mir_transform/src/inline.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
1010
use rustc_middle::mir::visit::*;
1111
use rustc_middle::mir::*;
1212
use rustc_middle::ty::TypeVisitableExt;
13-
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
13+
use rustc_middle::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt, TypeFlags};
1414
use rustc_session::config::{DebugInfo, OptLevel};
1515
use rustc_span::source_map::Spanned;
1616
use rustc_span::sym;
@@ -320,6 +320,16 @@ impl<'tcx> Inliner<'tcx> {
320320
InstanceDef::Intrinsic(_) | InstanceDef::Virtual(..) => {
321321
return Err("instance without MIR (intrinsic / virtual)");
322322
}
323+
324+
// FIXME(#127030): `ConstParamHasTy` has bad interactions with
325+
// the drop shim builder, which does not evaluate predicates in
326+
// the correct param-env for types being dropped. Stall resolving
327+
// the MIR for this instance until all of its const params are
328+
// substituted.
329+
InstanceDef::DropGlue(_, Some(ty)) if ty.has_type_flags(TypeFlags::HAS_CT_PARAM) => {
330+
return Err("still needs substitution");
331+
}
332+
323333
// This cannot result in an immediate cycle since the callee MIR is a shim, which does
324334
// not get any optimizations run on it. Any subsequent inlining may cause cycles, but we
325335
// do not need to catch this here, we can wait until the inliner decides to continue

‎compiler/rustc_parse/src/parser/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,9 @@ impl<'a> Parser<'a> {
12211221
if self.eat_keyword_case(kw::Unsafe, case) {
12221222
Safety::Unsafe(self.prev_token.uninterpolated_span())
12231223
} else if self.eat_keyword_case(kw::Safe, case) {
1224+
self.psess
1225+
.gated_spans
1226+
.gate(sym::unsafe_extern_blocks, self.prev_token.uninterpolated_span());
12241227
Safety::Safe(self.prev_token.uninterpolated_span())
12251228
} else {
12261229
Safety::Default

‎src/ci/docker/host-x86_64/dist-x86_64-netbsd/build-netbsd-toolchain.sh

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
# ignore-tidy-linelength
33

4-
set -ex
4+
set -eux
55

66
hide_output() {
77
set +x
@@ -20,24 +20,54 @@ exit 1
2020
set -x
2121
}
2222

23+
# Download, verify SHA512, and remove the downloaded file
24+
# Usage: <file name> <url> <file sha> <full tar command using fname>
25+
download() {
26+
fname="$1"
27+
shift
28+
url="$1"
29+
shift
30+
sha="$1"
31+
shift
32+
33+
curl "$url" -o "$fname"
34+
echo "$sha $fname" | shasum -a 512 --check || exit 1
35+
"$@"
36+
rm "$fname"
37+
}
38+
2339
mkdir netbsd
2440
cd netbsd
2541

2642
mkdir -p /x-tools/x86_64-unknown-netbsd/sysroot
2743

2844
# URL=https://ci-mirrors.rust-lang.org/rustc
2945

30-
SOURCE_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/source/sets
31-
curl $SOURCE_URL/src.tgz | tar xzf -
32-
curl $SOURCE_URL/gnusrc.tgz | tar xzf -
33-
curl $SOURCE_URL/sharesrc.tgz | tar xzf -
34-
curl $SOURCE_URL/syssrc.tgz | tar xzf -
35-
36-
BINARY_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/sets
37-
curl $BINARY_URL/base.tar.xz | \
38-
tar xJf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
39-
curl $BINARY_URL/comp.tar.xz | \
40-
tar xJf - -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib
46+
# Hashes come from https://cdn.netbsd.org/pub/NetBSD/security/hashes/NetBSD-9.0_hashes.asc
47+
SRC_SHA=2c791ae009a6929c6fc893ec5df7e62910ee8207e0b2159d6937309c03efe175b6ae1e445829a13d041b6851334ad35c521f2fa03c97675d4a05f1fafe58ede0
48+
GNUSRC_SHA=3710085a73feecf6a843415271ec794c90146b03f6bbd30f07c9e0c79febf8995d557e40194f1e05db655e4f5ef2fae97563f8456fceaae65d4ea98857a83b1c
49+
SHARESRC_SHA=f080776ed82c3ac5d6272dee39746f87897d8e6984996caf5bf6d87bf11d9c9e0c1ad5c437c21258bd278bb6fd76974946e878f548517885f71c556096231369
50+
SYSSRC_SHA=60b9ddf4cc6402256473e2e1eefeabd9001aa4e205208715ecc6d6fc3f5b400e469944580077271b8e80562a4c2f601249e69e07a504f46744e0c50335f1cbf1
51+
BASE_SHA=b5926b107cebf40c3c19b4f6cd039b610987dd7f819e7cdde3bd1e5230a856906e7930b15ab242d52ced9f0bda01d574be59488b8dbb95fa5df2987d0a70995f
52+
COMP_SHA=38ea54f30d5fc2afea87e5096f06873e00182789e8ad9cec0cb3e9f7c538c1aa4779e63fd401a36ba02676158e83fa5c95e8e87898db59c1914fb206aecd82d2
53+
54+
# FIXME: the archive URL is being used temporarily while the CDN is down.
55+
# We should serve this from our own CDN
56+
# SOURCE_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/source/sets
57+
SOURCE_URL=http://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.0/source/sets
58+
download src.tgz "$SOURCE_URL/src.tgz" "$SRC_SHA" tar xzf src.tgz
59+
download gnusrc.tgz "$SOURCE_URL/gnusrc.tgz" "$GNUSRC_SHA" tar xzf gnusrc.tgz
60+
download sharesrc.tgz "$SOURCE_URL/sharesrc.tgz" "$SHARESRC_SHA" tar xzf sharesrc.tgz
61+
download syssrc.tgz "$SOURCE_URL/syssrc.tgz" "$SYSSRC_SHA" tar xzf syssrc.tgz
62+
63+
# FIXME: the archive URL is being used temporarily while the CDN is down.
64+
# We should serve this from our own CDN
65+
# BINARY_URL=https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.0/amd64/binary/sets
66+
BINARY_URL=http://archive.netbsd.org/pub/NetBSD-archive/NetBSD-9.0/amd64/binary/sets
67+
download base.tar.xz "$BINARY_URL/base.tar.xz" "$BASE_SHA" \
68+
tar xJf base.tar.xz -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib ./lib
69+
download comp.tar.xz "$BINARY_URL/comp.tar.xz" "$COMP_SHA" \
70+
tar xJf comp.tar.xz -C /x-tools/x86_64-unknown-netbsd/sysroot ./usr/include ./usr/lib
4171

4272
cd usr/src
4373

‎tests/rustdoc-ui/doctest/non_local_defs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//@ normalize-stderr-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
55
//@ normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME"
66

7+
#![doc(test(attr(warn(non_local_definitions))))]
8+
79
//! ```
810
//! #[macro_export]
911
//! macro_rules! a_macro { () => {} }
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
2-
--> $DIR/non_local_defs.rs:9:1
2+
--> $DIR/non_local_defs.rs:11:1
33
|
44
LL | macro_rules! a_macro { () => {} }
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() { ... }`
88
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
99
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
10-
= note: `#[warn(non_local_definitions)]` on by default
10+
note: the lint level is defined here
11+
--> $DIR/non_local_defs.rs:8:9
12+
|
13+
LL | #![warn(non_local_definitions)]
14+
| ^^^^^^^^^^^^^^^^^^^^^
1115

1216
warning: 1 warning emitted
1317

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
running 1 test
3-
test $DIR/non_local_defs.rs - (line 7) ... ok
3+
test $DIR/non_local_defs.rs - (line 9) ... ok
44

55
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME
66

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: -Zinline-mir=yes --crate-type=lib
2+
//@ build-pass
3+
4+
use std::mem::ManuallyDrop;
5+
6+
pub struct Foo<T, const N: usize>([T; N]);
7+
8+
pub struct Dorp {}
9+
10+
impl Drop for Dorp {
11+
fn drop(&mut self) {}
12+
}
13+
14+
#[inline]
15+
// SAFETY: call this with a valid allocation idk
16+
pub unsafe fn drop<const M: usize>(x: *mut Foo<Dorp, M>) {
17+
std::ptr::drop_in_place(x);
18+
}

‎tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@ unsafe extern "C" {
22
//~^ ERROR extern block cannot be declared unsafe
33
}
44

5+
// We can't gate `unsafe extern` blocks themselves since they were previously
6+
// allowed, but we should gate the `safe` soft keyword.
7+
#[cfg(any())]
8+
unsafe extern "C" {
9+
safe fn foo();
10+
//~^ ERROR `unsafe extern {}` blocks and `safe` keyword are experimental
11+
}
12+
513
fn main() {}

‎tests/ui/feature-gates/feature-gate-unsafe-extern-blocks.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,16 @@ error: extern block cannot be declared unsafe
44
LL | unsafe extern "C" {
55
| ^^^^^^
66

7-
error: aborting due to 1 previous error
7+
error[E0658]: `unsafe extern {}` blocks and `safe` keyword are experimental
8+
--> $DIR/feature-gate-unsafe-extern-blocks.rs:9:5
9+
|
10+
LL | safe fn foo();
11+
| ^^^^
12+
|
13+
= note: see issue #123743 <https://github.com/rust-lang/rust/issues/123743> for more information
14+
= help: add `#![feature(unsafe_extern_blocks)]` to the crate attributes to enable
15+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
16+
17+
error: aborting due to 2 previous errors
818

19+
For more information about this error, try `rustc --explain E0658`.

‎tests/ui/lint/non-local-defs/cargo-update.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
// of the `cargo update` suggestion we assert it here.
1111
//@ error-pattern: `cargo update -p non_local_macro`
1212

13+
#![warn(non_local_definitions)]
14+
1315
extern crate non_local_macro;
1416

1517
struct LocalStruct;

‎tests/ui/lint/non-local-defs/cargo-update.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/cargo-update.rs:17:1
2+
--> $DIR/cargo-update.rs:19:1
33
|
44
LL | non_local_macro::non_local_impl!(LocalStruct);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -13,7 +13,11 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
1313
= note: the macro `non_local_macro::non_local_impl` may come from an old version of the `non_local_macro` crate, try updating your dependency with `cargo update -p non_local_macro`
1414
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
1515
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
16-
= note: `#[warn(non_local_definitions)]` on by default
16+
note: the lint level is defined here
17+
--> $DIR/cargo-update.rs:13:9
18+
|
19+
LL | #![warn(non_local_definitions)]
20+
| ^^^^^^^^^^^^^^^^^^^^^
1721
= note: this warning originates in the macro `non_local_macro::non_local_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
1822

1923
warning: 1 warning emitted

‎tests/ui/lint/non-local-defs/consts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//@ edition:2021
33
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
44

5+
#![warn(non_local_definitions)]
6+
57
struct Test;
68

79
trait Uto {}

‎tests/ui/lint/non-local-defs/consts.stderr

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/consts.rs:13:5
2+
--> $DIR/consts.rs:15:5
33
|
44
LL | const Z: () = {
55
| -----------
@@ -17,10 +17,14 @@ LL | impl Uto for &Test {}
1717
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1818
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration
1919
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
20-
= note: `#[warn(non_local_definitions)]` on by default
20+
note: the lint level is defined here
21+
--> $DIR/consts.rs:5:9
22+
|
23+
LL | #![warn(non_local_definitions)]
24+
| ^^^^^^^^^^^^^^^^^^^^^
2125

2226
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
23-
--> $DIR/consts.rs:24:5
27+
--> $DIR/consts.rs:26:5
2428
|
2529
LL | static A: u32 = {
2630
| ------------- move the `impl` block outside of this static `A`
@@ -36,7 +40,7 @@ LL | impl Uto2 for Test {}
3640
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3741

3842
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
39-
--> $DIR/consts.rs:32:5
43+
--> $DIR/consts.rs:34:5
4044
|
4145
LL | const B: u32 = {
4246
| ------------ move the `impl` block outside of this constant `B`
@@ -52,7 +56,7 @@ LL | impl Uto3 for Test {}
5256
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
5357

5458
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
55-
--> $DIR/consts.rs:43:5
59+
--> $DIR/consts.rs:45:5
5660
|
5761
LL | fn main() {
5862
| --------- move the `impl` block outside of this function `main`
@@ -65,7 +69,7 @@ LL | impl Test {
6569
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
6670

6771
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
68-
--> $DIR/consts.rs:50:9
72+
--> $DIR/consts.rs:52:9
6973
|
7074
LL | const {
7175
| ___________-
@@ -84,7 +88,7 @@ LL | | };
8488
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
8589

8690
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
87-
--> $DIR/consts.rs:59:9
91+
--> $DIR/consts.rs:61:9
8892
|
8993
LL | const _: u32 = {
9094
| ------------ move the `impl` block outside of this constant `_` and up 2 bodies
@@ -98,7 +102,7 @@ LL | impl Test {
98102
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
99103

100104
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
101-
--> $DIR/consts.rs:72:9
105+
--> $DIR/consts.rs:74:9
102106
|
103107
LL | let _a = || {
104108
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@@ -113,7 +117,7 @@ LL | impl Uto9 for Test {}
113117
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
114118

115119
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
116-
--> $DIR/consts.rs:79:9
120+
--> $DIR/consts.rs:81:9
117121
|
118122
LL | type A = [u32; {
119123
| ____________________-

‎tests/ui/lint/non-local-defs/exhaustive-trait.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
struct Dog;
57

68
fn main() {

‎tests/ui/lint/non-local-defs/exhaustive-trait.stderr

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/exhaustive-trait.rs:7:5
2+
--> $DIR/exhaustive-trait.rs:9:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -12,10 +12,14 @@ LL | impl PartialEq<()> for Dog {
1212
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1313
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1414
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
15-
= note: `#[warn(non_local_definitions)]` on by default
15+
note: the lint level is defined here
16+
--> $DIR/exhaustive-trait.rs:4:9
17+
|
18+
LL | #![warn(non_local_definitions)]
19+
| ^^^^^^^^^^^^^^^^^^^^^
1620

1721
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
18-
--> $DIR/exhaustive-trait.rs:14:5
22+
--> $DIR/exhaustive-trait.rs:16:5
1923
|
2024
LL | fn main() {
2125
| --------- move the `impl` block outside of this function `main`
@@ -31,7 +35,7 @@ LL | impl PartialEq<()> for &Dog {
3135
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3236

3337
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
34-
--> $DIR/exhaustive-trait.rs:21:5
38+
--> $DIR/exhaustive-trait.rs:23:5
3539
|
3640
LL | fn main() {
3741
| --------- move the `impl` block outside of this function `main`
@@ -47,7 +51,7 @@ LL | impl PartialEq<Dog> for () {
4751
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
4852

4953
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
50-
--> $DIR/exhaustive-trait.rs:28:5
54+
--> $DIR/exhaustive-trait.rs:30:5
5155
|
5256
LL | fn main() {
5357
| --------- move the `impl` block outside of this function `main`
@@ -63,7 +67,7 @@ LL | impl PartialEq<&Dog> for () {
6367
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
6468

6569
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
66-
--> $DIR/exhaustive-trait.rs:35:5
70+
--> $DIR/exhaustive-trait.rs:37:5
6771
|
6872
LL | fn main() {
6973
| --------- move the `impl` block outside of this function `main`
@@ -79,7 +83,7 @@ LL | impl PartialEq<Dog> for &Dog {
7983
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
8084

8185
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
82-
--> $DIR/exhaustive-trait.rs:42:5
86+
--> $DIR/exhaustive-trait.rs:44:5
8387
|
8488
LL | fn main() {
8589
| --------- move the `impl` block outside of this function `main`

‎tests/ui/lint/non-local-defs/exhaustive.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
use std::fmt::Display;
57

68
trait Trait {}

‎tests/ui/lint/non-local-defs/exhaustive.stderr

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/exhaustive.rs:10:5
2+
--> $DIR/exhaustive.rs:12:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -10,10 +10,14 @@ LL | impl Test {
1010
|
1111
= note: methods and associated constants are still usable outside the current expression, only `impl Local` and `impl dyn Local` can ever be private, and only if the type is nested in the same item as the `impl`
1212
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
13-
= note: `#[warn(non_local_definitions)]` on by default
13+
note: the lint level is defined here
14+
--> $DIR/exhaustive.rs:4:9
15+
|
16+
LL | #![warn(non_local_definitions)]
17+
| ^^^^^^^^^^^^^^^^^^^^^
1418

1519
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
16-
--> $DIR/exhaustive.rs:15:5
20+
--> $DIR/exhaustive.rs:17:5
1721
|
1822
LL | fn main() {
1923
| --------- move the `impl` block outside of this function `main`
@@ -29,7 +33,7 @@ LL | impl Display for Test {
2933
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3034

3135
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
32-
--> $DIR/exhaustive.rs:22:5
36+
--> $DIR/exhaustive.rs:24:5
3337
|
3438
LL | fn main() {
3539
| --------- move the `impl` block outside of this function `main`
@@ -43,7 +47,7 @@ LL | impl dyn Trait {}
4347
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
4448

4549
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
46-
--> $DIR/exhaustive.rs:25:5
50+
--> $DIR/exhaustive.rs:27:5
4751
|
4852
LL | fn main() {
4953
| --------- move the `impl` block outside of this function `main`
@@ -59,7 +63,7 @@ LL | impl<T: Trait> Trait for Vec<T> { }
5963
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
6064

6165
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
62-
--> $DIR/exhaustive.rs:28:5
66+
--> $DIR/exhaustive.rs:30:5
6367
|
6468
LL | fn main() {
6569
| --------- move the `impl` block outside of this function `main`
@@ -75,7 +79,7 @@ LL | impl Trait for &dyn Trait {}
7579
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
7680

7781
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
78-
--> $DIR/exhaustive.rs:31:5
82+
--> $DIR/exhaustive.rs:33:5
7983
|
8084
LL | fn main() {
8185
| --------- move the `impl` block outside of this function `main`
@@ -91,7 +95,7 @@ LL | impl Trait for *mut Test {}
9195
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
9296

9397
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
94-
--> $DIR/exhaustive.rs:34:5
98+
--> $DIR/exhaustive.rs:36:5
9599
|
96100
LL | fn main() {
97101
| --------- move the `impl` block outside of this function `main`
@@ -107,7 +111,7 @@ LL | impl Trait for *mut [Test] {}
107111
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
108112

109113
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
110-
--> $DIR/exhaustive.rs:37:5
114+
--> $DIR/exhaustive.rs:39:5
111115
|
112116
LL | fn main() {
113117
| --------- move the `impl` block outside of this function `main`
@@ -123,7 +127,7 @@ LL | impl Trait for [Test; 8] {}
123127
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
124128

125129
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
126-
--> $DIR/exhaustive.rs:40:5
130+
--> $DIR/exhaustive.rs:42:5
127131
|
128132
LL | fn main() {
129133
| --------- move the `impl` block outside of this function `main`
@@ -139,7 +143,7 @@ LL | impl Trait for (Test,) {}
139143
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
140144

141145
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
142-
--> $DIR/exhaustive.rs:43:5
146+
--> $DIR/exhaustive.rs:45:5
143147
|
144148
LL | fn main() {
145149
| --------- move the `impl` block outside of this function `main`
@@ -155,7 +159,7 @@ LL | impl Trait for fn(Test) -> () {}
155159
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
156160

157161
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
158-
--> $DIR/exhaustive.rs:46:5
162+
--> $DIR/exhaustive.rs:48:5
159163
|
160164
LL | fn main() {
161165
| --------- move the `impl` block outside of this function `main`
@@ -171,7 +175,7 @@ LL | impl Trait for fn() -> Test {}
171175
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
172176

173177
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
174-
--> $DIR/exhaustive.rs:50:9
178+
--> $DIR/exhaustive.rs:52:9
175179
|
176180
LL | let _a = || {
177181
| -- move the `impl` block outside of this closure `<unnameable>` and up 2 bodies
@@ -186,7 +190,7 @@ LL | impl Trait for Test {}
186190
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
187191

188192
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
189-
--> $DIR/exhaustive.rs:58:5
193+
--> $DIR/exhaustive.rs:60:5
190194
|
191195
LL | impl Trait for *mut InsideMain {}
192196
| ^^^^^-----^^^^^---------------
@@ -198,7 +202,7 @@ LL | impl Trait for *mut InsideMain {}
198202
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
199203
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
200204
help: move the `impl` block outside of this function `main`
201-
--> $DIR/exhaustive.rs:9:1
205+
--> $DIR/exhaustive.rs:11:1
202206
|
203207
LL | fn main() {
204208
| ^^^^^^^^^
@@ -208,7 +212,7 @@ LL | struct InsideMain;
208212
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
209213

210214
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
211-
--> $DIR/exhaustive.rs:60:5
215+
--> $DIR/exhaustive.rs:62:5
212216
|
213217
LL | impl Trait for *mut [InsideMain] {}
214218
| ^^^^^-----^^^^^-----------------
@@ -219,7 +223,7 @@ LL | impl Trait for *mut [InsideMain] {}
219223
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
220224
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
221225
help: move the `impl` block outside of this function `main`
222-
--> $DIR/exhaustive.rs:9:1
226+
--> $DIR/exhaustive.rs:11:1
223227
|
224228
LL | fn main() {
225229
| ^^^^^^^^^
@@ -229,7 +233,7 @@ LL | struct InsideMain;
229233
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
230234

231235
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
232-
--> $DIR/exhaustive.rs:62:5
236+
--> $DIR/exhaustive.rs:64:5
233237
|
234238
LL | impl Trait for [InsideMain; 8] {}
235239
| ^^^^^-----^^^^^---------------
@@ -240,7 +244,7 @@ LL | impl Trait for [InsideMain; 8] {}
240244
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
241245
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
242246
help: move the `impl` block outside of this function `main`
243-
--> $DIR/exhaustive.rs:9:1
247+
--> $DIR/exhaustive.rs:11:1
244248
|
245249
LL | fn main() {
246250
| ^^^^^^^^^
@@ -250,7 +254,7 @@ LL | struct InsideMain;
250254
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
251255

252256
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
253-
--> $DIR/exhaustive.rs:64:5
257+
--> $DIR/exhaustive.rs:66:5
254258
|
255259
LL | impl Trait for (InsideMain,) {}
256260
| ^^^^^-----^^^^^-------------
@@ -261,7 +265,7 @@ LL | impl Trait for (InsideMain,) {}
261265
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
262266
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
263267
help: move the `impl` block outside of this function `main`
264-
--> $DIR/exhaustive.rs:9:1
268+
--> $DIR/exhaustive.rs:11:1
265269
|
266270
LL | fn main() {
267271
| ^^^^^^^^^
@@ -271,7 +275,7 @@ LL | struct InsideMain;
271275
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
272276

273277
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
274-
--> $DIR/exhaustive.rs:66:5
278+
--> $DIR/exhaustive.rs:68:5
275279
|
276280
LL | impl Trait for fn(InsideMain) -> () {}
277281
| ^^^^^-----^^^^^--------------------
@@ -282,7 +286,7 @@ LL | impl Trait for fn(InsideMain) -> () {}
282286
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
283287
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
284288
help: move the `impl` block outside of this function `main`
285-
--> $DIR/exhaustive.rs:9:1
289+
--> $DIR/exhaustive.rs:11:1
286290
|
287291
LL | fn main() {
288292
| ^^^^^^^^^
@@ -292,7 +296,7 @@ LL | struct InsideMain;
292296
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
293297

294298
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
295-
--> $DIR/exhaustive.rs:68:5
299+
--> $DIR/exhaustive.rs:70:5
296300
|
297301
LL | impl Trait for fn() -> InsideMain {}
298302
| ^^^^^-----^^^^^------------------
@@ -303,7 +307,7 @@ LL | impl Trait for fn() -> InsideMain {}
303307
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
304308
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
305309
help: move the `impl` block outside of this function `main`
306-
--> $DIR/exhaustive.rs:9:1
310+
--> $DIR/exhaustive.rs:11:1
307311
|
308312
LL | fn main() {
309313
| ^^^^^^^^^
@@ -313,7 +317,7 @@ LL | struct InsideMain;
313317
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
314318

315319
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
316-
--> $DIR/exhaustive.rs:72:9
320+
--> $DIR/exhaustive.rs:74:9
317321
|
318322
LL | fn inside_inside() {
319323
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies
@@ -328,7 +332,7 @@ LL | impl Display for InsideMain {
328332
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
329333

330334
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
331-
--> $DIR/exhaustive.rs:79:9
335+
--> $DIR/exhaustive.rs:81:9
332336
|
333337
LL | fn inside_inside() {
334338
| ------------------ move the `impl` block outside of this function `inside_inside` and up 2 bodies

‎tests/ui/lint/non-local-defs/from-local-for-global.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
struct Cat;
57
struct Wrap<T>(T);
68

‎tests/ui/lint/non-local-defs/from-local-for-global.stderr

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/from-local-for-global.rs:8:5
2+
--> $DIR/from-local-for-global.rs:10:5
33
|
44
LL | fn main() {
55
| --------- move the `impl` block outside of this function `main`
@@ -12,10 +12,14 @@ LL | impl From<Cat> for () {
1212
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1313
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1414
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
15-
= note: `#[warn(non_local_definitions)]` on by default
15+
note: the lint level is defined here
16+
--> $DIR/from-local-for-global.rs:4:9
17+
|
18+
LL | #![warn(non_local_definitions)]
19+
| ^^^^^^^^^^^^^^^^^^^^^
1620

1721
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
18-
--> $DIR/from-local-for-global.rs:18:5
22+
--> $DIR/from-local-for-global.rs:20:5
1923
|
2024
LL | impl From<Wrap<Wrap<Elephant>>> for () {
2125
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^--
@@ -25,7 +29,7 @@ LL | impl From<Wrap<Wrap<Elephant>>> for () {
2529
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
2630
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
2731
help: move the `impl` block outside of this function `main`
28-
--> $DIR/from-local-for-global.rs:7:1
32+
--> $DIR/from-local-for-global.rs:9:1
2933
|
3034
LL | fn main() {
3135
| ^^^^^^^^^
@@ -35,7 +39,7 @@ LL | struct Elephant;
3539
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3640

3741
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
38-
--> $DIR/from-local-for-global.rs:32:5
42+
--> $DIR/from-local-for-global.rs:34:5
3943
|
4044
LL | impl StillNonLocal for &Foo {}
4145
| ^^^^^-------------^^^^^----
@@ -47,7 +51,7 @@ LL | impl StillNonLocal for &Foo {}
4751
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
4852
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
4953
help: move the `impl` block outside of this function `only_global`
50-
--> $DIR/from-local-for-global.rs:30:1
54+
--> $DIR/from-local-for-global.rs:32:1
5155
|
5256
LL | fn only_global() {
5357
| ^^^^^^^^^^^^^^^^
@@ -56,7 +60,7 @@ LL | struct Foo;
5660
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
5761

5862
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
59-
--> $DIR/from-local-for-global.rs:40:5
63+
--> $DIR/from-local-for-global.rs:42:5
6064
|
6165
LL | impl From<Local1> for GlobalSameFunction {
6266
| ^^^^^----^^^^^^^^^^^^^------------------
@@ -67,7 +71,7 @@ LL | impl From<Local1> for GlobalSameFunction {
6771
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
6872
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
6973
help: move the `impl` block outside of this function `same_function`
70-
--> $DIR/from-local-for-global.rs:38:1
74+
--> $DIR/from-local-for-global.rs:40:1
7175
|
7276
LL | fn same_function() {
7377
| ^^^^^^^^^^^^^^^^^^
@@ -76,7 +80,7 @@ LL | struct Local1(GlobalSameFunction);
7680
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
7781

7882
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
79-
--> $DIR/from-local-for-global.rs:48:5
83+
--> $DIR/from-local-for-global.rs:50:5
8084
|
8185
LL | impl From<Local2> for GlobalSameFunction {
8286
| ^^^^^----^^^^^^^^^^^^^------------------
@@ -87,7 +91,7 @@ LL | impl From<Local2> for GlobalSameFunction {
8791
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
8892
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
8993
help: move the `impl` block outside of this function `same_function`
90-
--> $DIR/from-local-for-global.rs:38:1
94+
--> $DIR/from-local-for-global.rs:40:1
9195
|
9296
LL | fn same_function() {
9397
| ^^^^^^^^^^^^^^^^^^

‎tests/ui/lint/non-local-defs/generics.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
trait Global {}
57

68
fn main() {

‎tests/ui/lint/non-local-defs/generics.stderr

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/generics.rs:9:5
2+
--> $DIR/generics.rs:11:5
33
|
44
LL | impl<T: Local> Global for Vec<T> { }
55
| ^^^^^^^^^^^^^^^------^^^^^---^^^
@@ -10,17 +10,21 @@ LL | impl<T: Local> Global for Vec<T> { }
1010
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1111
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1212
help: move the `impl` block outside of this function `main`
13-
--> $DIR/generics.rs:6:1
13+
--> $DIR/generics.rs:8:1
1414
|
1515
LL | fn main() {
1616
| ^^^^^^^^^
1717
LL | trait Local {};
1818
| ----------- may need to be moved as well
1919
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
20-
= note: `#[warn(non_local_definitions)]` on by default
20+
note: the lint level is defined here
21+
--> $DIR/generics.rs:4:9
22+
|
23+
LL | #![warn(non_local_definitions)]
24+
| ^^^^^^^^^^^^^^^^^^^^^
2125

2226
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
23-
--> $DIR/generics.rs:20:5
27+
--> $DIR/generics.rs:22:5
2428
|
2529
LL | impl Uto7 for Test where Local: std::any::Any {}
2630
| ^^^^^----^^^^^----
@@ -31,7 +35,7 @@ LL | impl Uto7 for Test where Local: std::any::Any {}
3135
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
3236
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
3337
help: move the `impl` block outside of this function `bad`
34-
--> $DIR/generics.rs:18:1
38+
--> $DIR/generics.rs:20:1
3539
|
3640
LL | fn bad() {
3741
| ^^^^^^^^
@@ -40,7 +44,7 @@ LL | struct Local;
4044
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
4145

4246
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
43-
--> $DIR/generics.rs:23:5
47+
--> $DIR/generics.rs:25:5
4448
|
4549
LL | fn bad() {
4650
| -------- move the `impl` block outside of this function `bad`
@@ -56,7 +60,7 @@ LL | impl<T> Uto8 for T {}
5660
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
5761

5862
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
59-
--> $DIR/generics.rs:32:5
63+
--> $DIR/generics.rs:34:5
6064
|
6165
LL | impl Default for UwU<OwO> {
6266
| ^^^^^-------^^^^^---^^^^^
@@ -67,7 +71,7 @@ LL | impl Default for UwU<OwO> {
6771
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
6872
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
6973
help: move the `impl` block outside of this function `fun`
70-
--> $DIR/generics.rs:29:1
74+
--> $DIR/generics.rs:31:1
7175
|
7276
LL | fn fun() {
7377
| ^^^^^^^^
@@ -77,7 +81,7 @@ LL | struct OwO;
7781
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
7882

7983
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
80-
--> $DIR/generics.rs:43:5
84+
--> $DIR/generics.rs:45:5
8185
|
8286
LL | impl AsRef<Cat> for () {
8387
| ^^^^^-----^^^^^^^^^^--
@@ -88,7 +92,7 @@ LL | impl AsRef<Cat> for () {
8892
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
8993
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
9094
help: move the `impl` block outside of this function `meow`
91-
--> $DIR/generics.rs:40:1
95+
--> $DIR/generics.rs:42:1
9296
|
9397
LL | fn meow() {
9498
| ^^^^^^^^^
@@ -98,7 +102,7 @@ LL | struct Cat;
98102
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
99103

100104
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
101-
--> $DIR/generics.rs:54:5
105+
--> $DIR/generics.rs:56:5
102106
|
103107
LL | impl PartialEq<B> for G {
104108
| ^^^^^---------^^^^^^^^-
@@ -109,7 +113,7 @@ LL | impl PartialEq<B> for G {
109113
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
110114
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
111115
help: move the `impl` block outside of this function `fun2`
112-
--> $DIR/generics.rs:51:1
116+
--> $DIR/generics.rs:53:1
113117
|
114118
LL | fn fun2() {
115119
| ^^^^^^^^^
@@ -119,7 +123,7 @@ LL | struct B;
119123
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
120124

121125
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
122-
--> $DIR/generics.rs:69:5
126+
--> $DIR/generics.rs:71:5
123127
|
124128
LL | impl From<Wrap<Wrap<Lion>>> for () {
125129
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^--
@@ -129,7 +133,7 @@ LL | impl From<Wrap<Wrap<Lion>>> for () {
129133
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
130134
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
131135
help: move the `impl` block outside of this function `rawr`
132-
--> $DIR/generics.rs:66:1
136+
--> $DIR/generics.rs:68:1
133137
|
134138
LL | fn rawr() {
135139
| ^^^^^^^^^
@@ -138,7 +142,7 @@ LL | struct Lion;
138142
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
139143

140144
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
141-
--> $DIR/generics.rs:76:5
145+
--> $DIR/generics.rs:78:5
142146
|
143147
LL | impl From<()> for Wrap<Lion> {
144148
| ^^^^^----^^^^^^^^^----^^^^^^
@@ -149,7 +153,7 @@ LL | impl From<()> for Wrap<Lion> {
149153
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
150154
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
151155
help: move the `impl` block outside of this function `rawr`
152-
--> $DIR/generics.rs:66:1
156+
--> $DIR/generics.rs:68:1
153157
|
154158
LL | fn rawr() {
155159
| ^^^^^^^^^

‎tests/ui/lint/non-local-defs/inside-macro_rules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
macro_rules! m {
57
() => {
68
trait MacroTrait {}

‎tests/ui/lint/non-local-defs/inside-macro_rules.stderr

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/inside-macro_rules.rs:9:13
2+
--> $DIR/inside-macro_rules.rs:11:13
33
|
44
LL | fn my_func() {
55
| ------------ move the `impl` block outside of this function `my_func`
@@ -15,7 +15,11 @@ LL | m!();
1515
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1616
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1717
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
18-
= note: `#[warn(non_local_definitions)]` on by default
18+
note: the lint level is defined here
19+
--> $DIR/inside-macro_rules.rs:4:9
20+
|
21+
LL | #![warn(non_local_definitions)]
22+
| ^^^^^^^^^^^^^^^^^^^^^
1923
= note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
2024

2125
warning: 1 warning emitted

‎tests/ui/lint/non-local-defs/local.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
use std::fmt::Debug;
57

68
trait GlobalTrait {}

‎tests/ui/lint/non-local-defs/macro_rules.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
//@ aux-build:non_local_macro.rs
44
//@ rustc-env:CARGO_CRATE_NAME=non_local_def
55

6+
#![warn(non_local_definitions)]
7+
68
extern crate non_local_macro;
79

810
const B: u32 = {

‎tests/ui/lint/non-local-defs/macro_rules.stderr

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
2-
--> $DIR/macro_rules.rs:10:5
2+
--> $DIR/macro_rules.rs:12:5
33
|
44
LL | macro_rules! m0 { () => { } };
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: remove the `#[macro_export]` or move this `macro_rules!` outside the of the current constant `B`
88
= note: a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute
99
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
10-
= note: `#[warn(non_local_definitions)]` on by default
10+
note: the lint level is defined here
11+
--> $DIR/macro_rules.rs:6:9
12+
|
13+
LL | #![warn(non_local_definitions)]
14+
| ^^^^^^^^^^^^^^^^^^^^^
1115

1216
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
13-
--> $DIR/macro_rules.rs:16:1
17+
--> $DIR/macro_rules.rs:18:1
1418
|
1519
LL | non_local_macro::non_local_macro_rules!(my_macro);
1620
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,7 +26,7 @@ LL | non_local_macro::non_local_macro_rules!(my_macro);
2226
= note: this warning originates in the macro `non_local_macro::non_local_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
2327

2428
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
25-
--> $DIR/macro_rules.rs:21:5
29+
--> $DIR/macro_rules.rs:23:5
2630
|
2731
LL | macro_rules! m { () => { } };
2832
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -32,7 +36,7 @@ LL | macro_rules! m { () => { } };
3236
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3337

3438
warning: non-local `macro_rules!` definition, `#[macro_export]` macro should be written at top level module
35-
--> $DIR/macro_rules.rs:29:13
39+
--> $DIR/macro_rules.rs:31:13
3640
|
3741
LL | macro_rules! m2 { () => { } };
3842
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

‎tests/ui/lint/non-local-defs/suggest-moving-inner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//@ check-pass
22

3+
#![warn(non_local_definitions)]
4+
35
trait Trait<T> {}
46

57
fn main() {

‎tests/ui/lint/non-local-defs/suggest-moving-inner.stderr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/suggest-moving-inner.rs:12:5
2+
--> $DIR/suggest-moving-inner.rs:14:5
33
|
44
LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
55
| ^^^^^^^^-----^^^^^^^^^^^^^^^^^----------------------------------
@@ -10,7 +10,7 @@ LL | impl<T> Trait<InsideMain> for &Vec<below::Type<(InsideMain, T)>>
1010
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1111
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1212
help: move the `impl` block outside of this function `main`
13-
--> $DIR/suggest-moving-inner.rs:5:1
13+
--> $DIR/suggest-moving-inner.rs:7:1
1414
|
1515
LL | fn main() {
1616
| ^^^^^^^^^
@@ -23,7 +23,11 @@ LL | struct InsideMain;
2323
LL | trait HasFoo {}
2424
| ------------ may need to be moved as well
2525
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
26-
= note: `#[warn(non_local_definitions)]` on by default
26+
note: the lint level is defined here
27+
--> $DIR/suggest-moving-inner.rs:3:9
28+
|
29+
LL | #![warn(non_local_definitions)]
30+
| ^^^^^^^^^^^^^^^^^^^^^
2731

2832
warning: 1 warning emitted
2933

‎tests/ui/lint/non-local-defs/trait-solver-overflow-123573.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
// https://github.com/rust-lang/rust/issues/123573#issue-2229428739
55

6+
#![warn(non_local_definitions)]
7+
68
pub trait Test {}
79

810
impl<'a, T: 'a> Test for &[T] where &'a T: Test {}

‎tests/ui/lint/non-local-defs/trait-solver-overflow-123573.stderr

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/trait-solver-overflow-123573.rs:12:5
2+
--> $DIR/trait-solver-overflow-123573.rs:14:5
33
|
44
LL | impl Test for &Local {}
55
| ^^^^^----^^^^^------
@@ -11,14 +11,18 @@ LL | impl Test for &Local {}
1111
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1212
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1313
help: move the `impl` block outside of this function `main`
14-
--> $DIR/trait-solver-overflow-123573.rs:10:1
14+
--> $DIR/trait-solver-overflow-123573.rs:12:1
1515
|
1616
LL | fn main() {
1717
| ^^^^^^^^^
1818
LL | struct Local {}
1919
| ------------ may need to be moved as well
2020
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
21-
= note: `#[warn(non_local_definitions)]` on by default
21+
note: the lint level is defined here
22+
--> $DIR/trait-solver-overflow-123573.rs:6:9
23+
|
24+
LL | #![warn(non_local_definitions)]
25+
| ^^^^^^^^^^^^^^^^^^^^^
2226

2327
warning: 1 warning emitted
2428

‎tests/ui/lint/non-local-defs/weird-exprs.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//@ check-pass
22
//@ edition:2021
33

4+
#![warn(non_local_definitions)]
5+
46
trait Uto {}
57
struct Test;
68

‎tests/ui/lint/non-local-defs/weird-exprs.stderr

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
2-
--> $DIR/weird-exprs.rs:8:5
2+
--> $DIR/weird-exprs.rs:10:5
33
|
44
LL | type A = [u32; {
55
| ________________-
@@ -16,10 +16,14 @@ LL | | }];
1616
= note: `impl` may be usable in bounds, etc. from outside the expression, which might e.g. make something constructible that previously wasn't, because it's still on a publicly-visible type
1717
= note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
1818
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
19-
= note: `#[warn(non_local_definitions)]` on by default
19+
note: the lint level is defined here
20+
--> $DIR/weird-exprs.rs:4:9
21+
|
22+
LL | #![warn(non_local_definitions)]
23+
| ^^^^^^^^^^^^^^^^^^^^^
2024

2125
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
22-
--> $DIR/weird-exprs.rs:16:9
26+
--> $DIR/weird-exprs.rs:18:9
2327
|
2428
LL | Discr = {
2529
| _____________-
@@ -38,7 +42,7 @@ LL | | }
3842
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
3943

4044
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
41-
--> $DIR/weird-exprs.rs:25:9
45+
--> $DIR/weird-exprs.rs:27:9
4246
|
4347
LL | let _array = [0i32; {
4448
| _________________________-
@@ -57,7 +61,7 @@ LL | | }];
5761
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
5862

5963
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
60-
--> $DIR/weird-exprs.rs:34:9
64+
--> $DIR/weird-exprs.rs:36:9
6165
|
6266
LL | type A = [u32; {
6367
| ____________________-
@@ -76,7 +80,7 @@ LL | | }];
7680
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
7781

7882
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
79-
--> $DIR/weird-exprs.rs:41:9
83+
--> $DIR/weird-exprs.rs:43:9
8084
|
8185
LL | fn a(_: [u32; {
8286
| ___________________-
@@ -95,7 +99,7 @@ LL | | }]) {}
9599
= note: this lint may become deny-by-default in the edition 2024 and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>
96100

97101
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
98-
--> $DIR/weird-exprs.rs:48:9
102+
--> $DIR/weird-exprs.rs:50:9
99103
|
100104
LL | fn b() -> [u32; {
101105
| _____________________-

0 commit comments

Comments
 (0)
Please sign in to comment.