Rollup merge of #52080 - oli-obk:dep_dedup_diagnostics, r=kennytm

Improve dependency deduplication diagnostics

r? @kennytm

this is obviously hard to test 😆

cc #52072
This commit is contained in:
kennytm 2018-07-06 07:07:24 +08:00
commit f1a36fc29f
No known key found for this signature in database
GPG Key ID: FEF6C8051D0E013C
2 changed files with 23 additions and 6 deletions

View File

@ -115,6 +115,7 @@
#![deny(warnings)]
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#[macro_use]
extern crate build_helper;

View File

@ -13,6 +13,7 @@ use std::env;
use std::iter;
use std::path::PathBuf;
use std::process::{Command, exit};
use std::collections::HashSet;
use Mode;
use Compiler;
@ -122,8 +123,13 @@ impl Step for ToolBuild {
let mut duplicates = Vec::new();
let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| {
// Only care about big things like the RLS/Cargo for now
if tool != "rls" && tool != "cargo" && tool != "clippy-driver" {
return
match tool {
| "rls"
| "cargo"
| "clippy-driver"
=> {}
_ => return,
}
let (id, features, filenames) = match msg {
compile::CargoMessage::CompilerArtifact {
@ -182,12 +188,22 @@ impl Step for ToolBuild {
typically means that something was recompiled because \
a transitive dependency has different features activated \
than in a previous build:\n");
println!("the following dependencies are duplicated although they \
have the same features enabled:");
for (id, cur, prev) in duplicates.drain_filter(|(_, cur, prev)| cur.2 == prev.2) {
println!(" {}", id);
// same features
println!(" `{}` ({:?})\n `{}` ({:?})", cur.0, cur.1, prev.0, prev.1);
}
println!("the following dependencies have different features:");
for (id, cur, prev) in duplicates {
println!(" {}", id);
println!(" `{}` enabled features {:?} at {:?}",
cur.0, cur.2, cur.1);
println!(" `{}` enabled features {:?} at {:?}",
prev.0, prev.2, prev.1);
let cur_features: HashSet<_> = cur.2.into_iter().collect();
let prev_features: HashSet<_> = prev.2.into_iter().collect();
println!(" `{}` additionally enabled features {:?} at {:?}",
cur.0, &cur_features - &prev_features, cur.1);
println!(" `{}` additionally enabled features {:?} at {:?}",
prev.0, &prev_features - &cur_features, prev.1);
}
println!("");
panic!("tools should not compile multiple copies of the same crate");