Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Projection cache and better warnings for #32330 #33816

Merged
merged 25 commits into from
Jun 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aecce2b
add flag for ReSkolemized
nikomatsakis Mar 15, 2016
1198434
make HR algorithms account for region subtyping
nikomatsakis Apr 20, 2016
08034eb
add `Issue32330` warning marker to bound regions
nikomatsakis Apr 21, 2016
52b2db1
warn if leak-check relies on LBRs that will change
nikomatsakis Apr 21, 2016
75543c0
simplify HR subtyping back to what we did before
nikomatsakis May 16, 2016
eaf13b2
better debug dumping with inference variables
nikomatsakis May 21, 2016
d3afbd6
more debug dumping in traits
nikomatsakis May 21, 2016
7cf63a2
more debug dumping in trans
nikomatsakis May 21, 2016
cacbb21
add trailing comma
nikomatsakis May 21, 2016
8770d0f
remove VerifyRegSubReg and cleanup region infer
nikomatsakis May 21, 2016
de6c52d
make region-param-def encoding more DRY
nikomatsakis May 21, 2016
9ef768c
add trailing comma
nikomatsakis May 21, 2016
b40529c
projection predicates can be copy
nikomatsakis May 21, 2016
5cff88f
add a higher-ranked match routine
nikomatsakis May 21, 2016
d042ce2
add a snapshottable hashmap
nikomatsakis May 21, 2016
21eb366
create but do not use a projection cache
nikomatsakis May 21, 2016
24d4f10
change to use `higher_ranked_match`
nikomatsakis May 21, 2016
5368432
thread vtable-closure obligations to result
nikomatsakis May 23, 2016
6751d68
cleanup imports for cache
nikomatsakis May 21, 2016
38995c9
consult cache in projection
nikomatsakis May 21, 2016
ad97f29
add FIXME to fulfill
nikomatsakis May 21, 2016
136a83a
fallout in tests
nikomatsakis May 21, 2016
72b9707
do not use fresh regions in return type
nikomatsakis May 21, 2016
d3d2fc5
some new tests
nikomatsakis May 21, 2016
480d18c
kill some unused imports
nikomatsakis May 24, 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 src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,5 +1647,5 @@ register_diagnostics! {
E0490, // a value of type `..` is borrowed for too long
E0491, // in type `..`, reference has a longer lifetime than the data it...
E0495, // cannot infer an appropriate lifetime due to conflicting requirements
E0525, // expected a closure that implements `..` but this closure only implements `..`
E0525 // expected a closure that implements `..` but this closure only implements `..`
}
54 changes: 31 additions & 23 deletions src/librustc/hir/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ pub trait Visitor<'v> : Sized {
fn visit_generics(&mut self, g: &'v Generics) {
walk_generics(self, g)
}
fn visit_where_predicate(&mut self, predicate: &'v WherePredicate) {
walk_where_predicate(self, predicate)
}
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, _: NodeId) {
walk_fn(self, fk, fd, b, s)
}
Expand Down Expand Up @@ -529,29 +532,34 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics
walk_list!(visitor, visit_ty, &param.default);
}
walk_list!(visitor, visit_lifetime_def, &generics.lifetimes);
for predicate in &generics.where_clause.predicates {
match predicate {
&WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
ref bounds,
ref bound_lifetimes,
..}) => {
visitor.visit_ty(bounded_ty);
walk_list!(visitor, visit_ty_param_bound, bounds);
walk_list!(visitor, visit_lifetime_def, bound_lifetimes);
}
&WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
ref bounds,
..}) => {
visitor.visit_lifetime(lifetime);
walk_list!(visitor, visit_lifetime, bounds);
}
&WherePredicate::EqPredicate(WhereEqPredicate{id,
ref path,
ref ty,
..}) => {
visitor.visit_path(path, id);
visitor.visit_ty(ty);
}
walk_list!(visitor, visit_where_predicate, &generics.where_clause.predicates);
}

pub fn walk_where_predicate<'v, V: Visitor<'v>>(
visitor: &mut V,
predicate: &'v WherePredicate)
{
match predicate {
&WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
ref bounds,
ref bound_lifetimes,
..}) => {
visitor.visit_ty(bounded_ty);
walk_list!(visitor, visit_ty_param_bound, bounds);
walk_list!(visitor, visit_lifetime_def, bound_lifetimes);
}
&WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
ref bounds,
..}) => {
visitor.visit_lifetime(lifetime);
walk_list!(visitor, visit_lifetime, bounds);
}
&WherePredicate::EqPredicate(WhereEqPredicate{id,
ref path,
ref ty,
..}) => {
visitor.visit_path(path, id);
visitor.visit_ty(ty);
}
}
}
Expand Down
27 changes: 25 additions & 2 deletions src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ use hir::map as ast_map;
use hir;
use hir::print as pprust;

use lint;
use hir::def::Def;
use hir::def_id::DefId;
use infer::{self, TypeOrigin};
Expand Down Expand Up @@ -1017,6 +1018,27 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
let (fn_decl, generics) = rebuilder.rebuild();
self.give_expl_lifetime_param(err, &fn_decl, unsafety, constness, name, &generics, span);
}

pub fn issue_32330_warnings(&self, span: Span, issue32330s: &[ty::Issue32330]) {
for issue32330 in issue32330s {
match *issue32330 {
ty::Issue32330::WontChange => { }
ty::Issue32330::WillChange { fn_def_id, region_name } => {
self.tcx.sess.add_lint(
lint::builtin::HR_LIFETIME_IN_ASSOC_TYPE,
ast::CRATE_NODE_ID,
span,
format!("lifetime parameter `{0}` declared on fn `{1}` \
appears only in the return type, \
but here is required to be higher-ranked, \
which means that `{0}` must appear in both \
argument and return types",
region_name,
self.tcx.item_path_str(fn_def_id)));
}
}
}
}
}

struct RebuildPathInfo<'a> {
Expand Down Expand Up @@ -1129,7 +1151,7 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
ty::BrAnon(i) => {
anon_nums.insert(i);
}
ty::BrNamed(_, name) => {
ty::BrNamed(_, name, _) => {
region_names.insert(name);
}
_ => ()
Expand All @@ -1143,7 +1165,7 @@ impl<'a, 'gcx, 'tcx> Rebuilder<'a, 'gcx, 'tcx> {
for sr in self.same_regions {
for br in &sr.regions {
match *br {
ty::BrNamed(_, name) => {
ty::BrNamed(_, name, _) => {
all_region_names.insert(name);
}
_ => ()
Expand Down Expand Up @@ -1923,3 +1945,4 @@ fn name_to_dummy_lifetime(name: ast::Name) -> hir::Lifetime {
span: codemap::DUMMY_SP,
name: name }
}

Loading