@@ -4,7 +4,6 @@ use crate::core::compiler::context::Metadata;
4
4
use crate :: core:: compiler:: job_queue:: JobState ;
5
5
use crate :: core:: { profiles:: ProfileRoot , PackageId } ;
6
6
use crate :: util:: errors:: CargoResult ;
7
- use crate :: util:: interning:: InternedString ;
8
7
use crate :: util:: machine_message:: { self , Message } ;
9
8
use crate :: util:: { internal, profile} ;
10
9
use anyhow:: Context as _;
@@ -270,7 +269,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
270
269
}
271
270
} )
272
271
. collect :: < Vec < _ > > ( ) ;
273
- let pkg_name = unit. pkg . name ( ) ;
272
+ let crate_name = unit. target . crate_name ( ) ;
274
273
let pkg_descr = unit. pkg . to_string ( ) ;
275
274
let build_script_outputs = Arc :: clone ( & cx. build_script_outputs ) ;
276
275
let id = unit. pkg . package_id ( ) ;
@@ -280,7 +279,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
280
279
let host_target_root = cx. files ( ) . host_dest ( ) . to_path_buf ( ) ;
281
280
let all = (
282
281
id,
283
- pkg_name ,
282
+ crate_name . clone ( ) ,
284
283
pkg_descr. clone ( ) ,
285
284
Arc :: clone ( & build_script_outputs) ,
286
285
output_file. clone ( ) ,
@@ -400,7 +399,7 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
400
399
paths:: write ( & root_output_file, paths:: path2bytes ( & script_out_dir) ?) ?;
401
400
let parsed_output = BuildOutput :: parse (
402
401
& output. stdout ,
403
- pkg_name ,
402
+ crate_name ,
404
403
& pkg_descr,
405
404
& script_out_dir,
406
405
& script_out_dir,
@@ -422,12 +421,12 @@ fn build_work(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Job> {
422
421
// itself to run when we actually end up just discarding what we calculated
423
422
// above.
424
423
let fresh = Work :: new ( move |state| {
425
- let ( id, pkg_name , pkg_descr, build_script_outputs, output_file, script_out_dir) = all;
424
+ let ( id, crate_name , pkg_descr, build_script_outputs, output_file, script_out_dir) = all;
426
425
let output = match prev_output {
427
426
Some ( output) => output,
428
427
None => BuildOutput :: parse_file (
429
428
& output_file,
430
- pkg_name ,
429
+ crate_name ,
431
430
& pkg_descr,
432
431
& prev_script_out_dir,
433
432
& script_out_dir,
@@ -479,7 +478,7 @@ fn insert_warnings_in_build_outputs(
479
478
impl BuildOutput {
480
479
pub fn parse_file (
481
480
path : & Path ,
482
- pkg_name : InternedString ,
481
+ crate_name : String ,
483
482
pkg_descr : & str ,
484
483
script_out_dir_when_generated : & Path ,
485
484
script_out_dir : & Path ,
@@ -489,7 +488,7 @@ impl BuildOutput {
489
488
let contents = paths:: read_bytes ( path) ?;
490
489
BuildOutput :: parse (
491
490
& contents,
492
- pkg_name ,
491
+ crate_name ,
493
492
pkg_descr,
494
493
script_out_dir_when_generated,
495
494
script_out_dir,
@@ -499,10 +498,12 @@ impl BuildOutput {
499
498
}
500
499
501
500
// Parses the output of a script.
502
- // The `pkg_name` is used for error messages.
501
+ // The `pkg_descr` is used for error messages.
502
+ // The `crate_name` is used for determining if RUSTC_BOOTSTRAP should be allowed.
503
503
pub fn parse (
504
504
input : & [ u8 ] ,
505
- pkg_name : InternedString ,
505
+ // Takes String instead of InternedString so passing `unit.pkg.name()` will give a compile error.
506
+ crate_name : String ,
506
507
pkg_descr : & str ,
507
508
script_out_dir_when_generated : & Path ,
508
509
script_out_dir : & Path ,
@@ -591,13 +592,12 @@ impl BuildOutput {
591
592
// behavior, so still only give a warning.
592
593
// NOTE: cargo only allows nightly features on RUSTC_BOOTSTRAP=1, but we
593
594
// want setting any value of RUSTC_BOOTSTRAP to downgrade this to a warning
594
- // (so that `RUSTC_BOOTSTRAP=pkg_name ` will work)
595
+ // (so that `RUSTC_BOOTSTRAP=crate_name ` will work)
595
596
let rustc_bootstrap_allows = |name : & str | {
596
- std:: env:: var ( "RUSTC_BOOTSTRAP" ) . map_or ( false , |var| {
597
- var. split ( ',' ) . any ( |s| s == name)
598
- } )
597
+ std:: env:: var ( "RUSTC_BOOTSTRAP" )
598
+ . map_or ( false , |var| var. split ( ',' ) . any ( |s| s == name) )
599
599
} ;
600
- if nightly_features_allowed || rustc_bootstrap_allows ( & * pkg_name ) {
600
+ if nightly_features_allowed || rustc_bootstrap_allows ( & * crate_name ) {
601
601
warnings. push ( format ! ( "Cannot set `RUSTC_BOOTSTRAP={}` from {}.\n \
602
602
note: Crates cannot set `RUSTC_BOOTSTRAP` themselves, as doing so would subvert the stability guarantees of Rust for your project.",
603
603
val, whence
@@ -610,7 +610,7 @@ impl BuildOutput {
610
610
help: If you're sure you want to do this in your project, set the environment variable `RUSTC_BOOTSTRAP={}` before running cargo instead.",
611
611
val,
612
612
whence,
613
- pkg_name ,
613
+ crate_name ,
614
614
) ;
615
615
}
616
616
} else {
@@ -867,7 +867,7 @@ fn prev_build_output(cx: &mut Context<'_, '_>, unit: &Unit) -> (Option<BuildOutp
867
867
(
868
868
BuildOutput :: parse_file (
869
869
& output_file,
870
- unit. pkg . name ( ) ,
870
+ unit. target . crate_name ( ) ,
871
871
& unit. pkg . to_string ( ) ,
872
872
& prev_script_out_dir,
873
873
& script_out_dir,
0 commit comments