Skip to content

Conversation

@lcnr
Copy link
Contributor

@lcnr lcnr commented Oct 29, 2025

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Oct 29, 2025
@lcnr lcnr marked this pull request as ready for review October 29, 2025 15:57
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. A-tidy Area: The tidy tool T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 29, 2025
@lcnr lcnr changed the title orphan check: don't support unnameable types remove support for typeof Oct 29, 2025
@lcnr lcnr added the S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. label Oct 29, 2025
@traviscross traviscross added the I-lang-radar Items that are on lang's radar and will need eventual work or consideration. label Oct 29, 2025
!ident_token.is_reserved_ident()
|| ident_token.is_path_segment_keyword()
|| [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Typeof, kw::Dyn]
|| [kw::Underscore, kw::For, kw::Impl, kw::Fn, kw::Unsafe, kw::Extern, kw::Dyn]
Copy link
Member

Choose a reason for hiding this comment

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

q: is there a chance this affects macros?

Copy link
Member

@fmease fmease Oct 29, 2025

Choose a reason for hiding this comment

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

Yes, the following artificial snippet will go from pass→fail:

macro_rules! ck { ($ty:ty) => {}; } ck!(typeof(0));

After this PR it'll fail with no rules expected keyword `typeof` (and hypothetically if typeof were to be demoted to a normal identifier, it would start failing with expected type, found `0`).

However, it's very unlikely anybody is relying on it. So it's not really a concern. MBE is notoriously forward incompatible.

Comment on lines +198 to +202
| ty::CoroutineWitness(..)
| ty::Alias(ty::Free, _)
| ty::Bound(..)
| ty::Placeholder(_)
| ty::Infer(_) => {
Copy link
Member

Choose a reason for hiding this comment

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

q: How is this related to this PR?

Copy link
Member

@fmease fmease Oct 29, 2025

Choose a reason for hiding this comment

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

With the removal of typeof inference, it should now be impossible to sneak these unnameable types into an impl (even with TAIT you can't do that IINM). The typeof removal is partially motivated by being able to perform this exact change as lcnr alluded to in the MCP. CC #147219, #146620 #147146.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the removal of typeof inference, it should now be impossible to sneak these unnameable types into an impl (even with TAIT you can't do that IINM)

Yes, there's currently no way to get unnameable types into impl headers or encounter them in coherence, and it's nice to be able to reason about that

// Reference
self.expect_and()?;
self.parse_borrowed_pointee()?
} else if self.eat_keyword_noexpect(kw::Typeof) {
Copy link
Member

Choose a reason for hiding this comment

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

It may be nice to keep a precise error message here and recover into an error type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-tidy Area: The tidy tool I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-MCP Status: PR has a compiler MCP and is waiting for the compiler MCP to complete. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

7 participants