-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Move abstract const to middle #99000
Conversation
Some changes occurred in const_evaluatable.rs cc @lcnr |
88d4c71
to
b189045
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move some more stuff, then r=me
This comment has been minimized.
This comment has been minimized.
a2847a2
to
916a91d
Compare
This comment has been minimized.
This comment has been minimized.
916a91d
to
a6c1672
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #99054) made this pull request unmergeable. Please resolve the merge conflicts. |
a6c1672
to
22b7e63
Compare
This comment has been minimized.
This comment has been minimized.
22b7e63
to
90887d4
Compare
This comment has been minimized.
This comment has been minimized.
90887d4
to
5e93508
Compare
☔ The latest upstream changes (presumably #98957) made this pull request unmergeable. Please resolve the merge conflicts. |
5e93508
to
3d1228d
Compare
doesnt seem like this PR has any changes to |
#[instrument(skip(tcx), level = "debug")] | ||
pub fn try_unify_abstract_consts<'tcx>( | ||
tcx: TyCtxt<'tcx>, | ||
(a, b): (ty::Unevaluated<'tcx, ()>, ty::Unevaluated<'tcx, ()>), | ||
param_env: ty::ParamEnv<'tcx>, | ||
) -> bool { | ||
(|| { | ||
if let Some(a) = AbstractConst::new(tcx, a)? { | ||
if let Some(b) = AbstractConst::new(tcx, b)? { | ||
let const_unify_ctxt = ConstUnifyCtxt { tcx, param_env }; | ||
return Ok(const_unify_ctxt.try_unify(a, b)); | ||
} | ||
} | ||
|
||
Ok(false) | ||
})() | ||
.unwrap_or_else(|_: ErrorGuaranteed| true) | ||
// FIXME(generic_const_exprs): We should instead have this | ||
// method return the resulting `ty::Const` and return `ConstKind::Error` | ||
// on `ErrorGuaranteed`. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it feels weird to have this be a query which is provided in rustc_trait_selection
even though it's fully defined in rustc_middle
.
I guess we actually want to keep try_unify_abstract_const
and the ConstUnifyCtxt
in rustc_trait_selection
for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i feel like this should be in rustc_trait_selection
still since it seems reasonable for try_unify
to want to be able to unify inference vars eventaully- although "eventually" we probably want to remove try_unify_abstract_consts
so I dont know how important this is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still relevant
@BoxyUwU oops I initially made this PR to fix the bug, but turns out I would have to move this to |
3d1228d
to
e612e26
Compare
This comment has been minimized.
This comment has been minimized.
f9d9386
to
de618fb
Compare
It seems that it works just by attempting the identity substs without actually walking the abstract const, |
de618fb
to
c8fd0fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's still a final nit, and then r=me ❤️ thanks a lot
#[instrument(skip(tcx), level = "debug")] | ||
pub fn try_unify_abstract_consts<'tcx>( | ||
tcx: TyCtxt<'tcx>, | ||
(a, b): (ty::Unevaluated<'tcx, ()>, ty::Unevaluated<'tcx, ()>), | ||
param_env: ty::ParamEnv<'tcx>, | ||
) -> bool { | ||
(|| { | ||
if let Some(a) = AbstractConst::new(tcx, a)? { | ||
if let Some(b) = AbstractConst::new(tcx, b)? { | ||
let const_unify_ctxt = ConstUnifyCtxt { tcx, param_env }; | ||
return Ok(const_unify_ctxt.try_unify(a, b)); | ||
} | ||
} | ||
|
||
Ok(false) | ||
})() | ||
.unwrap_or_else(|_: ErrorGuaranteed| true) | ||
// FIXME(generic_const_exprs): We should instead have this | ||
// method return the resulting `ty::Const` and return `ConstKind::Error` | ||
// on `ErrorGuaranteed`. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still relevant
c8fd0fe
to
297e23a
Compare
@bors delegate+ |
✌️ @JulianKnodt can now approve this pull request |
297e23a
to
20fb8ab
Compare
@bors r+ |
Rollup of 6 pull requests Successful merges: - rust-lang#98072 (Add provider API to error trait) - rust-lang#98580 (Emit warning when named arguments are used positionally in format) - rust-lang#99000 (Move abstract const to middle) - rust-lang#99192 (Fix spans for asm diagnostics) - rust-lang#99222 (Better error message for generic_const_exprs inference failure) - rust-lang#99236 (solaris: unbreak build on native platform) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Moves AbstractConst (and all associated methods) to rustc middle for use in
rustc_infer
.This allows for const resolution in infer to use abstract consts to walk consts and check if
they are resolvable.
This attempts to resolve the issue where
Foo<{ concrete const }, generic T>
is incorrectly marked as conflicting, and is independent from the other issue where nested abstract consts must be resolved.r? @lcnr