mirror of https://github.com/rust-lang/rust
105 lines
5.9 KiB
Plaintext
105 lines
5.9 KiB
Plaintext
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
|
--> $DIR/from-local-for-global.rs:10:5
|
|
|
|
|
LL | fn main() {
|
|
| --------- move the `impl` block outside of this function `main`
|
|
LL | impl From<Cat> for () {
|
|
| ^^^^^----^^^^^^^^^^--
|
|
| | |
|
|
| | `()` is not local
|
|
| `From` is not local
|
|
|
|
|
= 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
|
|
= 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`
|
|
= 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>
|
|
note: the lint level is defined here
|
|
--> $DIR/from-local-for-global.rs:4:9
|
|
|
|
|
LL | #![warn(non_local_definitions)]
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
|
--> $DIR/from-local-for-global.rs:20:5
|
|
|
|
|
LL | impl From<Wrap<Wrap<Elephant>>> for () {
|
|
| ^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^--
|
|
| | |
|
|
| `From` is not local `()` is not local
|
|
|
|
|
= 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
|
|
= 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`
|
|
help: move the `impl` block outside of this function `main`
|
|
--> $DIR/from-local-for-global.rs:9:1
|
|
|
|
|
LL | fn main() {
|
|
| ^^^^^^^^^
|
|
...
|
|
LL | struct Elephant;
|
|
| --------------- may need to be moved as well
|
|
= 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>
|
|
|
|
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
|
--> $DIR/from-local-for-global.rs:34:5
|
|
|
|
|
LL | impl StillNonLocal for &Foo {}
|
|
| ^^^^^-------------^^^^^----
|
|
| | |
|
|
| | `&'_ Foo` is not local
|
|
| | help: remove `&` to make the `impl` local
|
|
| `StillNonLocal` is not local
|
|
|
|
|
= 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
|
|
= 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`
|
|
help: move the `impl` block outside of this function `only_global`
|
|
--> $DIR/from-local-for-global.rs:32:1
|
|
|
|
|
LL | fn only_global() {
|
|
| ^^^^^^^^^^^^^^^^
|
|
LL | struct Foo;
|
|
| ---------- may need to be moved as well
|
|
= 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>
|
|
|
|
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
|
--> $DIR/from-local-for-global.rs:42:5
|
|
|
|
|
LL | impl From<Local1> for GlobalSameFunction {
|
|
| ^^^^^----^^^^^^^^^^^^^------------------
|
|
| | |
|
|
| | `GlobalSameFunction` is not local
|
|
| `From` is not local
|
|
|
|
|
= 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
|
|
= 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`
|
|
help: move the `impl` block outside of this function `same_function`
|
|
--> $DIR/from-local-for-global.rs:40:1
|
|
|
|
|
LL | fn same_function() {
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
LL | struct Local1(GlobalSameFunction);
|
|
| ------------- may need to be moved as well
|
|
= 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>
|
|
|
|
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
|
|
--> $DIR/from-local-for-global.rs:50:5
|
|
|
|
|
LL | impl From<Local2> for GlobalSameFunction {
|
|
| ^^^^^----^^^^^^^^^^^^^------------------
|
|
| | |
|
|
| | `GlobalSameFunction` is not local
|
|
| `From` is not local
|
|
|
|
|
= 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
|
|
= 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`
|
|
help: move the `impl` block outside of this function `same_function`
|
|
--> $DIR/from-local-for-global.rs:40:1
|
|
|
|
|
LL | fn same_function() {
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | struct Local2(GlobalSameFunction);
|
|
| ------------- may need to be moved as well
|
|
= 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>
|
|
|
|
warning: 5 warnings emitted
|
|
|