Skip to content

diagnostics: avoid ICE in confusable_method_name for associated functions#154225

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Unique-Usman:ua/rustc_confusable
Mar 23, 2026
Merged

diagnostics: avoid ICE in confusable_method_name for associated functions#154225
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Unique-Usman:ua/rustc_confusable

Conversation

@Unique-Usman
Copy link
Contributor

Avoid unconditionally slicing inputs()[1..], which assumes a self parameter. Use is_method() to conditionally skip the receiver, preventing out-of-bounds access and fixing suggestions for associated functions.

@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 Mar 22, 2026
@rustbot
Copy link
Collaborator

rustbot commented Mar 22, 2026

r? @fmease

rustbot has assigned @fmease.
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 69 candidates
  • Random selection from 12 candidates

…ions

Avoid unconditionally slicing `inputs()[1..]`, which assumes a `self`
parameter. Use `is_method()` to conditionally skip the receiver,
preventing out-of-bounds access and fixing suggestions for associated
functions.

Signed-off-by: Usman Akinyemi <usmanakinyemi202@gmail.com>
@Unique-Usman Unique-Usman changed the title fix(rustc): avoid ICE in confusable_method_name for associated functions diagnostics: avoid ICE in confusable_method_name for associated functions Mar 22, 2026
@Unique-Usman
Copy link
Contributor Author

Initially this will ICE

#![feature(rustc_attrs)]

struct S;

impl S {
    #[rustc_confusables("bar")]
    fn foo() {}
}

fn main() {
    S::bar();
}

but, with this pr, it does not

warning: the feature `rustc_attrs` is internal to the compiler or standard library
 --> foo.rs:1:12
  |
1 | #![feature(rustc_attrs)]
  |            ^^^^^^^^^^^
  |
  = note: using it is strongly discouraged
  = note: `#[warn(internal_features)]` on by default

error[E0599]: no function or associated item named `bar` found for struct `S` in the current scope
  --> foo.rs:11:8
   |
 3 | struct S;
   | -------- function or associated item `bar` not found for this struct
...
11 |     S::bar();
   |        ^^^ function or associated item not found in `S`
   |
help: you might have meant to use `foo`
   |
11 -     S::bar();
11 +     S::foo();
   |

@Kivooeo
Copy link
Member

Kivooeo commented Mar 22, 2026

r? me @bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 22, 2026

📌 Commit fa3e85a has been approved by Kivooeo

It is now in the queue for this repository.

@rust-bors rust-bors bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 22, 2026
@rust-bors rust-bors bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 22, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 23, 2026
…r=Kivooeo

diagnostics: avoid ICE in confusable_method_name for associated functions

Avoid unconditionally slicing `inputs()[1..]`, which assumes a `self` parameter. Use `is_method()` to conditionally skip the receiver, preventing out-of-bounds access and fixing suggestions for associated functions.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Mar 23, 2026
…r=Kivooeo

diagnostics: avoid ICE in confusable_method_name for associated functions

Avoid unconditionally slicing `inputs()[1..]`, which assumes a `self` parameter. Use `is_method()` to conditionally skip the receiver, preventing out-of-bounds access and fixing suggestions for associated functions.
rust-bors bot pushed a commit that referenced this pull request Mar 23, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #154241 (`rust-analyzer` subtree update)
 - #153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - #154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - #153069 ([BPF] add target feature allows-misaligned-mem-access)
 - #154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - #154191 (refactor RangeFromIter overflow-checks impl)
 - #154207 (Refactor query loading)
 - #153540 (drop derive helpers during attribute parsing)
 - #154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - #154161 (On E0277 tweak help when single type impls traits)
 - #154218 (interpret/validity: remove unreachable error kind)
 - #154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - #154228 (Improve inline assembly error messages)
@rust-bors rust-bors bot merged commit 50018ab into rust-lang:main Mar 23, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 23, 2026
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.

4 participants