Skip to content

downcast regression: ambiguity due to global where-bounds #172

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

Closed
compiler-errors opened this issue Apr 11, 2025 · 2 comments · Fixed by rust-lang/rust#139791
Closed

downcast regression: ambiguity due to global where-bounds #172

compiler-errors opened this issue Apr 11, 2025 · 2 comments · Fixed by rust-lang/rust#139791
Assignees
Labels
A-winnowing from-crater A regression found via a crater run, not part of our test suite

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Apr 11, 2025

https://crater-reports.s3.amazonaws.com/pr-133502-1/try%23fa8e241660363f48d64b66b05eea58c93ab828fb/reg/mockall-0.13.1/log.txt

pub trait Any: 'static {}

pub trait Downcast<T>: Any
where
    T: Any,
{
}

impl dyn Any {
    pub fn is<T>(&self)
    where
        T: Any,
        Self: Downcast<T>,
    {
    }
}
@compiler-errors
Copy link
Member Author

compiler-errors commented Apr 11, 2025

I believe this has to do with a disagreement in region responses between the param-env bound we get from elaborating Self: Downcast<T> -> Self: Any (where Self = dyn Any + 'static) and what we get from the built-in bound dyn Any: + 'static: Any.

This specifically requires that 'static as a super bound, suggesting that an extra '?0: 'static that comes from confirming the built-in object impl's super bounds is preventing us from merging two trait candidates.

@compiler-errors
Copy link
Member Author

Worst case we wait until we get better w/ regions in responses 💀

Best case we come up with some better fix to the way we combine candidates when their region responses are practically equal. (At least, I think that's the case here).

@lcnr lcnr added A-winnowing from-crater A regression found via a crater run, not part of our test suite labels Apr 14, 2025
@lcnr lcnr moved this from unknown to in progress in -Znext-solver=globally Apr 14, 2025
@lcnr lcnr self-assigned this Apr 14, 2025
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 15, 2025
…=compiler-errors

drop global where-bounds before merging candidates

fixes rust-lang/trait-system-refactor-initiative#172

r? `@compiler-errors`
jieyouxu added a commit to jieyouxu/rust that referenced this issue Apr 15, 2025
…=compiler-errors

drop global where-bounds before merging candidates

fixes rust-lang/trait-system-refactor-initiative#172

r? ``@compiler-errors``
Zalathar added a commit to Zalathar/rust that referenced this issue Apr 15, 2025
…=compiler-errors

drop global where-bounds before merging candidates

fixes rust-lang/trait-system-refactor-initiative#172

r? ```@compiler-errors```
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 15, 2025
Rollup merge of rust-lang#139791 - lcnr:ignore-global-where-bounds, r=compiler-errors

drop global where-bounds before merging candidates

fixes rust-lang/trait-system-refactor-initiative#172

r? ```@compiler-errors```
@lcnr lcnr moved this from in progress to done in -Znext-solver=globally Apr 16, 2025
@lcnr lcnr closed this as completed by moving to done in -Znext-solver=globally Apr 16, 2025
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this issue Apr 17, 2025
…-errors

drop global where-bounds before merging candidates

fixes rust-lang/trait-system-refactor-initiative#172

r? ```@compiler-errors```
@lcnr lcnr changed the title downcast regression downcast regression: ambiguity due to global where-bounds Apr 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-winnowing from-crater A regression found via a crater run, not part of our test suite
Projects
Development

Successfully merging a pull request may close this issue.

2 participants