From 845c1bc0635e21ce82cc7f3adef6e42355f0447e Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 19 Nov 2023 09:45:48 -0500 Subject: [PATCH 1/4] chore: bump `cargo-credential-*` crates as e58b84d broke stuff e58b84d3 changed the shape of response of cargo credential protocol trait, so credential plugins crates effectively depend on `cargo-credential@0.4.0`. However, `cargo@0.74.0` still depends on`cargo-credential@0.3.0`. They must depends on the same major version of `cargo-credential` otherwise incompatible. --- Cargo.lock | 6 +++--- Cargo.toml | 6 +++--- credential/cargo-credential-libsecret/Cargo.toml | 2 +- credential/cargo-credential-macos-keychain/Cargo.toml | 2 +- credential/cargo-credential-wincred/Cargo.toml | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc0cb9a8874..fda5f26c190 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -334,7 +334,7 @@ dependencies = [ [[package]] name = "cargo-credential-libsecret" -version = "0.3.2" +version = "0.4.0" dependencies = [ "anyhow", "cargo-credential", @@ -343,7 +343,7 @@ dependencies = [ [[package]] name = "cargo-credential-macos-keychain" -version = "0.3.1" +version = "0.4.0" dependencies = [ "cargo-credential", "security-framework", @@ -351,7 +351,7 @@ dependencies = [ [[package]] name = "cargo-credential-wincred" -version = "0.3.1" +version = "0.4.0" dependencies = [ "cargo-credential", "windows-sys", diff --git a/Cargo.toml b/Cargo.toml index 440304416a4..cd2171ebd20 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,9 +23,9 @@ base64 = "0.21.3" bytesize = "1.3" cargo = { path = "" } cargo-credential = { version = "0.4.0", path = "credential/cargo-credential" } -cargo-credential-libsecret = { version = "0.3.1", path = "credential/cargo-credential-libsecret" } -cargo-credential-wincred = { version = "0.3.0", path = "credential/cargo-credential-wincred" } -cargo-credential-macos-keychain = { version = "0.3.0", path = "credential/cargo-credential-macos-keychain" } +cargo-credential-libsecret = { version = "0.4.0", path = "credential/cargo-credential-libsecret" } +cargo-credential-wincred = { version = "0.4.0", path = "credential/cargo-credential-wincred" } +cargo-credential-macos-keychain = { version = "0.4.0", path = "credential/cargo-credential-macos-keychain" } cargo-platform = { path = "crates/cargo-platform", version = "0.1.4" } cargo-test-macro = { path = "crates/cargo-test-macro" } cargo-test-support = { path = "crates/cargo-test-support" } diff --git a/credential/cargo-credential-libsecret/Cargo.toml b/credential/cargo-credential-libsecret/Cargo.toml index 5bedad3b9cb..2b1e72327d7 100644 --- a/credential/cargo-credential-libsecret/Cargo.toml +++ b/credential/cargo-credential-libsecret/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-libsecret" -version = "0.3.2" +version = "0.4.0" edition.workspace = true license.workspace = true repository = "https://github.com/rust-lang/cargo" diff --git a/credential/cargo-credential-macos-keychain/Cargo.toml b/credential/cargo-credential-macos-keychain/Cargo.toml index 172e9c10b6a..ab29905cc53 100644 --- a/credential/cargo-credential-macos-keychain/Cargo.toml +++ b/credential/cargo-credential-macos-keychain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-macos-keychain" -version = "0.3.1" +version = "0.4.0" edition.workspace = true license.workspace = true repository = "https://github.com/rust-lang/cargo" diff --git a/credential/cargo-credential-wincred/Cargo.toml b/credential/cargo-credential-wincred/Cargo.toml index 6da6578a5c2..9d12c831489 100644 --- a/credential/cargo-credential-wincred/Cargo.toml +++ b/credential/cargo-credential-wincred/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-credential-wincred" -version = "0.3.1" +version = "0.4.0" edition.workspace = true license.workspace = true repository = "https://github.com/rust-lang/cargo" From 323efcced1d47322cf3f58ad2f74be08f5694880 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Tue, 24 Oct 2023 15:50:09 -0700 Subject: [PATCH 2/4] Fix unused_imports warning --- src/cargo/core/resolver/context.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/cargo/core/resolver/context.rs b/src/cargo/core/resolver/context.rs index f19c678a695..09b16b39cd9 100644 --- a/src/cargo/core/resolver/context.rs +++ b/src/cargo/core/resolver/context.rs @@ -10,10 +10,6 @@ use std::collections::HashMap; use std::num::NonZeroU64; use tracing::debug; -pub use super::encode::Metadata; -pub use super::encode::{EncodableDependency, EncodablePackageId, EncodableResolve}; -pub use super::resolve::Resolve; - // A `Context` is basically a bunch of local resolution information which is // kept around for all `BacktrackFrame` instances. As a result, this runs the // risk of being cloned *a lot* so we want to make this as cheap to clone as From cb272672798f2a46faf17fb851f8d1cac7a9a833 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 6 Nov 2023 09:55:31 -0600 Subject: [PATCH 3/4] tests: Remove plugin tests Compiler plugins were removed in rust-lang/rust#116412, so we don't need these tests. As for the `plugin` field on build-targets, it appears to be [stable-but-deprecated](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#the-plugin-field), so I left it alone --- tests/testsuite/cross_compile.rs | 86 ------- tests/testsuite/main.rs | 1 - tests/testsuite/plugins.rs | 421 ------------------------------- tests/testsuite/proc_macro.rs | 46 ---- 4 files changed, 554 deletions(-) delete mode 100644 tests/testsuite/plugins.rs diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 1bc0c277db1..b57ba2c7a89 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -411,92 +411,6 @@ fn linker() { .run(); } -#[cargo_test(nightly, reason = "plugins are unstable")] -fn plugin_with_extra_dylib_dep() { - if cross_compile::disabled() { - return; - } - - let foo = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [dependencies.bar] - path = "../bar" - "#, - ) - .file( - "src/main.rs", - r#" - #![feature(plugin)] - #![plugin(bar)] - - fn main() {} - "#, - ) - .build(); - let _bar = project() - .at("bar") - .file( - "Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - - [lib] - name = "bar" - plugin = true - - [dependencies.baz] - path = "../baz" - "#, - ) - .file( - "src/lib.rs", - r#" - #![feature(rustc_private)] - - extern crate baz; - extern crate rustc_driver; - - use rustc_driver::plugin::Registry; - - #[no_mangle] - pub fn __rustc_plugin_registrar(reg: &mut Registry) { - println!("{}", baz::baz()); - } - "#, - ) - .build(); - let _baz = project() - .at("baz") - .file( - "Cargo.toml", - r#" - [package] - name = "baz" - version = "0.0.1" - authors = [] - - [lib] - name = "baz" - crate_type = ["dylib"] - "#, - ) - .file("src/lib.rs", "pub fn baz() -> i32 { 1 }") - .build(); - - let target = cross_compile::alternate(); - foo.cargo("build --target").arg(&target).run(); -} - #[cargo_test] fn cross_tests() { if !cross_compile::can_run_on_host() { diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 8279f58180f..d7c5615943c 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -131,7 +131,6 @@ mod patch; mod path; mod paths; mod pkgid; -mod plugins; mod proc_macro; mod profile_config; mod profile_custom; diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs deleted file mode 100644 index 331ba32e00d..00000000000 --- a/tests/testsuite/plugins.rs +++ /dev/null @@ -1,421 +0,0 @@ -//! Tests for rustc plugins. - -use cargo_test_support::rustc_host; -use cargo_test_support::{basic_manifest, project}; - -#[cargo_test(nightly, reason = "plugins are unstable")] -fn plugin_to_the_max() { - let foo = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [lib] - name = "foo_lib" - - [dependencies.bar] - path = "../bar" - "#, - ) - .file( - "src/main.rs", - r#" - #![feature(plugin)] - #![plugin(bar)] - extern crate foo_lib; - - fn main() { foo_lib::foo(); } - "#, - ) - .file( - "src/foo_lib.rs", - r#" - #![feature(plugin)] - #![plugin(bar)] - - pub fn foo() {} - "#, - ) - .build(); - let _bar = project() - .at("bar") - .file( - "Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - - [lib] - name = "bar" - plugin = true - - [dependencies.baz] - path = "../baz" - "#, - ) - .file( - "src/lib.rs", - r#" - #![feature(rustc_private)] - - extern crate baz; - extern crate rustc_driver; - - use rustc_driver::plugin::Registry; - - #[no_mangle] - pub fn __rustc_plugin_registrar(_reg: &mut Registry) { - println!("{}", baz::baz()); - } - "#, - ) - .build(); - let _baz = project() - .at("baz") - .file( - "Cargo.toml", - r#" - [package] - name = "baz" - version = "0.0.1" - authors = [] - - [lib] - name = "baz" - crate_type = ["dylib"] - "#, - ) - .file("src/lib.rs", "pub fn baz() -> i32 { 1 }") - .build(); - - foo.cargo("build").run(); - foo.cargo("doc").run(); -} - -#[cargo_test(nightly, reason = "plugins are unstable")] -fn plugin_with_dynamic_native_dependency() { - let build = project() - .at("builder") - .file( - "Cargo.toml", - r#" - [package] - name = "builder" - version = "0.0.1" - authors = [] - - [lib] - name = "builder" - crate-type = ["dylib"] - "#, - ) - .file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") - .build(); - - let foo = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [dependencies.bar] - path = "bar" - "#, - ) - .file( - "src/main.rs", - r#" - #![feature(plugin)] - #![plugin(bar)] - - fn main() {} - "#, - ) - .file( - "bar/Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - build = 'build.rs' - - [lib] - name = "bar" - plugin = true - "#, - ) - .file( - "bar/build.rs", - r#" - use std::env; - use std::fs; - use std::path::PathBuf; - - fn main() { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap()); - let root = PathBuf::from(env::var("BUILDER_ROOT").unwrap()); - let file = format!("{}builder{}", - env::consts::DLL_PREFIX, - env::consts::DLL_SUFFIX); - let src = root.join(&file); - let dst = out_dir.join(&file); - fs::copy(src, dst).unwrap(); - if cfg!(target_env = "msvc") { - fs::copy(root.join("builder.dll.lib"), - out_dir.join("builder.dll.lib")).unwrap(); - } - println!("cargo:rustc-flags=-L {}", out_dir.display()); - } - "#, - ) - .file( - "bar/src/lib.rs", - r#" - #![feature(rustc_private)] - - extern crate rustc_driver; - use rustc_driver::plugin::Registry; - - #[cfg_attr(not(target_env = "msvc"), link(name = "builder"))] - #[cfg_attr(target_env = "msvc", link(name = "builder.dll"))] - extern { fn foo(); } - - #[no_mangle] - pub fn __rustc_plugin_registrar(_reg: &mut Registry) { - unsafe { foo() } - } - "#, - ) - .build(); - - build.cargo("build").run(); - - let root = build.root().join("target").join("debug"); - foo.cargo("build -v").env("BUILDER_ROOT", root).run(); -} - -#[cargo_test] -fn plugin_integration() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - build = "build.rs" - - [lib] - name = "foo" - plugin = true - doctest = false - "#, - ) - .file("build.rs", "fn main() {}") - .file("src/lib.rs", "") - .file("tests/it_works.rs", "") - .build(); - - p.cargo("test -v").run(); -} - -#[cargo_test] -fn doctest_a_plugin() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [dependencies] - bar = { path = "bar" } - "#, - ) - .file("src/lib.rs", "#[macro_use] extern crate bar;") - .file( - "bar/Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - - [lib] - name = "bar" - plugin = true - "#, - ) - .file("bar/src/lib.rs", "pub fn bar() {}") - .build(); - - p.cargo("test -v").run(); -} - -// See #1515 -#[cargo_test] -fn native_plugin_dependency_with_custom_linker() { - let target = rustc_host(); - - let _foo = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [lib] - plugin = true - "#, - ) - .file("src/lib.rs", "") - .build(); - - let bar = project() - .at("bar") - .file( - "Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - - [dependencies.foo] - path = "../foo" - "#, - ) - .file("src/lib.rs", "") - .file( - ".cargo/config", - &format!( - r#" - [target.{}] - linker = "nonexistent-linker" - "#, - target - ), - ) - .build(); - - bar.cargo("build --verbose") - .with_status(101) - .with_stderr_contains( - "\ -[COMPILING] foo v0.0.1 ([..]) -[RUNNING] `rustc [..] -C linker=nonexistent-linker [..]` -[ERROR] [..]linker[..] -", - ) - .run(); -} - -#[cargo_test(nightly, reason = "requires rustc_private")] -fn panic_abort_plugins() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [profile.dev] - panic = 'abort' - - [dependencies] - bar = { path = "bar" } - "#, - ) - .file("src/lib.rs", "") - .file( - "bar/Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - - [lib] - plugin = true - "#, - ) - .file( - "bar/src/lib.rs", - r#" - #![feature(rustc_private)] - extern crate rustc_ast; - extern crate rustc_driver; - "#, - ) - .build(); - - p.cargo("build").run(); -} - -#[cargo_test(nightly, reason = "requires rustc_private")] -fn shared_panic_abort_plugins() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [profile.dev] - panic = 'abort' - - [dependencies] - bar = { path = "bar" } - baz = { path = "baz" } - "#, - ) - .file("src/lib.rs", "extern crate baz;") - .file( - "bar/Cargo.toml", - r#" - [package] - name = "bar" - version = "0.0.1" - authors = [] - - [lib] - plugin = true - - [dependencies] - baz = { path = "../baz" } - "#, - ) - .file( - "bar/src/lib.rs", - r#" - #![feature(rustc_private)] - extern crate rustc_ast; - extern crate rustc_driver; - extern crate baz; - "#, - ) - .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) - .file("baz/src/lib.rs", "") - .build(); - - p.cargo("build -v").run(); -} diff --git a/tests/testsuite/proc_macro.rs b/tests/testsuite/proc_macro.rs index 7d6f6ba86f3..cabf251a0fa 100644 --- a/tests/testsuite/proc_macro.rs +++ b/tests/testsuite/proc_macro.rs @@ -202,52 +202,6 @@ fn impl_and_derive() { p.cargo("run").with_stdout("X { success: true }").run(); } -#[cargo_test(nightly, reason = "plugins are unstable")] -fn plugin_and_proc_macro() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - version = "0.0.1" - authors = [] - - [lib] - plugin = true - proc-macro = true - "#, - ) - .file( - "src/lib.rs", - r#" - #![feature(rustc_private)] - #![feature(proc_macro, proc_macro_lib)] - - extern crate rustc_driver; - use rustc_driver::plugin::Registry; - - extern crate proc_macro; - use proc_macro::TokenStream; - - #[no_mangle] - pub fn __rustc_plugin_registrar(reg: &mut Registry) {} - - #[proc_macro_derive(Questionable)] - pub fn questionable(input: TokenStream) -> TokenStream { - input - } - "#, - ) - .build(); - - let msg = " `lib.plugin` and `lib.proc-macro` cannot both be `true`"; - p.cargo("check") - .with_status(101) - .with_stderr_contains(msg) - .run(); -} - #[cargo_test] fn proc_macro_doctest() { let foo = project() From 9f68d567bf3cfbfab04e8f63c8f370784a29dc9a Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Sun, 19 Nov 2023 10:51:59 -0500 Subject: [PATCH 4/4] chore: bump to `cargo-semver-checks` 0.24.0 to support rustdoc json v27 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44dd76e1377..2c8af6ddf5d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -98,7 +98,7 @@ jobs: - name: Install cargo-semver-checks run: | mkdir installed-bins - curl -Lf https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.22.1/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz \ + curl -Lf https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.24.0/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz \ | tar -xz --directory=./installed-bins echo `pwd`/installed-bins >> $GITHUB_PATH - run: ci/validate-version-bump.sh