Skip to content

Commit

Permalink
Auto merge of rust-lang#97012 - oli-obk:🦀_intrinsics, r=davidtwco
Browse files Browse the repository at this point in the history
Add a query for checking whether a function is an intrinsic.

work towards rust-lang#93145

This will reduce churn when we add more ways to declare intrinsics

r? `@scottmcm`
  • Loading branch information
bors committed May 17, 2022
2 parents 7062eb4 + 0f30866 commit e9f3cdf
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use rustc_middle::ty::{self, adjustment::PointerCast, Ty, TyCtxt};
use rustc_semver::RustcVersion;
use rustc_span::symbol::sym;
use rustc_span::Span;
use rustc_target::spec::abi::Abi::RustIntrinsic;
use std::borrow::Cow;

type McfResult = Result<(), (Span, Cow<'static, str>)>;
Expand Down Expand Up @@ -323,7 +322,7 @@ fn check_terminator<'a, 'tcx>(
// within const fns. `transmute` is allowed in all other const contexts.
// This won't really scale to more intrinsics or functions. Let's allow const
// transmutes in const fn before we add more hacks to this.
if tcx.fn_sig(fn_def_id).abi() == RustIntrinsic && tcx.item_name(fn_def_id) == sym::transmute {
if tcx.is_intrinsic(fn_def_id) && tcx.item_name(fn_def_id) == sym::transmute {
return Err((
span,
"can only call `transmute` from const items, not `const fn`".into(),
Expand Down

0 comments on commit e9f3cdf

Please sign in to comment.