File tree 5 files changed +54
-5
lines changed
test/run-make/crate-name-priority
5 files changed +54
-5
lines changed Original file line number Diff line number Diff line change @@ -903,10 +903,21 @@ pub fn build_output_filenames(input: &Input,
903
903
} ;
904
904
905
905
// If a crate name is present, we use it as the link name
906
- let stem = match attr:: find_crate_name ( attrs) {
907
- None => input. filestem ( ) ,
908
- Some ( name) => name. get ( ) . to_string ( ) ,
909
- } ;
906
+ let stem = sess. opts . crate_name . clone ( ) . or_else ( || {
907
+ attr:: find_crate_name ( attrs) . map ( |n| n. get ( ) . to_string ( ) )
908
+ } ) . or_else ( || {
909
+ // NB: this clause can be removed once #[crate_id] is no longer
910
+ // deprecated.
911
+ //
912
+ // Also note that this will be warned about later so we don't
913
+ // warn about it here.
914
+ use syntax:: crateid:: CrateId ;
915
+ attrs. iter ( ) . find ( |at| at. check_name ( "crate_id" ) )
916
+ . and_then ( |at| at. value_str ( ) )
917
+ . and_then ( |s| from_str :: < CrateId > ( s. get ( ) ) )
918
+ . map ( |id| id. name )
919
+ } ) . unwrap_or ( input. filestem ( ) ) ;
920
+
910
921
OutputFilenames {
911
922
out_directory : dirpath,
912
923
out_filestem : stem,
Original file line number Diff line number Diff line change @@ -575,12 +575,12 @@ impl LintPass for UnusedAttribute {
575
575
] ;
576
576
577
577
static CRATE_ATTRS : & ' static [ & ' static str ] = & [
578
+ "crate_name" ,
578
579
"crate_type" ,
579
580
"feature" ,
580
581
"no_start" ,
581
582
"no_main" ,
582
583
"no_std" ,
583
- "crate_id" ,
584
584
"desc" ,
585
585
"comment" ,
586
586
"license" ,
Original file line number Diff line number Diff line change
1
+ -include ../tools.mk
2
+
3
+ all :
4
+ $(RUSTC ) foo.rs
5
+ rm $(TMPDIR ) /$(call BIN,foo)
6
+ $(RUSTC ) foo.rs --crate-name bar
7
+ rm $(TMPDIR ) /$(call BIN,bar)
8
+ $(RUSTC ) foo1.rs
9
+ rm $(TMPDIR ) /$(call BIN,foo)
10
+ $(RUSTC ) foo1.rs --crate-name bar
11
+ rm $(TMPDIR ) /$(call BIN,bar)
12
+ $(RUSTC ) foo1.rs --crate-name bar -o $(TMPDIR ) /bar1
13
+ rm $(TMPDIR ) /$(call BIN,bar1)
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2
+ // file at the top-level directory of this distribution and at
3
+ // http://rust-lang.org/COPYRIGHT.
4
+ //
5
+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6
+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7
+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8
+ // option. This file may not be copied, modified, or distributed
9
+ // except according to those terms.
10
+
11
+ #![ crate_name = "foo" ]
12
+
13
+ fn main ( ) { }
14
+
You can’t perform that action at this time.
0 commit comments