Merge pull request #436 from dtolnay/up
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Raise required compiler to Rust 1.68
authored by David Tolnay · committed by GitHub · parents b86c3c8, c898488 · Browse files · 9 files·+17 added−46 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+17 added−46 removed
- tests:+4 added−0 removed
- other:+13 added−46 removed
Provenance
- Commit
67df012- Tree
475cafe- Author
David Tolnay <dtolnay@gmail.com>- Committer
GitHub <noreply@github.com>- Parent 1
b86c3c8- Parent 2
c898488
9 files changed+17 added−46 removed
modified:.github/workflows/ci.yml+1 added-1 removed
55 unmodified lines5657585960606162636483 unmodified lines55 unmodified lines runs-on: ubuntu-latest strategy: fail-fast: false matrix: rust: [1.67.0, 1.65.0, 1.52.0, 1.51.0] rust: [1.68.0] timeout-minutes: 45 steps: - uses: actions/checkout@v6 - uses: dtolnay/rust-toolchain@master83 unmodified linesmodified:src/error.rs+2 added-8 removed
10 unmodified lines11 use core::fmt::{self, Debug, Display};12 use core::mem::ManuallyDrop;13 #[cfg(any(feature = "std", not(anyhow_no_core_error)))]14 use core::ops::{Deref, DerefMut};15-#[cfg(not(anyhow_no_core_unwind_safe))]15 use core::panic::{RefUnwindSafe, UnwindSafe};16 use core::ptr;17 use core::ptr::NonNull;19-#[cfg(all(feature = "std", anyhow_no_core_unwind_safe))]20-use std::panic::{RefUnwindSafe, UnwindSafe};18 19 impl Error {20 /// Create a new error object from any error type.21 ///756 unmodified lines778 {779 // Attach E's native StdError vtable onto a pointer to self._object.780 let unerased_ref = e.cast::<ErrorImpl<E>>();781 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())783 })784 }785 786 // Safety: requires layout of *e to match ErrorImpl<E>.28 unmodified lines815 // pointer to its E field.816 let unerased_ref = e.cast::<ErrorImpl<E>>();817 Some(818 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())820 })821 .cast::<()>(),822 )823 } else {257 unmodified lines1081 &**self1082 }1083 }1084 1088-#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]1085 impl UnwindSafe for Error {}1090-1091-#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]1086 impl RefUnwindSafe for Error {}modified:src/lib.rs+3 added-12 removed
207 unmodified lines208 209 #![doc(html_root_url = "https://docs.rs/anyhow/1.0.100")]210 #![cfg_attr(error_generic_member_access, feature(error_generic_member_access))]211 #![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)]213 #![allow(214 clippy::doc_markdown,215 clippy::elidable_lifetime_names,216 clippy::enum_glob_use,10 unmodified lines227 clippy::new_ret_no_self,228 clippy::redundant_else,229 clippy::return_self_not_must_use,230 clippy::struct_field_names,231+ clippy::uninlined_format_args,232 clippy::unused_self,233 clippy::used_underscore_binding,234 clippy::wildcard_imports,235 clippy::wrong_self_convention444 unmodified lines680 #[doc(hidden)]681 #[inline]682 #[cold]683 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() {685 // anyhow!("literal"), can downcast to &'static str686 Error::msg(message)687 } else {688 // anyhow!("interpolate {var}"), can downcast to String39 unmodified linesmodified:src/ptr.rs+1 added-1 removed
111 unmodified lines112 }113 }114 115 pub fn as_ptr(self) -> *const T {116- self.ptr.as_ptr() as *const T116+ self.ptr.as_ptr().cast_const()117 }118 119 pub unsafe fn deref(self) -> &'a T {120 unsafe { &*self.ptr.as_ptr() }67 unmodified linesmodified:tests/test_ensure.rs+2 added
14 unmodified lines15 clippy::match_bool,16 clippy::needless_else,17 clippy::never_loop,18 clippy::overly_complex_bool_expr,19+ clippy::ptr_cast_constness,20 clippy::redundant_closure_call,21 clippy::redundant_pattern_matching,22 clippy::too_many_lines,23+ clippy::uninlined_format_args,24 clippy::unit_arg,25 clippy::unnecessary_cast,26 clippy::while_immutable_condition,27 clippy::zero_ptr,729 unmodified linesmodified:tests/test_ffi.rs+1 added
1 #![deny(improper_ctypes, improper_ctypes_definitions)]2+#![allow(clippy::uninlined_format_args)]3 4 use anyhow::anyhow;5 6 #[no_mangle]13 unmodified linesmodified:tests/test_macros.rs+1 added
4 unmodified lines5 clippy::items_after_statements,6 clippy::match_single_binding,7 clippy::needless_pass_by_value,8 clippy::shadow_unrelated,9+ clippy::uninlined_format_args,10 clippy::wildcard_imports11 )]12 13 mod common;84 unmodified linesmodified:build.rs+5 added-23 removed
1+#![allow(clippy::uninlined_format_args)]2+3 use std::env;4 use std::ffi::OsString;5 use std::fs;6 use std::io::ErrorKind;56 unmodified lines63 println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");64 }65 }66 65- let rustc = match rustc_minor_version() {66- Some(rustc) => rustc,67- None => return,67+ let Some(rustc) = rustc_minor_version() else {68+ return;69 };70 71 if rustc >= 80 {72 println!("cargo:rustc-check-cfg=cfg(anyhow_build_probe)");73 println!("cargo:rustc-check-cfg=cfg(anyhow_nightly_testing)");74 println!("cargo:rustc-check-cfg=cfg(anyhow_no_clippy_format_args)");75 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)");76 println!("cargo:rustc-check-cfg=cfg(error_generic_member_access)");77 println!("cargo:rustc-check-cfg=cfg(std_backtrace)");78 }79 82- if rustc < 52 {83- // core::fmt::Arguments::as_str84- // https://blog.rust-lang.org/2021/05/06/Rust-1.52.0.html#stabilized-apis85- 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/7166889- 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-apis95- 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") {81 // std::backtrace::Backtrace82 // https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html#stabilized-apis83 println!("cargo:rustc-cfg=std_backtrace");84 }123 unmodified linesmodified:Cargo.toml+1 added-1 removed
7 unmodified lines8 edition = "2018"9 keywords = ["error", "error-handling"]10 license = "MIT OR Apache-2.0"11 repository = "https://github.com/dtolnay/anyhow"12-rust-version = "1.51"12+rust-version = "1.68"13 14 [features]15 default = ["std"]16 std = []24 unmodified lines