|
5 | 5 |
|
6 | 6 | use crate::msrvs::Msrv;
|
7 | 7 | use hir::LangItem;
|
8 |
| -use rustc_attr::{Since, CURRENT_RUSTC_VERSION}; |
| 8 | +use rustc_attr::Since; |
9 | 9 | use rustc_const_eval::transform::check_consts::ConstCx;
|
10 | 10 | use rustc_hir as hir;
|
11 | 11 | use rustc_hir::def_id::DefId;
|
@@ -372,23 +372,16 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool {
|
372 | 372 | // as a part of an unimplemented MSRV check https://github.com/rust-lang/rust/issues/65262.
|
373 | 373 |
|
374 | 374 | let const_stab_rust_version = match since {
|
375 |
| - Since::Version(version) => RustcVersion::new( |
376 |
| - u32::from(version.major), |
377 |
| - u32::from(version.minor), |
378 |
| - u32::from(version.patch), |
379 |
| - ), |
380 |
| - Since::Current => { |
381 |
| - // HACK(nilstrieb): CURRENT_RUSTC_VERSION can return versions like 1.66.0-dev. |
382 |
| - // `rustc-semver` doesn't accept the `-dev` version number so we have to strip it off. |
383 |
| - let short_version = CURRENT_RUSTC_VERSION.split('-').next().unwrap(); |
384 |
| - RustcVersion::parse(short_version).unwrap_or_else(|err| { |
385 |
| - panic!("`rustc_attr::StabilityLevel::Stable::since` is ill-formatted: `{CURRENT_RUSTC_VERSION}`, {err:?}") |
386 |
| - }) |
387 |
| - }, |
| 375 | + Since::Version(version) => version, |
| 376 | + Since::Current => rustc_session::RustcVersion::CURRENT, |
388 | 377 | Since::Err => return false,
|
389 | 378 | };
|
390 | 379 |
|
391 |
| - msrv.meets(const_stab_rust_version) |
| 380 | + msrv.meets(RustcVersion::new( |
| 381 | + u32::from(const_stab_rust_version.major), |
| 382 | + u32::from(const_stab_rust_version.minor), |
| 383 | + u32::from(const_stab_rust_version.patch), |
| 384 | + )) |
392 | 385 | } else {
|
393 | 386 | // Unstable const fn with the feature enabled.
|
394 | 387 | msrv.current().is_none()
|
|
0 commit comments