diff options
| author | bors <bors@rust-lang.org> | 2022-06-19 14:51:28 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-06-19 14:51:28 +0000 |
| commit | 68d0b29098ed75f50dabc7d07b96c70caab5c182 (patch) | |
| tree | 4aab4e2b4b5778738a08618abb7670c0221ff637 /compiler/rustc_const_eval/src | |
| parent | 67404f7200c13deec255ffe1146e1d2c9d0d3028 (diff) | |
| parent | 6a2a56da451a357141bc8c929045ec2aafa3421f (diff) | |
| download | rust-68d0b29098ed75f50dabc7d07b96c70caab5c182.tar.gz rust-68d0b29098ed75f50dabc7d07b96c70caab5c182.zip | |
Auto merge of #98255 - Dylan-DPC:rollup-hr129rg, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #98105 (rustdoc: remove tuple link on round braces) - #98136 (Rename `impl_constness` to `constness`) - #98146 (Remove --memory-init-file flag when linking with Emscripten) - #98219 (Skip late bound regions in GATSubstCollector) - #98233 (Remove accidental uses of `&A: Allocator`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/const_eval/fn_queries.rs | 13 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/check.rs | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs index d6f62062d1f..f1674d04f8d 100644 --- a/compiler/rustc_const_eval/src/const_eval/fn_queries.rs +++ b/compiler/rustc_const_eval/src/const_eval/fn_queries.rs @@ -17,13 +17,14 @@ pub fn is_unstable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Symbol> { pub fn is_parent_const_impl_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { let parent_id = tcx.local_parent(def_id); - tcx.def_kind(parent_id) == DefKind::Impl - && tcx.impl_constness(parent_id) == hir::Constness::Const + tcx.def_kind(parent_id) == DefKind::Impl && tcx.constness(parent_id) == hir::Constness::Const } -/// Checks whether the function has a `const` modifier or, in case it is an intrinsic, whether -/// said intrinsic has a `rustc_const_{un,}stable` attribute. -fn impl_constness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::Constness { +/// Checks whether an item is considered to be `const`. If it is a constructor, it is const. If +/// it is a trait impl/function, return if it has a `const` modifier. If it is an intrinsic, +/// report whether said intrinsic has a `rustc_const_{un,}stable` attribute. Otherwise, return +/// `Constness::NotConst`. +fn constness(tcx: TyCtxt<'_>, def_id: DefId) -> hir::Constness { let def_id = def_id.expect_local(); let node = tcx.hir().get_by_def_id(def_id); @@ -77,5 +78,5 @@ fn is_promotable_const_fn(tcx: TyCtxt<'_>, def_id: DefId) -> bool { } pub fn provide(providers: &mut Providers) { - *providers = Providers { impl_constness, is_promotable_const_fn, ..*providers }; + *providers = Providers { constness, is_promotable_const_fn, ..*providers }; } diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index b8a14e37a09..069fbed36ee 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -753,7 +753,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> { callee = did; } - if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) { + if let hir::Constness::NotConst = tcx.constness(data.impl_def_id) { self.check_op(ops::FnCallNonConst { caller, callee, |
