Skip to content

Commit 511b290

Browse files
committed
Remove with/without trait and bounds consideration
1 parent 1910413 commit 511b290

11 files changed

+9
-52
lines changed

compiler/rustc_lint/messages.ftl

+1-3
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,7 @@ lint_non_local_definitions_cargo_update = the {$macro_kind} `{$macro_name}` may
545545
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>
546546
547547
lint_non_local_definitions_impl = non-local `impl` definition, `impl` blocks should be written at the same level as their item
548-
.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`
549-
.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`
550-
.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
548+
.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`
551549
.doctest = make this doc-test a standalone test with its own `fn main() {"{"} ... {"}"}`
552550
.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
553551
.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
@@ -1358,7 +1358,6 @@ pub enum NonLocalDefinitionsDiag {
13581358
cargo_update: Option<NonLocalDefinitionsCargoUpdateNote>,
13591359
const_anon: Option<Option<Span>>,
13601360
doctest: bool,
1361-
has_trait: bool,
13621361
macro_to_change: Option<(String, &'static str)>,
13631362
},
13641363
MacroRules {
@@ -1380,7 +1379,6 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13801379
cargo_update,
13811380
const_anon,
13821381
doctest,
1383-
has_trait,
13841382
macro_to_change,
13851383
} => {
13861384
diag.primary_message(fluent::lint_non_local_definitions_impl);
@@ -1397,12 +1395,7 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
13971395
diag.subdiagnostic(cargo_update);
13981396
}
13991397

1400-
if has_trait {
1401-
diag.note(fluent::lint_bounds);
1402-
diag.note(fluent::lint_with_trait);
1403-
} else {
1404-
diag.note(fluent::lint_without_trait);
1405-
}
1398+
diag.note(fluent::lint_non_local);
14061399

14071400
if doctest {
14081401
diag.help(fluent::lint_doctest);

compiler/rustc_lint/src/non_local_def.rs

-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
221221
cargo_update: cargo_update(),
222222
const_anon,
223223
doctest,
224-
has_trait: impl_.of_trait.is_some(),
225224
macro_to_change,
226225
},
227226
)

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)