Skip to content

Commit

Permalink
Rollup merge of rust-lang#137834 - lolbinarycat:rustc_fluent_macro-13…
Browse files Browse the repository at this point in the history
…7815, r=BoxyUwU

rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME

fixes rust-lang#137815
  • Loading branch information
workingjubilee authored Mar 4, 2025
2 parents 60709ff + d1d0b9b commit 96ed4ec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ fn failed(crate_name: &Ident) -> proc_macro::TokenStream {

/// See [rustc_fluent_macro::fluent_messages].
pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let crate_name = std::env::var("CARGO_PKG_NAME")
// If `CARGO_PKG_NAME` is missing, then we're probably running in a test, so use
let crate_name = std::env::var("CARGO_CRATE_NAME")
// If `CARGO_CRATE_NAME` is missing, then we're probably running in a test, so use
// `no_crate`.
.unwrap_or_else(|_| "no_crate".to_string())
.replace("rustc_", "");
Expand Down
4 changes: 4 additions & 0 deletions tests/run-make/rustc_fluent_macro-hyphen-package/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "some-name"
version = "0.0.0"
edition = "2024"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
some_name_whatever_message = hello
8 changes: 8 additions & 0 deletions tests/run-make/rustc_fluent_macro-hyphen-package/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use run_make_support::external_deps::cargo::cargo;

// test to make sure that `rustc_fluent_macro` correctly handles
// packages that have hyphens in their package name.

fn main() {
cargo().arg("build").arg("--manifest-path=./Cargo.toml").run();
}
7 changes: 7 additions & 0 deletions tests/run-make/rustc_fluent_macro-hyphen-package/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![feature(rustc_private)]

extern crate rustc_driver;
extern crate rustc_errors;
extern crate rustc_fluent_macro;

rustc_fluent_macro::fluent_messages!("../messages.ftl");

0 comments on commit 96ed4ec

Please sign in to comment.