Skip to content

Commit 96ed4ec

Browse files
Rollup merge of rust-lang#137834 - lolbinarycat:rustc_fluent_macro-137815, r=BoxyUwU
rustc_fluent_macro: use CARGO_CRATE_NAME instead of CARGO_PKG_NAME fixes rust-lang#137815
2 parents 60709ff + d1d0b9b commit 96ed4ec

File tree

5 files changed

+22
-2
lines changed

5 files changed

+22
-2
lines changed

compiler/rustc_fluent_macro/src/fluent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ fn failed(crate_name: &Ident) -> proc_macro::TokenStream {
7878

7979
/// See [rustc_fluent_macro::fluent_messages].
8080
pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
81-
let crate_name = std::env::var("CARGO_PKG_NAME")
82-
// If `CARGO_PKG_NAME` is missing, then we're probably running in a test, so use
81+
let crate_name = std::env::var("CARGO_CRATE_NAME")
82+
// If `CARGO_CRATE_NAME` is missing, then we're probably running in a test, so use
8383
// `no_crate`.
8484
.unwrap_or_else(|_| "no_crate".to_string())
8585
.replace("rustc_", "");
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
name = "some-name"
3+
version = "0.0.0"
4+
edition = "2024"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
some_name_whatever_message = hello
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use run_make_support::external_deps::cargo::cargo;
2+
3+
// test to make sure that `rustc_fluent_macro` correctly handles
4+
// packages that have hyphens in their package name.
5+
6+
fn main() {
7+
cargo().arg("build").arg("--manifest-path=./Cargo.toml").run();
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(rustc_private)]
2+
3+
extern crate rustc_driver;
4+
extern crate rustc_errors;
5+
extern crate rustc_fluent_macro;
6+
7+
rustc_fluent_macro::fluent_messages!("../messages.ftl");

0 commit comments

Comments
 (0)