Skip to content

Commit

Permalink
Correct merge errors, broken tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Jul 2, 2013
1 parent 4a0469e commit ef5c439
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ impl FnCtxt {
result::Err(RegionError {
msg: {
fmt!("named region `%s` not in scope here",
bound_region_to_str(self.tcx(), br))
bound_region_ptr_to_str(self.tcx(), br))
},
replacement: {
self.infcx().next_region_var(
Expand Down
42 changes: 39 additions & 3 deletions src/librustc/middle/typeck/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ time of error detection.
*/

use core::prelude::*;
use std::prelude::*;
use middle::ty;
use middle::ty::Region;
use middle::typeck::infer;
Expand All @@ -80,10 +80,46 @@ use syntax::opt_vec::OptVec;
use util::ppaux::UserString;
use util::ppaux::note_and_explain_region;

impl InferCtxt {
pub trait ErrorReporting {
pub fn report_region_errors(@mut self,
errors: &OptVec<RegionResolutionError>);

pub fn report_and_explain_type_error(@mut self,
trace: TypeTrace,
terr: &ty::type_err);

fn values_str(@mut self, values: &ValuePairs) -> Option<~str>;

fn expected_found_str<T:UserString+Resolvable>(
@mut self,
exp_found: &ty::expected_found<T>)
-> Option<~str>;

fn report_concrete_failure(@mut self,
origin: SubregionOrigin,
sub: Region,
sup: Region);

fn report_sub_sup_conflict(@mut self,
var_origin: RegionVariableOrigin,
sub_origin: SubregionOrigin,
sub_region: Region,
sup_origin: SubregionOrigin,
sup_region: Region);

fn report_sup_sup_conflict(@mut self,
var_origin: RegionVariableOrigin,
origin1: SubregionOrigin,
region1: Region,
origin2: SubregionOrigin,
region2: Region);
}


impl ErrorReporting for InferCtxt {
pub fn report_region_errors(@mut self,
errors: &OptVec<RegionResolutionError>) {
for errors.each |error| {
for errors.iter().advance |error| {
match *error {
ConcreteFailure(origin, sub, sup) => {
self.report_concrete_failure(origin, sub, sup);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/middle/typeck/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use middle::typeck::infer::sub::Sub;
use middle::typeck::infer::lub::Lub;
use middle::typeck::infer::to_str::InferStr;
use middle::typeck::infer::unify::{ValsAndBindings, Root};
use middle::typeck::infer::error_reporting::ErrorReporting;
use middle::typeck::isr_alist;
use util::common::indent;
use util::ppaux::{bound_region_to_str, ty_to_str, trait_ref_to_str, Repr,
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/middle/typeck/infer/region_inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ mod doc;
enum Constraint {
ConstrainVarSubVar(RegionVid, RegionVid),
ConstrainRegSubVar(Region, RegionVid),
ConstrainVarSubReg(RegionVid, Region)
ConstrainVarSubReg(RegionVid, Region),
ConstrainRegSubReg(Region, Region),
}

#[deriving(Eq, IterBytes)]
Expand Down Expand Up @@ -454,7 +455,7 @@ impl RegionVarBindings {
{
let mut result_set = result_set;
if r == r1 { // Clearly, this is potentially inefficient.
if !result_set.iter().any_(|x| x == r2) {
if !result_set.iter().any_(|x| *x == r2) {
result_set.push(r2);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ impl Repr for @ast::pat {

impl Repr for ty::bound_region {
fn repr(&self, tcx: ctxt) -> ~str {
bound_region_to_str(tcx, *self)
bound_region_ptr_to_str(tcx, *self)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/compile-fail/regions-bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ struct an_enum<'self>(&'self int);
struct a_class<'self> { x:&'self int }

fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
return e; //~ ERROR mismatched types: expected `an_enum<'b> ` but found `an_enum<'a> `
return e; //~ ERROR mismatched types: expected `an_enum<'b>` but found `an_enum<'a>`
//~^ ERROR cannot infer an appropriate lifetime
}

fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
return e; //~ ERROR mismatched types: expected `a_class<'b> ` but found `a_class<'a> `
return e; //~ ERROR mismatched types: expected `a_class<'b>` but found `a_class<'a>`
//~^ ERROR cannot infer an appropriate lifetime
}

Expand Down

17 comments on commit ef5c439

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at nikomatsakis@ef5c439

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 into auto

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 merged ok, testing candidate = 3b966d4d

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate ef5c439 found, likely manual push to master

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 into auto

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 merged ok, testing candidate = 3e6242be

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate ef5c439 found, likely manual push to master

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 into auto

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 merged ok, testing candidate = 98f0e85f

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate ef5c439 found, likely manual push to master

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 into auto

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 merged ok, testing candidate = 8894f6e0

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No active merge of candidate ef5c439 found, likely manual push to master

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 into auto

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nikomatsakis/rust/issue-3238-defer-reasoning-about-regions = ef5c439 merged ok, testing candidate = 4347db13

@bors
Copy link
Contributor

@bors bors commented on ef5c439 Jul 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.