Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/refine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn stable_def_id_symbol(tcx: mir_ty::TyCtxt<'_>, did: DefId) -> String {
}

pub fn datatype_symbol(tcx: mir_ty::TyCtxt<'_>, did: DefId) -> DatatypeSymbol {
DatatypeSymbol::new(tcx.def_path_str(did).replace("::", "."))
DatatypeSymbol::new(stable_def_id_symbol(tcx, did))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve names for module-level datatypes

When verification uses an existing module-level enum—most notably std.option.Option in tests/ui/pass/slice_split_first_mut_loop.rs—this unconditionally replaces its prior readable symbol with a hash-suffixed name even though only locally nested enums need disambiguation. PCSat is sensitive to these names: this renaming increases that representative case from roughly 5 seconds to beyond the solver's 30-second default, turning a valid program into a timeout. Keep the old def_path_str symbol for paths consisting only of module/type-namespace segments and use the stable def-id symbol only for nested items.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Leaving this as is. The maintainer asked to drop the module-path branch, so this PR now uses the stable symbol for every enum. The slowdown is PCSat reacting to one particular name string: the SMT is semantically identical, and other renamings of the same file solve in 6–9s. So it isn't a good reason to keep two naming schemes. I'm waiting for CI on ff61c0b to see whether that test times out on the runner.


Generated by Claude Code

}

pub fn user_defined_pred(tcx: mir_ty::TyCtxt<'_>, did: DefId) -> UserDefinedPred {
Expand Down
56 changes: 56 additions & 0 deletions tests/ui/fail/enum_local_in_trait_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//@error-in-other-file: Unsat
//@compile-flags: -C debug-assertions=off

trait T {
fn f(b: bool) -> i64;
}

struct A;
struct B;

impl thrust_models::Model for A {
type Ty = Self;
}

impl thrust_models::Model for B {
type Ty = Self;
}

impl T for A {
fn f(b: bool) -> i64 {
enum E {
X(i64),
Y,
}
impl thrust_models::Model for E {
type Ty = Self;
}
let e = if b { E::X(1) } else { E::Y };
match e {
E::X(x) => x,
E::Y => 0,
}
}
}

impl T for B {
fn f(b: bool) -> i64 {
enum E {
Z(bool),
W(i64),
}
impl thrust_models::Model for E {
type Ty = Self;
}
let e = if b { E::Z(true) } else { E::W(5) };
match e {
E::Z(_) => 10,
E::W(v) => v,
}
}
}

fn main() {
assert!(A::f(true) == 1);
assert!(B::f(false) == 10);
}
56 changes: 56 additions & 0 deletions tests/ui/pass/enum_local_in_trait_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//@check-pass
//@compile-flags: -C debug-assertions=off

trait T {
fn f(b: bool) -> i64;
}

struct A;
struct B;

impl thrust_models::Model for A {
type Ty = Self;
}

impl thrust_models::Model for B {
type Ty = Self;
}

impl T for A {
fn f(b: bool) -> i64 {
enum E {
X(i64),
Y,
}
impl thrust_models::Model for E {
type Ty = Self;
}
let e = if b { E::X(1) } else { E::Y };
match e {
E::X(x) => x,
E::Y => 0,
}
}
}

impl T for B {
fn f(b: bool) -> i64 {
enum E {
Z(bool),
W(i64),
}
impl thrust_models::Model for E {
type Ty = Self;
}
let e = if b { E::Z(true) } else { E::W(5) };
match e {
E::Z(_) => 10,
E::W(v) => v,
}
}
}

fn main() {
assert!(A::f(true) == 1);
assert!(B::f(false) == 5);
}
Loading