@@ -82,15 +82,19 @@ fn config() -> color_eyre::Result<Config> {
82
82
#[ derive( Deserialize , Debug ) ]
83
83
#[ serde( rename = "compiler-artifact" , tag = "reason" ) ]
84
84
struct ArtifactMessage < ' a > {
85
- package_id : & ' a str ,
85
+ # [ serde ( borrow ) ]
86
86
target : ArtifactTarget < ' a > ,
87
+
88
+ #[ serde( borrow) ]
87
89
filenames : Vec < & ' a Path > ,
88
90
}
89
91
90
92
/// The `"target"` field of an [`ArtifactMessage`].
91
93
#[ derive( Deserialize , Debug ) ]
92
94
struct ArtifactTarget < ' a > {
93
95
name : & ' a str ,
96
+
97
+ #[ serde( borrow) ]
94
98
kind : Vec < & ' a str > ,
95
99
}
96
100
@@ -114,19 +118,17 @@ fn find_bevy_rlib() -> color_eyre::Result<PathBuf> {
114
118
115
119
ensure ! ( output. status. success( ) , "`cargo build --test=ui` failed." ) ;
116
120
117
- // The package ID of the `bevy` crate starts with this string.
118
- const BEVY_PACKAGE_ID_PREFIX : & str =
119
- "registry+https://github.com/rust-lang/crates.io-index#bevy@" ;
120
-
121
121
// It's theoretically possible for there to be multiple messages about building `libbevy.rlib`.
122
122
// We support this, but optimize for just 1 message.
123
123
let mut messages = Vec :: with_capacity ( 1 ) ;
124
124
125
+ // Convert the `stdout` to a string, replacing invalid characters with `�`.
126
+ let stdout = String :: from_utf8_lossy ( & output. stdout ) ;
127
+
125
128
// Iterate over each line in stdout, trying to deserialize it from JSON.
126
- for line in output . stdout . split ( | & byte| byte == b'\n' ) {
127
- if let Ok ( message) = serde_json:: from_slice :: < ArtifactMessage > ( line)
129
+ for line in stdout. lines ( ) {
130
+ if let Ok ( message) = serde_json:: from_str :: < ArtifactMessage > ( line)
128
131
// If the message passes the following conditions, it's probably the one we want.
129
- && message. package_id . starts_with ( BEVY_PACKAGE_ID_PREFIX )
130
132
&& message. target . name == "bevy"
131
133
&& message. target . kind . contains ( & "lib" )
132
134
{
0 commit comments