From 43126f357339bd35e6cdc28201516422f6a2dac1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 25 Apr 2021 13:59:10 +0200 Subject: [PATCH] get rid of min_const_fn references in library/ and rustdoc --- library/alloc/src/raw_vec.rs | 14 ++++---------- src/librustdoc/clean/inline.rs | 3 +-- src/librustdoc/clean/mod.rs | 4 ++-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/library/alloc/src/raw_vec.rs b/library/alloc/src/raw_vec.rs index dc02c9c883e..fe87a97bac1 100644 --- a/library/alloc/src/raw_vec.rs +++ b/library/alloc/src/raw_vec.rs @@ -53,17 +53,11 @@ pub struct RawVec { } impl RawVec { - /// HACK(Centril): This exists because `#[unstable]` `const fn`s needn't conform - /// to `min_const_fn` and so they cannot be called in `min_const_fn`s either. + /// HACK(Centril): This exists because stable `const fn` can only call stable `const fn`, so + /// they cannot call `Self::new()`. /// - /// If you change `RawVec::new` or dependencies, please take care to not - /// introduce anything that would truly violate `min_const_fn`. - /// - /// NOTE: We could avoid this hack and check conformance with some - /// `#[rustc_force_min_const_fn]` attribute which requires conformance - /// with `min_const_fn` but does not necessarily allow calling it in - /// `stable(...) const fn` / user code not enabling `foo` when - /// `#[rustc_const_unstable(feature = "foo", issue = "01234")]` is present. + /// If you change `RawVec::new` or dependencies, please take care to not introduce anything + /// that would truly const-call something unstable. pub const NEW: Self = Self::new(); /// Creates the biggest possible `RawVec` (on the system heap) diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e88a739d042..3986167bac8 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -10,7 +10,6 @@ use rustc_hir::def_id::DefId; use rustc_hir::Mutability; use rustc_metadata::creader::LoadedMacro; use rustc_middle::ty::{self, TyCtxt}; -use rustc_mir::const_eval::is_min_const_fn; use rustc_span::hygiene::MacroKind; use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::Span; @@ -210,7 +209,7 @@ fn build_external_function(cx: &mut DocContext<'_>, did: DefId) -> clean::Functi let sig = cx.tcx.fn_sig(did); let constness = - if is_min_const_fn(cx.tcx, did) { hir::Constness::Const } else { hir::Constness::NotConst }; + if cx.tcx.is_const_fn_raw(did) { hir::Constness::Const } else { hir::Constness::NotConst }; let asyncness = cx.tcx.asyncness(did); let predicates = cx.tcx.predicates_of(did); let (generics, decl) = clean::enter_impl_trait(cx, |cx| { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c0a8c88bdeb..6b04157d953 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -22,7 +22,7 @@ use rustc_middle::middle::resolve_lifetime as rl; use rustc_middle::ty::fold::TypeFolder; use rustc_middle::ty::subst::{InternalSubsts, Subst}; use rustc_middle::ty::{self, AdtKind, Lift, Ty, TyCtxt}; -use rustc_mir::const_eval::{is_const_fn, is_min_const_fn, is_unstable_const_fn}; +use rustc_mir::const_eval::{is_const_fn, is_unstable_const_fn}; use rustc_span::hygiene::{AstPass, MacroKind}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::{self, ExpnKind}; @@ -1048,7 +1048,7 @@ impl Clean for ty::AssocItem { ty::TraitContainer(_) => self.defaultness.has_value(), }; if provided { - let constness = if is_min_const_fn(tcx, self.def_id) { + let constness = if tcx.is_const_fn_raw(self.def_id) { hir::Constness::Const } else { hir::Constness::NotConst