Skip to content

Commit 3852a5a

Browse files
committed
Improve main note without a trait on the impl
1 parent c77a6d8 commit 3852a5a

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

compiler/rustc_lint/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks sho
446446
[one] `{$body_name}`
447447
*[other] `{$body_name}` and up {$depth} bodies
448448
}
449-
.without_trait = methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
449+
.without_trait = 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`
450450
.with_trait = 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`
451451
.bounds = `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
452452
.exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
5656
LL | impl Test {
5757
| ^^^^^^^^^
5858
|
59-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
59+
= 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`
6060
help: move this `impl` block outside of the current function `main`
6161
--> $DIR/consts.rs:43:5
6262
|
@@ -73,7 +73,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
7373
LL | impl Test {
7474
| ^^^^^^^^^
7575
|
76-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
76+
= 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`
7777
help: move this `impl` block outside of the current inline constant `<unnameable>` and up 2 bodies
7878
--> $DIR/consts.rs:50:9
7979
|
@@ -90,7 +90,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
9090
LL | impl Test {
9191
| ^^^^^^^^^
9292
|
93-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
93+
= 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`
9494
help: move this `impl` block outside of the current constant `_` and up 2 bodies
9595
--> $DIR/consts.rs:59:9
9696
|

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
44
LL | impl Test {
55
| ^^^^^^^^^
66
|
7-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
7+
= 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`
88
help: move this `impl` block outside of the current function `main`
99
--> $DIR/exhaustive.rs:10:5
1010
|
@@ -42,7 +42,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
4242
LL | impl dyn Trait {}
4343
| ^^^^^^^^^^^^^^
4444
|
45-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
45+
= 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`
4646
help: move this `impl` block outside of the current function `main`
4747
--> $DIR/exhaustive.rs:22:5
4848
|
@@ -313,7 +313,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
313313
LL | impl InsideMain {
314314
| ^^^^^^^^^^^^^^^
315315
|
316-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
316+
= 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`
317317
help: move this `impl` block outside of the current function `inside_inside` and up 2 bodies
318318
--> $DIR/exhaustive.rs:79:9
319319
|

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ warning: non-local `impl` definition, `impl` blocks should be written at the sam
3535
LL | impl Test {
3636
| ^^^^^^^^^
3737
|
38-
= note: methods and assoc const are still usable outside the current expression, only `impl Local` and `impl dyn Local` are local and only if the `Local` type is at the same nesting as the `impl` block
38+
= 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`
3939
help: move this `impl` block outside of the current constant expression `<unnameable>` and up 2 bodies
4040
--> $DIR/weird-exprs.rs:25:9
4141
|

0 commit comments

Comments
 (0)