Skip to content

Only prefer param-env candidates if they remain non-global after norm #140260

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Apr 24, 2025

Introduce CandidateSource::GlobalParamEnv, and dynamically compute the CandidateSource based on whether the predicate contains params post-normalization.

This code needs some cleanup and documentation. I'm just putting this up for review.

cc rust-lang/trait-system-refactor-initiative#179

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 Apr 24, 2025
@rustbot
Copy link
Collaborator

rustbot commented Apr 24, 2025

HIR ty lowering was modified

cc @fmease

Some changes occurred to the core trait solver

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

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@rust-log-analyzer
Copy link
Collaborator

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

Click to see the possible cause of the failure (guessed by this bot)
 Documenting rustc_next_trait_solver v0.0.0 (/checkout/compiler/rustc_next_trait_solver)
error: unresolved link to `I::DefId`
   --> compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs:161:15
    |
161 |     /// and [`I::DefId`].
    |               ^^^^^^^^ no item named `I` in scope
    |
    = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(rustdoc::broken_intra_doc_links)]`

error: could not document `rustc_next_trait_solver`
warning: build failed, waiting for other jobs to finish...
Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:01:31
  local time: Thu Apr 24 16:40:45 UTC 2025
  network time: Thu, 24 Apr 2025 16:40:45 GMT
##[error]Process completed with exit code 1.
Post job cleanup.

.any(|c| {
matches!(
c.source,
CandidateSource::ParamEnv(_) | CandidateSource::GlobalParamEnv(_)
Copy link
Contributor

Choose a reason for hiding this comment

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

vibe: bool on CandidateSource::ParamEnv seems nicer

@lcnr
Copy link
Contributor

lcnr commented Apr 25, 2025

pls add test

trait With {
    type Assoc;
}
impl<T> With for T {
    type Assoc = T;
}

trait Incomplete<T> {}
impl<T> Incomplete<T> for () {}
fn impls_incomplete<T: Incomplete<U>, U>() {}
fn foo<T>()
where
    u32: With<Assoc = T>,
    (): Incomplete<<u32 as With>::Assoc>,
{
    impls_incomplete::<(), _>();
}

fn main() {}

edit: actually, added as part of #140313

@bors
Copy link
Collaborator

bors commented Apr 26, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants