Skip to content

Implement higher-ranked trait bounds. #18993

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

Merged
merged 14 commits into from
Nov 18, 2014
Merged
Changes from all commits
Commits
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
12 changes: 2 additions & 10 deletions src/doc/reference.md
Original file line number Diff line number Diff line change
@@ -2513,11 +2513,6 @@ The currently implemented features of the reference compiler are:
closure as `once` is unlikely to be supported going forward. So
they are hidden behind this feature until they are to be removed.

* `overloaded_calls` - Allow implementing the `Fn*` family of traits on user
types, allowing overloading the call operator (`()`).
This feature may still undergo changes before being
stabilized.

* `phase` - Usage of the `#[phase]` attribute allows loading compiler plugins
for custom lints or syntax extensions. The implementation is
considered unwholesome and in need of overhaul, and it is not clear
@@ -2560,11 +2555,8 @@ The currently implemented features of the reference compiler are:
* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
hack that will certainly be removed.

* `unboxed_closure_sugar` - Allows using `|Foo| -> Bar` as a trait bound
meaning one of the `Fn` traits. Still
experimental.

* `unboxed_closures` - A work in progress feature with many known bugs.
* `unboxed_closures` - Rust's new closure design, which is currently a work in
progress feature with many known bugs.

* `unsafe_destructor` - Allows use of the `#[unsafe_destructor]` attribute,
which is considered wildly unsafe and will be
3 changes: 2 additions & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -144,5 +144,6 @@ register_diagnostics!(
E0165,
E0166,
E0167,
E0168
E0168,
E0169
)
7 changes: 2 additions & 5 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
@@ -294,7 +294,7 @@ fn parse_region(st: &mut PState, conv: conv_did) -> ty::Region {
match next(st) {
'b' => {
assert_eq!(next(st), '[');
let id = parse_uint(st) as ast::NodeId;
let id = ty::DebruijnIndex::new(parse_uint(st));
assert_eq!(next(st), '|');
let br = parse_bound_region(st, |x,y| conv(x,y));
assert_eq!(next(st), ']');
@@ -579,8 +579,6 @@ fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {

fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig {
assert_eq!(next(st), '[');
let id = parse_uint(st) as ast::NodeId;
assert_eq!(next(st), '|');
let mut inputs = Vec::new();
while peek(st) != ']' {
inputs.push(parse_ty(st, |x,y| conv(x,y)));
@@ -598,8 +596,7 @@ fn parse_sig(st: &mut PState, conv: conv_did) -> ty::FnSig {
}
_ => ty::FnConverging(parse_ty(st, |x,y| conv(x,y)))
};
ty::FnSig {binder_id: id,
inputs: inputs,
ty::FnSig {inputs: inputs,
output: output,
variadic: variadic}
}
4 changes: 2 additions & 2 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ fn enc_region_substs(w: &mut SeekableMemWriter, cx: &ctxt, substs: &subst::Regio
pub fn enc_region(w: &mut SeekableMemWriter, cx: &ctxt, r: ty::Region) {
match r {
ty::ReLateBound(id, br) => {
mywrite!(w, "b[{}|", id);
mywrite!(w, "b[{}|", id.depth);
enc_bound_region(w, cx, br);
mywrite!(w, "]");
}
@@ -331,7 +331,7 @@ pub fn enc_closure_ty(w: &mut SeekableMemWriter, cx: &ctxt, ft: &ty::ClosureTy)
}

fn enc_fn_sig(w: &mut SeekableMemWriter, cx: &ctxt, fsig: &ty::FnSig) {
mywrite!(w, "[{}|", fsig.binder_id);
mywrite!(w, "[");
for ty in fsig.inputs.iter() {
enc_ty(w, cx, *ty);
}
4 changes: 2 additions & 2 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
@@ -483,8 +483,8 @@ impl tr for def::Def {
impl tr for ty::Region {
fn tr(&self, dcx: &DecodeContext) -> ty::Region {
match *self {
ty::ReLateBound(id, br) => {
ty::ReLateBound(dcx.tr_id(id), br.tr(dcx))
ty::ReLateBound(debruijn, br) => {
ty::ReLateBound(debruijn, br.tr(dcx))
}
ty::ReEarlyBound(id, space, index, ident) => {
ty::ReEarlyBound(dcx.tr_id(id), space, index, ident)
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
@@ -65,8 +65,8 @@ pub type LoanDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, LoanDataFlowOperator

impl<'a, 'tcx, 'v> Visitor<'v> for BorrowckCtxt<'a, 'tcx> {
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
b: &'v Block, s: Span, n: NodeId) {
borrowck_fn(self, fk, fd, b, s, n);
b: &'v Block, s: Span, id: ast::NodeId) {
borrowck_fn(self, fk, fd, b, s, id);
}

fn visit_item(&mut self, item: &ast::Item) {
7 changes: 4 additions & 3 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
@@ -139,8 +139,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MatchCheckCtxt<'a, 'tcx> {
check_local(self, l);
}
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
b: &'v Block, s: Span, _: NodeId) {
check_fn(self, fk, fd, b, s);
b: &'v Block, s: Span, n: NodeId) {
check_fn(self, fk, fd, b, s, n);
}
}

@@ -920,7 +920,8 @@ fn check_fn(cx: &mut MatchCheckCtxt,
kind: FnKind,
decl: &FnDecl,
body: &Block,
sp: Span) {
sp: Span,
_: NodeId) {
visit::walk_fn(cx, kind, decl, body, sp);
for input in decl.inputs.iter() {
is_refutable(cx, &*input.pat, |pat| {
10 changes: 4 additions & 6 deletions src/librustc/middle/liveness.rs
Original file line number Diff line number Diff line change
@@ -187,9 +187,8 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, cx: &ty::ctxt) -> String {
}

impl<'a, 'tcx, 'v> Visitor<'v> for IrMaps<'a, 'tcx> {
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl,
b: &'v Block, s: Span, n: NodeId) {
visit_fn(self, fk, fd, b, s, n);
fn visit_fn(&mut self, fk: FnKind<'v>, fd: &'v FnDecl, b: &'v Block, s: Span, id: ast::NodeId) {
visit_fn(self, fk, fd, b, s, id);
}
fn visit_local(&mut self, l: &ast::Local) { visit_local(self, l); }
fn visit_expr(&mut self, ex: &Expr) { visit_expr(self, ex); }
@@ -374,9 +373,8 @@ fn visit_fn(ir: &mut IrMaps,
decl: &FnDecl,
body: &Block,
sp: Span,
id: NodeId) {
debug!("visit_fn: id={}", id);
let _i = ::util::common::indenter();
id: ast::NodeId) {
debug!("visit_fn");

// swap in a new set of IR maps for this function body:
let mut fn_maps = IrMaps::new(ir.tcx);
6 changes: 3 additions & 3 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
@@ -5038,10 +5038,10 @@ impl<'a> Resolver<'a> {
visit::walk_ty(self, ty);
}

TyPolyTraitRef(ref poly_trait_ref) => {
self.resolve_poly_trait_reference(
TyPolyTraitRef(ref bounds) => {
self.resolve_type_parameter_bounds(
ty.id,
&**poly_trait_ref,
bounds,
TraitObject);
visit::walk_ty(self, ty);
}
Loading