Skip to content

Add $CARGO_PKG_AUTHORZ that separates the entries with \x01 instead of : #15474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

nabijaczleweli
Copy link
Contributor

What does this PR try to resolve?

Valid and reasonable authors entries like

authors = ["наб <nabijaczleweli@nabijaczleweli.xyz>",
           "nevsal",
           "Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>"]

become

наб <nabijaczleweli@nabijaczleweli.xyz>
nevsal
Lynnesbian <https
//fedi.lynnesbian.space/@lynnesbian>

with the standard .replace(':', "\n") treatment.

There's no reason to use : instead of something that's guaranteed to never be in the string. \0 is unusable, so use \1.

How should we test and review this PR?

$ cat src/main.rs
#[macro_use]
extern crate clap;
fn main() {
    println!("{}", env!("CARGO_PKG_AUTHORS"));
    println!("{}", env!("CARGO_PKG_AUTHORZ"));
    println!("{}", crate_authors!("\n"));
    println!("{}", env!("CARGO_PKG_AUTHORZ").replace('\x01', "\n"));
}

$ cat Cargo.toml
[package]
name = "b"
version = "0.1.0"
authors = ["наб <nabijaczleweli@nabijaczleweli.xyz>",
           "nevsal",
           "Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>"]

[dependencies.clap]
version = "3.2"
features = ["cargo"]

$ ../cargo/target/debug/cargo run
наб <nabijaczleweli@nabijaczleweli.xyz>:nevsal:Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>
наб <nabijaczleweli@nabijaczleweli.xyz>nevsalLynnesbian <https://fedi.lynnesbian.space/@lynnesbian>
наб <nabijaczleweli@nabijaczleweli.xyz>
nevsal
Lynnesbian <https
//fedi.lynnesbian.space/@lynnesbian>
наб <nabijaczleweli@nabijaczleweli.xyz>
nevsal
Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>

$ ../cargo/target/debug/cargo run | cat -A
warning: no edition set: defaulting to the 2015 edition while the latest is 2024
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
     Running `target/debug/b`
M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>:nevsal:Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>$
M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>^Anevsal^ALynnesbian <https://fedi.lynnesbian.space/@lynnesbian>$
M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>$
nevsal$
Lynnesbian <https$
//fedi.lynnesbian.space/@lynnesbian>$
M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>$
nevsal$
Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>$

Additional information

Downstream report: nabijaczleweli/cargo-update#294

Valid and reasonable authors entries like
  authors = ["наб <nabijaczleweli@nabijaczleweli.xyz>",
             "nevsal",
             "Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>"]
become
  наб <nabijaczleweli@nabijaczleweli.xyz>
  nevsal
  Lynnesbian <https
  //fedi.lynnesbian.space/@Lynnesbian>
with the standard .replace(':', "\n") treatment.

There's no reason to use : instead of something that's guaranteed to
never be in the string. \0 is unusable, so use \1:
  $ cat src/main.rs
  #[macro_use]
  extern crate clap;
  fn main() {
      println!("{}", env!("CARGO_PKG_AUTHORS"));
      println!("{}", env!("CARGO_PKG_AUTHORZ"));
      println!("{}", crate_authors!("\n"));
      println!("{}", env!("CARGO_PKG_AUTHORZ").replace('\x01', "\n"));
  }

  $ cat Cargo.toml
  [package]
  name = "b"
  version = "0.1.0"
  authors = ["наб <nabijaczleweli@nabijaczleweli.xyz>",
             "nevsal",
             "Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>"]

  [dependencies.clap]
  version = "3.2"
  features = ["cargo"]

  $ ../cargo/target/debug/cargo run
  наб <nabijaczleweli@nabijaczleweli.xyz>:nevsal:Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>
  наб <nabijaczleweli@nabijaczleweli.xyz>nevsalLynnesbian <https://fedi.lynnesbian.space/@lynnesbian>
  наб <nabijaczleweli@nabijaczleweli.xyz>
  nevsal
  Lynnesbian <https
  //fedi.lynnesbian.space/@Lynnesbian>
  наб <nabijaczleweli@nabijaczleweli.xyz>
  nevsal
  Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>

  $ ../cargo/target/debug/cargo run | cat -A
  warning: no edition set: defaulting to the 2015 edition while the latest is 2024
      Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s
       Running `target/debug/b`
  M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>:nevsal:Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>$
  M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>^Anevsal^ALynnesbian <https://fedi.lynnesbian.space/@lynnesbian>$
  M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>$
  nevsal$
  Lynnesbian <https$
  //fedi.lynnesbian.space/@Lynnesbian>$
  M-PM-=M-PM-0M-PM-1 <nabijaczleweli@nabijaczleweli.xyz>$
  nevsal$
  Lynnesbian <https://fedi.lynnesbian.space/@lynnesbian>$

Ref: nabijaczleweli/cargo-update#294
@rustbot
Copy link
Collaborator

rustbot commented May 1, 2025

r? @weihanglo

rustbot has assigned @weihanglo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2025
@epage
Copy link
Contributor

epage commented May 1, 2025

Note that the package.authors field is deprecated as of 1.86 in #15068.

In light of that, I would be inclined to not add new features to better support this (in fact existing feature requests helped raised the visibility for the deprecation discussion).

@nabijaczleweli nabijaczleweli closed this by deleting the head repository May 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-scripts Area: build.rs scripts A-documenting-cargo-itself Area: Cargo's documentation A-manifest Area: Cargo.toml issues S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants