Skip to content

Semantic checks of impl restrictions#154661

Merged
rust-bors[bot] merged 13 commits intorust-lang:mainfrom
CoCo-Japan-pan:impl-restriction-check
Apr 11, 2026
Merged

Semantic checks of impl restrictions#154661
rust-bors[bot] merged 13 commits intorust-lang:mainfrom
CoCo-Japan-pan:impl-restriction-check

Conversation

@CoCo-Japan-pan
Copy link
Copy Markdown
Contributor

@CoCo-Japan-pan CoCo-Japan-pan commented Apr 1, 2026

View all comments

This PR implements semantic checks for impl restrictions proposed in the Restrictions RFC (Tracking Issue #105077), and linked to a GSOC idea/proposal.

It lowers the resolved paths of impl restrictions from the AST to HIR and into TraitDef, and integrates the checks into the coherence phase by extending check_impl. As parsing (#152943) and path resolution (#153556) have already been implemented, this PR provides a working implementation of impl restrictions.

r? @Urgau
cc @jhpratt

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 1, 2026

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann, @JonathanBrouwer

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Apr 1, 2026
@CoCo-Japan-pan CoCo-Japan-pan changed the title Impl restriction check impl restriction check Apr 1, 2026
@CoCo-Japan-pan CoCo-Japan-pan changed the title impl restriction check Semantic checks of impl restrictions Apr 1, 2026
Copy link
Copy Markdown
Member

@Urgau Urgau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks promising. Left some preliminary comments.

View changes since this review

Comment thread compiler/rustc_hir/src/intravisit.rs Outdated
Comment thread compiler/rustc_hir/src/hir.rs Outdated
Comment thread compiler/rustc_hir/src/hir.rs Outdated
Comment thread compiler/rustc_middle/src/ty/trait_def.rs Outdated
Comment thread src/librustdoc/clean/mod.rs Outdated
Comment thread tests/ui/impl-restriction/impl-restriction-check.rs Outdated
Comment thread tests/ui/impl-restriction/impl-restriction-check.rs
@Urgau Urgau added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 3, 2026
Comment thread compiler/rustc_middle/src/ty/trait_def.rs Outdated
@Urgau Urgau added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 5, 2026
Copy link
Copy Markdown
Member

@Urgau Urgau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I will let @jhpratt do the final review.

View changes since this review

@Urgau Urgau mentioned this pull request Apr 5, 2026
10 tasks
Comment thread tests/ui/impl-restriction/impl-restriction-check.e2015.stderr Outdated
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 11, 2026

📌 Commit 46befd8 has been approved by jhpratt

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 Apr 11, 2026
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Apr 11, 2026

@bors r=jhpratt,Urgau

Let's show the reviewers properly!

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Apr 11, 2026

📌 Commit 46befd8 has been approved by jhpratt,Urgau

It is now in the queue for this repository.

jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 11, 2026
…eck, r=jhpratt,Urgau

Semantic checks of `impl` restrictions

This PR implements semantic checks for `impl` restrictions proposed in the [Restrictions RFC](https://rust-lang.github.io/rfcs/3323-restrictions.html) (Tracking Issue rust-lang#105077), and linked to a [GSOC idea/proposal](https://github.com/rust-lang/google-summer-of-code/tree/142433eb3b104b2f32bae0b9dfafb78a0a2ac579?tab=readme-ov-file#implementing-impl-and-mut-restrictions).

It lowers the resolved paths of `impl` restrictions from the AST to HIR and into `TraitDef`, and integrates the checks into the coherence phase by extending `check_impl`. As parsing (rust-lang#152943) and path resolution (rust-lang#153556) have already been implemented, this PR provides a working implementation of `impl` restrictions.

r? @Urgau
cc @jhpratt
rust-bors bot pushed a commit that referenced this pull request Apr 11, 2026
Rollup of 4 pull requests

Successful merges:

 - #149357 (Implement `-Z allow-partial-mitigations` (RFC 3855))
 - #154661 (Semantic checks of `impl` restrictions)
 - #155132 (Suggest similar target names on unrecognized `--target`)
 - #155136 (Tweak comment about intrinsics in cross-crate-inlinable)
rust-bors bot pushed a commit that referenced this pull request Apr 11, 2026
Rollup of 3 pull requests

Successful merges:

 - #154661 (Semantic checks of `impl` restrictions)
 - #155132 (Suggest similar target names on unrecognized `--target`)
 - #155136 (Tweak comment about intrinsics in cross-crate-inlinable)
@rust-bors rust-bors bot merged commit 44bad02 into rust-lang:main Apr 11, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 11, 2026
rust-timer added a commit that referenced this pull request Apr 11, 2026
Rollup merge of #154661 - CoCo-Japan-pan:impl-restriction-check, r=jhpratt,Urgau

Semantic checks of `impl` restrictions

This PR implements semantic checks for `impl` restrictions proposed in the [Restrictions RFC](https://rust-lang.github.io/rfcs/3323-restrictions.html) (Tracking Issue #105077), and linked to a [GSOC idea/proposal](https://github.com/rust-lang/google-summer-of-code/tree/142433eb3b104b2f32bae0b9dfafb78a0a2ac579?tab=readme-ov-file#implementing-impl-and-mut-restrictions).

It lowers the resolved paths of `impl` restrictions from the AST to HIR and into `TraitDef`, and integrates the checks into the coherence phase by extending `check_impl`. As parsing (#152943) and path resolution (#153556) have already been implemented, this PR provides a working implementation of `impl` restrictions.

r? @Urgau
cc @jhpratt
flip1995 pushed a commit to flip1995/rust that referenced this pull request Apr 16, 2026
…eck, r=jhpratt,Urgau

Semantic checks of `impl` restrictions

This PR implements semantic checks for `impl` restrictions proposed in the [Restrictions RFC](https://rust-lang.github.io/rfcs/3323-restrictions.html) (Tracking Issue rust-lang#105077), and linked to a [GSOC idea/proposal](https://github.com/rust-lang/google-summer-of-code/tree/142433eb3b104b2f32bae0b9dfafb78a0a2ac579?tab=readme-ov-file#implementing-impl-and-mut-restrictions).

It lowers the resolved paths of `impl` restrictions from the AST to HIR and into `TraitDef`, and integrates the checks into the coherence phase by extending `check_impl`. As parsing (rust-lang#152943) and path resolution (rust-lang#153556) have already been implemented, this PR provides a working implementation of `impl` restrictions.

r? @Urgau
cc @jhpratt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc 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