Auto merge of #35769 - eddyb:rollup, r=eddyb
Rollup of 12 pull requests - Successful merges: #35346, #35734, #35739, #35740, #35742, #35744, #35749, #35750, #35751, #35756, #35766, #35768 - Failed merges:
This commit is contained in:
commit
9d6520f97b
@ -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
mk/cfg/mips-unknown-linux-uclibc.mk
Normal file
1
mk/cfg/mips-unknown-linux-uclibc.mk
Normal file
@ -0,0 +1 @@
|
||||
# rustbuild-only target
|
1
mk/cfg/mipsel-unknown-linux-uclibc.mk
Normal file
1
mk/cfg/mipsel-unknown-linux-uclibc.mk
Normal file
@ -0,0 +1 @@
|
||||
# rustbuild-only target
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
src/librustc_back/target/mips_unknown_linux_uclibc.rs
Normal file
30
src/librustc_back/target/mips_unknown_linux_uclibc.rs
Normal file
@ -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
src/librustc_back/target/mipsel_unknown_linux_uclibc.rs
Normal file
31
src/librustc_back/target/mipsel_unknown_linux_uclibc.rs
Normal file
@ -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()
|
||||
},
|
||||
})
|
||||
}
|
@ -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),
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -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
src/llvm
2
src/llvm
@ -1 +1 @@
|
||||
Subproject commit 786aad117be48547f4ca50fae84c4879fa992d4d
|
||||
Subproject commit c3eb3c7608f439231d0c1340af6b720f113b4bf4
|
@ -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
|
||||
|
@ -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!()
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
#![feature(intrinsics)]
|
||||
extern "rust-intrinsic" {
|
||||
fn foo(); //~ ERROR E0093
|
||||
fn foo();
|
||||
//~^ ERROR E0093
|
||||
//~| NOTE unrecognized intrinsic
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -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`
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
}
|
||||
|
@ -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
src/test/compile-fail/E0423.rs
Normal file
15
src/test/compile-fail/E0423.rs
Normal file
@ -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
src/test/compile-fail/E0424.rs
Normal file
22
src/test/compile-fail/E0424.rs
Normal file
@ -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
src/test/compile-fail/E0425.rs
Normal file
18
src/test/compile-fail/E0425.rs
Normal file
@ -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
src/test/compile-fail/E0426.rs
Normal file
15
src/test/compile-fail/E0426.rs
Normal file
@ -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
src/test/compile-fail/E0428.rs
Normal file
16
src/test/compile-fail/E0428.rs
Normal file
@ -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
src/test/compile-fail/E0429.rs
Normal file
15
src/test/compile-fail/E0429.rs
Normal file
@ -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
src/test/compile-fail/E0430.rs
Normal file
15
src/test/compile-fail/E0430.rs
Normal file
@ -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
src/test/compile-fail/E0431.rs
Normal file
14
src/test/compile-fail/E0431.rs
Normal file
@ -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
src/test/compile-fail/E0432.rs
Normal file
14
src/test/compile-fail/E0432.rs
Normal file
@ -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
src/test/compile-fail/E0433.rs
Normal file
13
src/test/compile-fail/E0433.rs
Normal file
@ -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
src/test/compile-fail/E0434.rs
Normal file
19
src/test/compile-fail/E0434.rs
Normal file
@ -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
src/test/compile-fail/E0435.rs
Normal file
14
src/test/compile-fail/E0435.rs
Normal file
@ -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
src/test/compile-fail/E0437.rs
Normal file
18
src/test/compile-fail/E0437.rs
Normal file
@ -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
src/test/compile-fail/E0438.rs
Normal file
20
src/test/compile-fail/E0438.rs
Normal file
@ -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
src/test/compile-fail/E0439.rs
Normal file
18
src/test/compile-fail/E0439.rs
Normal file
@ -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
src/test/compile-fail/E0440.rs
Normal file
22
src/test/compile-fail/E0440.rs
Normal file
@ -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
src/test/compile-fail/issue-11004.rs
Normal file
39
src/test/compile-fail/issue-11004.rs
Normal file
@ -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
src/test/run-pass/mir_early_return_scope.rs
Normal file
37
src/test/run-pass/mir_early_return_scope.rs
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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() {
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user