diff options
Diffstat (limited to 'vendor/tracing-attributes')
-rw-r--r-- | vendor/tracing-attributes/.cargo-checksum.json | 2 | ||||
-rw-r--r-- | vendor/tracing-attributes/CHANGELOG.md | 78 | ||||
-rw-r--r-- | vendor/tracing-attributes/Cargo.toml | 18 | ||||
-rw-r--r-- | vendor/tracing-attributes/README.md | 12 | ||||
-rw-r--r-- | vendor/tracing-attributes/src/attr.rs | 190 | ||||
-rw-r--r-- | vendor/tracing-attributes/src/expand.rs | 53 | ||||
-rw-r--r-- | vendor/tracing-attributes/src/lib.rs | 104 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/async_fn.rs | 26 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/err.rs | 73 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/follows_from.rs | 2 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/instrument.rs | 2 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/levels.rs | 46 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/ret.rs | 52 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/ui.rs | 7 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/ui/async_instrument.stderr | 8 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/ui/const_instrument.rs | 8 | ||||
-rw-r--r-- | vendor/tracing-attributes/tests/ui/const_instrument.stderr | 15 |
17 files changed, 537 insertions, 159 deletions
diff --git a/vendor/tracing-attributes/.cargo-checksum.json b/vendor/tracing-attributes/.cargo-checksum.json index e29c0854b..f03bd5d46 100644 --- a/vendor/tracing-attributes/.cargo-checksum.json +++ b/vendor/tracing-attributes/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"CHANGELOG.md":"7c292985e41b0fd9c89d32bd15594b76bb3109ff96177af7461d1a0d3ea48574","Cargo.toml":"1c272401b940ef2fd88638a6228af02c14e3d47d4b592ee5c445f7470a0d1763","LICENSE":"898b1ae9821e98daf8964c8d6c7f61641f5f5aa78ad500020771c0939ee0dea1","README.md":"aae710a2c0c4ade929a84f8f3d9f98fcb9ad1c1e9e52ae0b0393db9f353f6248","src/attr.rs":"4d26dad70c765fff3d4677ebe8e71b63599d67ceba5c48dbcb204d247b5394ce","src/expand.rs":"f070e38eb3526c4c50e98cfafb2c26e50c7170f27d0bd716838a29777c1174cd","src/lib.rs":"14803c868525f6ae95b846ce2f369a47d50b2befba336335354867cf2a1b2455","tests/async_fn.rs":"6ae845ab6c508f9f2d1ea7ec3855971e8cff85afdae326593089d0a53c9c6dcf","tests/destructuring.rs":"26b9800678bad09e06512a113a54556e2fac3ecb15a18dcccefe105fb8911c26","tests/err.rs":"3beb5f065e57a578825c383a56b9d64fb89794a508018bf36e16f113557909b8","tests/fields.rs":"3882bd4e744d6b492f59beac7475e8bf4ff4ca8ad85c6951c305a22c78e75fae","tests/follows_from.rs":"5bc856923e87b34e0558959149118238fe668ac621f1748cc444c21c90a86647","tests/instrument.rs":"e3a90f2aef0d2f56c2c25018e2fbacf518e90ef6810930941f86740279252d03","tests/levels.rs":"80ffb684163a4d28c69c40e31a82609ac02daf922086bab8247bca125aec3c69","tests/names.rs":"5afd6c4d526588bcea3141c130a45a21872956495b6868a01b44ddff57749827","tests/parents.rs":"673d3f81eed6ba433f685ec53fd007c5dd957b97d32499d7ea1537e1f289cb2e","tests/ret.rs":"083b4ca456d766c469b2fff7608b59524b422941e5c5e84f07c1ce0d7b345c7a","tests/targets.rs":"95ce1ce1e2d29794062c5b3429d91c1bfaba5813251d5d8440c12cb2db6e11bf","tests/ui.rs":"c73c70fe7371998df077862092f40df7210b13496e119ab4e657a1848e42ab30","tests/ui/async_instrument.rs":"00fcde05841e8f9f6cc6f9434f8cc4baed5cf6e3ca73e8faddccbdace14e9485","tests/ui/async_instrument.stderr":"6f0457b5cd035a9bc82f5e98fb6d3a74177336ec6a19ba2e7cb9dbf3e67c3aff"},"package":"4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"}
\ No newline at end of file +{"files":{"CHANGELOG.md":"51b693a78ec3115db6f20696605d5829a5928dc7270145810964f8edd4a5e574","Cargo.toml":"b8ad9f1020eeb1f1e495d7a693c825f7bdc3ee4bf29a72aeacbdef989870c61a","LICENSE":"898b1ae9821e98daf8964c8d6c7f61641f5f5aa78ad500020771c0939ee0dea1","README.md":"d878157a8f65779ef3d2e53d6772f99b5b79d7addccb6d04a2eb681ce1de99e1","src/attr.rs":"d0224a2a9be76743f039c86c1935622ca0b5b2e618b9323149855bf0e326fe48","src/expand.rs":"d2f3af4c987d79def03500d7a8cda1bd18c4da3e8395b500e37241968e38c7e0","src/lib.rs":"040047aa902ff3dc6d1b128a055de13d129d69fcd96b04f036223f4585d1fa1c","tests/async_fn.rs":"472a544e14b2141acd9d63e1cbe49f2610cfe8e924dff67b4d23c6a9121fc90f","tests/destructuring.rs":"26b9800678bad09e06512a113a54556e2fac3ecb15a18dcccefe105fb8911c26","tests/err.rs":"ef46724e62c4c307c2d0306e8689c1d4816df432709bfb7bbace7f8ceb67f86d","tests/fields.rs":"3882bd4e744d6b492f59beac7475e8bf4ff4ca8ad85c6951c305a22c78e75fae","tests/follows_from.rs":"f3cc336dac88533521b4cbe0b378fbcf1fb34e2d41a367b4726e98b49468309f","tests/instrument.rs":"dab616dac11043f82f91efbbb37c0dc5a375e51085449bf0b8d65c619f11166a","tests/levels.rs":"408a8eec7af33deba6a050ea9e59ed11e5e76a393f0a2549b11ddf683c0b785d","tests/names.rs":"5afd6c4d526588bcea3141c130a45a21872956495b6868a01b44ddff57749827","tests/parents.rs":"673d3f81eed6ba433f685ec53fd007c5dd957b97d32499d7ea1537e1f289cb2e","tests/ret.rs":"55473797667240c8f613b277360e68228e40047180b5f2828b13513873b9754e","tests/targets.rs":"95ce1ce1e2d29794062c5b3429d91c1bfaba5813251d5d8440c12cb2db6e11bf","tests/ui.rs":"60ed69aba2cbf4b1a2f42b78703f7f21d8a69f62e39bb0509f6a2224cad9b9de","tests/ui/async_instrument.rs":"00fcde05841e8f9f6cc6f9434f8cc4baed5cf6e3ca73e8faddccbdace14e9485","tests/ui/async_instrument.stderr":"1d650a0914f0f59beeb88946a8ad6991feffe885016462ba917ea8e09792f866","tests/ui/const_instrument.rs":"253160848b023cbf73c3d1dece4969ff892ae9a3149e771159230733fa1cab1b","tests/ui/const_instrument.stderr":"86527fbc2410ceba8f051771fdb4bf71eb853e086a4e4d17353089c65b918c18"},"package":"5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab"}
\ No newline at end of file diff --git a/vendor/tracing-attributes/CHANGELOG.md b/vendor/tracing-attributes/CHANGELOG.md index 42cb09b6a..6df517e85 100644 --- a/vendor/tracing-attributes/CHANGELOG.md +++ b/vendor/tracing-attributes/CHANGELOG.md @@ -1,3 +1,80 @@ +# 0.1.26 (June 21th, 2023) + +This release of `tracing-attributes` fixes warnings due to `allow` attributes in +generated code that allow lints which may not exist on earlier versions of rustc. + +### Fixed + +- Allow `unknown_lints` in macro-generated code ([#2626]) + +Thanks to @mladedav for contributing to this release! + +# 0.1.25 (June 19th, 2023) + +This release of `tracing-attributes` fixes the Clippy lint +[`let_with_type_underscore`] in code generated by the `#[instrument]` +attribute in Rust 1.70+. + +### Fixed + +- Allow [`clippy::let_with_type_underscore`] in macro-generated code ([#2609]) + +Thanks to @coolreader19 for contributing to this release! + +[#2609]: https://github.com/tokio-rs/tracing/pull/2609 + +[`let_with_type_underscore`]: http://rust-lang.github.io/rust-clippy/rust-1.70.0/index.html#let_with_type_underscore + +# 0.1.24 (April 24th, 2023) + +This release of `tracing-attributes` adds support for passing an optional +`level` to the `err` and `ret` arguments to `#[instrument]`, allowing the level +of the generated return-value event to be overridden. For example, + +```rust +#[instrument(err(level = "info"))] +fn my_great_function() -> Result<(), &'static str> { + // ... +} +``` + +will emit an `INFO`-level event if the function returns an `Err`. + +In addition, this release updates the [`syn`] dependency to v2.x.x. + +### Added + +- `level` argument to `err` and `ret` to override the level of the generated + return value event ([#2335]) +- Improved compiler error message when `#[instrument]` is added to a `const fn` + ([#2418]) + +### Changed + +- Updated `syn` dependency to 2.0 ([#2516]) + +### Fixed + +- Fix `clippy::unreachable` warnings in `#[instrument]`-generated code ([#2356]) +- Removed unused "visit" feature flag from `syn` dependency ([#2530]) + +### Documented + +- Documented default level for `err` ([#2433]) +- Improved documentation for levels in `#[instrument]` ([#2350]) + +Thanks to @nitnelave, @jsgf, @Abhicodes-crypto, @LukeMathWalker, @andrewpollack, +@quad, @klensy, @davidpdrsn, and @dbidwell94 for contributign to this release! + +[`syn`]: https://crates.io/crates/syn +[#2335]: https://github.com/tokio-rs/tracing/pull/2335 +[#2418]: https://github.com/tokio-rs/tracing/pull/2418 +[#2516]: https://github.com/tokio-rs/tracing/pull/2516 +[#2356]: https://github.com/tokio-rs/tracing/pull/2356 +[#2530]: https://github.com/tokio-rs/tracing/pull/2530 +[#2433]: https://github.com/tokio-rs/tracing/pull/2433 +[#2350]: https://github.com/tokio-rs/tracing/pull/2350 + # 0.1.23 (October 6, 2022) This release of `tracing-attributes` fixes a bug where compiler diagnostic spans @@ -5,6 +82,7 @@ for type errors in `#[instrument]`ed `async fn`s have the location of the `#[instrument]` attribute rather than the location of the actual error, and a bug where inner attributes in `#[instrument]`ed functions would cause a compiler error. + ### Fixed - Fix incorrect handling of inner attributes in `#[instrument]`ed functions ([#2307]) diff --git a/vendor/tracing-attributes/Cargo.toml b/vendor/tracing-attributes/Cargo.toml index 5639de0b3..281ea1fdc 100644 --- a/vendor/tracing-attributes/Cargo.toml +++ b/vendor/tracing-attributes/Cargo.toml @@ -11,9 +11,9 @@ [package] edition = "2018" -rust-version = "1.49.0" +rust-version = "1.56.0" name = "tracing-attributes" -version = "0.1.23" +version = "0.1.26" authors = [ "Tokio Contributors <team@tokio.rs>", "Eliza Weisman <eliza@buoyant.io>", @@ -43,18 +43,17 @@ repository = "https://github.com/tokio-rs/tracing" proc-macro = true [dependencies.proc-macro2] -version = "1" +version = "1.0.40" [dependencies.quote] -version = "1" +version = "1.0.20" [dependencies.syn] -version = "1.0.98" +version = "2.0" features = [ "full", "parsing", "printing", - "visit", "visit-mut", "clone-impls", "extra-traits", @@ -63,20 +62,17 @@ features = [ default-features = false [dev-dependencies.async-trait] -version = "0.1.56" +version = "0.1.67" [dev-dependencies.rustversion] version = "1.0.9" [dev-dependencies.tokio-test] -version = "0.3.0" +version = "0.4.2" [dev-dependencies.tracing] version = "0.1.35" -[dev-dependencies.tracing-core] -version = "0.1.28" - [dev-dependencies.tracing-subscriber] version = "0.3.0" features = ["env-filter"] diff --git a/vendor/tracing-attributes/README.md b/vendor/tracing-attributes/README.md index 356b511f2..f14dbb62b 100644 --- a/vendor/tracing-attributes/README.md +++ b/vendor/tracing-attributes/README.md @@ -18,7 +18,7 @@ Macro attributes for application-level tracing. [crates-badge]: https://img.shields.io/crates/v/tracing-attributes.svg [crates-url]: https://crates.io/crates/tracing-attributes [docs-badge]: https://docs.rs/tracing-attributes/badge.svg -[docs-url]: https://docs.rs/tracing-attributes/0.1.23 +[docs-url]: https://docs.rs/tracing-attributes/0.1.26 [docs-master-badge]: https://img.shields.io/badge/docs-master-blue [docs-master-url]: https://tracing-rs.netlify.com/tracing_attributes [mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg @@ -37,7 +37,7 @@ structured, event-based diagnostic information. This crate provides the Note that this macro is also re-exported by the main `tracing` crate. -*Compiler support: [requires `rustc` 1.49+][msrv]* +*Compiler support: [requires `rustc` 1.56+][msrv]* [msrv]: #supported-rust-versions @@ -47,7 +47,7 @@ First, add this to your `Cargo.toml`: ```toml [dependencies] -tracing-attributes = "0.1.23" +tracing-attributes = "0.1.26" ``` @@ -69,14 +69,14 @@ pub fn my_function(my_arg: usize) { ## Supported Rust Versions Tracing is built against the latest stable release. The minimum supported -version is 1.49. The current Tracing version is not guaranteed to build on Rust +version is 1.56. The current Tracing version is not guaranteed to build on Rust versions earlier than the minimum supported version. Tracing follows the same compiler support policies as the rest of the Tokio project. The current stable Rust compiler and the three most recent minor versions before it will always be supported. For example, if the current stable -compiler version is 1.45, the minimum supported version will not be increased -past 1.42, three minor versions prior. Increasing the minimum supported compiler +compiler version is 1.69, the minimum supported version will not be increased +past 1.66, three minor versions prior. Increasing the minimum supported compiler version is not considered a semver breaking change as long as doing so complies with this policy. diff --git a/vendor/tracing-attributes/src/attr.rs b/vendor/tracing-attributes/src/attr.rs index ff875e179..f5ad40939 100644 --- a/vendor/tracing-attributes/src/attr.rs +++ b/vendor/tracing-attributes/src/attr.rs @@ -6,6 +6,14 @@ use quote::{quote, quote_spanned, ToTokens}; use syn::ext::IdentExt as _; use syn::parse::{Parse, ParseStream}; +/// Arguments to `#[instrument(err(...))]` and `#[instrument(ret(...))]` which describe how the +/// return value event should be emitted. +#[derive(Clone, Default, Debug)] +pub(crate) struct EventArgs { + level: Option<Level>, + pub(crate) mode: FormatMode, +} + #[derive(Clone, Default, Debug)] pub(crate) struct InstrumentArgs { level: Option<Level>, @@ -16,51 +24,15 @@ pub(crate) struct InstrumentArgs { pub(crate) skips: HashSet<Ident>, pub(crate) skip_all: bool, pub(crate) fields: Option<Fields>, - pub(crate) err_mode: Option<FormatMode>, - pub(crate) ret_mode: Option<FormatMode>, + pub(crate) err_args: Option<EventArgs>, + pub(crate) ret_args: Option<EventArgs>, /// Errors describing any unrecognized parse inputs that we skipped. parse_warnings: Vec<syn::Error>, } impl InstrumentArgs { - pub(crate) fn level(&self) -> impl ToTokens { - fn is_level(lit: &LitInt, expected: u64) -> bool { - match lit.base10_parse::<u64>() { - Ok(value) => value == expected, - Err(_) => false, - } - } - - match &self.level { - Some(Level::Str(ref lit)) if lit.value().eq_ignore_ascii_case("trace") => { - quote!(tracing::Level::TRACE) - } - Some(Level::Str(ref lit)) if lit.value().eq_ignore_ascii_case("debug") => { - quote!(tracing::Level::DEBUG) - } - Some(Level::Str(ref lit)) if lit.value().eq_ignore_ascii_case("info") => { - quote!(tracing::Level::INFO) - } - Some(Level::Str(ref lit)) if lit.value().eq_ignore_ascii_case("warn") => { - quote!(tracing::Level::WARN) - } - Some(Level::Str(ref lit)) if lit.value().eq_ignore_ascii_case("error") => { - quote!(tracing::Level::ERROR) - } - Some(Level::Int(ref lit)) if is_level(lit, 1) => quote!(tracing::Level::TRACE), - Some(Level::Int(ref lit)) if is_level(lit, 2) => quote!(tracing::Level::DEBUG), - Some(Level::Int(ref lit)) if is_level(lit, 3) => quote!(tracing::Level::INFO), - Some(Level::Int(ref lit)) if is_level(lit, 4) => quote!(tracing::Level::WARN), - Some(Level::Int(ref lit)) if is_level(lit, 5) => quote!(tracing::Level::ERROR), - Some(Level::Path(ref pat)) => quote!(#pat), - Some(_) => quote! { - compile_error!( - "unknown verbosity level, expected one of \"trace\", \ - \"debug\", \"info\", \"warn\", or \"error\", or a number 1-5" - ) - }, - None => quote!(tracing::Level::INFO), - } + pub(crate) fn level(&self) -> Level { + self.level.clone().unwrap_or(Level::Info) } pub(crate) fn target(&self) -> impl ToTokens { @@ -167,12 +139,12 @@ impl Parse for InstrumentArgs { args.fields = Some(input.parse()?); } else if lookahead.peek(kw::err) { let _ = input.parse::<kw::err>(); - let mode = FormatMode::parse(input)?; - args.err_mode = Some(mode); + let err_args = EventArgs::parse(input)?; + args.err_args = Some(err_args); } else if lookahead.peek(kw::ret) { let _ = input.parse::<kw::ret>()?; - let mode = FormatMode::parse(input)?; - args.ret_mode = Some(mode); + let ret_args = EventArgs::parse(input)?; + args.ret_args = Some(ret_args); } else if lookahead.peek(Token![,]) { let _ = input.parse::<Token![,]>()?; } else { @@ -190,6 +162,55 @@ impl Parse for InstrumentArgs { } } +impl EventArgs { + pub(crate) fn level(&self, default: Level) -> Level { + self.level.clone().unwrap_or(default) + } +} + +impl Parse for EventArgs { + fn parse(input: ParseStream<'_>) -> syn::Result<Self> { + if !input.peek(syn::token::Paren) { + return Ok(Self::default()); + } + let content; + let _ = syn::parenthesized!(content in input); + let mut result = Self::default(); + let mut parse_one_arg = + || { + let lookahead = content.lookahead1(); + if lookahead.peek(kw::level) { + if result.level.is_some() { + return Err(content.error("expected only a single `level` argument")); + } + result.level = Some(content.parse()?); + } else if result.mode != FormatMode::default() { + return Err(content.error("expected only a single format argument")); + } else if let Some(ident) = content.parse::<Option<Ident>>()? { + match ident.to_string().as_str() { + "Debug" => result.mode = FormatMode::Debug, + "Display" => result.mode = FormatMode::Display, + _ => return Err(syn::Error::new( + ident.span(), + "unknown event formatting mode, expected either `Debug` or `Display`", + )), + } + } + Ok(()) + }; + parse_one_arg()?; + if !content.is_empty() { + if content.lookahead1().peek(Token![,]) { + let _ = content.parse::<Token![,]>()?; + parse_one_arg()?; + } else { + return Err(content.error("expected `,` or `)`")); + } + } + Ok(result) + } +} + struct StrArg<T> { value: LitStr, _p: std::marker::PhantomData<T>, @@ -231,7 +252,7 @@ impl Parse for Skips { let _ = input.parse::<kw::skip>(); let content; let _ = syn::parenthesized!(content in input); - let names: Punctuated<Ident, Token![,]> = content.parse_terminated(Ident::parse_any)?; + let names = content.parse_terminated(Ident::parse_any, Token![,])?; let mut skips = HashSet::new(); for name in names { if skips.contains(&name) { @@ -260,27 +281,6 @@ impl Default for FormatMode { } } -impl Parse for FormatMode { - fn parse(input: ParseStream<'_>) -> syn::Result<Self> { - if !input.peek(syn::token::Paren) { - return Ok(FormatMode::default()); - } - let content; - let _ = syn::parenthesized!(content in input); - let maybe_mode: Option<Ident> = content.parse()?; - maybe_mode.map_or(Ok(FormatMode::default()), |ident| { - match ident.to_string().as_str() { - "Debug" => Ok(FormatMode::Debug), - "Display" => Ok(FormatMode::Display), - _ => Err(syn::Error::new( - ident.span(), - "unknown error mode, must be Debug or Display", - )), - } - }) - } -} - #[derive(Clone, Debug)] pub(crate) struct Fields(pub(crate) Punctuated<Field, Token![,]>); @@ -303,7 +303,7 @@ impl Parse for Fields { let _ = input.parse::<kw::fields>(); let content; let _ = syn::parenthesized!(content in input); - let fields: Punctuated<_, Token![,]> = content.parse_terminated(Field::parse)?; + let fields = content.parse_terminated(Field::parse, Token![,])?; Ok(Self(fields)) } } @@ -348,7 +348,7 @@ impl ToTokens for Field { let name = &self.name; let kind = &self.kind; tokens.extend(quote! { - #name = #kind#value + #name = #kind #value }) } else if self.kind == FieldKind::Value { // XXX(eliza): I don't like that fields without values produce @@ -376,9 +376,12 @@ impl ToTokens for FieldKind { } #[derive(Clone, Debug)] -enum Level { - Str(LitStr), - Int(LitInt), +pub(crate) enum Level { + Trace, + Debug, + Info, + Warn, + Error, Path(Path), } @@ -388,9 +391,37 @@ impl Parse for Level { let _ = input.parse::<Token![=]>()?; let lookahead = input.lookahead1(); if lookahead.peek(LitStr) { - Ok(Self::Str(input.parse()?)) + let str: LitStr = input.parse()?; + match str.value() { + s if s.eq_ignore_ascii_case("trace") => Ok(Level::Trace), + s if s.eq_ignore_ascii_case("debug") => Ok(Level::Debug), + s if s.eq_ignore_ascii_case("info") => Ok(Level::Info), + s if s.eq_ignore_ascii_case("warn") => Ok(Level::Warn), + s if s.eq_ignore_ascii_case("error") => Ok(Level::Error), + _ => Err(input.error( + "unknown verbosity level, expected one of \"trace\", \ + \"debug\", \"info\", \"warn\", or \"error\", or a number 1-5", + )), + } } else if lookahead.peek(LitInt) { - Ok(Self::Int(input.parse()?)) + fn is_level(lit: &LitInt, expected: u64) -> bool { + match lit.base10_parse::<u64>() { + Ok(value) => value == expected, + Err(_) => false, + } + } + let int: LitInt = input.parse()?; + match &int { + i if is_level(i, 1) => Ok(Level::Trace), + i if is_level(i, 2) => Ok(Level::Debug), + i if is_level(i, 3) => Ok(Level::Info), + i if is_level(i, 4) => Ok(Level::Warn), + i if is_level(i, 5) => Ok(Level::Error), + _ => Err(input.error( + "unknown verbosity level, expected one of \"trace\", \ + \"debug\", \"info\", \"warn\", or \"error\", or a number 1-5", + )), + } } else if lookahead.peek(Ident) { Ok(Self::Path(input.parse()?)) } else { @@ -399,6 +430,19 @@ impl Parse for Level { } } +impl ToTokens for Level { + fn to_tokens(&self, tokens: &mut TokenStream) { + match self { + Level::Trace => tokens.extend(quote!(tracing::Level::TRACE)), + Level::Debug => tokens.extend(quote!(tracing::Level::DEBUG)), + Level::Info => tokens.extend(quote!(tracing::Level::INFO)), + Level::Warn => tokens.extend(quote!(tracing::Level::WARN)), + Level::Error => tokens.extend(quote!(tracing::Level::ERROR)), + Level::Path(ref pat) => tokens.extend(quote!(#pat)), + } + } +} + mod kw { syn::custom_keyword!(fields); syn::custom_keyword!(skip); diff --git a/vendor/tracing-attributes/src/expand.rs b/vendor/tracing-attributes/src/expand.rs index 7005b4423..eb7be8f47 100644 --- a/vendor/tracing-attributes/src/expand.rs +++ b/vendor/tracing-attributes/src/expand.rs @@ -10,7 +10,7 @@ use syn::{ }; use crate::{ - attr::{Field, Fields, FormatMode, InstrumentArgs}, + attr::{Field, Fields, FormatMode, InstrumentArgs, Level}, MaybeItemFn, MaybeItemFnRef, }; @@ -64,7 +64,10 @@ pub(crate) fn gen_function<'a, B: ToTokens + 'a>( // unreachable, but does affect inference, so it needs to be written // exactly that way for it to do its magic. let fake_return_edge = quote_spanned! {return_span=> - #[allow(unreachable_code, clippy::diverging_sub_expression, clippy::let_unit_value)] + #[allow( + unknown_lints, unreachable_code, clippy::diverging_sub_expression, + clippy::let_unit_value, clippy::unreachable, clippy::let_with_type_underscore + )] if false { let __tracing_attr_fake_return: #return_type = unreachable!("this is just for type inference, and is unreachable code"); @@ -116,7 +119,8 @@ fn gen_block<B: ToTokens>( .map(|name| quote!(#name)) .unwrap_or_else(|| quote!(#instrumented_function_name)); - let level = args.level(); + let args_level = args.level(); + let level = args_level.clone(); let follows_from = args.follows_from.iter(); let follows_from = quote! { @@ -134,7 +138,7 @@ fn gen_block<B: ToTokens>( .into_iter() .flat_map(|param| match param { FnArg::Typed(PatType { pat, ty, .. }) => { - param_names(*pat, RecordType::parse_from_ty(&*ty)) + param_names(*pat, RecordType::parse_from_ty(&ty)) } FnArg::Receiver(_) => Box::new(iter::once(( Ident::new("self", param.span()), @@ -232,21 +236,33 @@ fn gen_block<B: ToTokens>( let target = args.target(); - let err_event = match args.err_mode { - Some(FormatMode::Default) | Some(FormatMode::Display) => { - Some(quote!(tracing::error!(target: #target, error = %e))) + let err_event = match args.err_args { + Some(event_args) => { + let level_tokens = event_args.level(Level::Error); + match event_args.mode { + FormatMode::Default | FormatMode::Display => Some(quote!( + tracing::event!(target: #target, #level_tokens, error = %e) + )), + FormatMode::Debug => Some(quote!( + tracing::event!(target: #target, #level_tokens, error = ?e) + )), + } } - Some(FormatMode::Debug) => Some(quote!(tracing::error!(target: #target, error = ?e))), _ => None, }; - let ret_event = match args.ret_mode { - Some(FormatMode::Display) => Some(quote!( - tracing::event!(target: #target, #level, return = %x) - )), - Some(FormatMode::Default) | Some(FormatMode::Debug) => Some(quote!( - tracing::event!(target: #target, #level, return = ?x) - )), + let ret_event = match args.ret_args { + Some(event_args) => { + let level_tokens = event_args.level(args_level); + match event_args.mode { + FormatMode::Display => Some(quote!( + tracing::event!(target: #target, #level_tokens, return = %x) + )), + FormatMode::Default | FormatMode::Debug => Some(quote!( + tracing::event!(target: #target, #level_tokens, return = ?x) + )), + } + } _ => None, }; @@ -464,10 +480,7 @@ fn param_names(pat: Pat, record_type: RecordType) -> Box<dyn Iterator<Item = (Id .into_iter() .flat_map(|p| param_names(p, RecordType::Debug)), ), - Pat::TupleStruct(PatTupleStruct { - pat: PatTuple { elems, .. }, - .. - }) => Box::new( + Pat::TupleStruct(PatTupleStruct { elems, .. }) => Box::new( elems .into_iter() .flat_map(|p| param_names(p, RecordType::Debug)), @@ -551,7 +564,7 @@ impl<'block> AsyncInfo<'block> { // last expression of the block: it determines the return value of the // block, this is quite likely a `Box::pin` statement or an async block let (last_expr_stmt, last_expr) = block.stmts.iter().rev().find_map(|stmt| { - if let Stmt::Expr(expr) = stmt { + if let Stmt::Expr(expr, _semi) = stmt { Some((stmt, expr)) } else { None diff --git a/vendor/tracing-attributes/src/lib.rs b/vendor/tracing-attributes/src/lib.rs index f5974e4e5..c7477946d 100644 --- a/vendor/tracing-attributes/src/lib.rs +++ b/vendor/tracing-attributes/src/lib.rs @@ -6,17 +6,17 @@ //! //! Note that this macro is also re-exported by the main `tracing` crate. //! -//! *Compiler support: [requires `rustc` 1.49+][msrv]* +//! *Compiler support: [requires `rustc` 1.56+][msrv]* //! //! [msrv]: #supported-rust-versions //! //! ## Usage //! -//! First, add this to your `Cargo.toml`: +//! In the `Cargo.toml`: //! //! ```toml //! [dependencies] -//! tracing-attributes = "0.1.23" +//! tracing-attributes = "0.1.24" //! ``` //! //! The [`#[instrument]`][instrument] attribute can now be added to a function @@ -24,7 +24,7 @@ //! called. For example: //! //! ``` -//! use tracing_attributes::instrument; +//! use tracing::instrument; //! //! #[instrument] //! pub fn my_function(my_arg: usize) { @@ -41,18 +41,17 @@ //! ## Supported Rust Versions //! //! Tracing is built against the latest stable release. The minimum supported -//! version is 1.49. The current Tracing version is not guaranteed to build on +//! version is 1.56. The current Tracing version is not guaranteed to build on //! Rust versions earlier than the minimum supported version. //! //! Tracing follows the same compiler support policies as the rest of the Tokio //! project. The current stable Rust compiler and the three most recent minor //! versions before it will always be supported. For example, if the current -//! stable compiler version is 1.45, the minimum supported version will not be -//! increased past 1.42, three minor versions prior. Increasing the minimum +//! stable compiler version is 1.69, the minimum supported version will not be +//! increased past 1.66, three minor versions prior. Increasing the minimum //! supported compiler version is not considered a semver breaking change as //! long as doing so complies with this policy. //! -#![doc(html_root_url = "https://docs.rs/tracing-attributes/0.1.23")] #![doc( html_logo_url = "https://raw.githubusercontent.com/tokio-rs/tracing/master/assets/logo-type.png", issue_tracker_base_url = "https://github.com/tokio-rs/tracing/issues/" @@ -64,7 +63,6 @@ rust_2018_idioms, unreachable_pub, bad_style, - const_err, dead_code, improper_ctypes, non_shorthand_field_patterns, @@ -84,7 +82,7 @@ extern crate proc_macro; use proc_macro2::TokenStream; -use quote::ToTokens; +use quote::{quote, ToTokens}; use syn::parse::{Parse, ParseStream}; use syn::{Attribute, ItemFn, Signature, Visibility}; @@ -205,16 +203,17 @@ mod expand; /// /// # Adding Fields /// -/// Additional fields (key-value pairs with arbitrary data) may be added to the -/// generated span using the `fields` argument on the `#[instrument]` macro. Any +/// Additional fields (key-value pairs with arbitrary data) can be passed to +/// to the generated span through the `fields` argument on the +/// `#[instrument]` macro. Strings, integers or boolean literals are accepted values +/// for each field. The name of the field must be a single valid Rust +/// identifier, nested (dotted) field names are not supported. Any /// Rust expression can be used as a field value in this manner. These /// expressions will be evaluated at the beginning of the function's body, so /// arguments to the function may be used in these expressions. Field names may /// also be specified *without* values. Doing so will result in an [empty field] /// whose value may be recorded later within the function body. /// -/// This supports the same [field syntax] as the `span!` and `event!` macros. -/// /// Note that overlap between the names of fields and (non-skipped) arguments /// will result in a compile error. /// @@ -324,11 +323,15 @@ mod expand; /// Setting the level for the generated span: /// ``` /// # use tracing_attributes::instrument; -/// #[instrument(level = "debug")] +/// # use tracing::Level; +/// #[instrument(level = Level::DEBUG)] /// pub fn my_function() { /// // ... /// } /// ``` +/// Levels can be specified either with [`Level`] constants, literal strings +/// (e.g., `"debug"`, `"info"`) or numerically (1—5, corresponding to [`Level::TRACE`]—[`Level::ERROR`]). +/// /// Overriding the generated span's name: /// ``` /// # use tracing_attributes::instrument; @@ -399,7 +402,7 @@ mod expand; /// } /// ``` /// -/// To add an additional context to the span, pass key-value pairs to `fields`: +/// To add additional context to the span, pass key-value pairs to `fields`: /// /// ``` /// # use tracing_attributes::instrument; @@ -423,6 +426,17 @@ mod expand; /// By default, this will be [`INFO`], but if the level is overridden, the event will be at the same /// level. /// +/// It's also possible to override the level for the `ret` event independently: +/// +/// ``` +/// # use tracing_attributes::instrument; +/// # use tracing::Level; +/// #[instrument(ret(level = Level::WARN))] +/// fn my_function() -> i32 { +/// 42 +/// } +/// ``` +/// /// **Note**: if the function returns a `Result<T, E>`, `ret` will record returned values if and /// only if the function returns [`Result::Ok`]. /// @@ -438,8 +452,8 @@ mod expand; /// } /// ``` /// -/// If the function returns a `Result<T, E>` and `E` implements `std::fmt::Display`, you can add -/// `err` or `err(Display)` to emit error events when the function returns `Err`: +/// If the function returns a `Result<T, E>` and `E` implements `std::fmt::Display`, adding +/// `err` or `err(Display)` will emit error events when the function returns `Err`: /// /// ``` /// # use tracing_attributes::instrument; @@ -449,9 +463,22 @@ mod expand; /// } /// ``` /// +/// The level of the error value event defaults to `ERROR`. +/// +/// Similarly, overriding the level of the `err` event : +/// +/// ``` +/// # use tracing_attributes::instrument; +/// # use tracing::Level; +/// #[instrument(err(level = Level::INFO))] +/// fn my_function(arg: usize) -> Result<(), std::io::Error> { +/// Ok(()) +/// } +/// ``` +/// /// By default, error values will be recorded using their `std::fmt::Display` implementations. /// If an error implements `std::fmt::Debug`, it can be recorded using its `Debug` implementation -/// instead, by writing `err(Debug)`: +/// instead by writing `err(Debug)`: /// /// ``` /// # use tracing_attributes::instrument; @@ -510,32 +537,13 @@ mod expand; /// } /// ``` /// -/// Note than on `async-trait` <= 0.1.43, references to the `Self` -/// type inside the `fields` argument were only allowed when the instrumented -/// function is a method (i.e., the function receives `self` as an argument). -/// For example, this *used to not work* because the instrument function -/// didn't receive `self`: -/// ``` -/// # use tracing::instrument; -/// use async_trait::async_trait; +/// `const fn` cannot be instrumented, and will result in a compilation failure: /// -/// #[async_trait] -/// pub trait Bar { -/// async fn bar(); -/// } -/// -/// #[derive(Debug)] -/// struct BarImpl(usize); -/// -/// #[async_trait] -/// impl Bar for BarImpl { -/// #[instrument(fields(tmp = std::any::type_name::<Self>()))] -/// async fn bar() {} -/// } +/// ```compile_fail +/// # use tracing_attributes::instrument; +/// #[instrument] +/// const fn my_const_function() {} /// ``` -/// Instead, you should manually rewrite any `Self` types as the type for -/// which you implement the trait: `#[instrument(fields(tmp = std::any::type_name::<Bar>()))]` -/// (or maybe you can just bump `async-trait`). /// /// [span]: https://docs.rs/tracing/latest/tracing/span/index.html /// [name]: https://docs.rs/tracing/latest/tracing/struct.Metadata.html#method.name @@ -548,6 +556,9 @@ mod expand; /// [`follows_from`]: https://docs.rs/tracing/latest/tracing/struct.Span.html#method.follows_from /// [`tracing`]: https://github.com/tokio-rs/tracing /// [`fmt::Debug`]: std::fmt::Debug +/// [`Level`]: https://docs.rs/tracing/latest/tracing/struct.Level.html +/// [`Level::TRACE`]: https://docs.rs/tracing/latest/tracing/struct.Level.html#associatedconstant.TRACE +/// [`Level::ERROR`]: https://docs.rs/tracing/latest/tracing/struct.Level.html#associatedconstant.ERROR #[proc_macro_attribute] pub fn instrument( args: proc_macro::TokenStream, @@ -584,6 +595,13 @@ fn instrument_precise( let input = syn::parse::<ItemFn>(item)?; let instrumented_function_name = input.sig.ident.to_string(); + if input.sig.constness.is_some() { + return Ok(quote! { + compile_error!("the `#[instrument]` attribute may not be used with `const fn`s") + } + .into()); + } + // check for async_trait-like patterns in the block, and instrument // the future instead of the wrapper if let Some(async_like) = expand::AsyncInfo::from_fn(&input) { diff --git a/vendor/tracing-attributes/tests/async_fn.rs b/vendor/tracing-attributes/tests/async_fn.rs index c89963672..d6d874ffd 100644 --- a/vendor/tracing-attributes/tests/async_fn.rs +++ b/vendor/tracing-attributes/tests/async_fn.rs @@ -90,6 +90,8 @@ fn async_fn_only_enters_for_polls() { .exit(span::mock().named("test_async_fn")) .enter(span::mock().named("test_async_fn")) .exit(span::mock().named("test_async_fn")) + .enter(span::mock().named("test_async_fn")) + .exit(span::mock().named("test_async_fn")) .drop_span(span::mock().named("test_async_fn")) .done() .run_with_handle(); @@ -120,8 +122,12 @@ fn async_fn_nested() { .enter(span2.clone()) .event(event::mock().with_fields(field::mock("nested").with_value(&true))) .exit(span2.clone()) + .enter(span2.clone()) + .exit(span2.clone()) .drop_span(span2) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -199,13 +205,19 @@ fn async_fn_with_async_trait() { .enter(span3.clone()) .event(event::mock().with_fields(field::mock("val").with_value(&2u64))) .exit(span3.clone()) + .enter(span3.clone()) + .exit(span3.clone()) .drop_span(span3) .new_span(span2.clone().with_field(field::mock("self"))) .enter(span2.clone()) .event(event::mock().with_fields(field::mock("val").with_value(&5u64))) .exit(span2.clone()) + .enter(span2.clone()) + .exit(span2.clone()) .drop_span(span2) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -256,6 +268,8 @@ fn async_fn_with_async_trait_and_fields_expressions() { ) .enter(span.clone()) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -331,8 +345,12 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() { .with_field(field::mock("Self").with_value(&std::any::type_name::<TestImpl>())), ) .enter(span4.clone()) + .exit(span4.clone()) + .enter(span4.clone()) .exit(span4) .exit(span2.clone()) + .enter(span2.clone()) + .exit(span2.clone()) .drop_span(span2) .new_span( span3 @@ -341,6 +359,8 @@ fn async_fn_with_async_trait_and_fields_expressions_with_generic_parameter() { ) .enter(span3.clone()) .exit(span3.clone()) + .enter(span3.clone()) + .exit(span3.clone()) .drop_span(span3) .done() .run_with_handle(); @@ -382,6 +402,8 @@ fn out_of_scope_fields() { .new_span(span.clone()) .enter(span.clone()) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -417,6 +439,8 @@ fn manual_impl_future() { .enter(span.clone()) .event(poll_event()) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -448,6 +472,8 @@ fn manual_box_pin() { .enter(span.clone()) .event(poll_event()) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); diff --git a/vendor/tracing-attributes/tests/err.rs b/vendor/tracing-attributes/tests/err.rs index 9e6d6b78c..485dd1196 100644 --- a/vendor/tracing-attributes/tests/err.rs +++ b/vendor/tracing-attributes/tests/err.rs @@ -57,6 +57,8 @@ fn test_async() { .enter(span.clone()) .event(event::mock().at_level(Level::ERROR)) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -111,6 +113,8 @@ fn test_mut_async() { .enter(span.clone()) .event(event::mock().at_level(Level::ERROR)) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -231,3 +235,72 @@ fn test_err_custom_target() { }); handle.assert_finished(); } + +#[instrument(err(level = "info"))] +fn err_info() -> Result<u8, TryFromIntError> { + u8::try_from(1234) +} + +#[test] +fn test_err_info() { + let span = span::mock().named("err_info"); + let (subscriber, handle) = subscriber::mock() + .new_span(span.clone()) + .enter(span.clone()) + .event(event::mock().at_level(Level::INFO)) + .exit(span.clone()) + .drop_span(span) + .done() + .run_with_handle(); + with_default(subscriber, || err_info().ok()); + handle.assert_finished(); +} + +#[instrument(err(Debug, level = "info"))] +fn err_dbg_info() -> Result<u8, TryFromIntError> { + u8::try_from(1234) +} + +#[test] +fn test_err_dbg_info() { + let span = span::mock().named("err_dbg_info"); + let (subscriber, handle) = subscriber::mock() + .new_span(span.clone()) + .enter(span.clone()) + .event( + event::mock().at_level(Level::INFO).with_fields( + field::mock("error") + // use the actual error value that will be emitted, so + // that this test doesn't break if the standard library + // changes the `fmt::Debug` output from the error type + // in the future. + .with_value(&tracing::field::debug(u8::try_from(1234).unwrap_err())), + ), + ) + .exit(span.clone()) + .drop_span(span) + .done() + .run_with_handle(); + with_default(subscriber, || err_dbg_info().ok()); + handle.assert_finished(); +} + +#[instrument(level = "warn", err(level = "info"))] +fn err_warn_info() -> Result<u8, TryFromIntError> { + u8::try_from(1234) +} + +#[test] +fn test_err_warn_info() { + let span = span::mock().named("err_warn_info").at_level(Level::WARN); + let (subscriber, handle) = subscriber::mock() + .new_span(span.clone()) + .enter(span.clone()) + .event(event::mock().at_level(Level::INFO)) + .exit(span.clone()) + .drop_span(span) + .done() + .run_with_handle(); + with_default(subscriber, || err_warn_info().ok()); + handle.assert_finished(); +} diff --git a/vendor/tracing-attributes/tests/follows_from.rs b/vendor/tracing-attributes/tests/follows_from.rs index da0eec635..a589409de 100644 --- a/vendor/tracing-attributes/tests/follows_from.rs +++ b/vendor/tracing-attributes/tests/follows_from.rs @@ -58,6 +58,8 @@ fn follows_from_async_test() { .follows_from(consequence.clone(), cause_b) .follows_from(consequence.clone(), cause_c) .enter(consequence.clone()) + .exit(consequence.clone()) + .enter(consequence.clone()) .exit(consequence) .done() .run_with_handle(); diff --git a/vendor/tracing-attributes/tests/instrument.rs b/vendor/tracing-attributes/tests/instrument.rs index 768692748..b215b8455 100644 --- a/vendor/tracing-attributes/tests/instrument.rs +++ b/vendor/tracing-attributes/tests/instrument.rs @@ -17,7 +17,7 @@ fn override_everything() { #[instrument(target = "my_target", level = "debug")] fn my_fn() {} - #[instrument(level = "debug", target = "my_target")] + #[instrument(level = Level::DEBUG, target = "my_target")] fn my_other_fn() {} let span = span::mock() diff --git a/vendor/tracing-attributes/tests/levels.rs b/vendor/tracing-attributes/tests/levels.rs index b074ea4f2..94fc7e85a 100644 --- a/vendor/tracing-attributes/tests/levels.rs +++ b/vendor/tracing-attributes/tests/levels.rs @@ -94,3 +94,49 @@ fn numeric_levels() { handle.assert_finished(); } + +#[test] +fn enum_levels() { + #[instrument(level = Level::TRACE)] + fn trace() {} + + #[instrument(level = Level::DEBUG)] + fn debug() {} + + #[instrument(level = tracing::Level::INFO)] + fn info() {} + + #[instrument(level = Level::WARN)] + fn warn() {} + + #[instrument(level = Level::ERROR)] + fn error() {} + let (subscriber, handle) = subscriber::mock() + .new_span(span::mock().named("trace").at_level(Level::TRACE)) + .enter(span::mock().named("trace").at_level(Level::TRACE)) + .exit(span::mock().named("trace").at_level(Level::TRACE)) + .new_span(span::mock().named("debug").at_level(Level::DEBUG)) + .enter(span::mock().named("debug").at_level(Level::DEBUG)) + .exit(span::mock().named("debug").at_level(Level::DEBUG)) + .new_span(span::mock().named("info").at_level(Level::INFO)) + .enter(span::mock().named("info").at_level(Level::INFO)) + .exit(span::mock().named("info").at_level(Level::INFO)) + .new_span(span::mock().named("warn").at_level(Level::WARN)) + .enter(span::mock().named("warn").at_level(Level::WARN)) + .exit(span::mock().named("warn").at_level(Level::WARN)) + .new_span(span::mock().named("error").at_level(Level::ERROR)) + .enter(span::mock().named("error").at_level(Level::ERROR)) + .exit(span::mock().named("error").at_level(Level::ERROR)) + .done() + .run_with_handle(); + + with_default(subscriber, || { + trace(); + debug(); + info(); + warn(); + error(); + }); + + handle.assert_finished(); +} diff --git a/vendor/tracing-attributes/tests/ret.rs b/vendor/tracing-attributes/tests/ret.rs index cfd2de10d..f56c80baa 100644 --- a/vendor/tracing-attributes/tests/ret.rs +++ b/vendor/tracing-attributes/tests/ret.rs @@ -138,6 +138,8 @@ fn test_async() { .at_level(Level::INFO), ) .exit(span.clone()) + .enter(span.clone()) + .exit(span.clone()) .drop_span(span) .done() .run_with_handle(); @@ -253,3 +255,53 @@ fn test_ret_and_ok() { with_default(subscriber, || ret_and_ok().ok()); handle.assert_finished(); } + +#[instrument(level = "warn", ret(level = "info"))] +fn ret_warn_info() -> i32 { + 42 +} + +#[test] +fn test_warn_info() { + let span = span::mock().named("ret_warn_info").at_level(Level::WARN); + let (subscriber, handle) = subscriber::mock() + .new_span(span.clone()) + .enter(span.clone()) + .event( + event::mock() + .with_fields(field::mock("return").with_value(&tracing::field::debug(42))) + .at_level(Level::INFO), + ) + .exit(span.clone()) + .drop_span(span) + .done() + .run_with_handle(); + + with_default(subscriber, ret_warn_info); + handle.assert_finished(); +} + +#[instrument(ret(level = "warn", Debug))] +fn ret_dbg_warn() -> i32 { + 42 +} + +#[test] +fn test_dbg_warn() { + let span = span::mock().named("ret_dbg_warn").at_level(Level::INFO); + let (subscriber, handle) = subscriber::mock() + .new_span(span.clone()) + .enter(span.clone()) + .event( + event::mock() + .with_fields(field::mock("return").with_value(&tracing::field::debug(42))) + .at_level(Level::WARN), + ) + .exit(span.clone()) + .drop_span(span) + .done() + .run_with_handle(); + + with_default(subscriber, ret_dbg_warn); + handle.assert_finished(); +} diff --git a/vendor/tracing-attributes/tests/ui.rs b/vendor/tracing-attributes/tests/ui.rs index f11cc019e..73d7fdcef 100644 --- a/vendor/tracing-attributes/tests/ui.rs +++ b/vendor/tracing-attributes/tests/ui.rs @@ -5,3 +5,10 @@ fn async_instrument() { let t = trybuild::TestCases::new(); t.compile_fail("tests/ui/async_instrument.rs"); } + +#[rustversion::stable] +#[test] +fn const_instrument() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/const_instrument.rs"); +} diff --git a/vendor/tracing-attributes/tests/ui/async_instrument.stderr b/vendor/tracing-attributes/tests/ui/async_instrument.stderr index db6f6b434..2c64b0c15 100644 --- a/vendor/tracing-attributes/tests/ui/async_instrument.stderr +++ b/vendor/tracing-attributes/tests/ui/async_instrument.stderr @@ -16,7 +16,7 @@ error[E0308]: mismatched types 10 | "" | ^^- help: try using a conversion method: `.to_string()` | | - | expected struct `String`, found `&str` + | expected `String`, found `&str` | note: return type inferred to be `String` here --> tests/ui/async_instrument.rs:9:31 @@ -47,7 +47,7 @@ error[E0308]: mismatched types --> tests/ui/async_instrument.rs:23:5 | 23 | "" - | ^^ expected struct `Wrapper`, found `&str` + | ^^ expected `Wrapper<_>`, found `&str` | = note: expected struct `Wrapper<_>` found reference `&'static str` @@ -79,7 +79,7 @@ error[E0308]: mismatched types 36 | return ""; | ^^- help: try using a conversion method: `.to_string()` | | - | expected struct `String`, found `&str` + | expected `String`, found `&str` | note: return type inferred to be `String` here --> tests/ui/async_instrument.rs:34:28 @@ -93,6 +93,6 @@ error[E0308]: mismatched types 42 | async fn extra_semicolon() -> i32 { | ___________________________________^ 43 | | 1; - | | - help: remove this semicolon + | | - help: remove this semicolon to return this value 44 | | } | |_^ expected `i32`, found `()` diff --git a/vendor/tracing-attributes/tests/ui/const_instrument.rs b/vendor/tracing-attributes/tests/ui/const_instrument.rs new file mode 100644 index 000000000..a251e8f66 --- /dev/null +++ b/vendor/tracing-attributes/tests/ui/const_instrument.rs @@ -0,0 +1,8 @@ +#![allow(unreachable_code)] + +#[tracing::instrument] +const fn unit() { + "" +} + +fn main() {} diff --git a/vendor/tracing-attributes/tests/ui/const_instrument.stderr b/vendor/tracing-attributes/tests/ui/const_instrument.stderr new file mode 100644 index 000000000..e76d4acad --- /dev/null +++ b/vendor/tracing-attributes/tests/ui/const_instrument.stderr @@ -0,0 +1,15 @@ +error: macros that expand to items must be delimited with braces or followed by a semicolon + --> tests/ui/const_instrument.rs:3:1 + | +3 | #[tracing::instrument] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `tracing::instrument` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: the `#[instrument]` attribute may not be used with `const fn`s + --> tests/ui/const_instrument.rs:3:1 + | +3 | #[tracing::instrument] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `tracing::instrument` (in Nightly builds, run with -Z macro-backtrace for more info) |