Skip to content

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jan 24, 2025

cc #135996

blocked on rust-analyzer getting support for computing the right layout for pattern types

cc @Veykril no rush here, as long as we can't replace NonNull, there's no point in doing this change just yet

@rustbot

This comment was marked as outdated.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 24, 2025
@oli-obk oli-obk added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 24, 2025
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

Well r=me when/if it does get unblocked.

@rust-log-analyzer

This comment has been minimized.

#[repr(transparent)]
$(#[$m])*
#[cfg(not(bootstrap))]
$vis struct $name(pattern_type!($int is $low..=$high));
Copy link
Member

Choose a reason for hiding this comment

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

Unsure: at least for the NonZeroBlahInner ones, it'd be nicer if these could just be type $name = pattern_type!($int is $low..=$high);, without the extra wrapper. Is that feasible, or are the trait implementations too far off?

(Relatedly, I'd love to be able to just derive traits on these again, particularly to not have to manually StructuralPartialEq.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea... I wanna get there, but directly using pattern types is not a great experience at present

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@Veykril
Copy link
Member

Veykril commented Jan 27, 2025

Re rust-analyzer blocker, as it turns out to implement pattern types (to a degree that would unblock this) it comes down to the same architecture changes required as for rust-lang/rust-analyzer#7434 (which I am currently looking into), so that will take a bit.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jan 27, 2025

Some changes occurred to the CTFE machinery

cc @rust-lang/wg-const-eval

Some changes occurred to the CTFE / Miri interpreter

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

Comment on lines +270 to +272
ty::PatternKind::NotNull => {
self.tcx.types.unit.print(self)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Pattern types temporarily reusing tuple encoding risk breakage due to symbol conflicts. For example, the following fails to compile with -Csymbol-mangling-version=v0:

#![feature(pattern_types)]
#![feature(pattern_type_macro)]
use std::hint::black_box;
use std::mem::size_of;
use std::pat::pattern_type;

fn main() {
    black_box(size_of::<pattern_type!(usize is 0..=1)> as fn() -> usize);
    black_box(size_of::<(usize, [(); 0], [(); 1])> as fn() -> usize);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yea, I guess I need to change rustc-demangle first, then update our internal dependency on it, then update what we emit

@bors
Copy link
Collaborator

bors commented Jun 16, 2025

☔ The latest upstream changes (presumably #142556) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk force-pushed the push-tzonluoyuwkq branch from b329461 to e2e8462 Compare July 7, 2025 09:46
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 7, 2025

☔ The latest upstream changes (presumably #143582) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk force-pushed the push-tzonluoyuwkq branch from e2e8462 to 620b791 Compare July 15, 2025 08:33
@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Jul 15, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 15, 2025

This PR changes rustc_public

cc @oli-obk, @celinval, @ouz-a

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 22, 2025

☔ The latest upstream changes (presumably #144249) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk force-pushed the push-tzonluoyuwkq branch from 620b791 to a040d40 Compare July 23, 2025 06:56
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 23, 2025

☔ The latest upstream changes (presumably #143897) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk oli-obk force-pushed the push-tzonluoyuwkq branch from a040d40 to 85a0942 Compare July 24, 2025 07:24
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Aug 3, 2025

☔ The latest upstream changes (presumably #144814) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot rustbot added the T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue. label Sep 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 23, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer
Copy link
Collaborator

The job pr-check-2 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    |
793 |         match self.inner() {
    |               ^^^^^^^^^^^^ pattern `&rustc_type_ir::PatternKind::NotNull` not covered
    |
note: `rustc_type_ir::PatternKind<next_solver::interner::DbInterner<'_>>` defined here
   --> /checkout/compiler/rustc_type_ir/src/pattern.rs:14:1
    |
 14 | pub enum PatternKind<I: Interner> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
 17 |     NotNull,
    |     ------- not covered
    = note: the matched value is of type `&rustc_type_ir::PatternKind<next_solver::interner::DbInterner<'_>>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
804 ~             },
805 +             &rustc_type_ir::PatternKind::NotNull => todo!()
    |

error[E0004]: non-exhaustive patterns: `&rustc_type_ir::PatternKind::NotNull` not covered
   --> src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs:809:15
    |
809 |         match self.inner() {
    |               ^^^^^^^^^^^^ pattern `&rustc_type_ir::PatternKind::NotNull` not covered
    |
note: `rustc_type_ir::PatternKind<next_solver::interner::DbInterner<'_>>` defined here
   --> /checkout/compiler/rustc_type_ir/src/pattern.rs:14:1
    |
 14 | pub enum PatternKind<I: Interner> {
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
 17 |     NotNull,
    |     ------- not covered
    = note: the matched value is of type `&rustc_type_ir::PatternKind<next_solver::interner::DbInterner<'_>>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
819 ~             },
820 +             &rustc_type_ir::PatternKind::NotNull => todo!()
    |

error[E0004]: non-exhaustive patterns: `(rustc_type_ir::PatternKind::NotNull, _)` not covered
   --> src/tools/rust-analyzer/crates/hir-ty/src/next_solver/interner.rs:838:15
    |
838 |         match (a.kind(), b.kind()) {
    |               ^^^^^^^^^^^^^^^^^^^^ pattern `(rustc_type_ir::PatternKind::NotNull, _)` not covered
    |
    = note: the matched value is of type `(rustc_type_ir::PatternKind<next_solver::interner::DbInterner<'_>>, rustc_type_ir::PatternKind<next_solver::interner::DbInterner<'_>>)`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
857 ~             (PatternKind::Range { .. } | PatternKind::Or(_), _) => Err(TypeError::Mismatch),
858 ~             (rustc_type_ir::PatternKind::NotNull, _) => todo!(),
    |

[RUSTC-TIMING] serde_value test:false 0.301
    Checking protobuf-support v3.7.1
[RUSTC-TIMING] toml test:false 0.593

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Sep 25, 2025
Add proper name mangling for pattern types

requires adding demangler support first rust-lang/rustc-demangle#81

needed for rust-lang#136006 (comment) as otherwise we will have symbol collisions
rust-timer added a commit that referenced this pull request Sep 25, 2025
Rollup merge of #142401 - oli-obk:pattern-mango, r=petrochenkov

Add proper name mangling for pattern types

requires adding demangler support first rust-lang/rustc-demangle#81

needed for #136006 (comment) as otherwise we will have symbol collisions
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Sep 26, 2025
Add proper name mangling for pattern types

requires adding demangler support first rust-lang/rustc-demangle#81

needed for rust-lang/rust#136006 (comment) as otherwise we will have symbol collisions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. O-unix Operating system: Unix-like O-wasi Operating system: Wasi, Webassembly System Interface O-wasm Target: WASM (WebAssembly), http://webassembly.org/ S-blocked Status: Blocked on something else such as an RFC or other implementation work. T-clippy Relevant to the Clippy team. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustfmt Relevant to the rustfmt team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.