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

File tree

29 files changed

+211
-57
lines changed

29 files changed

+211
-57
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 26 additions & 7 deletions
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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 14 additions & 8 deletions
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

0 commit comments

Comments
 (0)