summaryrefslogtreecommitdiffstats
path: root/vendor/rustversion
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:19 +0000
commita0b8f38ab54ac451646aa00cd5e91b6c76f22a84 (patch)
treefc451898ccaf445814e26b46664d78702178101d /vendor/rustversion
parentAdding debian version 1.71.1+dfsg1-2. (diff)
downloadrustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.tar.xz
rustc-a0b8f38ab54ac451646aa00cd5e91b6c76f22a84.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustversion')
-rw-r--r--vendor/rustversion/.cargo-checksum.json2
-rw-r--r--vendor/rustversion/Cargo.toml21
-rw-r--r--vendor/rustversion/LICENSE-APACHE25
-rw-r--r--vendor/rustversion/README.md4
-rw-r--r--vendor/rustversion/build/build.rs82
-rw-r--r--vendor/rustversion/build/rustc.rs20
-rw-r--r--vendor/rustversion/src/expand.rs72
-rw-r--r--vendor/rustversion/src/lib.rs111
-rw-r--r--vendor/rustversion/tests/compiletest.rs1
-rw-r--r--vendor/rustversion/tests/test_const.rs2
-rw-r--r--vendor/rustversion/tests/test_parse.rs13
-rw-r--r--vendor/rustversion/tests/ui/bad-bound.stderr4
-rw-r--r--vendor/rustversion/tests/ui/bad-date.stderr4
-rw-r--r--vendor/rustversion/tests/ui/bad-not.stderr4
-rw-r--r--vendor/rustversion/tests/ui/bad-version.stderr4
-rw-r--r--vendor/rustversion/tests/ui/const-not-fn.stderr2
16 files changed, 211 insertions, 160 deletions
diff --git a/vendor/rustversion/.cargo-checksum.json b/vendor/rustversion/.cargo-checksum.json
index 0a134695a..4e9dbfced 100644
--- a/vendor/rustversion/.cargo-checksum.json
+++ b/vendor/rustversion/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"a09ee758f816eddff8a8c7fb5be54dd95e74caad18a207251faedd251ecfaf1c","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"01dc6a1bf499a12bd0bfbbfe4db2ca8460b2c151235bcf2aad2356de4c2ec50a","build/build.rs":"bae427f344972e6e0e348ec48dce0947274b3ec6cac0938497a8d3da5c9834e5","build/rustc.rs":"3e4acf7ea679f9331dd4e8dbe42a08a312f58379ea1eee5898793a9848d06d8c","src/attr.rs":"9301cd4aff5a9648c057d5d8de9eb66921f0c3a715c51ada4459576bd49c8b19","src/bound.rs":"44bda74d3aacfeeeac9dae2f7eef3acc844d4c3c7eaa9d3e6288e5aeff269dff","src/constfn.rs":"613b8f53b21cc06b4f619fce9000993d3e7873b650701ca01cef1e53bed5b40a","src/date.rs":"454c749a60db8144a706a813e06fe3ae39c981920ba9832ef82f3f9debe1f052","src/error.rs":"cb37102f03ebbaca313d80f9714fe08dfef92fe956789ee87d93eb6121705f4f","src/expr.rs":"8e8ca76f4f5838436d9d7273f499c698bb41f6c15bc07d32ec5c1cb8bd3dd731","src/iter.rs":"8d4b817b9abc4e817105b673e15f29ef9bb8284a010ce01ac2d83387fe136947","src/lib.rs":"5652f6f84fc80136bd29b2125f7676e80e0df7d40aac274b0658c99cecbd871d","src/release.rs":"abb8ddd877c39a023bf5e7bd67063d6e4144e79758a8bafa338167f9d15b89f1","src/time.rs":"bdd05a743b07a6bbfa0dbc9d4e415e051aba4a51a430c3be1e23447eae298c8b","src/token.rs":"824ce765f692db73afa02d3ebb0281c750748035efc98fa547be29d3072665ce","src/version.rs":"afdb048bba95bbb885945eba5527b6bf0eca0105642bfc304c2f82a8b7d556df","tests/compiletest.rs":"0a52a44786aea1c299c695bf948b2ed2081e4cc344e5c2cadceab4eb03d0010d","tests/test_const.rs":"a8297ca6559f895a3b2664964a42b6f82bbbc3c8faa9556a513006e6e1827995","tests/test_eval.rs":"6f0ee3f49c9a0d0c374a4d0e9a9dce753cd9fc2ca7725e000a435dbd5f4a9ce3","tests/test_parse.rs":"cdfe376020b9391330292968046117b0935c828d73385e8faeb2e333ec897088","tests/ui/bad-bound.rs":"25bde278fcaabf62868417148a5e5f2006bf589d7ebd7bf6004fb8d78e47594f","tests/ui/bad-bound.stderr":"a03dc78b380191c10d3b3406b1fd3208bb2609d4c26b9c33ccd335721e3cd072","tests/ui/bad-date.rs":"6e23714dae8b6346fefe50dacd4abba3265248bbadfdd60c739138aa8a0037ba","tests/ui/bad-date.stderr":"3a607fb950a69f7dc1b503295bce53541f9dee9f4674edc5d13ee3a69ff0e8cd","tests/ui/bad-not.rs":"f003df8bd245e9dd8edc3a6d94078ee5162fac7a98db881271f0f5b6db98d45d","tests/ui/bad-not.stderr":"d4ef78fae4a82419e737757158796cb103a5920df498956eaf57ed201797b463","tests/ui/bad-version.rs":"f4ea2cd038e6c63deb9c2e3ceffce93dbf179d9ce18c16d88f3b6cd7138a8c8e","tests/ui/bad-version.stderr":"60ed51c62f4c2fb6ff95cff7523cfca379ed434f319da9d82704318588792338","tests/ui/const-not-fn.rs":"10bbe38f0d89391fff0698756e4cfd4e72a41090360393a0c951b67df14d1c35","tests/ui/const-not-fn.stderr":"9551f7f222445b31d7af2415d467301c332d55bb3d5a143846484f2f00047a01"},"package":"61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088"} \ No newline at end of file
+{"files":{"Cargo.toml":"8170d87c04bae72045b64d66678864b3f228ff77b0ea822aaedcc321b7b7d70f","LICENSE-APACHE":"62c7a1e35f56406896d7aa7ca52d0cc0d272ac022b5d2796e7d6905db8a3636a","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","README.md":"9ba51325297bd22446d8cc89b60e10aaedc0a248ddaad9f12322e233032ac595","build/build.rs":"a5ac3f88a152167bdf624d18346b6db6459828bdbd1162a275fcde9c36e3ade6","build/rustc.rs":"0de80a0590facf36d76fa89c566789c774f5bfc3b787fe8d5b61f668deaed3f9","src/attr.rs":"9301cd4aff5a9648c057d5d8de9eb66921f0c3a715c51ada4459576bd49c8b19","src/bound.rs":"44bda74d3aacfeeeac9dae2f7eef3acc844d4c3c7eaa9d3e6288e5aeff269dff","src/constfn.rs":"613b8f53b21cc06b4f619fce9000993d3e7873b650701ca01cef1e53bed5b40a","src/date.rs":"454c749a60db8144a706a813e06fe3ae39c981920ba9832ef82f3f9debe1f052","src/error.rs":"cb37102f03ebbaca313d80f9714fe08dfef92fe956789ee87d93eb6121705f4f","src/expand.rs":"cfd1772b1af090532de1f318e1b61cc79c8004941a8c56a1a7f4962324b81c9d","src/expr.rs":"8e8ca76f4f5838436d9d7273f499c698bb41f6c15bc07d32ec5c1cb8bd3dd731","src/iter.rs":"8d4b817b9abc4e817105b673e15f29ef9bb8284a010ce01ac2d83387fe136947","src/lib.rs":"9ff11ad47fe4633bd4f1ed745221e393fda194f5be0cec8e4b28ae574a31394f","src/release.rs":"abb8ddd877c39a023bf5e7bd67063d6e4144e79758a8bafa338167f9d15b89f1","src/time.rs":"bdd05a743b07a6bbfa0dbc9d4e415e051aba4a51a430c3be1e23447eae298c8b","src/token.rs":"824ce765f692db73afa02d3ebb0281c750748035efc98fa547be29d3072665ce","src/version.rs":"afdb048bba95bbb885945eba5527b6bf0eca0105642bfc304c2f82a8b7d556df","tests/compiletest.rs":"022a8e400ef813d7ea1875b944549cee5125f6a995dc33e93b48cba3e1b57bd1","tests/test_const.rs":"44d72ea92a81544692ccabe7e93f5d560d29828e79835e9f9839fbb40acc499a","tests/test_eval.rs":"6f0ee3f49c9a0d0c374a4d0e9a9dce753cd9fc2ca7725e000a435dbd5f4a9ce3","tests/test_parse.rs":"a9d262ea18109f792da719c29f3434a2f6a5e5723286385a099359795495b6fb","tests/ui/bad-bound.rs":"25bde278fcaabf62868417148a5e5f2006bf589d7ebd7bf6004fb8d78e47594f","tests/ui/bad-bound.stderr":"96b5549a312cd64d503c560026a6f0e97ac2173fe7c136a14425f19dcb5968e3","tests/ui/bad-date.rs":"6e23714dae8b6346fefe50dacd4abba3265248bbadfdd60c739138aa8a0037ba","tests/ui/bad-date.stderr":"3cc6d10572b80d397954737340d444c541d2c0e54e7d26495861d6189b6b2a55","tests/ui/bad-not.rs":"f003df8bd245e9dd8edc3a6d94078ee5162fac7a98db881271f0f5b6db98d45d","tests/ui/bad-not.stderr":"1aebb3121d067d432a32dd95ff380ceac15a0531c34f90cee950582558841c56","tests/ui/bad-version.rs":"f4ea2cd038e6c63deb9c2e3ceffce93dbf179d9ce18c16d88f3b6cd7138a8c8e","tests/ui/bad-version.stderr":"e9421586d59cb9135123bd97710655014f95cc5f55b0f9611e1d2e8ce9e29a5d","tests/ui/const-not-fn.rs":"10bbe38f0d89391fff0698756e4cfd4e72a41090360393a0c951b67df14d1c35","tests/ui/const-not-fn.stderr":"1180662fd3b8c4426d46923918a2e58dd9b6259f1a364469ae13d5fc3d69ce6c"},"package":"4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06"} \ No newline at end of file
diff --git a/vendor/rustversion/Cargo.toml b/vendor/rustversion/Cargo.toml
index c72b1b2b3..073d2305e 100644
--- a/vendor/rustversion/Cargo.toml
+++ b/vendor/rustversion/Cargo.toml
@@ -3,28 +3,35 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g., crates.io) dependencies
+# to registry (e.g., crates.io) dependencies.
#
-# If you believe there's an error in this file please file an
-# issue against the rust-lang/cargo repository. If you're
-# editing this file be aware that the upstream Cargo.toml
-# will likely look very different (and much more reasonable)
+# If you are reading this file be aware that the original Cargo.toml
+# will likely look very different (and much more reasonable).
+# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
+rust-version = "1.31"
name = "rustversion"
-version = "1.0.5"
+version = "1.0.12"
authors = ["David Tolnay <dtolnay@gmail.com>"]
build = "build/build.rs"
description = "Conditional compilation according to rustc compiler version"
documentation = "https://docs.rs/rustversion"
readme = "README.md"
+categories = [
+ "development-tools::build-utils",
+ "no-std",
+]
license = "MIT OR Apache-2.0"
repository = "https://github.com/dtolnay/rustversion"
+
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[lib]
proc-macro = true
+
[dev-dependencies.trybuild]
-version = "1.0.35"
+version = "1.0.49"
+features = ["diff"]
diff --git a/vendor/rustversion/LICENSE-APACHE b/vendor/rustversion/LICENSE-APACHE
index 16fe87b06..1b5ec8b78 100644
--- a/vendor/rustversion/LICENSE-APACHE
+++ b/vendor/rustversion/LICENSE-APACHE
@@ -174,28 +174,3 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright [yyyy] [name of copyright owner]
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
diff --git a/vendor/rustversion/README.md b/vendor/rustversion/README.md
index 5b9727251..2c4be07c3 100644
--- a/vendor/rustversion/README.md
+++ b/vendor/rustversion/README.md
@@ -3,8 +3,8 @@ Compiler version cfg
[<img alt="github" src="https://img.shields.io/badge/github-dtolnay/rustversion-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/dtolnay/rustversion)
[<img alt="crates.io" src="https://img.shields.io/crates/v/rustversion.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/rustversion)
-[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rustversion-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/rustversion)
-[<img alt="build status" src="https://img.shields.io/github/workflow/status/dtolnay/rustversion/CI/master?style=for-the-badge" height="20">](https://github.com/dtolnay/rustversion/actions?query=branch%3Amaster)
+[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rustversion-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/rustversion)
+[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/dtolnay/rustversion/ci.yml?branch=master&style=for-the-badge" height="20">](https://github.com/dtolnay/rustversion/actions?query=branch%3Amaster)
This crate provides macros for conditional compilation according to rustc
compiler version, analogous to [`#[cfg(...)]`][cfg] and
diff --git a/vendor/rustversion/build/build.rs b/vendor/rustversion/build/build.rs
index 15312510d..0a45f4c2d 100644
--- a/vendor/rustversion/build/build.rs
+++ b/vendor/rustversion/build/build.rs
@@ -13,41 +13,63 @@ use std::path::Path;
use std::process::{self, Command};
fn main() {
+ println!("cargo:rerun-if-changed=build/build.rs");
+
let rustc = env::var_os("RUSTC").unwrap_or_else(|| OsString::from("rustc"));
- let output = match Command::new(&rustc).arg("--version").output() {
- Ok(output) => output,
- Err(e) => {
- let rustc = rustc.to_string_lossy();
- eprintln!("Error: failed to run `{} --version`: {}", rustc, e);
- process::exit(1);
- }
- };
- let string = match String::from_utf8(output.stdout) {
- Ok(string) => string,
- Err(e) => {
- let rustc = rustc.to_string_lossy();
- eprintln!(
- "Error: failed to parse output of `{} --version`: {}",
- rustc, e,
- );
- process::exit(1);
+ let mut is_clippy_driver = false;
+ let version = loop {
+ let mut command = Command::new(&rustc);
+ if is_clippy_driver {
+ command.arg("--rustc");
}
- };
+ command.arg("--version");
- let version = match rustc::parse(&string) {
- Some(version) => format!("{:#?}\n", version),
- None => {
- eprintln!(
- "Error: unexpected output from `rustc --version`: {:?}\n\n\
- Please file an issue in https://github.com/dtolnay/rustversion",
- string
- );
- process::exit(1);
- }
+ let output = match command.output() {
+ Ok(output) => output,
+ Err(e) => {
+ let rustc = rustc.to_string_lossy();
+ eprintln!("Error: failed to run `{} --version`: {}", rustc, e);
+ process::exit(1);
+ }
+ };
+
+ let string = match String::from_utf8(output.stdout) {
+ Ok(string) => string,
+ Err(e) => {
+ let rustc = rustc.to_string_lossy();
+ eprintln!(
+ "Error: failed to parse output of `{} --version`: {}",
+ rustc, e,
+ );
+ process::exit(1);
+ }
+ };
+
+ break match rustc::parse(&string) {
+ rustc::ParseResult::Success(version) => version,
+ rustc::ParseResult::OopsClippy if !is_clippy_driver => {
+ is_clippy_driver = true;
+ continue;
+ }
+ rustc::ParseResult::Unrecognized | rustc::ParseResult::OopsClippy => {
+ eprintln!(
+ "Error: unexpected output from `rustc --version`: {:?}\n\n\
+ Please file an issue in https://github.com/dtolnay/rustversion",
+ string
+ );
+ process::exit(1);
+ }
+ };
};
+ if version.minor < 38 {
+ // Prior to 1.38, a #[proc_macro] is not allowed to be named `cfg`.
+ println!("cargo:rustc-cfg=cfg_macro_not_allowed");
+ }
+
+ let version = format!("{:#?}\n", version);
let out_dir = env::var_os("OUT_DIR").expect("OUT_DIR not set");
- let out_file = Path::new(&out_dir).join("version.rs");
- fs::write(out_file, version).expect("failed to write version.rs");
+ let out_file = Path::new(&out_dir).join("version.expr");
+ fs::write(out_file, version).expect("failed to write version.expr");
}
diff --git a/vendor/rustversion/build/rustc.rs b/vendor/rustversion/build/rustc.rs
index dfc6a0516..71a830b93 100644
--- a/vendor/rustversion/build/rustc.rs
+++ b/vendor/rustversion/build/rustc.rs
@@ -1,6 +1,12 @@
use self::Channel::*;
use std::fmt::{self, Debug};
+pub enum ParseResult {
+ Success(Version),
+ OopsClippy,
+ Unrecognized,
+}
+
#[cfg_attr(test, derive(PartialEq))]
pub struct Version {
pub minor: u16,
@@ -23,14 +29,20 @@ pub struct Date {
pub day: u8,
}
-pub fn parse(string: &str) -> Option<Version> {
- let last_line = string.lines().last().unwrap_or(&string);
+pub fn parse(string: &str) -> ParseResult {
+ let last_line = string.lines().last().unwrap_or(string);
let mut words = last_line.trim().split(' ');
- if words.next()? != "rustc" {
- return None;
+ match words.next() {
+ Some("rustc") => {}
+ Some(word) if word.starts_with("clippy") => return ParseResult::OopsClippy,
+ Some(_) | None => return ParseResult::Unrecognized,
}
+ parse_words(&mut words).map_or(ParseResult::Unrecognized, ParseResult::Success)
+}
+
+fn parse_words(words: &mut dyn Iterator<Item = &str>) -> Option<Version> {
let mut version_channel = words.next()?.split('-');
let version = version_channel.next()?;
let channel = version_channel.next();
diff --git a/vendor/rustversion/src/expand.rs b/vendor/rustversion/src/expand.rs
new file mode 100644
index 000000000..813ba85d7
--- /dev/null
+++ b/vendor/rustversion/src/expand.rs
@@ -0,0 +1,72 @@
+use crate::attr::{self, Then};
+use crate::error::{Error, Result};
+use crate::{constfn, expr, iter, token};
+use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
+use std::iter::FromIterator;
+
+pub fn cfg(introducer: &str, args: TokenStream, input: TokenStream) -> TokenStream {
+ try_cfg(introducer, args, input).unwrap_or_else(Error::into_compile_error)
+}
+
+fn try_cfg(introducer: &str, args: TokenStream, input: TokenStream) -> Result<TokenStream> {
+ let introducer = Ident::new(introducer, Span::call_site());
+
+ let mut full_args = TokenStream::from(TokenTree::Ident(introducer));
+ if !args.is_empty() {
+ full_args.extend(std::iter::once(TokenTree::Group(Group::new(
+ Delimiter::Parenthesis,
+ args,
+ ))));
+ }
+
+ let ref mut full_args = iter::new(full_args);
+ let expr = expr::parse(full_args)?;
+ token::parse_end(full_args)?;
+
+ if expr.eval(crate::RUSTVERSION) {
+ Ok(input)
+ } else {
+ Ok(TokenStream::new())
+ }
+}
+
+pub fn try_attr(args: attr::Args, input: TokenStream) -> Result<TokenStream> {
+ if !args.condition.eval(crate::RUSTVERSION) {
+ return Ok(input);
+ }
+
+ match args.then {
+ Then::Const(const_token) => constfn::insert_const(input, const_token),
+ Then::Attribute(then) => {
+ // #[cfg_attr(all(), #then)]
+ Ok(TokenStream::from_iter(
+ vec![
+ TokenTree::Punct(Punct::new('#', Spacing::Alone)),
+ TokenTree::Group(Group::new(
+ Delimiter::Bracket,
+ TokenStream::from_iter(vec![
+ TokenTree::Ident(Ident::new("cfg_attr", Span::call_site())),
+ TokenTree::Group(Group::new(
+ Delimiter::Parenthesis,
+ TokenStream::from_iter(
+ vec![
+ TokenTree::Ident(Ident::new("all", Span::call_site())),
+ TokenTree::Group(Group::new(
+ Delimiter::Parenthesis,
+ TokenStream::new(),
+ )),
+ TokenTree::Punct(Punct::new(',', Spacing::Alone)),
+ ]
+ .into_iter()
+ .chain(then),
+ ),
+ )),
+ ]),
+ )),
+ ]
+ .into_iter()
+ .chain(input),
+ ))
+ }
+ }
+}
diff --git a/vendor/rustversion/src/lib.rs b/vendor/rustversion/src/lib.rs
index 172eb8938..a632f4055 100644
--- a/vendor/rustversion/src/lib.rs
+++ b/vendor/rustversion/src/lib.rs
@@ -2,7 +2,7 @@
//!
//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
-//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K
+//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs
//!
//! <br>
//!
@@ -145,12 +145,16 @@
//!
//! <br>
+#![doc(html_root_url = "https://docs.rs/rustversion/1.0.12")]
#![allow(
clippy::cast_lossless,
clippy::cast_possible_truncation,
+ clippy::derive_partial_eq_without_eq,
clippy::doc_markdown,
clippy::enum_glob_use,
clippy::from_iter_instead_of_collect,
+ // https://github.com/rust-lang/rust-clippy/issues/8539
+ clippy::iter_with_drain,
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::needless_doctest_main,
@@ -167,6 +171,7 @@ mod bound;
mod constfn;
mod date;
mod error;
+mod expand;
mod expr;
mod iter;
mod release;
@@ -174,124 +179,70 @@ mod time;
mod token;
mod version;
-use crate::attr::Then;
-use crate::error::{Error, Result};
+use crate::error::Error;
use crate::version::Version;
-use proc_macro::{Delimiter, Group, Ident, Punct, Spacing, Span, TokenStream, TokenTree};
-use std::iter::FromIterator;
+use proc_macro::TokenStream;
-const RUSTVERSION: Version = include!(concat!(env!("OUT_DIR"), "/version.rs"));
+const RUSTVERSION: Version = include!(concat!(env!("OUT_DIR"), "/version.expr"));
#[proc_macro_attribute]
pub fn stable(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("stable", args, input)
+ expand::cfg("stable", args, input)
}
#[proc_macro_attribute]
pub fn beta(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("beta", args, input)
+ expand::cfg("beta", args, input)
}
#[proc_macro_attribute]
pub fn nightly(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("nightly", args, input)
+ expand::cfg("nightly", args, input)
}
#[proc_macro_attribute]
pub fn since(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("since", args, input)
+ expand::cfg("since", args, input)
}
#[proc_macro_attribute]
pub fn before(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("before", args, input)
+ expand::cfg("before", args, input)
}
#[proc_macro_attribute]
pub fn not(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("not", args, input)
+ expand::cfg("not", args, input)
}
#[proc_macro_attribute]
pub fn any(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("any", args, input)
+ expand::cfg("any", args, input)
}
#[proc_macro_attribute]
pub fn all(args: TokenStream, input: TokenStream) -> TokenStream {
- cfg("all", args, input)
-}
-
-fn cfg(introducer: &str, args: TokenStream, input: TokenStream) -> TokenStream {
- try_cfg(introducer, args, input).unwrap_or_else(Error::into_compile_error)
-}
-
-fn try_cfg(introducer: &str, args: TokenStream, input: TokenStream) -> Result<TokenStream> {
- let introducer = Ident::new(introducer, Span::call_site());
-
- let mut full_args = TokenStream::from(TokenTree::Ident(introducer));
- if !args.is_empty() {
- full_args.extend(std::iter::once(TokenTree::Group(Group::new(
- Delimiter::Parenthesis,
- args,
- ))));
- }
-
- let ref mut full_args = iter::new(full_args);
- let expr = expr::parse(full_args)?;
- token::parse_end(full_args)?;
-
- if expr.eval(RUSTVERSION) {
- Ok(input)
- } else {
- Ok(TokenStream::new())
- }
+ expand::cfg("all", args, input)
}
#[proc_macro_attribute]
pub fn attr(args: TokenStream, input: TokenStream) -> TokenStream {
attr::parse(args)
- .and_then(|args| try_attr(args, input))
+ .and_then(|args| expand::try_attr(args, input))
.unwrap_or_else(Error::into_compile_error)
}
-fn try_attr(args: attr::Args, input: TokenStream) -> Result<TokenStream> {
- if !args.condition.eval(RUSTVERSION) {
- return Ok(input);
- }
-
- match args.then {
- Then::Const(const_token) => constfn::insert_const(input, const_token),
- Then::Attribute(then) => {
- // #[cfg_attr(all(), #then)]
- Ok(TokenStream::from_iter(
- vec![
- TokenTree::Punct(Punct::new('#', Spacing::Alone)),
- TokenTree::Group(Group::new(
- Delimiter::Bracket,
- TokenStream::from_iter(vec![
- TokenTree::Ident(Ident::new("cfg_attr", Span::call_site())),
- TokenTree::Group(Group::new(
- Delimiter::Parenthesis,
- TokenStream::from_iter(
- vec![
- TokenTree::Ident(Ident::new("all", Span::call_site())),
- TokenTree::Group(Group::new(
- Delimiter::Parenthesis,
- TokenStream::new(),
- )),
- TokenTree::Punct(Punct::new(',', Spacing::Alone)),
- ]
- .into_iter()
- .chain(then),
- ),
- )),
- ]),
- )),
- ]
- .into_iter()
- .chain(input),
- ))
- }
- }
+#[cfg(not(cfg_macro_not_allowed))]
+#[proc_macro]
+pub fn cfg(input: TokenStream) -> TokenStream {
+ use proc_macro::{Ident, Span, TokenTree};
+ (|| {
+ let ref mut args = iter::new(input);
+ let expr = expr::parse(args)?;
+ token::parse_end(args)?;
+ let boolean = expr.eval(RUSTVERSION);
+ let ident = Ident::new(&boolean.to_string(), Span::call_site());
+ Ok(TokenStream::from(TokenTree::Ident(ident)))
+ })()
+ .unwrap_or_else(Error::into_compile_error)
}
diff --git a/vendor/rustversion/tests/compiletest.rs b/vendor/rustversion/tests/compiletest.rs
index f9aea23b5..7974a6249 100644
--- a/vendor/rustversion/tests/compiletest.rs
+++ b/vendor/rustversion/tests/compiletest.rs
@@ -1,4 +1,5 @@
#[rustversion::attr(not(nightly), ignore)]
+#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
diff --git a/vendor/rustversion/tests/test_const.rs b/vendor/rustversion/tests/test_const.rs
index 1765c958b..3c4f7d5b6 100644
--- a/vendor/rustversion/tests/test_const.rs
+++ b/vendor/rustversion/tests/test_const.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::semicolon_if_nothing_returned)] // https://github.com/rust-lang/rust-clippy/issues/7324
+
#[rustversion::attr(all(), const)]
fn _basic() {}
const _BASIC: () = _basic();
diff --git a/vendor/rustversion/tests/test_parse.rs b/vendor/rustversion/tests/test_parse.rs
index cb39b3179..95064eece 100644
--- a/vendor/rustversion/tests/test_parse.rs
+++ b/vendor/rustversion/tests/test_parse.rs
@@ -1,4 +1,8 @@
-#![allow(clippy::enum_glob_use, clippy::must_use_candidate)]
+#![allow(
+ clippy::derive_partial_eq_without_eq,
+ clippy::enum_glob_use,
+ clippy::must_use_candidate
+)]
include!("../build/rustc.rs");
@@ -89,6 +93,11 @@ fn test_parse() {
];
for (string, expected) in cases {
- assert_eq!(parse(string).unwrap(), *expected);
+ match parse(string) {
+ ParseResult::Success(version) => assert_eq!(version, *expected),
+ ParseResult::OopsClippy | ParseResult::Unrecognized => {
+ panic!("unrecognized: {:?}", string);
+ }
+ }
}
}
diff --git a/vendor/rustversion/tests/ui/bad-bound.stderr b/vendor/rustversion/tests/ui/bad-bound.stderr
index 2c56acbdb..77956c66d 100644
--- a/vendor/rustversion/tests/ui/bad-bound.stderr
+++ b/vendor/rustversion/tests/ui/bad-bound.stderr
@@ -1,11 +1,11 @@
error: expected rustc release number like 1.31, or nightly date like 2020-02-25
- --> $DIR/bad-bound.rs:1:22
+ --> tests/ui/bad-bound.rs:1:22
|
1 | #[rustversion::since(stable)]
| ^^^^^^
error: expected rustc release number like 1.31, or nightly date like 2020-02-25
- --> $DIR/bad-bound.rs:4:26
+ --> tests/ui/bad-bound.rs:4:26
|
4 | #[rustversion::any(since(stable))]
| ^^^^^^
diff --git a/vendor/rustversion/tests/ui/bad-date.stderr b/vendor/rustversion/tests/ui/bad-date.stderr
index c523ccc02..378b00e0d 100644
--- a/vendor/rustversion/tests/ui/bad-date.stderr
+++ b/vendor/rustversion/tests/ui/bad-date.stderr
@@ -1,11 +1,11 @@
error: expected nightly date, like 2020-02-25
- --> $DIR/bad-date.rs:1:24
+ --> tests/ui/bad-date.rs:1:24
|
1 | #[rustversion::nightly(stable)]
| ^^^^^^
error: expected nightly date, like 2020-02-25
- --> $DIR/bad-date.rs:4:28
+ --> tests/ui/bad-date.rs:4:28
|
4 | #[rustversion::any(nightly(stable))]
| ^^^^^^
diff --git a/vendor/rustversion/tests/ui/bad-not.stderr b/vendor/rustversion/tests/ui/bad-not.stderr
index bfe239b2e..2b0c69933 100644
--- a/vendor/rustversion/tests/ui/bad-not.stderr
+++ b/vendor/rustversion/tests/ui/bad-not.stderr
@@ -1,11 +1,11 @@
error: expected `(` after `not`
- --> $DIR/bad-not.rs:1:20
+ --> tests/ui/bad-not.rs:1:20
|
1 | #[rustversion::any(not)]
| ^^^
error: expected `(`
- --> $DIR/bad-not.rs:4:23
+ --> tests/ui/bad-not.rs:4:23
|
4 | #[rustversion::any(not, not)]
| ^
diff --git a/vendor/rustversion/tests/ui/bad-version.stderr b/vendor/rustversion/tests/ui/bad-version.stderr
index 5f7a01fac..bf3f144b1 100644
--- a/vendor/rustversion/tests/ui/bad-version.stderr
+++ b/vendor/rustversion/tests/ui/bad-version.stderr
@@ -1,11 +1,11 @@
error: expected rustc release number, like 1.31
- --> $DIR/bad-version.rs:1:23
+ --> tests/ui/bad-version.rs:1:23
|
1 | #[rustversion::stable(nightly)]
| ^^^^^^^
error: expected rustc release number, like 1.31
- --> $DIR/bad-version.rs:4:27
+ --> tests/ui/bad-version.rs:4:27
|
4 | #[rustversion::any(stable(nightly))]
| ^^^^^^^
diff --git a/vendor/rustversion/tests/ui/const-not-fn.stderr b/vendor/rustversion/tests/ui/const-not-fn.stderr
index 7371ff289..d3cb4aa67 100644
--- a/vendor/rustversion/tests/ui/const-not-fn.stderr
+++ b/vendor/rustversion/tests/ui/const-not-fn.stderr
@@ -1,5 +1,5 @@
error: only allowed on a fn item
- --> $DIR/const-not-fn.rs:1:28
+ --> tests/ui/const-not-fn.rs:1:28
|
1 | #[rustversion::attr(all(), const)]
| ^^^^^