Skip to content

Commit 67df012

Browse files
authored
Merge pull request #436 from dtolnay/up
Raise required compiler to Rust 1.68
2 parents b86c3c8 + c898488 commit 67df012

File tree

9 files changed

+17
-46
lines changed

9 files changed

+17
-46
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
strategy:
5858
fail-fast: false
5959
matrix:
60-
rust: [1.67.0, 1.65.0, 1.52.0, 1.51.0]
60+
rust: [1.68.0]
6161
timeout-minutes: 45
6262
steps:
6363
- uses: actions/checkout@v6

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2018"
99
keywords = ["error", "error-handling"]
1010
license = "MIT OR Apache-2.0"
1111
repository = "https://github.com/dtolnay/anyhow"
12-
rust-version = "1.51"
12+
rust-version = "1.68"
1313

1414
[features]
1515
default = ["std"]

build.rs

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::uninlined_format_args)]
2+
13
use std::env;
24
use std::ffi::OsString;
35
use std::fs;
@@ -62,40 +64,20 @@ fn main() {
6264
}
6365
}
6466

65-
let rustc = match rustc_minor_version() {
66-
Some(rustc) => rustc,
67-
None => return,
67+
let Some(rustc) = rustc_minor_version() else {
68+
return;
6869
};
6970

7071
if rustc >= 80 {
7172
println!("cargo:rustc-check-cfg=cfg(anyhow_build_probe)");
7273
println!("cargo:rustc-check-cfg=cfg(anyhow_nightly_testing)");
7374
println!("cargo:rustc-check-cfg=cfg(anyhow_no_clippy_format_args)");
7475
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_error)");
75-
println!("cargo:rustc-check-cfg=cfg(anyhow_no_core_unwind_safe)");
76-
println!("cargo:rustc-check-cfg=cfg(anyhow_no_fmt_arguments_as_str)");
77-
println!("cargo:rustc-check-cfg=cfg(anyhow_no_unsafe_op_in_unsafe_fn_lint)");
7876
println!("cargo:rustc-check-cfg=cfg(error_generic_member_access)");
7977
println!("cargo:rustc-check-cfg=cfg(std_backtrace)");
8078
}
8179

82-
if rustc < 52 {
83-
// core::fmt::Arguments::as_str
84-
// https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html#stabilized-apis
85-
println!("cargo:rustc-cfg=anyhow_no_fmt_arguments_as_str");
86-
87-
// #![deny(unsafe_op_in_unsafe_fn)]
88-
// https://github.com/rust-lang/rust/issues/71668
89-
println!("cargo:rustc-cfg=anyhow_no_unsafe_op_in_unsafe_fn_lint");
90-
}
91-
92-
if rustc < 56 {
93-
// core::panic::{UnwindSafe, RefUnwindSafe}
94-
// https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html#stabilized-apis
95-
println!("cargo:rustc-cfg=anyhow_no_core_unwind_safe");
96-
}
97-
98-
if !error_generic_member_access && cfg!(feature = "std") && rustc >= 65 {
80+
if !error_generic_member_access && cfg!(feature = "std") {
9981
// std::backtrace::Backtrace
10082
// https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#stabilized-apis
10183
println!("cargo:rustc-cfg=std_backtrace");

src/error.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ use core::fmt::{self, Debug, Display};
1212
use core::mem::ManuallyDrop;
1313
#[cfg(any(feature = "std", not(anyhow_no_core_error)))]
1414
use core::ops::{Deref, DerefMut};
15-
#[cfg(not(anyhow_no_core_unwind_safe))]
1615
use core::panic::{RefUnwindSafe, UnwindSafe};
1716
use core::ptr;
1817
use core::ptr::NonNull;
19-
#[cfg(all(feature = "std", anyhow_no_core_unwind_safe))]
20-
use std::panic::{RefUnwindSafe, UnwindSafe};
2118

2219
impl Error {
2320
/// Create a new error object from any error type.
@@ -782,7 +779,7 @@ where
782779
// Attach E's native StdError vtable onto a pointer to self._object.
783780
let unerased_ref = e.cast::<ErrorImpl<E>>();
784781
Ref::from_raw(unsafe {
785-
NonNull::new_unchecked(ptr::addr_of!((*unerased_ref.as_ptr())._object) as *mut E)
782+
NonNull::new_unchecked(ptr::addr_of!((*unerased_ref.as_ptr())._object).cast_mut())
786783
})
787784
}
788785

@@ -819,7 +816,7 @@ where
819816
let unerased_ref = e.cast::<ErrorImpl<E>>();
820817
Some(
821818
Ref::from_raw(unsafe {
822-
NonNull::new_unchecked(ptr::addr_of!((*unerased_ref.as_ptr())._object) as *mut E)
819+
NonNull::new_unchecked(ptr::addr_of!((*unerased_ref.as_ptr())._object).cast_mut())
823820
})
824821
.cast::<()>(),
825822
)
@@ -1085,8 +1082,5 @@ impl AsRef<dyn StdError> for Error {
10851082
}
10861083
}
10871084

1088-
#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]
10891085
impl UnwindSafe for Error {}
1090-
1091-
#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]
10921086
impl RefUnwindSafe for Error {}

src/lib.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,7 @@
209209
#![doc(html_root_url = "https://docs.rs/anyhow/1.0.100")]
210210
#![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]
211211
#![no_std]
212-
#![deny(dead_code, unused_imports, unused_mut)]
213-
#![cfg_attr(
214-
not(anyhow_no_unsafe_op_in_unsafe_fn_lint),
215-
deny(unsafe_op_in_unsafe_fn)
216-
)]
217-
#![cfg_attr(anyhow_no_unsafe_op_in_unsafe_fn_lint, allow(unused_unsafe))]
212+
#![deny(dead_code, unsafe_op_in_unsafe_fn, unused_imports, unused_mut)]
218213
#![allow(
219214
clippy::doc_markdown,
220215
clippy::elidable_lifetime_names,
@@ -233,6 +228,7 @@
233228
clippy::redundant_else,
234229
clippy::return_self_not_must_use,
235230
clippy::struct_field_names,
231+
clippy::uninlined_format_args,
236232
clippy::unused_self,
237233
clippy::used_underscore_binding,
238234
clippy::wildcard_imports,
@@ -685,12 +681,7 @@ pub mod __private {
685681
#[inline]
686682
#[cold]
687683
pub fn format_err(args: Arguments) -> Error {
688-
#[cfg(anyhow_no_fmt_arguments_as_str)]
689-
let fmt_arguments_as_str = None::<&str>;
690-
#[cfg(not(anyhow_no_fmt_arguments_as_str))]
691-
let fmt_arguments_as_str = args.as_str();
692-
693-
if let Some(message) = fmt_arguments_as_str {
684+
if let Some(message) = args.as_str() {
694685
// anyhow!("literal"), can downcast to &'static str
695686
Error::msg(message)
696687
} else {

src/ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ where
113113
}
114114

115115
pub fn as_ptr(self) -> *const T {
116-
self.ptr.as_ptr() as *const T
116+
self.ptr.as_ptr().cast_const()
117117
}
118118

119119
pub unsafe fn deref(self) -> &'a T {

tests/test_ensure.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
clippy::needless_else,
1717
clippy::never_loop,
1818
clippy::overly_complex_bool_expr,
19+
clippy::ptr_cast_constness,
1920
clippy::redundant_closure_call,
2021
clippy::redundant_pattern_matching,
2122
clippy::too_many_lines,
23+
clippy::uninlined_format_args,
2224
clippy::unit_arg,
2325
clippy::unnecessary_cast,
2426
clippy::while_immutable_condition,

tests/test_ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![deny(improper_ctypes, improper_ctypes_definitions)]
2+
#![allow(clippy::uninlined_format_args)]
23

34
use anyhow::anyhow;
45

tests/test_macros.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
clippy::match_single_binding,
77
clippy::needless_pass_by_value,
88
clippy::shadow_unrelated,
9+
clippy::uninlined_format_args,
910
clippy::wildcard_imports
1011
)]
1112

0 commit comments

Comments
 (0)