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

Stop using translate_args in the new solver #125776

Merged
merged 1 commit into from
May 31, 2024

Conversation

compiler-errors
Copy link
Member

It was unnecessary and also sketchy, since it was doing an out-of-search-graph fulfillment loop. Added a test for the only really minor subtlety of translating args, though not sure if it was being tested before, though I wouldn't be surprised if it wasn't.

r? lcnr

@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 May 30, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 30, 2024

Some changes occurred to the core trait solver

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

@rust-log-analyzer

This comment has been minimized.

impl<T> Spec for [T; 0] {}

fn main() {
let x: <[u32; 0] as Spec>::Assoc = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

you're not testing the [_; 0] ice?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, because it's not fixed in the old solver. Could add one for the new solver if you want?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a test for the ambiguity case, and known-bug:unknown in the old solver

@rust-log-analyzer

This comment has been minimized.

Comment on lines 237 to 268
let args = match assoc_def.defining_node {
Node::Trait(_) => goal.predicate.alias.args,
Node::Impl(target_impl_def_id) => {
let impl_args_with_gat = goal.predicate.alias.args.rebase_onto(
tcx,
goal_trait_ref.def_id,
impl_args,
);
if target_impl_def_id == impl_def_id {
// Same impl, no need to rebase.
impl_args_with_gat
} else {
let target_args = ecx.fresh_args_for_item(target_impl_def_id);
let target_trait_ref = tcx
.impl_trait_ref(target_impl_def_id)
.unwrap()
.instantiate(tcx, target_args);
// Relate source impl to target impl by equating trait refs.
ecx.eq(goal.param_env, impl_trait_ref, target_trait_ref)?;
// Also add predicates since they may be needed to constrain the
// target impl's params.
ecx.add_goals(
GoalSource::Misc,
tcx.predicates_of(target_impl_def_id)
.instantiate(tcx, target_args)
.into_iter()
.map(|(pred, _)| goal.with(tcx, pred)),
);
impl_args_with_gat.rebase_onto(tcx, impl_def_id, target_args)
}
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

can you move this into a seperate method? 🤔 it's fairly involved and feels like it's also conceptionally self-contained.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

r=me after nit

Comment on lines 885 to 886
fn translate_args<'tcx>(
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

why is that not a method on EvalCtxt? 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷 fetch_eligible_assoc_item_def isn't one either

Copy link
Contributor

Choose a reason for hiding this comment

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

i feel like both should be, r=me with or without that change

@compiler-errors
Copy link
Member Author

@bors r=lcnr rollup

@bors
Copy link
Contributor

bors commented May 31, 2024

📌 Commit 20699fe has been approved by lcnr

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 May 31, 2024
jieyouxu added a commit to jieyouxu/rust that referenced this pull request May 31, 2024
…lcnr

Stop using `translate_args` in the new solver

It was unnecessary and also sketchy, since it was doing an out-of-search-graph fulfillment loop. Added a test for the only really minor subtlety of translating args, though not sure if it was being tested before, though I wouldn't be surprised if it wasn't.

r? lcnr
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#125652 (Revert propagation of drop-live information from Polonius)
 - rust-lang#125730 (Apply `x clippy --fix` and `x fmt` on Rustc)
 - rust-lang#125756 (coverage: Optionally instrument the RHS of lazy logical operators)
 - rust-lang#125776 (Stop using `translate_args` in the new solver)
 - rust-lang#125796 (Also InstSimplify `&raw*`)
 - rust-lang#125807 (Also resolve the type of constants, even if we already turned it into an error constant)
 - rust-lang#125816 (Don't build the `rust-demangler` binary for coverage tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5109a76 into rust-lang:master May 31, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 31, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2024
Rollup merge of rust-lang#125776 - compiler-errors:translate-args, r=lcnr

Stop using `translate_args` in the new solver

It was unnecessary and also sketchy, since it was doing an out-of-search-graph fulfillment loop. Added a test for the only really minor subtlety of translating args, though not sure if it was being tested before, though I wouldn't be surprised if it wasn't.

r? lcnr
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.

reimplement translate_args inside of the solver
5 participants