Skip to content

Rollup of 12 pull requests #35769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Aug 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
127489a
Update compiler error 0093 to use new error format
stanislav-tkach Aug 9, 2016
1cf9caf
add mips-uclibc targets
Aug 16, 2016
f0ff2d3
E0403 update error format
circuitfox Aug 17, 2016
34f856e
Update LLVM to include 4 backported commits by @majnemer.
eddyb Aug 17, 2016
4254b31
Update minimum CMake version in README
spladug Aug 17, 2016
7675e4b
Update E0009 to new format
Aug 17, 2016
12a159a
Add 'make help' for rustbuild
SimonSapin Aug 17, 2016
feeed0b
Fixes issue #11004
GuillaumeGomez Aug 17, 2016
d01bfb1
Remove trailing white space
Aug 17, 2016
6a1efbd
Merge branch 'master' into E0403-update-error-format
circuitfox Aug 17, 2016
2179def
New output for E0407
tvladyslav Aug 16, 2016
2d36642
Properly invalidate the early exit cache
nagisa Aug 17, 2016
2c3250a
Nice graphs
nagisa Aug 17, 2016
8d78237
Add new error code tests
GuillaumeGomez Aug 17, 2016
de5aaee
Updated test for E0221
tvladyslav Aug 17, 2016
3c4ecc9
Display secondary span for E0053 for Sort TypeErrors
KiChjang Aug 10, 2016
34bc3c9
Display secondary span for E0053 for Mutability TypeErrors
KiChjang Aug 17, 2016
31d56cb
Add UI test for E0053
KiChjang Aug 17, 2016
ed54226
Fix tidy check.
tvladyslav Aug 17, 2016
612506b
Rollup merge of #35346 - DarkEld3r:e0093-formatting, r=jonathandturner
eddyb Aug 18, 2016
5e9a5b3
Rollup merge of #35734 - japaric:mips-uclibc, r=alexcrichton
eddyb Aug 18, 2016
71759ec
Rollup merge of #35739 - circuitfox:E0403-update-error-format, r=jona…
eddyb Aug 18, 2016
99e5efd
Rollup merge of #35740 - eddyb:llvm-prl-fix, r=alexcrichton
eddyb Aug 18, 2016
7a27444
Rollup merge of #35742 - spladug:readme-cmake-version, r=nikomatsakis
eddyb Aug 18, 2016
394c449
Rollup merge of #35744 - DevShep:ds/update_E0009, r=jonathandturner
eddyb Aug 18, 2016
f1861b8
Rollup merge of #35749 - GuillaumeGomez:raw_field, r=jonathandturner
eddyb Aug 18, 2016
1e13de8
Rollup merge of #35750 - SimonSapin:help, r=alexcrichton
eddyb Aug 18, 2016
64c1aef
Rollup merge of #35751 - nagisa:mir-scope-fix-again, r=eddyb
eddyb Aug 18, 2016
c3601d4
Rollup merge of #35756 - crypto-universe:E0407, r=GuillaumeGomez
eddyb Aug 18, 2016
8ccc11b
Rollup merge of #35765 - KiChjang:e0053-bonus, r=jonathandturner
eddyb Aug 18, 2016
d36b296
Rollup merge of #35768 - GuillaumeGomez:err_codes, r=jonathandturner
eddyb Aug 18, 2016
d69cd72
Rollup merge of #35770 - crypto-universe:E0221, r=jonathandturner
eddyb Aug 18, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Read ["Installing Rust"] from [The Book].
* `g++` 4.7 or later or `clang++` 3.x
* `python` 2.7 (but not 3.x)
* GNU `make` 3.81 or later
* `cmake` 2.8.8 or later
* `cmake` 3.4.3 or later
* `curl`
* `git`

Expand Down
1 change: 1 addition & 0 deletions mk/cfg/mips-unknown-linux-uclibc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rustbuild-only target
1 change: 1 addition & 0 deletions mk/cfg/mipsel-unknown-linux-uclibc.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# rustbuild-only target
4 changes: 4 additions & 0 deletions src/bootstrap/mk/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ BOOTSTRAP := $(CFG_PYTHON) $(CFG_SRC_DIR)src/bootstrap/bootstrap.py $(BOOTSTRAP_
all:
$(Q)$(BOOTSTRAP)

# Don’t use $(Q) here, always show how to invoke the bootstrap script directly
help:
$(BOOTSTRAP) --help

clean:
$(Q)$(BOOTSTRAP) --clean

Expand Down
7 changes: 7 additions & 0 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ impl<'ast> Map<'ast> {
}
}

pub fn expect_impl_item(&self, id: NodeId) -> &'ast ImplItem {
match self.find(id) {
Some(NodeImplItem(item)) => item,
_ => bug!("expected impl item, found {}", self.node_to_string(id))
}
}

pub fn expect_trait_item(&self, id: NodeId) -> &'ast TraitItem {
match self.find(id) {
Some(NodeTraitItem(item)) => item,
Expand Down
6 changes: 5 additions & 1 deletion src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
pub fn note_type_err(&self,
diag: &mut DiagnosticBuilder<'tcx>,
origin: TypeOrigin,
secondary_span: Option<(Span, String)>,
values: Option<ValuePairs<'tcx>>,
terr: &TypeError<'tcx>)
{
Expand Down Expand Up @@ -553,6 +554,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
}

diag.span_label(span, &terr);
if let Some((sp, msg)) = secondary_span {
diag.span_label(sp, &msg);
}

self.note_error_origin(diag, &origin);
self.check_and_note_conflicting_crates(diag, terr, span);
Expand All @@ -569,7 +573,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
self.tcx.sess, trace.origin.span(), E0308,
"{}", trace.origin.as_failure_str()
);
self.note_type_err(&mut diag, trace.origin, Some(trace.values), terr);
self.note_type_err(&mut diag, trace.origin, None, Some(trace.values), terr);
diag
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
self.tcx.sess, origin.span(), E0271,
"type mismatch resolving `{}`", predicate
);
self.note_type_err(&mut diag, origin, values, err);
self.note_type_err(&mut diag, origin, None, values, err);
self.note_obligation_cause(&mut diag, obligation);
diag.emit();
});
Expand Down
30 changes: 30 additions & 0 deletions src/librustc_back/target/mips_unknown_linux_uclibc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use target::{Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "mips-unknown-linux-uclibc".to_string(),
target_endian: "big".to_string(),
target_pointer_width: "32".to_string(),
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
arch: "mips".to_string(),
target_os: "linux".to_string(),
target_env: "uclibc".to_string(),
target_vendor: "unknown".to_string(),
options: TargetOptions {
cpu: "mips32r2".to_string(),
features: "+mips32r2,+soft-float".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
},
})
}
31 changes: 31 additions & 0 deletions src/librustc_back/target/mipsel_unknown_linux_uclibc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use target::{Target, TargetOptions, TargetResult};

pub fn target() -> TargetResult {
Ok(Target {
llvm_target: "mipsel-unknown-linux-uclibc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "32".to_string(),
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
arch: "mips".to_string(),
target_os: "linux".to_string(),
target_env: "uclibc".to_string(),
target_vendor: "unknown".to_string(),

options: TargetOptions {
cpu: "mips32".to_string(),
features: "+mips32,+soft-float".to_string(),
max_atomic_width: 32,
..super::linux_base::opts()
},
})
}
2 changes: 2 additions & 0 deletions src/librustc_back/target/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ supported_targets! {
("i686-unknown-linux-musl", i686_unknown_linux_musl),
("mips-unknown-linux-musl", mips_unknown_linux_musl),
("mipsel-unknown-linux-musl", mipsel_unknown_linux_musl),
("mips-unknown-linux-uclibc", mips_unknown_linux_uclibc),
("mipsel-unknown-linux-uclibc", mipsel_unknown_linux_uclibc),

("i686-linux-android", i686_linux_android),
("arm-linux-androideabi", arm_linux_androideabi),
Expand Down
9 changes: 5 additions & 4 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,10 +1121,11 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
.span_label(p.span, &format!("moves value into pattern guard"))
.emit();
} else if by_ref_span.is_some() {
let mut err = struct_span_err!(cx.tcx.sess, p.span, E0009,
"cannot bind by-move and by-ref in the same pattern");
span_note!(&mut err, by_ref_span.unwrap(), "by-ref binding occurs here");
err.emit();
struct_span_err!(cx.tcx.sess, p.span, E0009,
"cannot bind by-move and by-ref in the same pattern")
.span_label(p.span, &format!("by-move pattern here"))
.span_label(by_ref_span.unwrap(), &format!("both by-ref and by-move used"))
.emit();
}
};

Expand Down
79 changes: 59 additions & 20 deletions src/librustc_mir/build/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ impl<'tcx> Scope<'tcx> {
///
/// Should always be run for all inner scopes when a drop is pushed into some scope enclosing a
/// larger extent of code.
fn invalidate_cache(&mut self) {
self.cached_exits = FnvHashMap();
///
/// `unwind` controls whether caches for the unwind branch are also invalidated.
fn invalidate_cache(&mut self, unwind: bool) {
self.cached_exits.clear();
if !unwind { return; }
for dropdata in &mut self.drops {
if let DropKind::Value { ref mut cached_block } = dropdata.kind {
*cached_block = None;
Expand Down Expand Up @@ -455,25 +458,65 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
};

for scope in self.scopes.iter_mut().rev() {
if scope.extent == extent {
let this_scope = scope.extent == extent;
// When building drops, we try to cache chains of drops in such a way so these drops
// could be reused by the drops which would branch into the cached (already built)
// blocks. This, however, means that whenever we add a drop into a scope which already
// had some blocks built (and thus, cached) for it, we must invalidate all caches which
// might branch into the scope which had a drop just added to it. This is necessary,
// because otherwise some other code might use the cache to branch into already built
// chain of drops, essentially ignoring the newly added drop.
//
// For example consider there’s two scopes with a drop in each. These are built and
// thus the caches are filled:
//
// +--------------------------------------------------------+
// | +---------------------------------+ |
// | | +--------+ +-------------+ | +---------------+ |
// | | | return | <-+ | drop(outer) | <-+ | drop(middle) | |
// | | +--------+ +-------------+ | +---------------+ |
// | +------------|outer_scope cache|--+ |
// +------------------------------|middle_scope cache|------+
//
// Now, a new, inner-most scope is added along with a new drop into both inner-most and
// outer-most scopes:
//
// +------------------------------------------------------------+
// | +----------------------------------+ |
// | | +--------+ +-------------+ | +---------------+ | +-------------+
// | | | return | <+ | drop(new) | <-+ | drop(middle) | <--+| drop(inner) |
// | | +--------+ | | drop(outer) | | +---------------+ | +-------------+
// | | +-+ +-------------+ | |
// | +---|invalid outer_scope cache|----+ |
// +----=----------------|invalid middle_scope cache|-----------+
//
// If, when adding `drop(new)` we do not invalidate the cached blocks for both
// outer_scope and middle_scope, then, when building drops for the inner (right-most)
// scope, the old, cached blocks, without `drop(new)` will get used, producing the
// wrong results.
//
// The cache and its invalidation for unwind branch is somewhat special. The cache is
// per-drop, rather than per scope, which has a several different implications. Adding
// a new drop into a scope will not invalidate cached blocks of the prior drops in the
// scope. That is true, because none of the already existing drops will have an edge
// into a block with the newly added drop.
//
// Note that this code iterates scopes from the inner-most to the outer-most,
// invalidating caches of each scope visited. This way bare minimum of the
// caches gets invalidated. i.e. if a new drop is added into the middle scope, the
// cache of outer scpoe stays intact.
let invalidate_unwind = needs_drop && !this_scope;
scope.invalidate_cache(invalidate_unwind);
if this_scope {
if let DropKind::Value { .. } = drop_kind {
scope.needs_cleanup = true;
}

// No need to invalidate any caches here. The just-scheduled drop will branch into
// the drop that comes before it in the vector.
scope.drops.push(DropData {
span: span,
location: lvalue.clone(),
kind: drop_kind
});
return;
} else {
// We must invalidate all the cached_blocks leading up to the scope we’re
// looking for, because all of the blocks in the chain will become incorrect.
if let DropKind::Value { .. } = drop_kind {
scope.invalidate_cache()
}
}
}
span_bug!(span, "extent {:?} not in scope to drop {:?}", extent, lvalue);
Expand All @@ -490,11 +533,12 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
value: &Lvalue<'tcx>,
item_ty: Ty<'tcx>) {
for scope in self.scopes.iter_mut().rev() {
// See the comment in schedule_drop above. The primary difference is that we invalidate
// the unwind blocks unconditionally. That’s because the box free may be considered
// outer-most cleanup within the scope.
scope.invalidate_cache(true);
if scope.extent == extent {
assert!(scope.free.is_none(), "scope already has a scheduled free!");
// We also must invalidate the caches in the scope for which the free is scheduled
// because the drops must branch into the free we schedule here.
scope.invalidate_cache();
scope.needs_cleanup = true;
scope.free = Some(FreeData {
span: span,
Expand All @@ -503,11 +547,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
cached_block: None
});
return;
} else {
// We must invalidate all the cached_blocks leading up to the scope we’re looking
// for, because otherwise some/most of the blocks in the chain will become
// incorrect.
scope.invalidate_cache();
}
}
span_bug!(span, "extent {:?} not in scope to free {:?}", extent, value);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ A `struct` variant name was used like a function name.
Erroneous code example:

```compile_fail,E0423
struct Foo { a: bool};
struct Foo { a: bool };

let f = Foo();
// error: `Foo` is a struct variant name, but this expression uses
Expand Down
44 changes: 26 additions & 18 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ enum ResolutionError<'a> {
/// error E0402: cannot use an outer type parameter in this context
OuterTypeParameterContext,
/// error E0403: the name is already used for a type parameter in this type parameter list
NameAlreadyUsedInTypeParameterList(Name),
NameAlreadyUsedInTypeParameterList(Name, &'a Span),
/// error E0404: is not a trait
IsNotATrait(&'a str),
/// error E0405: use of undeclared trait name
Expand Down Expand Up @@ -209,13 +209,17 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
E0402,
"cannot use an outer type parameter in this context")
}
ResolutionError::NameAlreadyUsedInTypeParameterList(name) => {
struct_span_err!(resolver.session,
span,
E0403,
"the name `{}` is already used for a type parameter in this type \
parameter list",
name)
ResolutionError::NameAlreadyUsedInTypeParameterList(name, first_use_span) => {
let mut err = struct_span_err!(resolver.session,
span,
E0403,
"the name `{}` is already used for a type parameter \
in this type parameter list",
name);
err.span_label(span, &format!("already used"));
err.span_label(first_use_span.clone(), &format!("first use of `{}`", name));
err

}
ResolutionError::IsNotATrait(name) => {
let mut err = struct_span_err!(resolver.session,
Expand All @@ -237,12 +241,14 @@ fn resolve_struct_error<'b, 'a: 'b, 'c>(resolver: &'b Resolver<'a>,
err
}
ResolutionError::MethodNotMemberOfTrait(method, trait_) => {
struct_span_err!(resolver.session,
span,
E0407,
"method `{}` is not a member of trait `{}`",
method,
trait_)
let mut err = struct_span_err!(resolver.session,
span,
E0407,
"method `{}` is not a member of trait `{}`",
method,
trait_);
err.span_label(span, &format!("not a member of `{}`", trait_));
err
}
ResolutionError::TypeNotMemberOfTrait(type_, trait_) => {
struct_span_err!(resolver.session,
Expand Down Expand Up @@ -1726,17 +1732,19 @@ impl<'a> Resolver<'a> {
match type_parameters {
HasTypeParameters(generics, rib_kind) => {
let mut function_type_rib = Rib::new(rib_kind);
let mut seen_bindings = HashSet::new();
let mut seen_bindings = HashMap::new();
for type_parameter in &generics.ty_params {
let name = type_parameter.ident.name;
debug!("with_type_parameter_rib: {}", type_parameter.id);

if seen_bindings.contains(&name) {
if seen_bindings.contains_key(&name) {
let span = seen_bindings.get(&name).unwrap();
resolve_error(self,
type_parameter.span,
ResolutionError::NameAlreadyUsedInTypeParameterList(name));
ResolutionError::NameAlreadyUsedInTypeParameterList(name,
span));
}
seen_bindings.insert(name);
seen_bindings.entry(name).or_insert(type_parameter.span);

// plain insert (no renaming)
let def_id = self.definitions.local_def_id(type_parameter.id);
Expand Down
Loading