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

Remove is global hack #116417

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 2 additions & 23 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,30 +1752,9 @@ impl<'tcx> ParamEnv<'tcx> {
Self::new(List::empty(), self.reveal())
}

/// Creates a suitable environment in which to perform trait
/// queries on the given value. When type-checking, this is simply
/// the pair of the environment plus value. But when reveal is set to
/// All, then if `value` does not reference any type parameters, we will
/// pair it with the empty environment. This improves caching and is generally
/// invisible.
///
/// N.B., we preserve the environment when type-checking because it
/// is possible for the user to have wacky where-clauses like
/// `where Box<u32>: Copy`, which are clearly never
/// satisfiable. We generally want to behave as if they were true,
/// although the surrounding function is never reachable.
/// Creates a pair of param-env and value for use in queries.
pub fn and<T: TypeVisitable<TyCtxt<'tcx>>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
match self.reveal() {
Reveal::UserFacing => ParamEnvAnd { param_env: self, value },

Reveal::All => {
if value.is_global() {
ParamEnvAnd { param_env: self.without_caller_bounds(), value }
} else {
ParamEnvAnd { param_env: self, value }
}
}
}
ParamEnvAnd { param_env: self, value }
}
}

Expand Down
21 changes: 21 additions & 0 deletions tests/ui/traits/associated_type_bound/impl-is-shadowed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// check-pass
trait Bar<'a> {
type Assoc: 'static;
}

impl<'a> Bar<'a> for () {
type Assoc = ();
}

struct ImplsStatic<CG: Bar<'static>> {
d: &'static <CG as Bar<'static>>::Assoc,
}

fn caller(b: ImplsStatic<()>)
where
for<'a> (): Bar<'a>
{
let _: &<() as Bar<'static>>::Assoc = b.d;
}

fn main() {}
Loading