Skip to content

Commit d092d4e

Browse files
committed
Remove possibly footgunny is_const method
1 parent ddb9e59 commit d092d4e

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4593,10 +4593,6 @@ impl FnHeader {
45934593
matches!(self.asyncness, IsAsync::Async(_))
45944594
}
45954595

4596-
pub fn is_const(&self) -> bool {
4597-
matches!(self.constness, Constness::Const { .. })
4598-
}
4599-
46004596
pub fn is_unsafe(&self) -> bool {
46014597
self.safety().is_unsafe()
46024598
}

compiler/rustc_passes/src/stability.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ fn lookup_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ConstSt
206206
let parent_stab = tcx.lookup_stability(parent)?;
207207
if parent_stab.is_unstable()
208208
&& let Some(fn_sig) = tcx.hir_node_by_def_id(def_id).fn_sig()
209-
&& fn_sig.header.is_const()
209+
&& matches!(fn_sig.header.constness, Constness::Const { .. })
210210
{
211211
let const_stable_indirect = find_attr!(tcx, def_id, RustcConstStableIndirect);
212212
return Some(ConstStability::unmarked(const_stable_indirect, parent_stab));
@@ -228,7 +228,7 @@ fn lookup_const_stability(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<ConstSt
228228
// If this is a const fn but not annotated with stability markers, see if we can inherit
229229
// regular stability.
230230
if let Some(fn_sig) = tcx.hir_node_by_def_id(def_id).fn_sig()
231-
&& fn_sig.header.is_const()
231+
&& matches!(fn_sig.header.constness, Constness::Const { .. })
232232
&& const_stab.is_none()
233233
// We only ever inherit unstable features.
234234
&& let Some(inherit_regular_stab) = tcx.lookup_stability(def_id)
@@ -384,7 +384,7 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
384384
// implied), check if the function/method is const or the parent impl block is const.
385385
let fn_sig = self.tcx.hir_node_by_def_id(def_id).fn_sig();
386386
if let Some(fn_sig) = fn_sig
387-
&& !fn_sig.header.is_const()
387+
&& !matches!(fn_sig.header.constness, Constness::Const { .. })
388388
&& const_stab.is_some()
389389
&& find_attr_span!(RustcConstStability).is_some()
390390
{

0 commit comments

Comments
 (0)