Skip to content

Commit 68df9d6

Browse files
committed
Auto merge of #48077 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests - Successful merges: #47835, #47854, #48015, #48047, #48051, #48058, #48064, #47790, #48059, #48078, #48080, #48085 - Failed merges:
2 parents 3bcda48 + 4a3394a commit 68df9d6

File tree

27 files changed

+248
-508
lines changed

27 files changed

+248
-508
lines changed

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@
151151
# default.
152152
#extended = false
153153

154+
# Installs choosen set of extended tools if enables. By default builds all.
155+
# If choosen tool failed to build the installation fails.
156+
#tools = ["cargo", "rls", "rustfmt", "analysis", "src"]
157+
154158
# Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose
155159
#verbose = 0
156160

src/bootstrap/builder.rs

+22-5
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,25 @@ impl<'a> Builder<'a> {
600600
//
601601
// FIXME: the guard against msvc shouldn't need to be here
602602
if !target.contains("msvc") {
603-
let cc = self.cc(target);
604-
cargo.env(format!("CC_{}", target), cc)
605-
.env("CC", cc);
603+
let ccache = self.config.ccache.as_ref();
604+
let ccacheify = |s: &Path| {
605+
let ccache = match ccache {
606+
Some(ref s) => s,
607+
None => return s.display().to_string(),
608+
};
609+
// FIXME: the cc-rs crate only recognizes the literal strings
610+
// `ccache` and `sccache` when doing caching compilations, so we
611+
// mirror that here. It should probably be fixed upstream to
612+
// accept a new env var or otherwise work with custom ccache
613+
// vars.
614+
match &ccache[..] {
615+
"ccache" | "sccache" => format!("{} {}", ccache, s.display()),
616+
_ => s.display().to_string(),
617+
}
618+
};
619+
let cc = ccacheify(&self.cc(target));
620+
cargo.env(format!("CC_{}", target), &cc)
621+
.env("CC", &cc);
606622

607623
let cflags = self.cflags(target).join(" ");
608624
cargo.env(format!("CFLAGS_{}", target), cflags.clone())
@@ -617,8 +633,9 @@ impl<'a> Builder<'a> {
617633
}
618634

619635
if let Ok(cxx) = self.cxx(target) {
620-
cargo.env(format!("CXX_{}", target), cxx)
621-
.env("CXX", cxx)
636+
let cxx = ccacheify(&cxx);
637+
cargo.env(format!("CXX_{}", target), &cxx)
638+
.env("CXX", &cxx)
622639
.env(format!("CXXFLAGS_{}", target), cflags.clone())
623640
.env("CXXFLAGS", cflags);
624641
}

src/bootstrap/config.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! This module implements parsing `config.toml` configuration files to tweak
1414
//! how the build runs.
1515
16-
use std::collections::HashMap;
16+
use std::collections::{HashMap, HashSet};
1717
use std::env;
1818
use std::fs::File;
1919
use std::io::prelude::*;
@@ -52,6 +52,7 @@ pub struct Config {
5252
pub target_config: HashMap<Interned<String>, Target>,
5353
pub full_bootstrap: bool,
5454
pub extended: bool,
55+
pub tools: Option<HashSet<String>>,
5556
pub sanitizers: bool,
5657
pub profiler: bool,
5758
pub ignore_git: bool,
@@ -191,6 +192,7 @@ struct Build {
191192
python: Option<String>,
192193
full_bootstrap: Option<bool>,
193194
extended: Option<bool>,
195+
tools: Option<HashSet<String>>,
194196
verbose: Option<usize>,
195197
sanitizers: Option<bool>,
196198
profiler: Option<bool>,
@@ -395,6 +397,7 @@ impl Config {
395397
set(&mut config.vendor, build.vendor);
396398
set(&mut config.full_bootstrap, build.full_bootstrap);
397399
set(&mut config.extended, build.extended);
400+
config.tools = build.tools;
398401
set(&mut config.verbose, build.verbose);
399402
set(&mut config.sanitizers, build.sanitizers);
400403
set(&mut config.profiler, build.profiler);

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def v(*args):
144144
o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two")
145145
o("extended", "build.extended", "build an extended rust tool set")
146146

147+
v("tools", "build.tools", "List of extended tools will be installed")
147148
v("build", "build.build", "GNUs ./configure syntax LLVM build triple")
148149
v("host", None, "GNUs ./configure syntax LLVM host triples")
149150
v("target", None, "GNUs ./configure syntax LLVM target triples")

src/bootstrap/install.rs

+23-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use dist::{self, pkgname, sanitize_sh, tmpdir};
2222

2323
use builder::{Builder, RunConfig, ShouldRun, Step};
2424
use cache::Interned;
25+
use config::Config;
2526

2627
pub fn install_docs(builder: &Builder, stage: u32, host: Interned<String>) {
2728
install_sh(builder, "docs", "rust-docs", stage, Some(host));
@@ -144,6 +145,19 @@ macro_rules! install {
144145
pub host: Interned<String>,
145146
}
146147

148+
impl $name {
149+
#[allow(dead_code)]
150+
fn should_build(config: &Config) -> bool {
151+
config.extended && config.tools.as_ref()
152+
.map_or(true, |t| t.contains($path))
153+
}
154+
155+
#[allow(dead_code)]
156+
fn should_install(builder: &Builder) -> bool {
157+
builder.config.tools.as_ref().map_or(false, |t| t.contains($path))
158+
}
159+
}
160+
147161
impl Step for $name {
148162
type Output = ();
149163
const DEFAULT: bool = true;
@@ -185,32 +199,34 @@ install!((self, builder, _config),
185199
install_std(builder, self.stage, *target);
186200
}
187201
};
188-
Cargo, "cargo", _config.extended, only_hosts: true, {
202+
Cargo, "cargo", Self::should_build(_config), only_hosts: true, {
189203
builder.ensure(dist::Cargo { stage: self.stage, target: self.target });
190204
install_cargo(builder, self.stage, self.target);
191205
};
192-
Rls, "rls", _config.extended, only_hosts: true, {
193-
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() {
206+
Rls, "rls", Self::should_build(_config), only_hosts: true, {
207+
if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() ||
208+
Self::should_install(builder) {
194209
install_rls(builder, self.stage, self.target);
195210
} else {
196211
println!("skipping Install RLS stage{} ({})", self.stage, self.target);
197212
}
198213
};
199-
Rustfmt, "rustfmt", _config.extended, only_hosts: true, {
200-
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() {
214+
Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, {
215+
if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() ||
216+
Self::should_install(builder) {
201217
install_rustfmt(builder, self.stage, self.target);
202218
} else {
203219
println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target);
204220
}
205221
};
206-
Analysis, "analysis", _config.extended, only_hosts: false, {
222+
Analysis, "analysis", Self::should_build(_config), only_hosts: false, {
207223
builder.ensure(dist::Analysis {
208224
compiler: builder.compiler(self.stage, self.host),
209225
target: self.target
210226
});
211227
install_analysis(builder, self.stage, self.target);
212228
};
213-
Src, "src", _config.extended, only_hosts: true, {
229+
Src, "src", Self::should_build(_config) , only_hosts: true, {
214230
builder.ensure(dist::Src);
215231
install_src(builder, self.stage);
216232
}, ONLY_BUILD;

src/dlmalloc

src/libcore/char.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl From<u8> for char {
211211

212212
/// An error which can be returned when parsing a char.
213213
#[stable(feature = "char_from_str", since = "1.20.0")]
214-
#[derive(Clone, Debug)]
214+
#[derive(Clone, Debug, PartialEq, Eq)]
215215
pub struct ParseCharError {
216216
kind: CharErrorKind,
217217
}

src/librustc/traits/error_reporting.rs

+49-44
Original file line numberDiff line numberDiff line change
@@ -764,8 +764,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
764764
} else {
765765
let (closure_span, found) = found_did
766766
.and_then(|did| self.tcx.hir.get_if_local(did))
767-
.map(|node| self.get_fn_like_arguments(node))
768-
.unwrap_or((found_span.unwrap(), found));
767+
.map(|node| {
768+
let (found_span, found) = self.get_fn_like_arguments(node);
769+
(Some(found_span), found)
770+
}).unwrap_or((found_span, found));
769771

770772
self.report_arg_count_mismatch(span,
771773
closure_span,
@@ -875,7 +877,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
875877
fn report_arg_count_mismatch(
876878
&self,
877879
span: Span,
878-
found_span: Span,
880+
found_span: Option<Span>,
879881
expected_args: Vec<ArgKind>,
880882
found_args: Vec<ArgKind>,
881883
is_closure: bool,
@@ -913,48 +915,51 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
913915
);
914916

915917
err.span_label(span, format!( "expected {} that takes {}", kind, expected_str));
916-
err.span_label(found_span, format!("takes {}", found_str));
917-
918-
if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] {
919-
if fields.len() == expected_args.len() {
920-
let sugg = fields.iter()
921-
.map(|(name, _)| name.to_owned())
922-
.collect::<Vec<String>>().join(", ");
923-
err.span_suggestion(found_span,
924-
"change the closure to take multiple arguments instead of \
925-
a single tuple",
926-
format!("|{}|", sugg));
918+
919+
if let Some(found_span) = found_span {
920+
err.span_label(found_span, format!("takes {}", found_str));
921+
922+
if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] {
923+
if fields.len() == expected_args.len() {
924+
let sugg = fields.iter()
925+
.map(|(name, _)| name.to_owned())
926+
.collect::<Vec<String>>().join(", ");
927+
err.span_suggestion(found_span,
928+
"change the closure to take multiple arguments instead of \
929+
a single tuple",
930+
format!("|{}|", sugg));
931+
}
927932
}
928-
}
929-
if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] {
930-
if fields.len() == found_args.len() && is_closure {
931-
let sugg = format!(
932-
"|({}){}|",
933-
found_args.iter()
934-
.map(|arg| match arg {
935-
ArgKind::Arg(name, _) => name.to_owned(),
936-
_ => "_".to_owned(),
937-
})
938-
.collect::<Vec<String>>()
939-
.join(", "),
940-
// add type annotations if available
941-
if found_args.iter().any(|arg| match arg {
942-
ArgKind::Arg(_, ty) => ty != "_",
943-
_ => false,
944-
}) {
945-
format!(": ({})",
946-
fields.iter()
947-
.map(|(_, ty)| ty.to_owned())
948-
.collect::<Vec<String>>()
949-
.join(", "))
950-
} else {
951-
"".to_owned()
952-
},
953-
);
954-
err.span_suggestion(found_span,
955-
"change the closure to accept a tuple instead of individual \
956-
arguments",
957-
sugg);
933+
if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] {
934+
if fields.len() == found_args.len() && is_closure {
935+
let sugg = format!(
936+
"|({}){}|",
937+
found_args.iter()
938+
.map(|arg| match arg {
939+
ArgKind::Arg(name, _) => name.to_owned(),
940+
_ => "_".to_owned(),
941+
})
942+
.collect::<Vec<String>>()
943+
.join(", "),
944+
// add type annotations if available
945+
if found_args.iter().any(|arg| match arg {
946+
ArgKind::Arg(_, ty) => ty != "_",
947+
_ => false,
948+
}) {
949+
format!(": ({})",
950+
fields.iter()
951+
.map(|(_, ty)| ty.to_owned())
952+
.collect::<Vec<String>>()
953+
.join(", "))
954+
} else {
955+
"".to_owned()
956+
},
957+
);
958+
err.span_suggestion(found_span,
959+
"change the closure to accept a tuple instead of \
960+
individual arguments",
961+
sugg);
962+
}
958963
}
959964
}
960965

0 commit comments

Comments
 (0)