Skip to content

Commit 218949d

Browse files
committed
3373: Change to a warn-by-default lint
1 parent 66ef463 commit 218949d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

text/3373-avoid-nonlocal-definitions-in-fns.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
# Summary
77
[summary]: #summary
88

9-
Starting in Rust 2024, stop allowing items inside functions or expressions to
9+
Add a warn-by-default lint for items inside functions or expressions that
1010
implement methods or traits that are visible outside the function or
11-
expression.
11+
expression. Consider ramping that lint to deny-by-default for Rust 2024, and
12+
evaluating a hard error for 2027.
1213

1314
# Motivation
1415
[motivation]: #motivation
@@ -21,9 +22,10 @@ not cross-reference those definitions at all.
2122
Humans cross-referencing such uses and definitions may find themselves
2223
similarly baffled.
2324

24-
With this change, both humans and tools can limit the scope of their search and
25-
avoid looking for definitions inside other functions or items, without missing
26-
any relevant definitions.
25+
This change helps humans limit the scope of their search and avoid looking for
26+
definitions inside other functions or items, without missing any relevant
27+
definitions. If in the future we manage to forbid it entirely within a
28+
subsequent Rust edtion, tools will be able to rely on this as well.
2729

2830
# Explanation
2931
[explanation]: #explanation
@@ -35,7 +37,7 @@ expressions, including the definitions of other items:
3537
- The values assigned to `static`/`const` items
3638
- The discriminant values assigned to `enum` variants
3739

38-
Starting in the Rust 2024 edition:
40+
Rust will emit a warn-by-default lint for all of the following cases:
3941
- An item nested inside an expression-containing item (through any level of
4042
nesting) may not define an `impl Type` block unless the `Type` is also nested
4143
inside the same expression-containing item.
@@ -46,8 +48,9 @@ Starting in the Rust 2024 edition:
4648
nesting) may not define an exported macro visible outside the
4749
expression-containing item (e.g. using `#[macro_export]`).
4850

49-
Rust 2015, 2018, and 2021 continue to permit this, but will produce a
50-
warn-by-default lint.
51+
In a future edition, we may consider making this lint deny-by-default, or
52+
eventually making it a hard error. We'll evaluate the impact on the ecosystem
53+
and existing use cases before doing so.
5154

5255
# Drawbacks
5356
[drawbacks]: #drawbacks

0 commit comments

Comments
 (0)