Skip to content

Commit 9195d65

Browse files
committed
Remove with/without trait and bounds consideration
1 parent 0f665e2 commit 9195d65

11 files changed

+9
-52
lines changed

compiler/rustc_lint/messages.ftl

+1-3
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,7 @@ lint_non_local_definitions_cargo_update = the {$macro_kind} `{$macro_name}` may
592592
lint_non_local_definitions_deprecation = 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>
593593
594594
lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks should be written at the same level as their item
595-
.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`
596-
.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`
597-
.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
595+
.non_local = 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`
598596
.doctest = make this doc-test a standalone test with its own `fn main() {"{"} ... {"}"}`
599597
.exception = items in an anonymous const item (`const _: () = {"{"} ... {"}"}`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
600598
.const_anon = use a const-anon item to suppress this lint

compiler/rustc_lint/src/lints.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,6 @@ pub(crate) enum NonLocalDefinitionsDiag {
13761376
cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
13771377
const_anon: Option<Option<Span>>,
13781378
doctest: bool,
1379-
has_trait: bool,
13801379
macro_to_change: Option<(String, &'static str)>,
13811380
},
13821381
MacroRules {
@@ -1398,7 +1397,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13981397
cargo_update,
13991398
const_anon,
14001399
doctest,
1401-
has_trait,
14021400
macro_to_change,
14031401
} => {
14041402
diag.primary_message(fluent::lint_non_local_definitions_impl);
@@ -1415,12 +1413,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
14151413
diag.subdiagnostic(cargo_update);
14161414
}
14171415

1418-
if has_trait {
1419-
diag.note(fluent::lint_bounds);
1420-
diag.note(fluent::lint_with_trait);
1421-
} else {
1422-
diag.note(fluent::lint_without_trait);
1423-
}
1416+
diag.note(fluent::lint_non_local);
14241417

14251418
if doctest {
14261419
diag.help(fluent::lint_doctest);

compiler/rustc_lint/src/non_local_def.rs

-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
216216
cargo_update: cargo_update(),
217217
const_anon,
218218
doctest,
219-
has_trait: impl_.of_trait.is_some(),
220219
macro_to_change,
221220
})
222221
}

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

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ LL | non_local_macro::non_local_impl!(LocalStruct);
1010
|
1111
= note: the macro `non_local_macro::non_local_impl` defines the non-local `impl`, and may need to be changed
1212
= 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`
13-
= 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
1413
= 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`
1514
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
1615
= 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>

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

+3-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ LL | impl Uto for &Test {}
1313
| | `Test` is not local
1414
| `Uto` is not local
1515
|
16-
= 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
1716
= 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`
1817
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
1918
= 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>
@@ -30,7 +29,6 @@ LL | impl Uto2 for Test {}
3029
| | `Test` is not local
3130
| `Uto2` is not local
3231
|
33-
= 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
3432
= 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`
3533
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
3634
= 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>
@@ -46,7 +44,6 @@ LL | impl Uto3 for Test {}
4644
| | `Test` is not local
4745
| `Uto3` is not local
4846
|
49-
= 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
5047
= 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`
5148
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
5249
= 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>
@@ -61,7 +58,7 @@ LL | impl Test {
6158
| |
6259
| `Test` is not local
6360
|
64-
= 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`
61+
= 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`
6562
= 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>
6663

6764
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@@ -80,7 +77,7 @@ LL | | 1
8077
LL | | };
8178
| |_____- move the `impl` block outside of this inline constant `<unnameable>` and up 2 bodies
8279
|
83-
= 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`
80+
= 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`
8481
= 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>
8582

8683
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
@@ -93,7 +90,7 @@ LL | impl Test {
9390
| |
9491
| `Test` is not local
9592
|
96-
= 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`
93+
= 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`
9794
= note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
9895
= 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>
9996

@@ -108,7 +105,6 @@ LL | impl Uto9 for Test {}
108105
| | `Test` is not local
109106
| `Uto9` is not local
110107
|
111-
= 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
112108
= 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`
113109
= 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>
114110

@@ -127,7 +123,6 @@ LL | |
127123
LL | | }];
128124
| |_____- move the `impl` block outside of this constant expression `<unnameable>` and up 2 bodies
129125
|
130-
= 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
131126
= 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`
132127
= 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>
133128

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

-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ LL | impl PartialEq<()> for Dog {
99
| | `Dog` is not local
1010
| `PartialEq` is not local
1111
|
12-
= 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
1312
= 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`
1413
= 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>
1514
= note: `#[warn(non_local_definitions)]` on by default
@@ -26,7 +25,6 @@ LL | impl PartialEq<()> for &Dog {
2625
| | `Dog` is not local
2726
| `PartialEq` is not local
2827
|
29-
= 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
3028
= 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`
3129
= 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>
3230

@@ -42,7 +40,6 @@ LL | impl PartialEq<Dog> for () {
4240
| | `Dog` is not local
4341
| `PartialEq` is not local
4442
|
45-
= 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
4643
= 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`
4744
= 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>
4845

@@ -58,7 +55,6 @@ LL | impl PartialEq<&Dog> for () {
5855
| | `Dog` is not local
5956
| `PartialEq` is not local
6057
|
61-
= 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
6258
= 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`
6359
= 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>
6460

@@ -75,7 +71,6 @@ LL | impl PartialEq<Dog> for &Dog {
7571
| | `Dog` is not local
7672
| `PartialEq` is not local
7773
|
78-
= 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
7974
= 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`
8075
= 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>
8176

@@ -92,7 +87,6 @@ LL | impl PartialEq<&Dog> for &Dog {
9287
| | `Dog` is not local
9388
| `PartialEq` is not local
9489
|
95-
= 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
9690
= 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`
9791
= 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>
9892

0 commit comments

Comments
 (0)