Skip to content

Commit 100b309

Browse files
authored
Auto merge of #36227 - jonathandturner:rollup, r=jonathandturner
Rollup of 12 pull requests - Successful merges: #35754, #35793, #36099, #36160, #36171, #36178, #36180, #36190, #36198, #36205, #36210, #36223 - Failed merges:
2 parents ef9786c + c701490 commit 100b309

29 files changed

+211
-57
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ before_install:
1515
script:
1616
- docker run -v `pwd`:/build rust
1717
sh -c "
18-
./configure --llvm-root=/usr/lib/llvm-3.7 &&
18+
./configure --enable-rustbuild --llvm-root=/usr/lib/llvm-3.7 &&
1919
make tidy &&
20-
make check-notidy -j4
20+
make check -j4
2121
"
2222
2323
# Real testing happens on http://buildbot.rust-lang.org/

configure

+8-4
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,13 @@ abs_path() {
360360
(unset CDPATH && cd "$_path" > /dev/null && pwd)
361361
}
362362

363+
HELP=0
364+
for arg; do
365+
case "$arg" in
366+
--help) HELP=1;;
367+
esac
368+
done
369+
363370
msg "looking for configure programs"
364371
need_cmd cmp
365372
need_cmd mkdir
@@ -566,11 +573,8 @@ esac
566573

567574

568575
OPTIONS=""
569-
HELP=0
570-
if [ "$1" = "--help" ]
576+
if [ "$HELP" -eq 1 ]
571577
then
572-
HELP=1
573-
shift
574578
echo
575579
echo "Usage: $CFG_SELF [options]"
576580
echo

mk/main.mk

+1
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
348348
LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))
349349

350350
LLVM_ALL_COMPONENTS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --components)
351+
LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)
351352

352353
endef
353354

mk/tests.mk

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
649649
--lldb-python $$(CFG_LLDB_PYTHON) \
650650
--gdb-version="$(CFG_GDB_VERSION)" \
651651
--lldb-version="$(CFG_LLDB_VERSION)" \
652+
--llvm-version="$$(LLVM_VERSION_$(3))" \
652653
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
653654
--adb-path=$(CFG_ADB) \
654655
--adb-test-dir=$(CFG_ADB_TEST_DIR) \

src/bootstrap/check.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ pub fn compiletest(build: &Build,
148148
if let Some(ref dir) = build.lldb_python_dir {
149149
cmd.arg("--lldb-python-dir").arg(dir);
150150
}
151+
let llvm_config = build.llvm_config(target);
152+
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
153+
cmd.arg("--llvm-version").arg(llvm_version);
151154

152155
cmd.args(&build.flags.args);
153156

@@ -158,7 +161,6 @@ pub fn compiletest(build: &Build,
158161
// Only pass correct values for these flags for the `run-make` suite as it
159162
// requires that a C++ compiler was configured which isn't always the case.
160163
if suite == "run-make" {
161-
let llvm_config = build.llvm_config(target);
162164
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
163165
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
164166
cmd.arg("--cc").arg(build.cc(target))

src/bootstrap/compile.rs

+4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
203203
cargo.env("LLVM_RUSTLLVM", "1");
204204
}
205205
cargo.env("LLVM_CONFIG", build.llvm_config(target));
206+
let target_config = build.config.target_config.get(target);
207+
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
208+
cargo.env("CFG_LLVM_ROOT", s);
209+
}
206210
if build.config.llvm_static_stdcpp {
207211
cargo.env("LLVM_STATIC_STDCPP",
208212
compiler_file(build.cxx(target), "libstdc++.a"));

src/doc/reference.md

+3
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,9 @@ macro scope.
20712071
trait of the same name. `{Self}` will be replaced with the type that is supposed
20722072
to implement the trait but doesn't. To use this, the `on_unimplemented` feature gate
20732073
must be enabled.
2074+
- `must_use` - on structs and enums, will warn if a value of this type isn't used or
2075+
assigned to a variable. You may also include an optional message by using
2076+
`#[must_use = "message"]` which will be given alongside the warning.
20742077

20752078
### Conditional compilation
20762079

src/libcore/macros.rs

+26-7
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,19 @@ macro_rules! debug_assert_eq {
189189
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
190190
}
191191

192-
/// Helper macro for unwrapping `Result` values while returning early with an
193-
/// error if the value of the expression is `Err`. Can only be used in
194-
/// functions that return `Result` because of the early return of `Err` that
195-
/// it provides.
192+
/// Helper macro for reducing boilerplate code for matching `Result` together
193+
/// with converting downstream errors.
194+
///
195+
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
196+
/// expression has the value of the wrapped value.
197+
///
198+
/// In case of the `Err` variant, it retrieves the inner error. `try!` then
199+
/// performs conversion using `From`. This provides automatic conversion
200+
/// between specialized errors and more general ones. The resulting
201+
/// error is then immediately returned.
202+
///
203+
/// Because of the early return, `try!` can only be used in functions that
204+
/// return `Result`.
196205
///
197206
/// # Examples
198207
///
@@ -201,18 +210,28 @@ macro_rules! debug_assert_eq {
201210
/// use std::fs::File;
202211
/// use std::io::prelude::*;
203212
///
204-
/// fn write_to_file_using_try() -> Result<(), io::Error> {
213+
/// enum MyError {
214+
/// FileWriteError
215+
/// }
216+
///
217+
/// impl From<io::Error> for MyError {
218+
/// fn from(e: io::Error) -> MyError {
219+
/// MyError::FileWriteError
220+
/// }
221+
/// }
222+
///
223+
/// fn write_to_file_using_try() -> Result<(), MyError> {
205224
/// let mut file = try!(File::create("my_best_friends.txt"));
206225
/// try!(file.write_all(b"This is a list of my best friends."));
207226
/// println!("I wrote to the file");
208227
/// Ok(())
209228
/// }
210229
/// // This is equivalent to:
211-
/// fn write_to_file_using_match() -> Result<(), io::Error> {
230+
/// fn write_to_file_using_match() -> Result<(), MyError> {
212231
/// let mut file = try!(File::create("my_best_friends.txt"));
213232
/// match file.write_all(b"This is a list of my best friends.") {
214233
/// Ok(v) => v,
215-
/// Err(e) => return Err(e),
234+
/// Err(e) => return Err(From::from(e)),
216235
/// }
217236
/// println!("I wrote to the file");
218237
/// Ok(())

src/libcore/ops.rs

+12
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,12 @@ macro_rules! forward_ref_binop {
282282
/// Point { x: 3, y: 3 });
283283
/// }
284284
/// ```
285+
///
286+
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
287+
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
288+
/// operations of the form `SystemTime = SystemTime + Duration`.
289+
///
290+
/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html
285291
#[lang = "add"]
286292
#[stable(feature = "rust1", since = "1.0.0")]
287293
pub trait Add<RHS=Self> {
@@ -349,6 +355,12 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
349355
/// Point { x: 1, y: 0 });
350356
/// }
351357
/// ```
358+
///
359+
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
360+
/// [std::time::SystemTime] implements `Sub<Duration>`, which permits
361+
/// operations of the form `SystemTime = SystemTime - Duration`.
362+
///
363+
/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html
352364
#[lang = "sub"]
353365
#[stable(feature = "rust1", since = "1.0.0")]
354366
pub trait Sub<RHS=Self> {

src/librustc_borrowck/borrowck/mod.rs

+14-8
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10281028
}
10291029

10301030
err_out_of_scope(super_scope, sub_scope, cause) => {
1031+
let (value_kind, value_msg) = match err.cmt.cat {
1032+
mc::Categorization::Rvalue(_) =>
1033+
("temporary value", "temporary value created here"),
1034+
_ =>
1035+
("borrowed value", "does not live long enough")
1036+
};
10311037
match cause {
10321038
euv::ClosureCapture(s) => {
10331039
// The primary span starts out as the closure creation point.
@@ -1038,13 +1044,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10381044
Some(primary) => {
10391045
db.span = MultiSpan::from_span(s);
10401046
db.span_label(primary, &format!("capture occurs here"));
1041-
db.span_label(s, &format!("does not live long enough"));
1047+
db.span_label(s, &value_msg);
10421048
}
10431049
None => ()
10441050
}
10451051
}
10461052
_ => {
1047-
db.span_label(error_span, &format!("does not live long enough"));
1053+
db.span_label(error_span, &value_msg);
10481054
}
10491055
}
10501056

@@ -1053,14 +1059,15 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10531059

10541060
match (sub_span, super_span) {
10551061
(Some(s1), Some(s2)) if s1 == s2 => {
1056-
db.span_label(s1, &"borrowed value dropped before borrower");
1062+
db.span_label(s1, &format!("{} dropped before borrower", value_kind));
10571063
db.note("values in a scope are dropped in the opposite order \
10581064
they are created");
10591065
}
10601066
_ => {
10611067
match sub_span {
10621068
Some(s) => {
1063-
db.span_label(s, &"borrowed value must be valid until here");
1069+
db.span_label(s, &format!("{} needs to live until here",
1070+
value_kind));
10641071
}
10651072
None => {
10661073
self.tcx.note_and_explain_region(
@@ -1072,7 +1079,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10721079
}
10731080
match super_span {
10741081
Some(s) => {
1075-
db.span_label(s, &"borrowed value only valid until here");
1082+
db.span_label(s, &format!("{} only lives until here", value_kind));
10761083
}
10771084
None => {
10781085
self.tcx.note_and_explain_region(
@@ -1085,9 +1092,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
10851092
}
10861093
}
10871094

1088-
if let Some(span) = statement_scope_span(self.tcx, super_scope) {
1089-
db.span_help(span,
1090-
"consider using a `let` binding to increase its lifetime");
1095+
if let Some(_) = statement_scope_span(self.tcx, super_scope) {
1096+
db.note("consider using a `let` binding to increase its lifetime");
10911097
}
10921098
}
10931099

src/librustc_errors/emitter.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,11 @@ impl Destination {
883883
Style::FileNameStyle | Style::LineAndColumn => {}
884884
Style::LineNumber => {
885885
try!(self.start_attr(term::Attr::Bold));
886-
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
886+
if cfg!(windows) {
887+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_CYAN)));
888+
} else {
889+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
890+
}
887891
}
888892
Style::ErrorCode => {
889893
try!(self.start_attr(term::Attr::Bold));
@@ -896,6 +900,9 @@ impl Destination {
896900
}
897901
Style::OldSchoolNoteText | Style::HeaderMsg => {
898902
try!(self.start_attr(term::Attr::Bold));
903+
if cfg!(windows) {
904+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_WHITE)));
905+
}
899906
}
900907
Style::UnderlinePrimary | Style::LabelPrimary => {
901908
try!(self.start_attr(term::Attr::Bold));
@@ -904,7 +911,11 @@ impl Destination {
904911
Style::UnderlineSecondary |
905912
Style::LabelSecondary => {
906913
try!(self.start_attr(term::Attr::Bold));
907-
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
914+
if cfg!(windows) {
915+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_CYAN)));
916+
} else {
917+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
918+
}
908919
}
909920
Style::NoStyle => {}
910921
Style::Level(l) => {

src/librustc_errors/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,13 @@ impl Level {
732732
pub fn color(self) -> term::color::Color {
733733
match self {
734734
Bug | Fatal | PhaseFatal | Error => term::color::BRIGHT_RED,
735-
Warning => term::color::YELLOW,
735+
Warning => {
736+
if cfg!(windows) {
737+
term::color::BRIGHT_YELLOW
738+
} else {
739+
term::color::YELLOW
740+
}
741+
},
736742
Note => term::color::BRIGHT_GREEN,
737743
Help => term::color::BRIGHT_CYAN,
738744
Cancelled => unreachable!(),

src/librustc_typeck/astconv.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1878,11 +1878,16 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
18781878
hir::DefaultReturn(..) => self.tcx().mk_nil(),
18791879
};
18801880

1881+
let input_tys = self_ty.into_iter().chain(arg_tys).collect();
1882+
1883+
debug!("ty_of_method_or_bare_fn: input_tys={:?}", input_tys);
1884+
debug!("ty_of_method_or_bare_fn: output_ty={:?}", output_ty);
1885+
18811886
(self.tcx().mk_bare_fn(ty::BareFnTy {
18821887
unsafety: unsafety,
18831888
abi: abi,
18841889
sig: ty::Binder(ty::FnSig {
1885-
inputs: self_ty.into_iter().chain(arg_tys).collect(),
1890+
inputs: input_tys,
18861891
output: output_ty,
18871892
variadic: decl.variadic
18881893
}),

src/librustc_typeck/check/_match.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
248248
} else if let Some(rest) = size.checked_sub(min_len) {
249249
(inner_ty, tcx.mk_array(inner_ty, rest))
250250
} else {
251-
span_err!(tcx.sess, pat.span, E0528,
252-
"pattern requires at least {} elements but array has {}",
253-
min_len, size);
251+
struct_span_err!(tcx.sess, pat.span, E0528,
252+
"pattern requires at least {} elements but array has {}",
253+
min_len, size)
254+
.span_label(pat.span,
255+
&format!("pattern cannot match array of {} elements", size))
256+
.emit();
254257
(inner_ty, tcx.types.err)
255258
}
256259
}
@@ -270,7 +273,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
270273
_ => {}
271274
}
272275
}
273-
err.emit();
276+
277+
err.span_label( pat.span,
278+
&format!("pattern cannot match with input type `{}`", expected_ty)
279+
).emit();
274280
}
275281
(tcx.types.err, tcx.types.err)
276282
}

src/librustc_typeck/check/closure.rs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
7474

7575
let fn_sig = self.tcx.liberate_late_bound_regions(
7676
self.tcx.region_maps.call_site_extent(expr.id, body.id), &fn_ty.sig);
77+
let fn_sig =
78+
(**self).normalize_associated_types_in(body.span, body.id, &fn_sig);
7779

7880
check_fn(self, hir::Unsafety::Normal, expr.id, &fn_sig, decl, expr.id, &body);
7981

src/libsyntax/attr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,9 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Inte
438438
} else {
439439
struct_span_err!(diag, attr.span, E0558,
440440
"export_name attribute has invalid format")
441-
.help("use #[export_name=\"*\"]")
442-
.emit();
441+
.span_label(attr.span,
442+
&format!("did you mean #[export_name=\"*\"]?"))
443+
.emit();
443444
None
444445
}
445446
} else {

src/test/compile-fail/E0528.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
fn main() {
1414
let r = &[1, 2];
1515
match r {
16-
&[a, b, c, rest..] => { //~ ERROR E0528
16+
&[a, b, c, rest..] => {
17+
//~^ ERROR E0528
18+
//~| NOTE pattern cannot match array of 2 elements
1719
}
1820
}
1921
}

src/test/compile-fail/E0529.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
fn main() {
1414
let r: f32 = 1.0;
1515
match r {
16-
[a, b] => { //~ ERROR E0529
16+
[a, b] => {
17+
//~^ ERROR E0529
18+
//~| NOTE pattern cannot match with input type `f32`
1719
}
1820
}
1921
}

src/test/compile-fail/E0558.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[export_name] //~ ERROR E0558
11+
#[export_name]
12+
//~^ ERROR E0558
13+
//~| NOTE did you mean #[export_name="*"]?
14+
1215
pub fn something() {}
1316

1417
fn main() {}

0 commit comments

Comments
 (0)