Skip to content

Commit

Permalink
Remove most version_check usage
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Sep 1, 2024
1 parent 27142aa commit 7ad11db
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 44 deletions.
7 changes: 3 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ optional = true
default-features = false

[dev-dependencies]
version_check = "0.9"
test-crate = { path = "./test-crate" }
syn = { version = "2", features = ["full"] }
trybuild = { version = "1.0.99", features = ["diff"] }

[build-dependencies]
version_check = "0.9"

[features]
default = ["syn-error"]
syn-error = ["syn"]
syn-error = ["dep:syn"]
nightly = []
13 changes: 0 additions & 13 deletions build.rs

This file was deleted.

3 changes: 0 additions & 3 deletions proc-macro-error-attr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
quote = "1"
proc-macro2 = "1"

[build-dependencies]
version_check = "0.9"
6 changes: 0 additions & 6 deletions proc-macro-error-attr/build.rs

This file was deleted.

12 changes: 0 additions & 12 deletions proc-macro-error-attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ fn impl_proc_macro_error(attr: TokenStream2, input: TokenStream2) -> Result<Toke
Ok(res.into())
}

#[cfg(not(always_assert_unwind))]
fn gen_body(block: TokenTree, settings: Settings) -> proc_macro2::TokenStream {
let is_proc_macro_hack = settings.is_set(ProcMacroHack);
let closure = if settings.is_set(AssertUnwindSafe) {
Expand All @@ -93,17 +92,6 @@ fn gen_body(block: TokenTree, settings: Settings) -> proc_macro2::TokenStream {
quote!( ::proc_macro_error::entry_point(#closure, #is_proc_macro_hack) )
}

// FIXME:
// proc_macro::TokenStream does not implement UnwindSafe until 1.37.0.
// Considering this is the closure's return type the unwind safety check would fail
// for virtually every closure possible, the check is meaningless.
#[cfg(always_assert_unwind)]
fn gen_body(block: TokenTree, settings: Settings) -> proc_macro2::TokenStream {
let is_proc_macro_hack = settings.is_set(ProcMacroHack);
let closure = quote!(::std::panic::AssertUnwindSafe(|| #block ));
quote!( ::proc_macro_error::entry_point(#closure, #is_proc_macro_hack) )
}

fn detect_proc_macro_hack(attrs: &[Attribute]) -> bool {
attrs
.iter()
Expand Down
1 change: 0 additions & 1 deletion src/imp/delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ pub(crate) fn emit_diagnostic(diag: Diagnostic) {
IS_DIRTY.with(|c| c.set(true));
PLevel::Error
}
_ => unreachable!(),
};

let mut res = PDiag::spanned(span, level, msg);
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
//! [`ToTokens`]: https://docs.rs/quote/1.0.3/quote/trait.ToTokens.html
//!

#![cfg_attr(not(use_fallback), feature(proc_macro_diagnostic))]
#![cfg_attr(feature = "nightly", feature(proc_macro_diagnostic))]
#![forbid(unsafe_code)]
#![allow(clippy::needless_doctest_main)]

Expand All @@ -295,11 +295,11 @@ mod diagnostic;
mod macros;
mod sealed;

#[cfg(use_fallback)]
#[cfg(not(feature = "nightly"))]
#[path = "imp/fallback.rs"]
mod imp;

#[cfg(not(use_fallback))]
#[cfg(feature = "nightly")]
#[path = "imp/delegate.rs"]
mod imp;

Expand Down
5 changes: 3 additions & 2 deletions tests/macro-errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#[cfg_attr(skip_ui_tests, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/*.rs");
if !version_check::Channel::read().is_some_and(|c| c.is_nightly()) {
t.compile_fail("tests/ui/*.rs");
}
}

0 comments on commit 7ad11db

Please sign in to comment.