Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize anon consts in new solver #112183

Merged
merged 4 commits into from
Jun 3, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jun 1, 2023

We don't do any of that expand_abstract_consts stuff so this isn't sufficient to make GCE work, but it does allow, e.g. [(); 1]: Default, to solve.

r? @BoxyUwU

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 1, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jun 1, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

@compiler-errors compiler-errors changed the title New solver anon ct Normalize anon consts in new solver Jun 1, 2023
Copy link
Member

@BoxyUwU BoxyUwU left a comment

Choose a reason for hiding this comment

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

Can you try get a more explicit test for this that doesnt rely on std's Default impl for arrays having an anon const for the const argument to the array. I wouldn't expect that impl to stay like that forever.

@@ -672,7 +672,10 @@ impl<'a, 'b, 'tcx> TypeFolder<TyCtxt<'tcx>> for AssocTypeNormalizer<'a, 'b, 'tcx
#[instrument(skip(self), level = "debug")]
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
let tcx = self.selcx.tcx();
if tcx.lazy_normalization() || !needs_normalization(&constant, self.param_env.reveal()) {
if tcx.features().generic_const_exprs
|| tcx.trait_solver_next()
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if it makes sense to do this- we dont stop fold_ty from normalizing things if trait_solver_next is enabled so I wouldn't think it makes sense to avoid normalization of consts.

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't hurt, though? Like, the only reason we have eager normalization of types currently is because it's difficult to disable because of alias-relate ambiguities (like due to lifetimes primarily).

I could revert this, but it does seem to move us closer to actually-lazy-norm at least for consts?

Copy link
Member

Choose a reason for hiding this comment

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

I guess i'm a bit nervous about having types/consts diverge especially when it comes to implementing lazy norm since if we only do it for consts it seems more likely that bugs would go hidden since usage of const generics is way rarer than usage of type generics.

Copy link
Member

@BoxyUwU BoxyUwU Jun 1, 2023

Choose a reason for hiding this comment

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

I think i'd want @lcnr to be okay with doing this if this is going to get merged as is

Copy link
Member Author

Choose a reason for hiding this comment

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

That's fair, I can revert it and we can discuss "if and how we want to get to actually-lazy-norm-for-consts" in the new solver separately then.

@rust-cloud-vms rust-cloud-vms bot force-pushed the new-solver-anon-ct branch from 3144a57 to 84196f3 Compare June 2, 2023 22:15
@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 2, 2023

r=me if CI passes

@compiler-errors
Copy link
Member Author

@bors r=BoxyUwU

@bors
Copy link
Contributor

bors commented Jun 2, 2023

📌 Commit 84196f3 has been approved by BoxyUwU

It is now in the queue for this repository.

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jun 2, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 2, 2023
…mpiler-errors

Rollup of 6 pull requests

Successful merges:

 - rust-lang#109609 (Separate AnonConst from ConstBlock in HIR.)
 - rust-lang#112166 (bootstrap: Rename profile = user to profile = dist)
 - rust-lang#112168 (Lower `unchecked_div`/`_rem` to MIR's `BinOp::Div`/`Rem`)
 - rust-lang#112183 (Normalize anon consts in new solver)
 - rust-lang#112211 (pass `--lib` to `x doc`)
 - rust-lang#112223 (Don't ICE in new solver when auto traits have associated types)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e4a6b24 into rust-lang:master Jun 3, 2023
@rustbot rustbot added this to the 1.72.0 milestone Jun 3, 2023
@compiler-errors compiler-errors deleted the new-solver-anon-ct branch August 11, 2023 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants