diff --git a/cargo-dylint/tests/boundary_toolchains.rs b/cargo-dylint/tests/boundary_toolchains.rs index 1c6f72079..49dc67834 100644 --- a/cargo-dylint/tests/boundary_toolchains.rs +++ b/cargo-dylint/tests/boundary_toolchains.rs @@ -6,7 +6,12 @@ use tempfile::tempdir; use test_log::test; // smoelius: The channel date is one day later than the `rustc --version` date. -const BOUNDARIES: [(&str, &str); 2] = [("2022-07-14", "2022-07-15"), ("2022-09-08", "2022-09-09")]; +// smoelius: Put recent boundaries first, since they're more likely to cause problems. +const BOUNDARIES: [(&str, &str); 3] = [ + ("2023-01-19", "2023-01-20"), + ("2022-09-08", "2022-09-09"), + ("2022-07-14", "2022-07-15"), +]; #[test] fn boundary_toolchains() { diff --git a/scripts/publish.sh b/scripts/publish.sh index 8b8a60451..d6a3dc7b7 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -50,7 +50,7 @@ published() { echo '[workspace]' >> Cargo.toml cat > rust-toolchain << EOF [toolchain] -channel = "nightly-2023-01-19" +channel = "nightly" components = ["llvm-tools-preview", "rustc-dev"] EOF echo "Checking whether \`$1:$2\` is published ..." >&2 diff --git a/utils/linting/Cargo.lock b/utils/linting/Cargo.lock index 34548657b..a67b30c2c 100644 --- a/utils/linting/Cargo.lock +++ b/utils/linting/Cargo.lock @@ -8,6 +8,32 @@ version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cb2f989d18dd141ab8ae82f64d1a8cdd37e0840f73a406896cf5e99502fab61" +[[package]] +name = "assert_cmd" +version = "2.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9834fcc22e0874394a010230586367d4a3e9f11b560f469262678547e1d2575e" +dependencies = [ + "bstr", + "doc-comment", + "predicates", + "predicates-core", + "predicates-tree", + "wait-timeout", +] + +[[package]] +name = "bstr" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45ea9b00a7b3f2988e9a65ad3917e62123c38dba709b666506207be96d1790b" +dependencies = [ + "memchr", + "once_cell", + "regex-automata", + "serde", +] + [[package]] name = "camino" version = "1.1.2" @@ -40,6 +66,18 @@ dependencies = [ "thiserror", ] +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + [[package]] name = "dylint_internal" version = "2.1.3" @@ -52,6 +90,7 @@ dependencies = [ name = "dylint_linting" version = "2.1.3" dependencies = [ + "assert_cmd", "cargo_metadata", "dylint_internal", "paste", @@ -61,24 +100,84 @@ dependencies = [ "toml", ] +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + [[package]] name = "if_chain" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440" +[[package]] +name = "libc" +version = "0.2.139" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "once_cell" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" + [[package]] name = "paste" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" +[[package]] +name = "predicates" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +dependencies = [ + "difflib", + "itertools", + "predicates-core", +] + +[[package]] +name = "predicates-core" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f883590242d3c6fc5bf50299011695fa6590c2c70eac95ee1bdb9a733ad1a2" + +[[package]] +name = "predicates-tree" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54ff541861505aabf6ea722d2131ee980b8276e10a1297b94e896dd8b621850d" +dependencies = [ + "predicates-core", + "termtree", +] + [[package]] name = "proc-macro2" version = "1.0.49" @@ -97,6 +196,12 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" + [[package]] name = "rustversion" version = "1.0.11" @@ -160,6 +265,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "termtree" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" + [[package]] name = "thiserror" version = "1.0.38" @@ -194,3 +305,12 @@ name = "unicode-ident" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" + +[[package]] +name = "wait-timeout" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +dependencies = [ + "libc", +] diff --git a/utils/linting/Cargo.toml b/utils/linting/Cargo.toml index fe80a9c1c..646cbbaac 100644 --- a/utils/linting/Cargo.toml +++ b/utils/linting/Cargo.toml @@ -17,6 +17,9 @@ toml = "0.5" dylint_internal = { version = "=2.1.3", path = "../../internal" } +[dev-dependencies] +assert_cmd = "2.0" + [package.metadata.docs.rs] rustdoc-args = ["--cfg", "docsrs"] diff --git a/utils/linting/rust-toolchain b/utils/linting/rust-toolchain index becaaad2a..af11b9fcc 100644 --- a/utils/linting/rust-toolchain +++ b/utils/linting/rust-toolchain @@ -1,4 +1,3 @@ [toolchain] -# smoelius: Temporarily pin to `nightly-2023-01-19` until rust-lang/rust#106810 can be dealt with. -channel = "nightly-2023-01-19" +channel = "nightly" components = ["llvm-tools-preview", "rustc-dev"] diff --git a/utils/linting/src/lib.rs b/utils/linting/src/lib.rs index 1e1df7125..48596520d 100644 --- a/utils/linting/src/lib.rs +++ b/utils/linting/src/lib.rs @@ -16,7 +16,13 @@ use cargo_metadata::{Metadata, MetadataCommand}; use dylint_internal::env; use rustc_session::Session; use rustc_span::Symbol; -use std::{any::type_name, cell::RefCell, fs::read_to_string, path::Path, sync::Mutex}; +use std::{ + any::type_name, + cell::RefCell, + fs::read_to_string, + path::{Path, PathBuf}, + sync::Mutex, +}; use thiserror::Error; pub const DYLINT_VERSION: &str = "0.1.0"; @@ -72,8 +78,8 @@ macro_rules! __make_late_closure { } // smoelius: Relevant PR and merge commit: -// * https://github.com/rust-lang/rust/pull/101501 -// * https://github.com/rust-lang/rust/commit/87788097b776f8e3662f76627944230684b671bd +// - https://github.com/rust-lang/rust/pull/101501 +// - https://github.com/rust-lang/rust/commit/87788097b776f8e3662f76627944230684b671bd #[rustversion::since(2022-09-08)] #[doc(hidden)] #[macro_export] @@ -310,8 +316,7 @@ pub fn try_init_config(sess: &Session) -> ConfigResult<()> { Some(Symbol::intern(&value)), )); Some(value) - } else if let Some(local_crate_source_file) = sess - .local_crate_source_file + } else if let Some(local_crate_source_file) = local_crate_source_file(sess) .as_deref() .map(Path::canonicalize) .transpose()? @@ -363,3 +368,16 @@ pub fn try_init_config(sess: &Session) -> ConfigResult<()> { Ok(()) } + +#[rustversion::before(2023-01-19)] +fn local_crate_source_file(sess: &Session) -> Option { + sess.local_crate_source_file.clone() +} + +// smoelius: Relevant PR and merge commit: +// - https://github.com/rust-lang/rust/pull/106810 +// - https://github.com/rust-lang/rust/commit/65d2f2a5f9c323c88d1068e8e90d0b47a20d491c +#[rustversion::since(2023-01-19)] +fn local_crate_source_file(sess: &Session) -> Option { + sess.local_crate_source_file() +} diff --git a/utils/linting/tests/build.rs b/utils/linting/tests/build.rs new file mode 100644 index 000000000..c707ddf83 --- /dev/null +++ b/utils/linting/tests/build.rs @@ -0,0 +1,18 @@ +use assert_cmd::{assert::AssertResult, prelude::*}; + +#[test] +fn builds_with_latest_nightly() { + update_nightly().unwrap(); + + std::process::Command::new("cargo") + .args(["+nightly", "build"]) + .assert() + .success(); +} + +fn update_nightly() -> AssertResult { + std::process::Command::new("rustup") + .args(["update", "--no-self-update", "nightly"]) + .assert() + .try_success() +}