Skip to content

Commit 954d9a8

Browse files
committed
Remove remap_env_constness in queries
1 parent 131211a commit 954d9a8

File tree

8 files changed

+25
-69
lines changed

8 files changed

+25
-69
lines changed

compiler/rustc_macros/src/query.rs

-8
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,6 @@ struct QueryModifiers {
112112
/// Use a separate query provider for local and extern crates
113113
separate_provide_extern: Option<Ident>,
114114

115-
/// Always remap the ParamEnv's constness before hashing.
116-
remap_env_constness: Option<Ident>,
117-
118115
/// Generate a `feed` method to set the query's value from another query.
119116
feedable: Option<Ident>,
120117
}
@@ -130,7 +127,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
130127
let mut eval_always = None;
131128
let mut depth_limit = None;
132129
let mut separate_provide_extern = None;
133-
let mut remap_env_constness = None;
134130
let mut feedable = None;
135131

136132
while !input.is_empty() {
@@ -189,8 +185,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
189185
try_insert!(depth_limit = modifier);
190186
} else if modifier == "separate_provide_extern" {
191187
try_insert!(separate_provide_extern = modifier);
192-
} else if modifier == "remap_env_constness" {
193-
try_insert!(remap_env_constness = modifier);
194188
} else if modifier == "feedable" {
195189
try_insert!(feedable = modifier);
196190
} else {
@@ -211,7 +205,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
211205
eval_always,
212206
depth_limit,
213207
separate_provide_extern,
214-
remap_env_constness,
215208
feedable,
216209
})
217210
}
@@ -332,7 +325,6 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
332325
eval_always,
333326
depth_limit,
334327
separate_provide_extern,
335-
remap_env_constness,
336328
);
337329

338330
if modifiers.cache.is_some() {

compiler/rustc_middle/src/infer/canonical.rs

-8
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,6 @@ impl<'tcx, R> Canonical<'tcx, QueryResponse<'tcx, R>> {
336336
}
337337
}
338338

339-
impl<'tcx, R> Canonical<'tcx, ty::ParamEnvAnd<'tcx, R>> {
340-
#[inline]
341-
pub fn without_const(mut self) -> Self {
342-
self.value = self.value.without_const();
343-
self
344-
}
345-
}
346-
347339
impl<'tcx, V> Canonical<'tcx, V> {
348340
/// Allows you to map the `value` of a canonical while keeping the
349341
/// same set of bound variables.

compiler/rustc_middle/src/query/mod.rs

-25
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,6 @@ rustc_queries! {
10881088
key: ty::ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
10891089
) -> Option<mir::DestructuredConstant<'tcx>> {
10901090
desc { "destructuring MIR constant"}
1091-
remap_env_constness
10921091
}
10931092

10941093
/// Dereference a constant reference or raw pointer and turn the result into a constant
@@ -1097,7 +1096,6 @@ rustc_queries! {
10971096
key: ty::ParamEnvAnd<'tcx, mir::ConstantKind<'tcx>>
10981097
) -> mir::ConstantKind<'tcx> {
10991098
desc { "dereferencing MIR constant" }
1100-
remap_env_constness
11011099
}
11021100

11031101
query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> {
@@ -1340,32 +1338,26 @@ rustc_queries! {
13401338
/// `ty.is_copy()`, etc, since that will prune the environment where possible.
13411339
query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
13421340
desc { "computing whether `{}` is `Copy`", env.value }
1343-
remap_env_constness
13441341
}
13451342
/// Query backing `Ty::is_sized`.
13461343
query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
13471344
desc { "computing whether `{}` is `Sized`", env.value }
1348-
remap_env_constness
13491345
}
13501346
/// Query backing `Ty::is_freeze`.
13511347
query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
13521348
desc { "computing whether `{}` is freeze", env.value }
1353-
remap_env_constness
13541349
}
13551350
/// Query backing `Ty::is_unpin`.
13561351
query is_unpin_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
13571352
desc { "computing whether `{}` is `Unpin`", env.value }
1358-
remap_env_constness
13591353
}
13601354
/// Query backing `Ty::needs_drop`.
13611355
query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
13621356
desc { "computing whether `{}` needs drop", env.value }
1363-
remap_env_constness
13641357
}
13651358
/// Query backing `Ty::has_significant_drop_raw`.
13661359
query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
13671360
desc { "computing whether `{}` has a significant drop", env.value }
1368-
remap_env_constness
13691361
}
13701362

13711363
/// Query backing `Ty::is_structural_eq_shallow`.
@@ -1405,7 +1397,6 @@ rustc_queries! {
14051397
) -> Result<ty::layout::TyAndLayout<'tcx>, ty::layout::LayoutError<'tcx>> {
14061398
depth_limit
14071399
desc { "computing layout of `{}`", key.value }
1408-
remap_env_constness
14091400
}
14101401

14111402
/// Compute a `FnAbi` suitable for indirect calls, i.e. to `fn` pointers.
@@ -1416,7 +1407,6 @@ rustc_queries! {
14161407
key: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
14171408
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
14181409
desc { "computing call ABI of `{}` function pointers", key.value.0 }
1419-
remap_env_constness
14201410
}
14211411

14221412
/// Compute a `FnAbi` suitable for declaring/defining an `fn` instance, and for
@@ -1428,7 +1418,6 @@ rustc_queries! {
14281418
key: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>
14291419
) -> Result<&'tcx abi::call::FnAbi<'tcx, Ty<'tcx>>, ty::layout::FnAbiError<'tcx>> {
14301420
desc { "computing call ABI of `{}`", key.value.0 }
1431-
remap_env_constness
14321421
}
14331422

14341423
query dylib_dependency_formats(_: CrateNum)
@@ -1935,15 +1924,13 @@ rustc_queries! {
19351924
NoSolution,
19361925
> {
19371926
desc { "normalizing `{}`", goal.value.value }
1938-
remap_env_constness
19391927
}
19401928

19411929
/// Do not call this query directly: invoke `try_normalize_erasing_regions` instead.
19421930
query try_normalize_generic_arg_after_erasing_regions(
19431931
goal: ParamEnvAnd<'tcx, GenericArg<'tcx>>
19441932
) -> Result<GenericArg<'tcx>, NoSolution> {
19451933
desc { "normalizing `{}`", goal.value }
1946-
remap_env_constness
19471934
}
19481935

19491936
query implied_outlives_bounds(
@@ -1953,7 +1940,6 @@ rustc_queries! {
19531940
NoSolution,
19541941
> {
19551942
desc { "computing implied outlives bounds for `{}`", goal.value.value }
1956-
remap_env_constness
19571943
}
19581944

19591945
/// Do not call this query directly:
@@ -1965,7 +1951,6 @@ rustc_queries! {
19651951
NoSolution,
19661952
> {
19671953
desc { "computing dropck types for `{}`", goal.value.value }
1968-
remap_env_constness
19691954
}
19701955

19711956
/// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
@@ -1993,7 +1978,6 @@ rustc_queries! {
19931978
NoSolution,
19941979
> {
19951980
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal.value.value }
1996-
remap_env_constness
19971981
}
19981982

19991983
/// Do not call this query directly: part of the `Eq` type-op
@@ -2004,7 +1988,6 @@ rustc_queries! {
20041988
NoSolution,
20051989
> {
20061990
desc { "evaluating `type_op_eq` `{:?}`", goal.value.value }
2007-
remap_env_constness
20081991
}
20091992

20101993
/// Do not call this query directly: part of the `Subtype` type-op
@@ -2015,7 +1998,6 @@ rustc_queries! {
20151998
NoSolution,
20161999
> {
20172000
desc { "evaluating `type_op_subtype` `{:?}`", goal.value.value }
2018-
remap_env_constness
20192001
}
20202002

20212003
/// Do not call this query directly: part of the `ProvePredicate` type-op
@@ -2036,7 +2018,6 @@ rustc_queries! {
20362018
NoSolution,
20372019
> {
20382020
desc { "normalizing `{}`", goal.value.value.value }
2039-
remap_env_constness
20402021
}
20412022

20422023
/// Do not call this query directly: part of the `Normalize` type-op
@@ -2047,7 +2028,6 @@ rustc_queries! {
20472028
NoSolution,
20482029
> {
20492030
desc { "normalizing `{:?}`", goal.value.value.value }
2050-
remap_env_constness
20512031
}
20522032

20532033
/// Do not call this query directly: part of the `Normalize` type-op
@@ -2058,7 +2038,6 @@ rustc_queries! {
20582038
NoSolution,
20592039
> {
20602040
desc { "normalizing `{:?}`", goal.value.value.value }
2061-
remap_env_constness
20622041
}
20632042

20642043
/// Do not call this query directly: part of the `Normalize` type-op
@@ -2069,7 +2048,6 @@ rustc_queries! {
20692048
NoSolution,
20702049
> {
20712050
desc { "normalizing `{:?}`", goal.value.value.value }
2072-
remap_env_constness
20732051
}
20742052

20752053
query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
@@ -2091,7 +2069,6 @@ rustc_queries! {
20912069
goal: CanonicalTyGoal<'tcx>
20922070
) -> MethodAutoderefStepsResult<'tcx> {
20932071
desc { "computing autoderef types for `{}`", goal.value.value }
2094-
remap_env_constness
20952072
}
20962073

20972074
query supported_target_features(_: CrateNum) -> &'tcx FxHashMap<String, Option<Symbol>> {
@@ -2136,7 +2113,6 @@ rustc_queries! {
21362113
key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)>
21372114
) -> Result<Option<ty::Instance<'tcx>>, ErrorGuaranteed> {
21382115
desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) }
2139-
remap_env_constness
21402116
}
21412117

21422118
query resolve_instance_of_const_arg(
@@ -2146,7 +2122,6 @@ rustc_queries! {
21462122
"resolving instance of the const argument `{}`",
21472123
ty::Instance::new(key.value.0.to_def_id(), key.value.2),
21482124
}
2149-
remap_env_constness
21502125
}
21512126

21522127
query reveal_opaque_types_in_bounds(key: &'tcx ty::List<ty::Predicate<'tcx>>) -> &'tcx ty::List<ty::Predicate<'tcx>> {

compiler/rustc_middle/src/ty/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1849,12 +1849,6 @@ impl<'tcx, T> ParamEnvAnd<'tcx, T> {
18491849
pub fn into_parts(self) -> (ParamEnv<'tcx>, T) {
18501850
(self.param_env, self.value)
18511851
}
1852-
1853-
#[inline]
1854-
pub fn without_const(mut self) -> Self {
1855-
self.param_env = self.param_env.without_const();
1856-
self
1857-
}
18581852
}
18591853

18601854
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]

compiler/rustc_middle/src/ty/query.rs

-14
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,6 @@ macro_rules! separate_provide_extern_default {
202202
};
203203
}
204204

205-
macro_rules! opt_remap_env_constness {
206-
([][$name:ident]) => {};
207-
([(remap_env_constness) $($rest:tt)*][$name:ident]) => {
208-
let $name = $name.without_const();
209-
};
210-
([$other:tt $($modifiers:tt)*][$name:ident]) => {
211-
opt_remap_env_constness!([$($modifiers)*][$name])
212-
};
213-
}
214-
215205
macro_rules! define_callbacks {
216206
(
217207
$($(#[$attr:meta])*
@@ -353,7 +343,6 @@ macro_rules! define_callbacks {
353343
#[inline(always)]
354344
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
355345
let key = key.into_query_param();
356-
opt_remap_env_constness!([$($modifiers)*][key]);
357346

358347
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
359348
Some(_) => return,
@@ -372,7 +361,6 @@ macro_rules! define_callbacks {
372361
#[inline(always)]
373362
pub fn $name(self, key: query_helper_param_ty!($($K)*)) {
374363
let key = key.into_query_param();
375-
opt_remap_env_constness!([$($modifiers)*][key]);
376364

377365
match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
378366
Some(_) => return,
@@ -402,7 +390,6 @@ macro_rules! define_callbacks {
402390
pub fn $name(self, key: query_helper_param_ty!($($K)*)) -> $V
403391
{
404392
let key = key.into_query_param();
405-
opt_remap_env_constness!([$($modifiers)*][key]);
406393

407394
restore::<$V>(match try_get_cached(self.tcx, &self.tcx.query_system.caches.$name, &key) {
408395
Some(value) => value,
@@ -492,7 +479,6 @@ macro_rules! define_feedable {
492479
#[inline(always)]
493480
pub fn $name(self, value: query_provided::$name<'tcx>) -> $V {
494481
let key = self.key().into_query_param();
495-
opt_remap_env_constness!([$($modifiers)*][key]);
496482

497483
let tcx = self.tcx;
498484
let erased = query_provided_to_value::$name(tcx, value);

compiler/rustc_trait_selection/src/traits/query/type_op/prove_predicate.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,8 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
3232

3333
fn perform_query(
3434
tcx: TyCtxt<'tcx>,
35-
mut canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>,
35+
canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Self>>,
3636
) -> Fallible<CanonicalQueryResponse<'tcx, ()>> {
37-
match canonicalized.value.value.predicate.kind().skip_binder() {
38-
ty::PredicateKind::Clause(ty::Clause::Trait(pred)) => {
39-
canonicalized.value.param_env.remap_constness_with(pred.constness);
40-
}
41-
_ => canonicalized.value.param_env = canonicalized.value.param_env.without_const(),
42-
}
4337
tcx.type_op_prove_predicate(canonicalized)
4438
}
4539
}

tests/ui/const-generics/issues/issue-88119.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
// check-pass
1+
// known-bug: #88119
2+
// failure-status: 101
3+
// normalize-stderr-test "note: .*\n" -> ""
4+
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
5+
// normalize-stderr-test "\s\d{1,}: .*\n" -> ""
6+
// normalize-stderr-test "\s at .*\n" -> ""
7+
// rustc-env:RUST_BACKTRACE=0
28

39
#![allow(incomplete_features)]
410
#![feature(const_trait_impl, generic_const_exprs)]

0 commit comments

Comments
 (0)