@@ -46,11 +46,15 @@ fn main() {
46
46
}
47
47
48
48
if let Some ( "miri" ) = std:: env:: args ( ) . nth ( 1 ) . as_ref ( ) . map ( AsRef :: as_ref) {
49
- // this arm is when `cargo miri` is called
49
+ // this arm is when `cargo miri` is called. We call `cargo rustc` for
50
+ // each applicable target, but with the RUSTC env var set to the `cargo-miri`
51
+ // binary so that we come back in the other branch, and dispatch
52
+ // the invocations to rustc and miri, respectively.
50
53
51
54
let test = std:: env:: args ( ) . nth ( 2 ) . map_or ( false , |text| text == "test" ) ;
52
55
let skip = if test { 3 } else { 2 } ;
53
56
57
+ // We need to get the manifest, and then the metadata, to enumerate targets.
54
58
let manifest_path_arg = std:: env:: args ( ) . skip ( skip) . find ( |val| {
55
59
val. starts_with ( "--manifest-path=" )
56
60
} ) ;
@@ -92,6 +96,9 @@ fn main() {
92
96
} )
93
97
. expect ( "could not find matching package" ) ;
94
98
let package = metadata. packages . remove ( package_index) ;
99
+
100
+ // Finally we got the metadata, iterate all targets and see for which ones
101
+ // we do anything.
95
102
for target in package. targets {
96
103
let args = std:: env:: args ( ) . skip ( skip) ;
97
104
let kind = target. kind . get ( 0 ) . expect (
@@ -139,7 +146,8 @@ fn main() {
139
146
}
140
147
}
141
148
} else {
142
- // this arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself
149
+ // This arm is executed when cargo-miri runs `cargo rustc` with the `RUSTC` env var set to itself:
150
+ // Dependencies get dispatched to rustc, the final test/binary to miri.
143
151
144
152
let home = option_env ! ( "RUSTUP_HOME" ) . or ( option_env ! ( "MULTIRUST_HOME" ) ) ;
145
153
let toolchain = option_env ! ( "RUSTUP_TOOLCHAIN" ) . or ( option_env ! ( "MULTIRUST_TOOLCHAIN" ) ) ;
0 commit comments