Skip to content
Merged
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
@@ -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`

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
@@ -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

7 changes: 7 additions & 0 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
6 changes: 5 additions & 1 deletion src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
@@ -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>)
{
@@ -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);
@@ -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
}

2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
@@ -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();
});
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
@@ -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),
9 changes: 5 additions & 4 deletions src/librustc_const_eval/check_match.rs
Original file line number Diff line number Diff line change
@@ -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();
}
};

79 changes: 59 additions & 20 deletions src/librustc_mir/build/scope.rs
Original file line number Diff line number Diff line change
@@ -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;
@@ -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);
@@ -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,
@@ -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);
2 changes: 1 addition & 1 deletion src/librustc_resolve/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -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
44 changes: 26 additions & 18 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
@@ -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
@@ -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,
@@ -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,
@@ -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);
106 changes: 85 additions & 21 deletions src/librustc_typeck/check/compare_method.rs
Original file line number Diff line number Diff line change
@@ -12,10 +12,9 @@ use middle::free_region::FreeRegionMap;
use rustc::infer::{self, InferOk, TypeOrigin};
use rustc::ty;
use rustc::traits::{self, Reveal};
use rustc::ty::error::ExpectedFound;
use rustc::ty::error::{ExpectedFound, TypeError};
use rustc::ty::subst::{Subst, Substs};
use rustc::hir::map::Node;
use rustc::hir::{ImplItemKind, TraitItem_};
use rustc::hir::{ImplItemKind, TraitItem_, Ty_};

use syntax::ast;
use syntax_pos::Span;
@@ -300,6 +299,7 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
impl_m_span,
impl_m_body_id,
&impl_sig);
let impl_args = impl_sig.inputs.clone();
let impl_fty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy {
unsafety: impl_m.fty.unsafety,
abi: impl_m.fty.abi,
@@ -318,6 +318,7 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
impl_m_span,
impl_m_body_id,
&trait_sig);
let trait_args = trait_sig.inputs.clone();
let trait_fty = tcx.mk_fn_ptr(tcx.mk_bare_fn(ty::BareFnTy {
unsafety: trait_m.fty.unsafety,
abi: trait_m.fty.abi,
@@ -331,16 +332,82 @@ pub fn compare_impl_method<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
impl_fty,
trait_fty);

let impl_m_iter = match tcx.map.expect_impl_item(impl_m_node_id).node {
ImplItemKind::Method(ref impl_m_sig, _) => impl_m_sig.decl.inputs.iter(),
_ => bug!("{:?} is not a method", impl_m)
};

let (impl_err_span, trait_err_span) = match terr {
TypeError::Mutability => {
if let Some(trait_m_node_id) = tcx.map.as_local_node_id(trait_m.def_id) {
let trait_m_iter = match tcx.map.expect_trait_item(trait_m_node_id).node {
TraitItem_::MethodTraitItem(ref trait_m_sig, _) =>
trait_m_sig.decl.inputs.iter(),
_ => bug!("{:?} is not a MethodTraitItem", trait_m)
};

impl_m_iter.zip(trait_m_iter).find(|&(ref impl_arg, ref trait_arg)| {
match (&impl_arg.ty.node, &trait_arg.ty.node) {
(&Ty_::TyRptr(_, ref impl_mt), &Ty_::TyRptr(_, ref trait_mt)) |
(&Ty_::TyPtr(ref impl_mt), &Ty_::TyPtr(ref trait_mt)) =>
impl_mt.mutbl != trait_mt.mutbl,
_ => false
}
}).map(|(ref impl_arg, ref trait_arg)| {
match (impl_arg.to_self(), trait_arg.to_self()) {
(Some(impl_self), Some(trait_self)) =>
(impl_self.span, Some(trait_self.span)),
(None, None) => (impl_arg.ty.span, Some(trait_arg.ty.span)),
_ => bug!("impl and trait fns have different first args, \
impl: {:?}, trait: {:?}", impl_arg, trait_arg)
}
}).unwrap_or((origin.span(), tcx.map.span_if_local(trait_m.def_id)))
} else {
(origin.span(), tcx.map.span_if_local(trait_m.def_id))
}
}
TypeError::Sorts(ExpectedFound { expected, found }) => {
if let Some(trait_m_node_id) = tcx.map.as_local_node_id(trait_m.def_id) {
let trait_m_iter = match tcx.map.expect_trait_item(trait_m_node_id).node {
TraitItem_::MethodTraitItem(ref trait_m_sig, _) =>
trait_m_sig.decl.inputs.iter(),
_ => bug!("{:?} is not a MethodTraitItem", trait_m)
};
let impl_iter = impl_args.iter();
let trait_iter = trait_args.iter();
let arg_idx = impl_iter.zip(trait_iter)
.position(|(impl_arg_ty, trait_arg_ty)| {
*impl_arg_ty == found && *trait_arg_ty == expected
}).unwrap();
impl_m_iter.zip(trait_m_iter)
.nth(arg_idx)
.map(|(impl_arg, trait_arg)|
(impl_arg.ty.span, Some(trait_arg.ty.span)))
.unwrap_or(
(origin.span(), tcx.map.span_if_local(trait_m.def_id)))
} else {
(origin.span(), tcx.map.span_if_local(trait_m.def_id))
}
}
_ => (origin.span(), tcx.map.span_if_local(trait_m.def_id))
};

let origin = TypeOrigin::MethodCompatCheck(impl_err_span);

let mut diag = struct_span_err!(
tcx.sess, origin.span(), E0053,
"method `{}` has an incompatible type for trait", trait_m.name
);

infcx.note_type_err(
&mut diag, origin,
&mut diag,
origin,
trait_err_span.map(|sp| (sp, format!("original trait requirement"))),
Some(infer::ValuePairs::Types(ExpectedFound {
expected: trait_fty,
found: impl_fty
})), &terr
expected: trait_fty,
found: impl_fty
})),
&terr
);
diag.emit();
return
@@ -487,12 +554,9 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
trait_ty);

// Locate the Span containing just the type of the offending impl
if let Some(impl_trait_node) = tcx.map.get_if_local(impl_c.def_id) {
if let Node::NodeImplItem(impl_trait_item) = impl_trait_node {
if let ImplItemKind::Const(ref ty, _) = impl_trait_item.node {
origin = TypeOrigin::Misc(ty.span);
}
}
match tcx.map.expect_impl_item(impl_c_node_id).node {
ImplItemKind::Const(ref ty, _) => origin = TypeOrigin::Misc(ty.span),
_ => bug!("{:?} is not a impl const", impl_c)
}

let mut diag = struct_span_err!(
@@ -502,16 +566,16 @@ pub fn compare_const_impl<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
);

// Add a label to the Span containing just the type of the item
if let Some(orig_trait_node) = tcx.map.get_if_local(trait_c.def_id) {
if let Node::NodeTraitItem(orig_trait_item) = orig_trait_node {
if let TraitItem_::ConstTraitItem(ref ty, _) = orig_trait_item.node {
diag.span_label(ty.span, &format!("original trait requirement"));
}
}
}
let trait_c_node_id = tcx.map.as_local_node_id(trait_c.def_id).unwrap();
let trait_c_span = match tcx.map.expect_trait_item(trait_c_node_id).node {
TraitItem_::ConstTraitItem(ref ty, _) => ty.span,
_ => bug!("{:?} is not a trait const", trait_c)
};

infcx.note_type_err(
&mut diag, origin,
&mut diag,
origin,
Some((trait_c_span, format!("original trait requirement"))),
Some(infer::ValuePairs::Types(ExpectedFound {
expected: trait_ty,
found: impl_ty
7 changes: 5 additions & 2 deletions src/librustc_typeck/check/intrinsic.rs
Original file line number Diff line number Diff line change
@@ -301,8 +301,11 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) {
}

ref other => {
span_err!(tcx.sess, it.span, E0093,
"unrecognized intrinsic function: `{}`", *other);
struct_span_err!(tcx.sess, it.span, E0093,
"unrecognized intrinsic function: `{}`",
*other)
.span_label(it.span, &format!("unrecognized intrinsic"))
.emit();
return;
}
};
4 changes: 4 additions & 0 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
@@ -3000,6 +3000,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
but no field with that name was found",
field.node, actual)
}, expr_t);
if let ty::TyRawPtr(..) = expr_t.sty {
err.note(&format!("`{0}` is a native pointer; perhaps you need to deref with \
`(*{0}).{1}`", pprust::expr_to_string(base), field.node));
}
if let ty::TyStruct(def, _) = expr_t.sty {
Self::suggest_field_names(&mut err, def.struct_variant(), field, vec![]);
}
2 changes: 1 addition & 1 deletion src/rustllvm/llvm-auto-clean-trigger
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
2016-08-07
2016-08-17
5 changes: 4 additions & 1 deletion src/test/compile-fail/E0009.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,10 @@ fn main() {
struct X { x: (), }
let x = Some((X { x: () }, X { x: () }));
match x {
Some((y, ref z)) => {}, //~ ERROR E0009
Some((y, ref z)) => {},
//~^ ERROR E0009
//~| NOTE by-move pattern here
//~| NOTE both by-ref and by-move used
None => panic!()
}
}
14 changes: 10 additions & 4 deletions src/test/compile-fail/E0053.rs
Original file line number Diff line number Diff line change
@@ -9,15 +9,21 @@
// except according to those terms.

trait Foo {
fn foo(x: u16);
fn bar(&self);
fn foo(x: u16); //~ NOTE original trait requirement
fn bar(&self); //~ NOTE original trait requirement
}

struct Bar;

impl Foo for Bar {
fn foo(x: i16) { } //~ ERROR E0053
fn bar(&mut self) { } //~ ERROR E0053
fn foo(x: i16) { }
//~^ ERROR method `foo` has an incompatible type for trait
//~| NOTE expected u16
fn bar(&mut self) { }
//~^ ERROR method `bar` has an incompatible type for trait
//~| NOTE values differ in mutability
//~| NOTE expected type `fn(&Bar)`
//~| NOTE found type `fn(&mut Bar)`
}

fn main() {
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0093.rs
Original file line number Diff line number Diff line change
@@ -10,7 +10,9 @@

#![feature(intrinsics)]
extern "rust-intrinsic" {
fn foo(); //~ ERROR E0093
fn foo();
//~^ ERROR E0093
//~| NOTE unrecognized intrinsic
}

fn main() {
6 changes: 5 additions & 1 deletion src/test/compile-fail/E0221.rs
Original file line number Diff line number Diff line change
@@ -18,7 +18,11 @@ trait Foo {
trait Bar : Foo {
type A: T2;
fn do_something() {
let _: Self::A; //~ ERROR E0221
let _: Self::A;
//~^ ERROR E0221
//~| NOTE ambiguous associated type `A`
//~| NOTE associated type `Self` could derive from `Foo`
//~| NOTE associated type `Self` could derive from `Bar`
}
}

2 changes: 2 additions & 0 deletions src/test/compile-fail/E0403.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
// except according to those terms.

fn foo<T, T>(s: T, u: T) {} //~ ERROR E0403
//~| NOTE already used
//~| NOTE first use of `T`

fn main() {
}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0407.rs
Original file line number Diff line number Diff line change
@@ -16,7 +16,9 @@ struct Bar;

impl Foo for Bar {
fn a() {}
fn b() {} //~ ERROR E0407
fn b() {}
//~^ ERROR E0407
//~| NOTE not a member of `Foo`
}

fn main() {
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0423.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

fn main () {
struct Foo { a: bool };

let f = Foo(); //~ ERROR E0423
}
22 changes: 22 additions & 0 deletions src/test/compile-fail/E0424.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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.

struct Foo;

impl Foo {
fn bar(self) {}

fn foo() {
self.bar(); //~ ERROR E0424
}
}

fn main () {
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/E0425.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

trait Foo {
fn bar() {
Self; //~ ERROR E0425
}
}

fn main () {
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0426.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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.

fn main () {
loop {
break 'a; //~ ERROR E0426
}
}
16 changes: 16 additions & 0 deletions src/test/compile-fail/E0428.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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.

struct Bar;
struct Bar; //~ ERROR E0428
//~^ ERROR E0428

fn main () {
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0429.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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 std::fmt::self; //~ ERROR E0429
//~^ ERROR E0432

fn main () {
}
15 changes: 15 additions & 0 deletions src/test/compile-fail/E0430.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// 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 std::fmt::{self, self}; //~ ERROR E0430
//~^ ERROR E0252

fn main () {
}
14 changes: 14 additions & 0 deletions src/test/compile-fail/E0431.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 {self}; //~ ERROR E0431

fn main () {
}
14 changes: 14 additions & 0 deletions src/test/compile-fail/E0432.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 something::Foo; //~ ERROR E0432

fn main () {
}
13 changes: 13 additions & 0 deletions src/test/compile-fail/E0433.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// 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.

fn main () {
let map = HashMap::new(); //~ ERROR E0433
}
19 changes: 19 additions & 0 deletions src/test/compile-fail/E0434.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

fn foo() {
let y = 5;
fn bar() -> u32 {
y //~ ERROR E0434
}
}

fn main () {
}
14 changes: 14 additions & 0 deletions src/test/compile-fail/E0435.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.

fn main () {
let foo = 42u32;
const FOO : u32 = foo; //~ ERROR E0435
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/E0437.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

trait Foo {}

impl Foo for i32 {
type Bar = bool; //~ ERROR E0437
}

fn main () {
}
20 changes: 20 additions & 0 deletions src/test/compile-fail/E0438.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// 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.

#![feature(associated_consts)]

trait Foo {}

impl Foo for i32 {
const BAR: bool = true; //~ ERROR E0438
}

fn main () {
}
18 changes: 18 additions & 0 deletions src/test/compile-fail/E0439.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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.

#![feature(platform_intrinsics)]

extern "platform-intrinsic" {
fn simd_shuffle<A,B>(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439
}

fn main () {
}
22 changes: 22 additions & 0 deletions src/test/compile-fail/E0440.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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.

#![feature(repr_simd)]
#![feature(platform_intrinsics)]

#[repr(simd)]
struct f64x2(f64, f64);

extern "platform-intrinsic" {
fn x86_mm_movemask_pd<T>(x: f64x2) -> i32; //~ ERROR E0440
}

fn main () {
}
39 changes: 39 additions & 0 deletions src/test/compile-fail/issue-11004.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// 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 std::mem;

struct A { x: i32, y: f64 }

#[cfg(not(works))]
unsafe fn access(n:*mut A) -> (i32, f64) {
let x : i32 = n.x; //~ ERROR attempted access of field `x`
//~| NOTE `n` is a native pointer; perhaps you need to deref with `(*n).x`
let y : f64 = n.y; //~ ERROR attempted access of field `y`
//~| NOTE `n` is a native pointer; perhaps you need to deref with `(*n).y`
(x, y)
}

#[cfg(works)]
unsafe fn access(n:*mut A) -> (i32, f64) {
let x : i32 = (*n).x;
let y : f64 = (*n).y;
(x, y)
}

fn main() {
let a : A = A { x: 3, y: 3.14 };
let p : &A = &a;
let (x,y) = unsafe {
let n : *mut A = mem::transmute(p);
access(n)
};
println!("x: {}, y: {}", x, y);
}
37 changes: 37 additions & 0 deletions src/test/run-pass/mir_early_return_scope.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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.

static mut DROP: bool = false;

struct ConnWrap(Conn);
impl ::std::ops::Deref for ConnWrap {
type Target=Conn;
fn deref(&self) -> &Conn { &self.0 }
}

struct Conn;
impl Drop for Conn {
fn drop(&mut self) { unsafe { DROP = true; } }
}

fn inner() {
let conn = &*match Some(ConnWrap(Conn)) {
Some(val) => val,
None => return,
};
return;
}

fn main() {
inner();
unsafe {
assert_eq!(DROP, true);
}
}
27 changes: 27 additions & 0 deletions src/test/ui/mismatched_types/trait-impl-fn-incompatibility.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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.

// rustc-env:RUST_NEW_ERROR_FORMAT

trait Foo {
fn foo(x: u16);
fn bar(&mut self, bar: &mut Bar);
}

struct Bar;

impl Foo for Bar {
fn foo(x: i16) { }
fn bar(&mut self, bar: &Bar) { }
}

fn main() {
}

23 changes: 23 additions & 0 deletions src/test/ui/mismatched_types/trait-impl-fn-incompatibility.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0053]: method `foo` has an incompatible type for trait
--> $DIR/trait-impl-fn-incompatibility.rs:21:15
|
14 | fn foo(x: u16);
| --- original trait requirement
...
21 | fn foo(x: i16) { }
| ^^^ expected u16, found i16

error[E0053]: method `bar` has an incompatible type for trait
--> $DIR/trait-impl-fn-incompatibility.rs:22:28
|
15 | fn bar(&mut self, bar: &mut Bar);
| -------- original trait requirement
...
22 | fn bar(&mut self, bar: &Bar) { }
| ^^^^ values differ in mutability
|
= note: expected type `fn(&mut Bar, &mut Bar)`
= note: found type `fn(&mut Bar, &Bar)`

error: aborting due to 2 previous errors