Skip to content

Commit ea4d566

Browse files
committed
---
yaml --- r: 277403 b: refs/heads/try c: b52d76a h: refs/heads/master i: 277401: dca4b3c 277399: bef097c
1 parent ff9ce59 commit ea4d566

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+934
-252
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 5cdcad9d357aa59ce0423b4f68cb9386310aba73
4+
refs/heads/try: b52d76a08528273b218f168753ed846ecfb59aec
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
623623
--lldb-python $$(CFG_LLDB_PYTHON) \
624624
--gdb-version="$(CFG_GDB_VERSION)" \
625625
--lldb-version="$(CFG_LLDB_VERSION)" \
626-
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
626+
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
627627
--adb-path=$(CFG_ADB) \
628628
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
629629
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \

branches/try/src/libcore/clone.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ pub trait Clone : Sized {
7575
}
7676
}
7777

78+
// FIXME(aburka): this method is used solely by #[derive] to
79+
// assert that every component of a type implements Clone.
80+
//
81+
// This should never be called by user code.
82+
#[doc(hidden)]
83+
#[inline(always)]
84+
#[unstable(feature = "derive_clone_copy",
85+
reason = "deriving hack, should not be public",
86+
issue = "0")]
87+
pub fn assert_receiver_is_clone<T: Clone + ?Sized>(_: &T) {}
88+
7889
#[stable(feature = "rust1", since = "1.0.0")]
7990
impl<'a, T: ?Sized> Clone for &'a T {
8091
/// Returns a shallow copy of the reference.

branches/try/src/librustc/infer/mod.rs

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use ty::fold::TypeFoldable;
3535
use ty::relate::{Relate, RelateResult, TypeRelation};
3636
use traits::{self, PredicateObligations, ProjectionMode};
3737
use rustc_data_structures::unify::{self, UnificationTable};
38-
use std::cell::{RefCell, Ref};
38+
use std::cell::{Cell, RefCell, Ref};
3939
use std::fmt;
4040
use syntax::ast;
4141
use syntax::codemap;
@@ -110,6 +110,25 @@ pub struct InferCtxt<'a, 'tcx: 'a> {
110110
// documentation for `ProjectionMode`.
111111
projection_mode: ProjectionMode,
112112

113+
// When an error occurs, we want to avoid reporting "derived"
114+
// errors that are due to this original failure. Normally, we
115+
// handle this with the `err_count_on_creation` count, which
116+
// basically just tracks how many errors were reported when we
117+
// started type-checking a fn and checks to see if any new errors
118+
// have been reported since then. Not great, but it works.
119+
//
120+
// However, when errors originated in other passes -- notably
121+
// resolve -- this heuristic breaks down. Therefore, we have this
122+
// auxiliary flag that one can set whenever one creates a
123+
// type-error that is due to an error in a prior pass.
124+
//
125+
// Don't read this flag directly, call `is_tainted_by_errors()`
126+
// and `set_tainted_by_errors()`.
127+
tainted_by_errors_flag: Cell<bool>,
128+
129+
// Track how many errors were reported when this infcx is created.
130+
// If the number of errors increases, that's also a sign (line
131+
// `tained_by_errors`) to avoid reporting certain kinds of errors.
113132
err_count_on_creation: usize,
114133
}
115134

@@ -379,6 +398,7 @@ pub fn new_infer_ctxt<'a, 'tcx>(tcx: &'a TyCtxt<'tcx>,
379398
reported_trait_errors: RefCell::new(FnvHashSet()),
380399
normalize: false,
381400
projection_mode: projection_mode,
401+
tainted_by_errors_flag: Cell::new(false),
382402
err_count_on_creation: tcx.sess.err_count()
383403
}
384404
}
@@ -1128,15 +1148,36 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11281148
.map(|method| resolve_ty(method.ty)))
11291149
}
11301150

1131-
pub fn errors_since_creation(&self) -> bool {
1132-
self.tcx.sess.err_count() - self.err_count_on_creation != 0
1151+
/// True if errors have been reported since this infcx was
1152+
/// created. This is sometimes used as a heuristic to skip
1153+
/// reporting errors that often occur as a result of earlier
1154+
/// errors, but where it's hard to be 100% sure (e.g., unresolved
1155+
/// inference variables, regionck errors).
1156+
pub fn is_tainted_by_errors(&self) -> bool {
1157+
debug!("is_tainted_by_errors(err_count={}, err_count_on_creation={}, \
1158+
tainted_by_errors_flag={})",
1159+
self.tcx.sess.err_count(),
1160+
self.err_count_on_creation,
1161+
self.tainted_by_errors_flag.get());
1162+
1163+
if self.tcx.sess.err_count() > self.err_count_on_creation {
1164+
return true; // errors reported since this infcx was made
1165+
}
1166+
self.tainted_by_errors_flag.get()
1167+
}
1168+
1169+
/// Set the "tainted by errors" flag to true. We call this when we
1170+
/// observe an error from a prior pass.
1171+
pub fn set_tainted_by_errors(&self) {
1172+
debug!("set_tainted_by_errors()");
1173+
self.tainted_by_errors_flag.set(true)
11331174
}
11341175

11351176
pub fn node_type(&self, id: ast::NodeId) -> Ty<'tcx> {
11361177
match self.tables.borrow().node_types.get(&id) {
11371178
Some(&t) => t,
11381179
// FIXME
1139-
None if self.errors_since_creation() =>
1180+
None if self.is_tainted_by_errors() =>
11401181
self.tcx.types.err,
11411182
None => {
11421183
bug!("no type for node {}: {} in fcx",
@@ -1158,7 +1199,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
11581199
free_regions: &FreeRegionMap,
11591200
subject_node_id: ast::NodeId) {
11601201
let errors = self.region_vars.resolve_regions(free_regions, subject_node_id);
1161-
if !self.errors_since_creation() {
1202+
if !self.is_tainted_by_errors() {
11621203
// As a heuristic, just skip reporting region errors
11631204
// altogether if other errors have been reported while
11641205
// this infcx was in use. This is totally hokey but

branches/try/src/librustc/infer/sub.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ impl<'a, 'tcx> TypeRelation<'a, 'tcx> for Sub<'a, 'tcx> {
9191
}
9292

9393
(&ty::TyError, _) | (_, &ty::TyError) => {
94+
infcx.set_tainted_by_errors();
9495
Ok(self.tcx().types.err)
9596
}
9697

branches/try/src/librustc/middle/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ impl RegionMaps {
389389
// but this isn't the only place
390390
}
391391
let idx = CodeExtent(self.code_extents.borrow().len() as u32);
392-
info!("CodeExtent({}) = {:?} [parent={}]", idx.0, e, parent.0);
392+
debug!("CodeExtent({}) = {:?} [parent={}]", idx.0, e, parent.0);
393393
self.code_extents.borrow_mut().push(e);
394394
self.scope_map.borrow_mut().push(parent);
395395
*v.insert(idx)

branches/try/src/librustc/traits/error_reporting.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,12 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
624624
predicate,
625625
obligation);
626626

627+
// Ambiguity errors are often caused as fallout from earlier
628+
// errors. So just ignore them if this infcx is tainted.
629+
if infcx.is_tainted_by_errors() {
630+
return;
631+
}
632+
627633
match predicate {
628634
ty::Predicate::Trait(ref data) => {
629635
let trait_ref = data.to_poly_trait_ref();

branches/try/src/librustc/traits/fulfill.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,12 +542,12 @@ fn process_predicate1<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
542542
let trait_obligation = obligation.with(data.clone());
543543
match selcx.select(&trait_obligation) {
544544
Ok(Some(vtable)) => {
545-
info!("selecting trait `{:?}` at depth {} yielded Ok(Some)",
545+
debug!("selecting trait `{:?}` at depth {} yielded Ok(Some)",
546546
data, obligation.recursion_depth);
547547
Ok(Some(vtable.nested_obligations()))
548548
}
549549
Ok(None) => {
550-
info!("selecting trait `{:?}` at depth {} yielded Ok(None)",
550+
debug!("selecting trait `{:?}` at depth {} yielded Ok(None)",
551551
data, obligation.recursion_depth);
552552

553553
// This is a bit subtle: for the most part, the
@@ -781,8 +781,6 @@ impl<'tcx> GlobalFulfilledPredicates<'tcx> {
781781
self.dep_graph.read(data.dep_node());
782782
debug!("check_duplicate: global predicate `{:?}` already proved elsewhere", data);
783783

784-
info!("check_duplicate_trait hit: `{:?}`", data);
785-
786784
true
787785
} else {
788786
false
@@ -798,7 +796,6 @@ impl<'tcx> GlobalFulfilledPredicates<'tcx> {
798796
if data.is_global() {
799797
if self.set.insert(data.clone()) {
800798
debug!("add_if_global: global predicate `{:?}` added", data);
801-
info!("check_duplicate_trait entry: `{:?}`", data);
802799
}
803800
}
804801
}

branches/try/src/librustc_back/target/arm_linux_androideabi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use target::Target;
1212

1313
pub fn target() -> Target {
1414
let mut base = super::android_base::opts();
15-
base.features = "+v7".to_string();
15+
base.features = "+v7,+vfp3,+d16".to_string();
1616

1717
Target {
1818
llvm_target: "arm-linux-androideabi".to_string(),

branches/try/src/librustc_trans/debuginfo/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use rustc::hir;
3434
use abi::Abi;
3535
use common::{NodeIdAndSpan, CrateContext, FunctionContext, Block, BlockAndBuilder};
3636
use monomorphize::Instance;
37+
use rustc::infer::normalize_associated_type;
3738
use rustc::ty::{self, Ty};
3839
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
3940
use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet};
@@ -368,6 +369,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
368369

369370
name_to_append_suffix_to.push('<');
370371
for (i, &actual_type) in actual_types.iter().enumerate() {
372+
let actual_type = normalize_associated_type(cx.tcx(), &actual_type);
371373
// Add actual type name to <...> clause of function name
372374
let actual_type_name = compute_debuginfo_type_name(cx,
373375
actual_type,
@@ -383,7 +385,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
383385
// Again, only create type information if full debuginfo is enabled
384386
let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo {
385387
generics.types.as_slice().iter().enumerate().map(|(i, param)| {
386-
let actual_type = actual_types[i];
388+
let actual_type = normalize_associated_type(cx.tcx(), &actual_types[i]);
387389
let actual_type_metadata = type_metadata(cx, actual_type, codemap::DUMMY_SP);
388390
let name = CString::new(param.name.as_str().as_bytes()).unwrap();
389391
unsafe {

branches/try/src/librustc_typeck/astconv.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ pub trait AstConv<'tcx> {
155155
_trait_ref: ty::TraitRef<'tcx>,
156156
_item_name: ast::Name)
157157
-> Ty<'tcx>;
158+
159+
/// Invoked when we encounter an error from some prior pass
160+
/// (e.g. resolve) that is translated into a ty-error. This is
161+
/// used to help suppress derived errors typeck might otherwise
162+
/// report.
163+
fn set_tainted_by_errors(&self);
158164
}
159165

160166
pub fn ast_region_to_region(tcx: &TyCtxt, lifetime: &hir::Lifetime)
@@ -1533,6 +1539,7 @@ fn base_def_to_ty<'tcx>(this: &AstConv<'tcx>,
15331539
prim_ty_to_ty(tcx, base_segments, prim_ty)
15341540
}
15351541
Def::Err => {
1542+
this.set_tainted_by_errors();
15361543
return this.tcx().types.err;
15371544
}
15381545
_ => {

branches/try/src/librustc_typeck/check/_match.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
209209
let self_ty = fcx.to_ty(&qself.ty);
210210
let path_res = if let Some(&d) = tcx.def_map.borrow().get(&pat.id) {
211211
if d.base_def == Def::Err {
212+
fcx.infcx().set_tainted_by_errors();
212213
fcx.write_error(pat.id);
213214
return;
214215
}
@@ -628,6 +629,7 @@ fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
628629
let path_res = match tcx.def_map.borrow().get(&pat.id) {
629630
Some(&path_res) if path_res.base_def != Def::Err => path_res,
630631
_ => {
632+
fcx.infcx().set_tainted_by_errors();
631633
fcx.write_error(pat.id);
632634

633635
if let Some(subpats) = subpats {

0 commit comments

Comments
 (0)