Skip to content

Use verbose suggestion for const _ - #163046

Open
estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:anon-const
Open

estebank wants to merge 1 commit into
rust-lang:mainfrom
estebank:anon-const

Conversation

@estebank

Copy link
Copy Markdown
Contributor
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> $DIR/consts.rs:13:5
   |
LL | const Z: () = {
   | ----------- move the `impl` block outside of this constant `Z`
...
LL |     impl Uto for &Test {}
   |     ^^^^^---^^^^^^----
   |          |        |
   |          |        `Test` is not local
   |          `Uto` is not local
   |
   = 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: 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
   = note: `#[warn(non_local_definitions)]` on by default
help: use a const-anon item to suppress this lint
   |
LL - const Z: () = {
LL + const _: () = {
   |

```
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> $DIR/consts.rs:13:5
   |
LL | const Z: () = {
   | ----------- move the `impl` block outside of this constant `Z`
...
LL |     impl Uto for &Test {}
   |     ^^^^^---^^^^^^----
   |          |        |
   |          |        `Test` is not local
   |          `Uto` is not local
   |
   = 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: 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
   = note: `#[warn(non_local_definitions)]` on by default
help: use a const-anon item to suppress this lint
   |
LL - const Z: () = {
LL + const _: () = {
   |
```
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 20, 2026
@rustbot

rustbot commented Sep 20, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 77 candidates
  • Random selection from 19 candidates

@folkertdev

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 109d3ae has been approved by folkertdev

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 20, 2026
Use verbose suggestion for `const _`

```
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> $DIR/consts.rs:13:5
   |
LL | const Z: () = {
   | ----------- move the `impl` block outside of this constant `Z`
...
LL |     impl Uto for &Test {}
   |     ^^^^^---^^^^^^----
   |          |        |
   |          |        `Test` is not local
   |          `Uto` is not local
   |
   = 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: 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
   = note: `#[warn(non_local_definitions)]` on by default
help: use a const-anon item to suppress this lint
   |
LL - const Z: () = {
LL + const _: () = {
   |
```
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 20, 2026
Use verbose suggestion for `const _`

```
warning: non-local `impl` definition, `impl` blocks should be written at the same level as their item
  --> $DIR/consts.rs:13:5
   |
LL | const Z: () = {
   | ----------- move the `impl` block outside of this constant `Z`
...
LL |     impl Uto for &Test {}
   |     ^^^^^---^^^^^^----
   |          |        |
   |          |        `Test` is not local
   |          `Uto` is not local
   |
   = 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: 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
   = note: `#[warn(non_local_definitions)]` on by default
help: use a const-anon item to suppress this lint
   |
LL - const Z: () = {
LL + const _: () = {
   |
```
rust-bors Bot pushed a commit that referenced this pull request Sep 20, 2026
…uwer

Rollup of 15 pull requests

Successful merges:

 - #162726 (std: fix unix socket address panic on a full sun_path)
 - #163016 (Don't claim that escaping value is a reference in diagnostics)
 - #163040 (Tweak "use array's length as const param" suggestion)
 - #163060 (Point to fields that introduce trait requirements)
 - #163066 (don't mark `f128` as reliable on AIX)
 - #162098 (Tweak `Infallible` docs)
 - #162854 (Add safety section for atomic_load/store)
 - #163015 (add `minicore::ffi::VaList`)
 - #163021 (`va_arg`: pass in `TyAndLayout`)
 - #163036 ([rustdoc] Correctly handle `dyn` trait methods linking for jump to def feature)
 - #163042 (Remove redundant output from suggestion)
 - #163046 (Use verbose suggestion for `const _`)
 - #163050 (Use verbose suggestion for similarly named label suggestion)
 - #163052 (Use verbose suggestion for wrong primitive type names)
 - #163055 (Use the full path of `bug_impl` to avoid bogus errors in rust-analyzer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants