Skip to content

Commit

Permalink
Auto merge of #36227 - jonathandturner:rollup, r=jonathandturner
Browse files Browse the repository at this point in the history
Rollup of 12 pull requests

- Successful merges: #35754, #35793, #36099, #36160, #36171, #36178, #36180, #36190, #36198, #36205, #36210, #36223
- Failed merges:
  • Loading branch information
bors authored Sep 3, 2016
2 parents ef9786c + c701490 commit 100b309
Show file tree
Hide file tree
Showing 29 changed files with 211 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ before_install:
script:
- docker run -v `pwd`:/build rust
sh -c "
./configure --llvm-root=/usr/lib/llvm-3.7 &&
./configure --enable-rustbuild --llvm-root=/usr/lib/llvm-3.7 &&
make tidy &&
make check-notidy -j4
make check -j4
"
# Real testing happens on http://buildbot.rust-lang.org/
Expand Down
12 changes: 8 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ abs_path() {
(unset CDPATH && cd "$_path" > /dev/null && pwd)
}

HELP=0
for arg; do
case "$arg" in
--help) HELP=1;;
esac
done

msg "looking for configure programs"
need_cmd cmp
need_cmd mkdir
Expand Down Expand Up @@ -566,11 +573,8 @@ esac


OPTIONS=""
HELP=0
if [ "$1" = "--help" ]
if [ "$HELP" -eq 1 ]
then
HELP=1
shift
echo
echo "Usage: $CFG_SELF [options]"
echo
Expand Down
1 change: 1 addition & 0 deletions mk/main.mk
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ LLVM_AS_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llvm-as$$(X_$(1))
LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))

LLVM_ALL_COMPONENTS_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --components)
LLVM_VERSION_$(1)=$$(shell "$$(LLVM_CONFIG_$(1))" --version)

endef

Expand Down
1 change: 1 addition & 0 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
--lldb-python $$(CFG_LLDB_PYTHON) \
--gdb-version="$(CFG_GDB_VERSION)" \
--lldb-version="$(CFG_LLDB_VERSION)" \
--llvm-version="$$(LLVM_VERSION_$(3))" \
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
--adb-path=$(CFG_ADB) \
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ pub fn compiletest(build: &Build,
if let Some(ref dir) = build.lldb_python_dir {
cmd.arg("--lldb-python-dir").arg(dir);
}
let llvm_config = build.llvm_config(target);
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
cmd.arg("--llvm-version").arg(llvm_version);

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

Expand All @@ -158,7 +161,6 @@ pub fn compiletest(build: &Build,
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if suite == "run-make" {
let llvm_config = build.llvm_config(target);
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
cmd.arg("--cc").arg(build.cc(target))
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
cargo.env("LLVM_RUSTLLVM", "1");
}
cargo.env("LLVM_CONFIG", build.llvm_config(target));
let target_config = build.config.target_config.get(target);
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
cargo.env("CFG_LLVM_ROOT", s);
}
if build.config.llvm_static_stdcpp {
cargo.env("LLVM_STATIC_STDCPP",
compiler_file(build.cxx(target), "libstdc++.a"));
Expand Down
3 changes: 3 additions & 0 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,9 @@ macro scope.
trait of the same name. `{Self}` will be replaced with the type that is supposed
to implement the trait but doesn't. To use this, the `on_unimplemented` feature gate
must be enabled.
- `must_use` - on structs and enums, will warn if a value of this type isn't used or
assigned to a variable. You may also include an optional message by using
`#[must_use = "message"]` which will be given alongside the warning.

### Conditional compilation

Expand Down
33 changes: 26 additions & 7 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,19 @@ macro_rules! debug_assert_eq {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
}

/// Helper macro for unwrapping `Result` values while returning early with an
/// error if the value of the expression is `Err`. Can only be used in
/// functions that return `Result` because of the early return of `Err` that
/// it provides.
/// Helper macro for reducing boilerplate code for matching `Result` together
/// with converting downstream errors.
///
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
/// expression has the value of the wrapped value.
///
/// In case of the `Err` variant, it retrieves the inner error. `try!` then
/// performs conversion using `From`. This provides automatic conversion
/// between specialized errors and more general ones. The resulting
/// error is then immediately returned.
///
/// Because of the early return, `try!` can only be used in functions that
/// return `Result`.
///
/// # Examples
///
Expand All @@ -201,18 +210,28 @@ macro_rules! debug_assert_eq {
/// use std::fs::File;
/// use std::io::prelude::*;
///
/// fn write_to_file_using_try() -> Result<(), io::Error> {
/// enum MyError {
/// FileWriteError
/// }
///
/// impl From<io::Error> for MyError {
/// fn from(e: io::Error) -> MyError {
/// MyError::FileWriteError
/// }
/// }
///
/// fn write_to_file_using_try() -> Result<(), MyError> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// try!(file.write_all(b"This is a list of my best friends."));
/// println!("I wrote to the file");
/// Ok(())
/// }
/// // This is equivalent to:
/// fn write_to_file_using_match() -> Result<(), io::Error> {
/// fn write_to_file_using_match() -> Result<(), MyError> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// match file.write_all(b"This is a list of my best friends.") {
/// Ok(v) => v,
/// Err(e) => return Err(e),
/// Err(e) => return Err(From::from(e)),
/// }
/// println!("I wrote to the file");
/// Ok(())
Expand Down
12 changes: 12 additions & 0 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ macro_rules! forward_ref_binop {
/// Point { x: 3, y: 3 });
/// }
/// ```
///
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
/// [std::time::SystemTime] implements `Add<Duration>`, which permits
/// operations of the form `SystemTime = SystemTime + Duration`.
///
/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html
#[lang = "add"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Add<RHS=Self> {
Expand Down Expand Up @@ -349,6 +355,12 @@ add_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }
/// Point { x: 1, y: 0 });
/// }
/// ```
///
/// Note that `RHS = Self` by default, but this is not mandatory. For example,
/// [std::time::SystemTime] implements `Sub<Duration>`, which permits
/// operations of the form `SystemTime = SystemTime - Duration`.
///
/// [std::time::SystemTime]: ../../std/time/struct.SystemTime.html
#[lang = "sub"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Sub<RHS=Self> {
Expand Down
22 changes: 14 additions & 8 deletions src/librustc_borrowck/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}

err_out_of_scope(super_scope, sub_scope, cause) => {
let (value_kind, value_msg) = match err.cmt.cat {
mc::Categorization::Rvalue(_) =>
("temporary value", "temporary value created here"),
_ =>
("borrowed value", "does not live long enough")
};
match cause {
euv::ClosureCapture(s) => {
// The primary span starts out as the closure creation point.
Expand All @@ -1038,13 +1044,13 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
Some(primary) => {
db.span = MultiSpan::from_span(s);
db.span_label(primary, &format!("capture occurs here"));
db.span_label(s, &format!("does not live long enough"));
db.span_label(s, &value_msg);
}
None => ()
}
}
_ => {
db.span_label(error_span, &format!("does not live long enough"));
db.span_label(error_span, &value_msg);
}
}

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

match (sub_span, super_span) {
(Some(s1), Some(s2)) if s1 == s2 => {
db.span_label(s1, &"borrowed value dropped before borrower");
db.span_label(s1, &format!("{} dropped before borrower", value_kind));
db.note("values in a scope are dropped in the opposite order \
they are created");
}
_ => {
match sub_span {
Some(s) => {
db.span_label(s, &"borrowed value must be valid until here");
db.span_label(s, &format!("{} needs to live until here",
value_kind));
}
None => {
self.tcx.note_and_explain_region(
Expand All @@ -1072,7 +1079,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
match super_span {
Some(s) => {
db.span_label(s, &"borrowed value only valid until here");
db.span_label(s, &format!("{} only lives until here", value_kind));
}
None => {
self.tcx.note_and_explain_region(
Expand All @@ -1085,9 +1092,8 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
}
}

if let Some(span) = statement_scope_span(self.tcx, super_scope) {
db.span_help(span,
"consider using a `let` binding to increase its lifetime");
if let Some(_) = statement_scope_span(self.tcx, super_scope) {
db.note("consider using a `let` binding to increase its lifetime");
}
}

Expand Down
15 changes: 13 additions & 2 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,11 @@ impl Destination {
Style::FileNameStyle | Style::LineAndColumn => {}
Style::LineNumber => {
try!(self.start_attr(term::Attr::Bold));
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
if cfg!(windows) {
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_CYAN)));
} else {
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
}
}
Style::ErrorCode => {
try!(self.start_attr(term::Attr::Bold));
Expand All @@ -896,6 +900,9 @@ impl Destination {
}
Style::OldSchoolNoteText | Style::HeaderMsg => {
try!(self.start_attr(term::Attr::Bold));
if cfg!(windows) {
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_WHITE)));
}
}
Style::UnderlinePrimary | Style::LabelPrimary => {
try!(self.start_attr(term::Attr::Bold));
Expand All @@ -904,7 +911,11 @@ impl Destination {
Style::UnderlineSecondary |
Style::LabelSecondary => {
try!(self.start_attr(term::Attr::Bold));
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
if cfg!(windows) {
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_CYAN)));
} else {
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
}
}
Style::NoStyle => {}
Style::Level(l) => {
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,13 @@ impl Level {
pub fn color(self) -> term::color::Color {
match self {
Bug | Fatal | PhaseFatal | Error => term::color::BRIGHT_RED,
Warning => term::color::YELLOW,
Warning => {
if cfg!(windows) {
term::color::BRIGHT_YELLOW
} else {
term::color::YELLOW
}
},
Note => term::color::BRIGHT_GREEN,
Help => term::color::BRIGHT_CYAN,
Cancelled => unreachable!(),
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1878,11 +1878,16 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
hir::DefaultReturn(..) => self.tcx().mk_nil(),
};

let input_tys = self_ty.into_iter().chain(arg_tys).collect();

debug!("ty_of_method_or_bare_fn: input_tys={:?}", input_tys);
debug!("ty_of_method_or_bare_fn: output_ty={:?}", output_ty);

(self.tcx().mk_bare_fn(ty::BareFnTy {
unsafety: unsafety,
abi: abi,
sig: ty::Binder(ty::FnSig {
inputs: self_ty.into_iter().chain(arg_tys).collect(),
inputs: input_tys,
output: output_ty,
variadic: decl.variadic
}),
Expand Down
14 changes: 10 additions & 4 deletions src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else if let Some(rest) = size.checked_sub(min_len) {
(inner_ty, tcx.mk_array(inner_ty, rest))
} else {
span_err!(tcx.sess, pat.span, E0528,
"pattern requires at least {} elements but array has {}",
min_len, size);
struct_span_err!(tcx.sess, pat.span, E0528,
"pattern requires at least {} elements but array has {}",
min_len, size)
.span_label(pat.span,
&format!("pattern cannot match array of {} elements", size))
.emit();
(inner_ty, tcx.types.err)
}
}
Expand All @@ -270,7 +273,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
_ => {}
}
}
err.emit();

err.span_label( pat.span,
&format!("pattern cannot match with input type `{}`", expected_ty)
).emit();
}
(tcx.types.err, tcx.types.err)
}
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_typeck/check/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {

let fn_sig = self.tcx.liberate_late_bound_regions(
self.tcx.region_maps.call_site_extent(expr.id, body.id), &fn_ty.sig);
let fn_sig =
(**self).normalize_associated_types_in(body.span, body.id, &fn_sig);

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

Expand Down
5 changes: 3 additions & 2 deletions src/libsyntax/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,9 @@ pub fn find_export_name_attr(diag: &Handler, attrs: &[Attribute]) -> Option<Inte
} else {
struct_span_err!(diag, attr.span, E0558,
"export_name attribute has invalid format")
.help("use #[export_name=\"*\"]")
.emit();
.span_label(attr.span,
&format!("did you mean #[export_name=\"*\"]?"))
.emit();
None
}
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0528.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
fn main() {
let r = &[1, 2];
match r {
&[a, b, c, rest..] => { //~ ERROR E0528
&[a, b, c, rest..] => {
//~^ ERROR E0528
//~| NOTE pattern cannot match array of 2 elements
}
}
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0529.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
fn main() {
let r: f32 = 1.0;
match r {
[a, b] => { //~ ERROR E0529
[a, b] => {
//~^ ERROR E0529
//~| NOTE pattern cannot match with input type `f32`
}
}
}
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0558.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[export_name] //~ ERROR E0558
#[export_name]
//~^ ERROR E0558
//~| NOTE did you mean #[export_name="*"]?

pub fn something() {}

fn main() {}
Loading

0 comments on commit 100b309

Please sign in to comment.