Skip to content

Commit

Permalink
Remove track_caller feature detection because msrv was bumped
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Jun 15, 2024
1 parent db36f6d commit 89cbd82
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 26 deletions.
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ generate-parsing-rs = ["peg"]
testing-helpers = ["rustc_version"]
is_variant = ["convert_case"]
unwrap = ["convert_case", "rustc_version"]
# Feature that requires post-MSRV Rust version,
# of 1.46. We perform rustc version detection in the
# build script for features that require this.
# (Currently just `unwrap`.)
# Unused, kept for backwards compatibility
track-caller = []

default = [
Expand Down
13 changes: 0 additions & 13 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@ fn detect_nightly() {
}
}

#[cfg(not(feature = "unwrap"))]
fn detect_track_caller() {}
/// Detect availability of the `#[track_caller]` attribute for
/// use in derived panicking methods like `.unwrap_*()`.
#[cfg(feature = "unwrap")]
fn detect_track_caller() {
use rustc_version::version_meta;
if version_meta().unwrap().semver.minor >= 46 {
println!("cargo:rustc-cfg=feature=\"track-caller\"");
}
}

fn main() {
detect_nightly();
detect_track_caller();
generate_peg();
}
10 changes: 1 addition & 9 deletions src/unwrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,8 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result<TokenStre
}
});

// The `track-caller` feature is set by our build script based
// on rustc version detection, as `#[track_caller]` was
// stabilized in a later version (1.46) of Rust than our MSRV (1.36).
let track_caller = if cfg!(feature = "track-caller") {
quote! { #[track_caller] }
} else {
quote! {}
};
let func = quote! {
#track_caller
#[track_caller]
pub fn #fn_name(self) -> #ret_type {
match self {
#enum_name ::#variant_ident #data_pattern => #ret_value,
Expand Down

0 comments on commit 89cbd82

Please sign in to comment.