Skip to content
Myr

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

9 files+17 added−46 removed

modified:.github/workflows/ci.yml+1 added-1 removed
modified:src/error.rs+2 added-8 removed
10 unmodified lines
11use core::fmt::{self, Debug, Display};12use core::mem::ManuallyDrop;13#[cfg(any(feature = "std", not(anyhow_no_core_error)))]14use core::ops::{Deref, DerefMut};15#[cfg(not(anyhow_no_core_unwind_safe))]15use core::panic::{RefUnwindSafe, UnwindSafe};16use core::ptr;17use core::ptr::NonNull;19#[cfg(all(feature = "std", anyhow_no_core_unwind_safe))]20use std::panic::{RefUnwindSafe, UnwindSafe};1819impl Error {20 /// Create a new error object from any error type.21 ///
756 unmodified lines
778{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}785786// Safety: requires layout of *e to match ErrorImpl<E>.
28 unmodified lines
815 // 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 lines
1081 &**self1082 }1083}10841088#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]1085impl UnwindSafe for Error {}10901091#[cfg(any(feature = "std", not(anyhow_no_core_unwind_safe)))]1086impl RefUnwindSafe for Error {}
modified:src/lib.rs+3 added-12 removed
207 unmodified lines
208209#![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 lines
227 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_convention
444 unmodified lines
680 #[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();692693 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 String
39 unmodified lines
modified:src/ptr.rs+1 added-1 removed
111 unmodified lines
112 }113 }114115 pub fn as_ptr(self) -> *const T {116 self.ptr.as_ptr() as *const T116 self.ptr.as_ptr().cast_const()117 }118119 pub unsafe fn deref(self) -> &'a T {120 unsafe { &*self.ptr.as_ptr() }
67 unmodified lines
modified:tests/test_ensure.rs+2 added
14 unmodified lines
15 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 lines
modified:tests/test_ffi.rs+1 added
1#![deny(improper_ctypes, improper_ctypes_definitions)]2#![allow(clippy::uninlined_format_args)]34use anyhow::anyhow;56#[no_mangle]
13 unmodified lines
modified:tests/test_macros.rs+1 added
4 unmodified lines
5 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)]1213mod common;
84 unmodified lines
modified:build.rs+5 added-23 removed
1#![allow(clippy::uninlined_format_args)]23use std::env;4use std::ffi::OsString;5use std::fs;6use std::io::ErrorKind;
56 unmodified lines
63 println!("cargo:rerun-if-env-changed=RUSTC_BOOTSTRAP");64 }65 }6665 let rustc = match rustc_minor_version() {66 Some(rustc) => rustc,67 None => return,67 let Some(rustc) = rustc_minor_version() else {68 return;69 };7071 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 }7982 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");8687 // #![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 }9192 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 }9798 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 lines
modified:Cargo.toml+1 added-1 removed
7 unmodified lines
8edition = "2018"9keywords = ["error", "error-handling"]10license = "MIT OR Apache-2.0"11repository = "https://github.com/dtolnay/anyhow"12rust-version = "1.51"12rust-version = "1.68"1314[features]15default = ["std"]16std = []
24 unmodified lines