@@ -48,6 +48,7 @@ const LICENSES: &[&str] = &[
48
48
49
49
type ExceptionList = & ' static [ ( & ' static str , & ' static str ) ] ;
50
50
51
+ #[ derive( Clone , Copy ) ]
51
52
pub ( crate ) struct WorkspaceInfo < ' a > {
52
53
/// Path to the directory containing the workspace root Cargo.toml file.
53
54
pub ( crate ) path : & ' a str ,
@@ -56,7 +57,8 @@ pub(crate) struct WorkspaceInfo<'a> {
56
57
/// Optionally:
57
58
/// * A list of crates for which dependencies need to be explicitly allowed.
58
59
/// * The list of allowed dependencies.
59
- pub ( crate ) crates_and_deps : Option < ( & ' a [ & ' a str ] , & ' a [ & ' a str ] ) > ,
60
+ /// * The source code location of the allowed dependencies list
61
+ crates_and_deps : Option < ( & ' a [ & ' a str ] , & ' a [ & ' a str ] , ListLocation ) > ,
60
62
/// Submodules required for the workspace
61
63
pub ( crate ) submodules : & ' a [ & ' a str ] ,
62
64
}
@@ -65,7 +67,7 @@ impl<'a> WorkspaceInfo<'a> {
65
67
const fn new (
66
68
path : & ' a str ,
67
69
exceptions : ExceptionList ,
68
- crates_and_deps : Option < ( & ' a [ & str ] , & ' a [ & str ] ) > ,
70
+ crates_and_deps : Option < ( & ' a [ & str ] , & ' a [ & str ] , ListLocation ) > ,
69
71
submodules : & ' a [ & str ] ,
70
72
) -> Self {
71
73
Self { path, exceptions, crates_and_deps, submodules }
@@ -76,18 +78,27 @@ impl<'a> WorkspaceInfo<'a> {
76
78
// FIXME auto detect all cargo workspaces
77
79
pub ( crate ) const WORKSPACES : & [ WorkspaceInfo < ' static > ] = & [
78
80
// The root workspace has to be first for check_rustfix to work.
79
- WorkspaceInfo :: new ( "." , EXCEPTIONS , Some ( ( & [ "rustc-main" ] , PERMITTED_RUSTC_DEPENDENCIES ) ) , & [ ] ) ,
81
+ WorkspaceInfo :: new (
82
+ "." ,
83
+ EXCEPTIONS ,
84
+ Some ( ( & [ "rustc-main" ] , PERMITTED_RUSTC_DEPENDENCIES , PERMITTED_RUSTC_DEPS_LOCATION ) ) ,
85
+ & [ ] ,
86
+ ) ,
80
87
WorkspaceInfo :: new (
81
88
"library" ,
82
89
EXCEPTIONS_STDLIB ,
83
- Some ( ( & [ "sysroot" ] , PERMITTED_STDLIB_DEPENDENCIES ) ) ,
90
+ Some ( ( & [ "sysroot" ] , PERMITTED_STDLIB_DEPENDENCIES , PERMITTED_STDLIB_DEPS_LOCATION ) ) ,
84
91
& [ ] ,
85
92
) ,
86
93
// Outside of the alphabetical section because rustfmt formats it using multiple lines.
87
94
WorkspaceInfo :: new (
88
95
"compiler/rustc_codegen_cranelift" ,
89
96
EXCEPTIONS_CRANELIFT ,
90
- Some ( ( & [ "rustc_codegen_cranelift" ] , PERMITTED_CRANELIFT_DEPENDENCIES ) ) ,
97
+ Some ( (
98
+ & [ "rustc_codegen_cranelift" ] ,
99
+ PERMITTED_CRANELIFT_DEPENDENCIES ,
100
+ PERMITTED_CRANELIFT_DEPS_LOCATION ,
101
+ ) ) ,
91
102
& [ ] ,
92
103
) ,
93
104
// tidy-alphabetical-start
@@ -261,6 +272,7 @@ const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[
261
272
( "r-efi" , "MIT OR Apache-2.0 OR LGPL-2.1-or-later" ) , // LGPL is not acceptable, but we use it under MIT OR Apache-2.0
262
273
] ;
263
274
275
+ #[ derive( Clone , Copy ) ]
264
276
struct ListLocation {
265
277
path : & ' static str ,
266
278
line : u32 ,
@@ -499,6 +511,8 @@ const PERMITTED_RUSTC_DEPENDENCIES: &[&str] = &[
499
511
// tidy-alphabetical-end
500
512
] ;
501
513
514
+ const PERMITTED_STDLIB_DEPS_LOCATION : ListLocation = location ! ( +2 ) ;
515
+
502
516
const PERMITTED_STDLIB_DEPENDENCIES : & [ & str ] = & [
503
517
// tidy-alphabetical-start
504
518
"addr2line" ,
@@ -540,6 +554,8 @@ const PERMITTED_STDLIB_DEPENDENCIES: &[&str] = &[
540
554
// tidy-alphabetical-end
541
555
] ;
542
556
557
+ const PERMITTED_CRANELIFT_DEPS_LOCATION : ListLocation = location ! ( +2 ) ;
558
+
543
559
const PERMITTED_CRANELIFT_DEPENDENCIES : & [ & str ] = & [
544
560
// tidy-alphabetical-start
545
561
"allocator-api2" ,
@@ -632,9 +648,9 @@ pub fn check(root: &Path, cargo: &Path, bless: bool, bad: &mut bool) {
632
648
let metadata = t ! ( cmd. exec( ) ) ;
633
649
634
650
check_license_exceptions ( & metadata, path, exceptions, bad) ;
635
- if let Some ( ( crates, permitted_deps) ) = crates_and_deps {
651
+ if let Some ( ( crates, permitted_deps, location ) ) = crates_and_deps {
636
652
let descr = crates. get ( 0 ) . unwrap_or ( & path) ;
637
- check_permitted_dependencies ( & metadata, descr, permitted_deps, crates, bad) ;
653
+ check_permitted_dependencies ( & metadata, descr, permitted_deps, crates, location , bad) ;
638
654
}
639
655
640
656
if path == "library" {
@@ -882,6 +898,7 @@ fn check_permitted_dependencies(
882
898
descr : & str ,
883
899
permitted_dependencies : & [ & ' static str ] ,
884
900
restricted_dependency_crates : & [ & ' static str ] ,
901
+ permitted_location : ListLocation ,
885
902
bad : & mut bool ,
886
903
) {
887
904
let mut has_permitted_dep_error = false ;
@@ -942,8 +959,7 @@ fn check_permitted_dependencies(
942
959
}
943
960
944
961
if has_permitted_dep_error {
945
- let ListLocation { path, line } = PERMITTED_RUSTC_DEPS_LOCATION ;
946
- eprintln ! ( "Go to `{path}:{line}` for the list." ) ;
962
+ eprintln ! ( "Go to `{}:{}` for the list." , permitted_location. path, permitted_location. line) ;
947
963
}
948
964
}
949
965
0 commit comments