Rollup merge of #33852 - arielb1:autoderef-iterator, r=eddyb

refactor autoderef to avoid prematurely registering obligations

Refactor `FnCtxt::autoderef` to use an external iterator and to not
register any obligation from the main autoderef loop, but rather to
register them after (and if) the loop successfully completes.

Fixes #24819
Fixes #25801
Fixes #27631
Fixes #31258
Fixes #31964
Fixes #32320
Fixes #33515
Fixes #33755

r? @eddyb
This commit is contained in:
Manish Goregaokar 2016-05-28 19:52:16 +05:30
commit edd7d422b7
18 changed files with 507 additions and 464 deletions

View file

@ -19,5 +19,4 @@ fn main() {
let foo = Foo;
let ref_foo = &&Foo;
ref_foo.foo(); //~ ERROR E0055
//~^ ERROR E0275
}

View file

@ -99,7 +99,7 @@ fn assign_field1<'a>(x: Own<Point>) {
}
fn assign_field2<'a>(x: &'a Own<Point>) {
x.y = 3; //~ ERROR cannot assign
x.y = 3; //~ ERROR cannot borrow
}
fn assign_field3<'a>(x: &'a mut Own<Point>) {

View file

@ -0,0 +1,21 @@
// 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::collections::HashSet;
fn main() {
let mut v = Vec::new();
foo(&mut v);
//~^ ERROR mismatched types
//~| expected struct `std::collections::HashSet`, found struct `std::vec::Vec`
}
fn foo(h: &mut HashSet<u32>) {
}

View file

@ -34,7 +34,8 @@ impl<'a, 't> Foo<'a, 't> for &'a isize {
}
fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) {
//~^ ERROR method `wrong_bound1` has an incompatible type for trait
//~^ ERROR method not compatible with trait
//~^^ ERROR method not compatible with trait
//
// Note: This is a terrible error message. It is caused
// because, in the trait, 'b is early bound, and in the impl,

View file

@ -23,7 +23,7 @@ impl<'a> get_ctxt for has_ctxt<'a> {
// Here an error occurs because we used `&self` but
// the definition used `&`:
fn get_ctxt(&self) -> &'a ctxt { //~ ERROR method `get_ctxt` has an incompatible type
fn get_ctxt(&self) -> &'a ctxt { //~ ERROR method not compatible with trait
self.c
}