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/thiserror/build.rs | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'vendor/thiserror/build.rs') diff --git a/vendor/thiserror/build.rs b/vendor/thiserror/build.rs index 004dfb015..7983a2b07 100644 --- a/vendor/thiserror/build.rs +++ b/vendor/thiserror/build.rs @@ -4,27 +4,56 @@ use std::path::Path; use std::process::{Command, ExitStatus, Stdio}; use std::str; -// This code exercises the surface area that we expect of the Provider API. If -// the current toolchain is able to compile it, then thiserror is able to use -// providers for backtrace support. +// 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 +// thiserror is able to provide backtrace support. const PROBE: &str = r#" - #![feature(provide_any)] + #![feature(error_generic_member_access)] - use std::any::{Demand, Provider}; + use std::error::{Error, Request}; + use std::fmt::{self, Debug, Display}; - fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) { - p.provide(demand); + struct MyError(Thing); + struct Thing; + + impl Debug for MyError { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unimplemented!() + } + } + + impl Display for MyError { + fn fmt(&self, _formatter: &mut fmt::Formatter) -> fmt::Result { + unimplemented!() + } + } + + impl Error for MyError { + fn provide<'a>(&'a self, request: &mut Request<'a>) { + request.provide_ref(&self.0); + } } "#; fn main() { match compile_probe() { - Some(status) if status.success() => println!("cargo:rustc-cfg=provide_any"), + Some(status) if status.success() => println!("cargo:rustc-cfg=error_generic_member_access"), _ => {} } } 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