From 712a894acd5ad690d05a25d39ddb60b66d119dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=C4=9Fuz=20A=C4=9Fcayaz=C4=B1?= Date: Wed, 4 Oct 2023 14:11:38 +0300 Subject: [PATCH] remove is global hack --- compiler/rustc_middle/src/ty/mod.rs | 17 ++------------- .../associated_type_bound/impl-is-shadowed.rs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 tests/ui/traits/associated_type_bound/impl-is-shadowed.rs diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 783963589692c..905bd4d402a63 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -1754,10 +1754,7 @@ impl<'tcx> ParamEnv<'tcx> { /// 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. + /// the pair of the environment plus value. /// /// N.B., we preserve the environment when type-checking because it /// is possible for the user to have wacky where-clauses like @@ -1765,17 +1762,7 @@ impl<'tcx> ParamEnv<'tcx> { /// satisfiable. We generally want to behave as if they were true, /// although the surrounding function is never reachable. pub fn and>>(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 } } } diff --git a/tests/ui/traits/associated_type_bound/impl-is-shadowed.rs b/tests/ui/traits/associated_type_bound/impl-is-shadowed.rs new file mode 100644 index 0000000000000..6c3125a9fc5fd --- /dev/null +++ b/tests/ui/traits/associated_type_bound/impl-is-shadowed.rs @@ -0,0 +1,21 @@ +// check-pass +trait Bar<'a> { + type Assoc: 'static; +} + +impl<'a> Bar<'a> for () { + type Assoc = (); +} + +struct ImplsStatic> { + d: &'static >::Assoc, +} + +fn caller(b: ImplsStatic<()>) +where + for<'a> (): Bar<'a> +{ + let _: &<() as Bar<'static>>::Assoc = b.d; +} + +fn main() {}