From d1b2d29528b7794b41e66fc2136e395a02f8529b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:59:35 +0200 Subject: Merging upstream version 1.73.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/anyhow/build.rs | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) (limited to 'vendor/anyhow/build.rs') diff --git a/vendor/anyhow/build.rs b/vendor/anyhow/build.rs index 38006832e..fc585cf64 100644 --- a/vendor/anyhow/build.rs +++ b/vendor/anyhow/build.rs @@ -11,49 +11,38 @@ compile_error! { "`backtrace` feature without `std` feature is not supported" } -// This code exercises the surface area that we expect of the std Backtrace -// type. If the current toolchain is able to compile it, we go ahead and use -// backtrace in anyhow. +// This code exercises the surface area that we expect of the Error generic +// member access API. If the current toolchain is able to compile it, then +// anyhow is able to provide backtrace support. const PROBE: &str = r#" - #![feature(error_generic_member_access, provide_any)] + #![feature(error_generic_member_access)] - use std::any::{Demand, Provider}; - use std::backtrace::{Backtrace, BacktraceStatus}; - use std::error::Error; - use std::fmt::{self, Display}; + use std::backtrace::Backtrace; + use std::error::{self, Error, Request}; + use std::fmt::{self, Debug, Display}; - #[derive(Debug)] - struct E { - backtrace: Backtrace, - } + struct MyError(Thing); + struct Thing; - impl Display for E { + impl Debug for MyError { fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { unimplemented!() } } - impl Error for E { - fn provide<'a>(&'a self, demand: &mut Demand<'a>) { - demand.provide_ref(&self.backtrace); + impl Display for MyError { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unimplemented!() } } - struct P; - - impl Provider for P { - fn provide<'a>(&'a self, _demand: &mut Demand<'a>) {} - } - - const _: fn() = || { - let backtrace: Backtrace = Backtrace::capture(); - let status: BacktraceStatus = backtrace.status(); - match status { - BacktraceStatus::Captured | BacktraceStatus::Disabled | _ => {} + impl Error for MyError { + fn provide<'a>(&'a self, request: &mut Request<'a>) { + request.provide_ref(&self.0); } - }; + } - const _: fn(&dyn Error) -> Option<&Backtrace> = |err| err.request_ref::(); + const _: fn(&dyn Error) -> Option<&Backtrace> = |err| error::request_ref::(err); "#; fn main() { @@ -79,6 +68,17 @@ fn main() { } fn compile_probe() -> Option { + if env::var_os("RUSTC_STAGE").is_some() { + // We are running inside rustc bootstrap. This is a highly non-standard + // environment with issues such as: + // + // https://github.com/rust-lang/cargo/issues/11138 + // https://github.com/rust-lang/rust/issues/114839 + // + // Let's just not use nightly features here. + return None; + } + let rustc = env::var_os("RUSTC")?; let out_dir = env::var_os("OUT_DIR")?; let probefile = Path::new(&out_dir).join("probe.rs"); -- cgit v1.2.3