Skip to content

using impl candidates shadowed by where-bound overflows by using impl with only super trait bounds #76

New issue

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

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

Already on GitHub? # to your account

Open
lcnr opened this issue Nov 13, 2023 · 2 comments · Fixed by rust-lang/rust#120836

Comments

@lcnr
Copy link
Contributor

lcnr commented Nov 13, 2023

https://rust.godbolt.org/z/8fzsP4MbE

trait Super {
    type SuperAssoc;
}

trait Trait: Super<SuperAssoc = Self::TraitAssoc> {
    type TraitAssoc;
}

impl<T, U> Trait for T
where
    T: Super<SuperAssoc = U>,
{
    type TraitAssoc = U;
}

fn overflow<T: Trait>() {
    let x: <T as Trait>::TraitAssoc;
}

normalizing <T as Trait>::TraitAssoc in the elaborated environment [T: Trait, T: Super, <T as Super>::SuperAssoc = <T as Trait>::TraitAssoc] has a single impl candidate, which uses the environment to normalize <T as Trait>::TraitAssoc to itself :3

@lcnr
Copy link
Contributor Author

lcnr commented Jan 9, 2024

NOTE TO SELF: shadowing impl candidates if there's a trait candidate in teh param env causes issues with inlining/adding additional bounds to the environment

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Feb 9, 2024
hide impls if trait bound is proven from env

AVERT YOUR EYES `@compiler-errors`

fixes rust-lang/trait-system-refactor-initiative#76 and rust-lang/trait-system-refactor-initiative#12 (comment)

this is kinda ugly and I hate it, but I wasn't able to think of a cleaner approach for now. I am also unsure whether we have to refine this filtering later on, so by making the change pretty minimal it should be easier to improve going forward.

r? `@BoxyUwU`
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 9, 2024
Rollup merge of rust-lang#120836 - lcnr:param-env-hide-impl, r=BoxyUwU

hide impls if trait bound is proven from env

AVERT YOUR EYES `@compiler-errors`

fixes rust-lang/trait-system-refactor-initiative#76 and rust-lang/trait-system-refactor-initiative#12 (comment)

this is kinda ugly and I hate it, but I wasn't able to think of a cleaner approach for now. I am also unsure whether we have to refine this filtering later on, so by making the change pretty minimal it should be easier to improve going forward.

r? `@BoxyUwU`
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Feb 10, 2024
hide impls if trait bound is proven from env

AVERT YOUR EYES `@compiler-errors`

fixes rust-lang/trait-system-refactor-initiative#76 and rust-lang/trait-system-refactor-initiative#12 (comment)

this is kinda ugly and I hate it, but I wasn't able to think of a cleaner approach for now. I am also unsure whether we have to refine this filtering later on, so by making the change pretty minimal it should be easier to improve going forward.

r? `@BoxyUwU`
@lcnr
Copy link
Contributor Author

lcnr commented Sep 5, 2024

test from #83

pub fn choice<I>(iter: I) -> Option<I::Item>
where
    I: IntoIterator,
    I::IntoIter: Iterator,
{
    todo!()
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant