Fix ICE: Restrict param constraint suggestion by estebank · Pull Request #117246 · rust-lang/rust

@estebank

When encountering an associated item with a type param that could be
constrained, do not look at the parent item if the type param comes from
the associated item.

Fix rust-lang#117209.

@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

Oct 26, 2023

@estebank estebank changed the title Restrict param constraint suggestion Fix ICE: Restrict param constraint suggestion

Oct 26, 2023

lqd

compiler-errors

petrochenkov

@estebank

@bors bors 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-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Oct 27, 2023

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 27, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#116834 (Remove `rustc_symbol_mangling/messages.ftl`.)
 - rust-lang#117212 (Properly restore snapshot when failing to recover parsing ternary)
 - rust-lang#117246 (Fix ICE: Restrict param constraint suggestion)
 - rust-lang#117247 (NVPTX: Allow PassMode::Direct for ptx kernels for now)
 - rust-lang#117270 (Hide internal methods from documentation)
 - rust-lang#117281 (std::thread : add SAFETY comment)
 - rust-lang#117287 (fix miri target information for Test step)

r? `@ghost`
`@rustbot` modify labels: rollup

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 27, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#116834 (Remove `rustc_symbol_mangling/messages.ftl`.)
 - rust-lang#117212 (Properly restore snapshot when failing to recover parsing ternary)
 - rust-lang#117246 (Fix ICE: Restrict param constraint suggestion)
 - rust-lang#117247 (NVPTX: Allow PassMode::Direct for ptx kernels for now)
 - rust-lang#117270 (Hide internal methods from documentation)
 - rust-lang#117281 (std::thread : add SAFETY comment)
 - rust-lang#117287 (fix miri target information for Test step)

r? `@ghost`
`@rustbot` modify labels: rollup

rust-timer added a commit to rust-lang-ci/rust that referenced this pull request

Oct 27, 2023
Rollup merge of rust-lang#117246 - estebank:issue-117209, r=petrochenkov

Fix ICE: Restrict param constraint suggestion

When encountering an associated item with a type param that could be constrained, do not look at the parent item if the type param comes from the associated item.

Fix rust-lang#117209, fix rust-lang#89868.

bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request

Oct 31, 2023

bors-ferrocene bot added a commit to ferrocene/ferrocene that referenced this pull request

Oct 31, 2023

@lqd lqd mentioned this pull request

Nov 6, 2023

bors added a commit to rust-lang-ci/rust that referenced this pull request

Apr 21, 2024
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.

bors added a commit to rust-lang-ci/rust that referenced this pull request

May 24, 2024
…enkov

Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.

bors added a commit to rust-lang-ci/rust that referenced this pull request

May 25, 2024
…enkov

Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.

github-actions bot pushed a commit to rust-lang/miri that referenced this pull request

May 25, 2024
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang/rust#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang/rust#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.

bors added a commit to rust-lang/rust-analyzer that referenced this pull request

Jun 20, 2024
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang/rust#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang/rust#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.

flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request

Jun 28, 2024
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang/rust#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang/rust#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.

Kobzol pushed a commit to Kobzol/portable-simd that referenced this pull request

Feb 3, 2026
Warn (or error) when `Self` ctor from outer item is referenced in inner nested item

This implements a warning `SELF_CONSTRUCTOR_FROM_OUTER_ITEM` when a self constructor from an outer impl is referenced in an inner nested item. This is a proper fix mentioned rust-lang/rust#117246 (comment).

This warning is additionally bumped to a hard error when the self type references generic parameters, since it's almost always going to ICE, and is basically *never* correct to do.

This also reverts part of rust-lang/rust#117246, since I believe this is the proper fix and we shouldn't need the helper functions (`opt_param_at`/`opt_type_param`) any longer, since they shouldn't really ever be used in cases where we don't have this problem.