libstd: Remove "dual impls" from the language and enforce coherence rules. r=brson
"Dual impls" are impls that are both type implementations and trait implementations. They can lead to ambiguity and so this patch removes them from the language. This also enforces coherence rules. Without this patch, records can implement traits not defined in the current crate. This patch fixes this, and updates all of rustc to adhere to the new enforcement. Most of this patch is fixing rustc to obey the coherence rules, which involves converting a bunch of records to structs.
This commit is contained in:
parent
f1e78c6dd7
commit
eb4d39e1fe
77 changed files with 699 additions and 832 deletions
|
@ -42,6 +42,7 @@ with destructors.
|
||||||
#[allow(structural_records)];
|
#[allow(structural_records)];
|
||||||
|
|
||||||
use cast;
|
use cast;
|
||||||
|
use container::{Container, Mutable, Map, Set};
|
||||||
use io;
|
use io;
|
||||||
use libc::{size_t, uintptr_t};
|
use libc::{size_t, uintptr_t};
|
||||||
use option::{None, Option, Some};
|
use option::{None, Option, Some};
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
use cmp::Eq;
|
use cmp::Eq;
|
||||||
use hash::Hash;
|
use hash::Hash;
|
||||||
use prelude::*;
|
|
||||||
use to_bytes::IterBytes;
|
use to_bytes::IterBytes;
|
||||||
|
|
||||||
/// Open addressing with linear probing.
|
/// Open addressing with linear probing.
|
||||||
|
@ -464,6 +463,7 @@ pub mod linear {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub mod test {
|
pub mod test {
|
||||||
|
use container::{Container, Mutable, Map, Set};
|
||||||
use option::{None, Some};
|
use option::{None, Some};
|
||||||
use hashmap::linear::LinearMap;
|
use hashmap::linear::LinearMap;
|
||||||
use hashmap::linear;
|
use hashmap::linear;
|
||||||
|
|
|
@ -23,6 +23,11 @@ pub trait Num {
|
||||||
static pure fn from_int(n: int) -> self;
|
static pure fn from_int(n: int) -> self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait IntConvertible {
|
||||||
|
pure fn to_int(&self) -> int;
|
||||||
|
static pure fn from_int(n: int) -> self;
|
||||||
|
}
|
||||||
|
|
||||||
pub trait Zero {
|
pub trait Zero {
|
||||||
static pure fn zero() -> self;
|
static pure fn zero() -> self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,10 +96,9 @@ use either::{Either, Left, Right};
|
||||||
use kinds::Owned;
|
use kinds::Owned;
|
||||||
use libc;
|
use libc;
|
||||||
use option;
|
use option;
|
||||||
use option::unwrap;
|
use option::{None, Option, Some, unwrap};
|
||||||
use pipes;
|
use pipes;
|
||||||
use ptr;
|
use ptr;
|
||||||
use prelude::*;
|
|
||||||
use private;
|
use private;
|
||||||
use task;
|
use task;
|
||||||
use vec;
|
use vec;
|
||||||
|
|
|
@ -35,6 +35,8 @@ pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
|
||||||
pub use vec::{OwnedVector, OwnedCopyableVector};
|
pub use vec::{OwnedVector, OwnedCopyableVector};
|
||||||
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
|
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
|
||||||
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
|
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
|
||||||
|
pub use container::{Container, Mutable, Map, Set};
|
||||||
|
pub use pipes::{GenericChan, GenericPort};
|
||||||
|
|
||||||
pub use num::Num;
|
pub use num::Num;
|
||||||
pub use ptr::Ptr;
|
pub use ptr::Ptr;
|
||||||
|
|
|
@ -22,7 +22,7 @@ use option::{Some, None, swap_unwrap};
|
||||||
use private::at_exit::at_exit;
|
use private::at_exit::at_exit;
|
||||||
use private::global::global_data_clone_create;
|
use private::global::global_data_clone_create;
|
||||||
use private::finally::Finally;
|
use private::finally::Finally;
|
||||||
use pipes::{Port, Chan, SharedChan, stream};
|
use pipes::{Port, Chan, SharedChan, GenericSmartChan, stream};
|
||||||
use task::{Task, task, spawn};
|
use task::{Task, task, spawn};
|
||||||
use task::rt::{task_id, get_task_id};
|
use task::rt::{task_id, get_task_id};
|
||||||
use hashmap::linear::LinearMap;
|
use hashmap::linear::LinearMap;
|
||||||
|
|
|
@ -45,7 +45,7 @@ use iter;
|
||||||
use libc;
|
use libc;
|
||||||
use option;
|
use option;
|
||||||
use result::Result;
|
use result::Result;
|
||||||
use pipes::{stream, Chan, Port, SharedChan};
|
use pipes::{stream, Chan, GenericChan, GenericPort, Port, SharedChan};
|
||||||
use pipes;
|
use pipes;
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
use ptr;
|
use ptr;
|
||||||
|
|
|
@ -74,8 +74,10 @@
|
||||||
#[warn(deprecated_mode)];
|
#[warn(deprecated_mode)];
|
||||||
|
|
||||||
use cast;
|
use cast;
|
||||||
|
use container::Map;
|
||||||
|
use oldcomm;
|
||||||
use option;
|
use option;
|
||||||
use pipes::{stream, Chan, Port};
|
use pipes::{Chan, GenericChan, GenericPort, Port};
|
||||||
use pipes;
|
use pipes;
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
use private;
|
use private;
|
||||||
|
|
|
@ -37,6 +37,7 @@ use core::to_bytes::IterBytes;
|
||||||
use core::uint;
|
use core::uint;
|
||||||
use core::vec;
|
use core::vec;
|
||||||
use std::map::HashMap;
|
use std::map::HashMap;
|
||||||
|
use std::serialize::Encodable;
|
||||||
use std::{ebml, map};
|
use std::{ebml, map};
|
||||||
use std;
|
use std;
|
||||||
use syntax::ast::*;
|
use syntax::ast::*;
|
||||||
|
|
|
@ -17,7 +17,8 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::ty::{FnTyBase, FnMeta, FnSig};
|
use middle::ty::{FnTyBase, FnMeta, FnSig, arg, creader_cache_key, field};
|
||||||
|
use middle::ty::{substs};
|
||||||
|
|
||||||
use core::io;
|
use core::io;
|
||||||
use core::str;
|
use core::str;
|
||||||
|
@ -174,9 +175,11 @@ fn parse_substs(st: @pstate, conv: conv_did) -> ty::substs {
|
||||||
while peek(st) != ']' { params.push(parse_ty(st, conv)); }
|
while peek(st) != ']' { params.push(parse_ty(st, conv)); }
|
||||||
st.pos = st.pos + 1u;
|
st.pos = st.pos + 1u;
|
||||||
|
|
||||||
return {self_r: self_r,
|
return substs {
|
||||||
|
self_r: self_r,
|
||||||
self_ty: self_ty,
|
self_ty: self_ty,
|
||||||
tps: params};
|
tps: params
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_bound_region(st: @pstate) -> ty::bound_region {
|
fn parse_bound_region(st: @pstate) -> ty::bound_region {
|
||||||
|
@ -308,7 +311,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
||||||
let mut fields: ~[ty::field] = ~[];
|
let mut fields: ~[ty::field] = ~[];
|
||||||
while peek(st) != ']' {
|
while peek(st) != ']' {
|
||||||
let name = st.tcx.sess.ident_of(parse_str(st, '='));
|
let name = st.tcx.sess.ident_of(parse_str(st, '='));
|
||||||
fields.push({ident: name, mt: parse_mt(st, conv)});
|
fields.push(ty::field { ident: name, mt: parse_mt(st, conv) });
|
||||||
}
|
}
|
||||||
st.pos = st.pos + 1u;
|
st.pos = st.pos + 1u;
|
||||||
return ty::mk_rec(st.tcx, fields);
|
return ty::mk_rec(st.tcx, fields);
|
||||||
|
@ -333,12 +336,13 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
||||||
assert (next(st) == ':');
|
assert (next(st) == ':');
|
||||||
let len = parse_hex(st);
|
let len = parse_hex(st);
|
||||||
assert (next(st) == '#');
|
assert (next(st) == '#');
|
||||||
match st.tcx.rcache.find({cnum: st.crate, pos: pos, len: len}) {
|
let key = creader_cache_key { cnum: st.crate, pos: pos, len: len };
|
||||||
|
match st.tcx.rcache.find(key) {
|
||||||
Some(tt) => return tt,
|
Some(tt) => return tt,
|
||||||
None => {
|
None => {
|
||||||
let ps = @{pos: pos ,.. copy *st};
|
let ps = @{pos: pos ,.. copy *st};
|
||||||
let tt = parse_ty(ps, conv);
|
let tt = parse_ty(ps, conv);
|
||||||
st.tcx.rcache.insert({cnum: st.crate, pos: pos, len: len}, tt);
|
st.tcx.rcache.insert(key, tt);
|
||||||
return tt;
|
return tt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,8 +425,7 @@ fn parse_onceness(c: char) -> ast::Onceness {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_arg(st: @pstate, conv: conv_did) -> ty::arg {
|
fn parse_arg(st: @pstate, conv: conv_did) -> ty::arg {
|
||||||
{mode: parse_mode(st),
|
ty::arg { mode: parse_mode(st), ty: parse_ty(st, conv) }
|
||||||
ty: parse_ty(st, conv)}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_mode(st: @pstate) -> ast::mode {
|
fn parse_mode(st: @pstate) -> ast::mode {
|
||||||
|
@ -446,7 +449,7 @@ fn parse_ty_fn(st: @pstate, conv: conv_did) -> ty::FnTy {
|
||||||
let mut inputs: ~[ty::arg] = ~[];
|
let mut inputs: ~[ty::arg] = ~[];
|
||||||
while peek(st) != ']' {
|
while peek(st) != ']' {
|
||||||
let mode = parse_mode(st);
|
let mode = parse_mode(st);
|
||||||
inputs.push({mode: mode, ty: parse_ty(st, conv)});
|
inputs.push(ty::arg { mode: mode, ty: parse_ty(st, conv) });
|
||||||
}
|
}
|
||||||
st.pos += 1u; // eat the ']'
|
st.pos += 1u; // eat the ']'
|
||||||
let ret_ty = parse_ty(st, conv);
|
let ret_ty = parse_ty(st, conv);
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
|
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
|
use middle::ty::{Vid, param_ty};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::ty::Vid;
|
|
||||||
|
|
||||||
use core::io::WriterUtil;
|
use core::io::WriterUtil;
|
||||||
use core::io;
|
use core::io;
|
||||||
|
@ -301,7 +301,7 @@ fn enc_sty(w: io::Writer, cx: @ctxt, +st: ty::sty) {
|
||||||
ty::ty_infer(_) => {
|
ty::ty_infer(_) => {
|
||||||
cx.diag.handler().bug(~"Cannot encode inference variable types");
|
cx.diag.handler().bug(~"Cannot encode inference variable types");
|
||||||
}
|
}
|
||||||
ty::ty_param({idx: id, def_id: did}) => {
|
ty::ty_param(param_ty {idx: id, def_id: did}) => {
|
||||||
w.write_char('p');
|
w.write_char('p');
|
||||||
w.write_str((cx.ds)(did));
|
w.write_str((cx.ds)(did));
|
||||||
w.write_char('|');
|
w.write_char('|');
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::borrowck::{Loan, bckerr, borrowck_ctxt, cmt, inherent_mutability};
|
use middle::borrowck::{Loan, bckerr, borrowck_ctxt, cmt, inherent_mutability};
|
||||||
use middle::borrowck::{req_maps, save_and_restore};
|
use middle::borrowck::{req_maps, root_map_key, save_and_restore};
|
||||||
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
|
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
|
||||||
use middle::mem_categorization::{cat_local, cat_rvalue, cat_self};
|
use middle::mem_categorization::{cat_local, cat_rvalue, cat_self};
|
||||||
use middle::mem_categorization::{cat_special, gc_ptr, loan_path, lp_arg};
|
use middle::mem_categorization::{cat_special, gc_ptr, loan_path, lp_arg};
|
||||||
|
@ -396,7 +396,10 @@ impl check_loan_ctxt {
|
||||||
|
|
||||||
match ptr_kind {
|
match ptr_kind {
|
||||||
gc_ptr(ast::m_mutbl) => {
|
gc_ptr(ast::m_mutbl) => {
|
||||||
let key = { id: base.id, derefs: deref_count };
|
let key = root_map_key {
|
||||||
|
id: base.id,
|
||||||
|
derefs: deref_count
|
||||||
|
};
|
||||||
self.bccx.write_guard_map.insert(key, ());
|
self.bccx.write_guard_map.insert(key, ());
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::borrowck::preserve::{preserve_condition, pc_ok, pc_if_pure};
|
use middle::borrowck::preserve::{preserve_condition, pc_ok, pc_if_pure};
|
||||||
use middle::borrowck::{Loan, bckres, borrowck_ctxt, err_mutbl, req_maps};
|
use middle::borrowck::{Loan, bckerr, bckres, borrowck_ctxt, err_mutbl};
|
||||||
|
use middle::borrowck::{req_maps};
|
||||||
use middle::mem_categorization::{cat_binding, cat_discr, cmt, comp_variant};
|
use middle::mem_categorization::{cat_binding, cat_discr, cmt, comp_variant};
|
||||||
use middle::mem_categorization::{mem_categorization_ctxt};
|
use middle::mem_categorization::{mem_categorization_ctxt};
|
||||||
use middle::mem_categorization::{opt_deref_kind};
|
use middle::mem_categorization::{opt_deref_kind};
|
||||||
|
@ -452,8 +453,7 @@ impl gather_loan_ctxt {
|
||||||
debug!("required is const or they are the same");
|
debug!("required is const or they are the same");
|
||||||
Ok(pc_ok)
|
Ok(pc_ok)
|
||||||
} else {
|
} else {
|
||||||
let e = {cmt: cmt,
|
let e = bckerr { cmt: cmt, code: err_mutbl(req_mutbl) };
|
||||||
code: err_mutbl(req_mutbl)};
|
|
||||||
if req_mutbl == m_imm {
|
if req_mutbl == m_imm {
|
||||||
// if this is an @mut box, then it's generally OK to borrow as
|
// if this is an @mut box, then it's generally OK to borrow as
|
||||||
// &imm; this will result in a write guard
|
// &imm; this will result in a write guard
|
||||||
|
|
|
@ -43,7 +43,7 @@ XXX --- much more needed, don't have time to write this all up now
|
||||||
|
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::borrowck::{Loan, bckres, borrowck_ctxt, cmt, err_mutbl};
|
use middle::borrowck::{Loan, bckerr, bckres, borrowck_ctxt, cmt, err_mutbl};
|
||||||
use middle::borrowck::{err_out_of_scope};
|
use middle::borrowck::{err_out_of_scope};
|
||||||
use middle::mem_categorization::{cat_arg, cat_binding, cat_discr, cat_comp};
|
use middle::mem_categorization::{cat_arg, cat_binding, cat_discr, cat_comp};
|
||||||
use middle::mem_categorization::{cat_deref, cat_discr, cat_local, cat_self};
|
use middle::mem_categorization::{cat_deref, cat_discr, cat_local, cat_self};
|
||||||
|
@ -309,8 +309,10 @@ impl LoanContext {
|
||||||
// We do not allow non-mutable data to be loaned
|
// We do not allow non-mutable data to be loaned
|
||||||
// out as mutable under any circumstances.
|
// out as mutable under any circumstances.
|
||||||
if cmt.mutbl != m_mutbl {
|
if cmt.mutbl != m_mutbl {
|
||||||
return Err({cmt:cmt,
|
return Err(bckerr {
|
||||||
code:err_mutbl(req_mutbl)});
|
cmt:cmt,
|
||||||
|
code:err_mutbl(req_mutbl)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_const | m_imm => {
|
m_const | m_imm => {
|
||||||
|
@ -332,9 +334,10 @@ impl LoanContext {
|
||||||
} else {
|
} else {
|
||||||
// The loan being requested lives longer than the data
|
// The loan being requested lives longer than the data
|
||||||
// being loaned out!
|
// being loaned out!
|
||||||
return Err({cmt:cmt,
|
return Err(bckerr {
|
||||||
code:err_out_of_scope(scope_ub,
|
cmt:cmt,
|
||||||
self.scope_region)});
|
code:err_out_of_scope(scope_ub, self.scope_region)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,7 +344,11 @@ type root_map = HashMap<root_map_key, RootInfo>;
|
||||||
// if you have an expression `x.f` and x has type ~@T, we could add an
|
// if you have an expression `x.f` and x has type ~@T, we could add an
|
||||||
// entry {id:x, derefs:0} to refer to `x` itself, `{id:x, derefs:1}`
|
// entry {id:x, derefs:0} to refer to `x` itself, `{id:x, derefs:1}`
|
||||||
// to refer to the deref of the unique pointer, and so on.
|
// to refer to the deref of the unique pointer, and so on.
|
||||||
type root_map_key = {id: ast::node_id, derefs: uint};
|
#[deriving_eq]
|
||||||
|
struct root_map_key {
|
||||||
|
id: ast::node_id,
|
||||||
|
derefs: uint
|
||||||
|
}
|
||||||
|
|
||||||
// set of ids of local vars / formal arguments that are modified / moved.
|
// set of ids of local vars / formal arguments that are modified / moved.
|
||||||
// this is used in trans for optimization purposes.
|
// this is used in trans for optimization purposes.
|
||||||
|
@ -411,13 +415,10 @@ impl bckerr_code : cmp::Eq {
|
||||||
|
|
||||||
// Combination of an error code and the categorization of the expression
|
// Combination of an error code and the categorization of the expression
|
||||||
// that caused it
|
// that caused it
|
||||||
type bckerr = {cmt: cmt, code: bckerr_code};
|
#[deriving_eq]
|
||||||
|
struct bckerr {
|
||||||
impl bckerr : cmp::Eq {
|
cmt: cmt,
|
||||||
pure fn eq(&self, other: &bckerr) -> bool {
|
code: bckerr_code
|
||||||
(*self).cmt == (*other).cmt && (*self).code == (*other).code
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &bckerr) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// shorthand for something that fails with `bckerr` or succeeds with `T`
|
// shorthand for something that fails with `bckerr` or succeeds with `T`
|
||||||
|
@ -446,15 +447,6 @@ fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
|
||||||
|
|
||||||
/// Creates and returns a new root_map
|
/// Creates and returns a new root_map
|
||||||
|
|
||||||
impl root_map_key : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &root_map_key) -> bool {
|
|
||||||
(*self).id == (*other).id && (*self).derefs == (*other).derefs
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &root_map_key) -> bool {
|
|
||||||
! ((*self) == (*other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl root_map_key : to_bytes::IterBytes {
|
impl root_map_key : to_bytes::IterBytes {
|
||||||
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
|
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
|
||||||
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
|
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
|
||||||
|
@ -501,7 +493,7 @@ impl borrowck_ctxt {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_discr(cmt: cmt, match_id: ast::node_id) -> cmt {
|
fn cat_discr(cmt: cmt, match_id: ast::node_id) -> cmt {
|
||||||
return @{cat:cat_discr(cmt, match_id),.. *cmt};
|
return @cmt_ { cat: cat_discr(cmt, match_id),.. *cmt };
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mc_ctxt() -> mem_categorization_ctxt {
|
fn mc_ctxt() -> mem_categorization_ctxt {
|
||||||
|
|
|
@ -18,7 +18,7 @@ use core::prelude::*;
|
||||||
use middle::borrowck::{RootInfo, bckerr, bckerr_code, bckres, borrowck_ctxt};
|
use middle::borrowck::{RootInfo, bckerr, bckerr_code, bckres, borrowck_ctxt};
|
||||||
use middle::borrowck::{cmt, err_mut_uniq, err_mut_variant};
|
use middle::borrowck::{cmt, err_mut_uniq, err_mut_variant};
|
||||||
use middle::borrowck::{err_out_of_root_scope, err_out_of_scope};
|
use middle::borrowck::{err_out_of_root_scope, err_out_of_scope};
|
||||||
use middle::borrowck::{err_root_not_permitted};
|
use middle::borrowck::{err_root_not_permitted, root_map_key};
|
||||||
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
|
use middle::mem_categorization::{cat_arg, cat_binding, cat_comp, cat_deref};
|
||||||
use middle::mem_categorization::{cat_discr, cat_local, cat_self, cat_special};
|
use middle::mem_categorization::{cat_discr, cat_local, cat_self, cat_special};
|
||||||
use middle::mem_categorization::{cat_stack_upvar, comp_field, comp_index};
|
use middle::mem_categorization::{cat_stack_upvar, comp_field, comp_index};
|
||||||
|
@ -291,7 +291,7 @@ priv impl &preserve_ctxt {
|
||||||
Ok(pc_ok) => {
|
Ok(pc_ok) => {
|
||||||
match cmt_base.mutbl {
|
match cmt_base.mutbl {
|
||||||
m_mutbl | m_const => {
|
m_mutbl | m_const => {
|
||||||
Ok(pc_if_pure({cmt:cmt, code:code}))
|
Ok(pc_if_pure(bckerr { cmt: cmt, code: code }))
|
||||||
}
|
}
|
||||||
m_imm => {
|
m_imm => {
|
||||||
Ok(pc_ok)
|
Ok(pc_ok)
|
||||||
|
@ -318,8 +318,10 @@ priv impl &preserve_ctxt {
|
||||||
if self.bccx.is_subregion_of(self.scope_region, scope_ub) {
|
if self.bccx.is_subregion_of(self.scope_region, scope_ub) {
|
||||||
Ok(pc_ok)
|
Ok(pc_ok)
|
||||||
} else {
|
} else {
|
||||||
Err({cmt:cmt, code:err_out_of_scope(scope_ub,
|
Err(bckerr {
|
||||||
self.scope_region)})
|
cmt:cmt,
|
||||||
|
code:err_out_of_scope(scope_ub, self.scope_region)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +347,7 @@ priv impl &preserve_ctxt {
|
||||||
// would be sort of pointless to avoid rooting the inner
|
// would be sort of pointless to avoid rooting the inner
|
||||||
// box by rooting an outer box, as it would just keep more
|
// box by rooting an outer box, as it would just keep more
|
||||||
// memory live than necessary, so we set root_ub to none.
|
// memory live than necessary, so we set root_ub to none.
|
||||||
return Err({cmt:cmt, code:err_root_not_permitted});
|
return Err(bckerr { cmt: cmt, code: err_root_not_permitted });
|
||||||
}
|
}
|
||||||
|
|
||||||
let root_region = ty::re_scope(self.root_ub);
|
let root_region = ty::re_scope(self.root_ub);
|
||||||
|
@ -359,7 +361,7 @@ priv impl &preserve_ctxt {
|
||||||
derefs, scope_id, self.root_ub);
|
derefs, scope_id, self.root_ub);
|
||||||
if self.bccx.is_subregion_of(self.scope_region, root_region) {
|
if self.bccx.is_subregion_of(self.scope_region, root_region) {
|
||||||
debug!("Elected to root");
|
debug!("Elected to root");
|
||||||
let rk = {id: base.id, derefs: derefs};
|
let rk = root_map_key { id: base.id, derefs: derefs };
|
||||||
// This code could potentially lead cause boxes to be frozen
|
// This code could potentially lead cause boxes to be frozen
|
||||||
// for longer than necessarily at runtime. It prevents an
|
// for longer than necessarily at runtime. It prevents an
|
||||||
// ICE in trans; the fundamental problem is that it's hard
|
// ICE in trans; the fundamental problem is that it's hard
|
||||||
|
@ -389,17 +391,20 @@ priv impl &preserve_ctxt {
|
||||||
return Ok(pc_ok);
|
return Ok(pc_ok);
|
||||||
} else {
|
} else {
|
||||||
debug!("Unable to root");
|
debug!("Unable to root");
|
||||||
return Err({cmt:cmt,
|
return Err(bckerr {
|
||||||
|
cmt: cmt,
|
||||||
code: err_out_of_root_scope(root_region,
|
code: err_out_of_root_scope(root_region,
|
||||||
self.scope_region)});
|
self.scope_region)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we won't be able to root long enough
|
// we won't be able to root long enough
|
||||||
_ => {
|
_ => {
|
||||||
return Err({cmt:cmt,
|
return Err(bckerr {
|
||||||
code:err_out_of_root_scope(root_region,
|
cmt:cmt,
|
||||||
self.scope_region)});
|
code:err_out_of_root_scope(root_region, self.scope_region)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,27 +113,18 @@ enum special_kind {
|
||||||
// which the value is stored.
|
// which the value is stored.
|
||||||
//
|
//
|
||||||
// note: cmt stands for "categorized mutable type".
|
// note: cmt stands for "categorized mutable type".
|
||||||
type cmt_ = {id: ast::node_id, // id of expr/pat producing this value
|
#[deriving_eq]
|
||||||
|
struct cmt_ {
|
||||||
|
id: ast::node_id, // id of expr/pat producing this value
|
||||||
span: span, // span of same expr/pat
|
span: span, // span of same expr/pat
|
||||||
cat: categorization, // categorization of expr
|
cat: categorization, // categorization of expr
|
||||||
lp: Option<@loan_path>, // loan path for expr, if any
|
lp: Option<@loan_path>, // loan path for expr, if any
|
||||||
mutbl: ast::mutability, // mutability of expr as lvalue
|
mutbl: ast::mutability, // mutability of expr as lvalue
|
||||||
ty: ty::t}; // type of the expr
|
ty: ty::t // type of the expr
|
||||||
|
}
|
||||||
|
|
||||||
type cmt = @cmt_;
|
type cmt = @cmt_;
|
||||||
|
|
||||||
impl cmt_ : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &cmt_) -> bool {
|
|
||||||
(*self).id == (*other).id &&
|
|
||||||
(*self).span == (*other).span &&
|
|
||||||
(*self).cat == (*other).cat &&
|
|
||||||
(*self).lp == (*other).lp &&
|
|
||||||
(*self).mutbl == (*other).mutbl &&
|
|
||||||
(*self).ty == (*other).ty
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &cmt_) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
// a loan path is like a category, but it exists only when the data is
|
// a loan path is like a category, but it exists only when the data is
|
||||||
// interior to the stack frame. loan paths are used as the key to a
|
// interior to the stack frame. loan paths are used as the key to a
|
||||||
// map indicating what is borrowed at any point in time.
|
// map indicating what is borrowed at any point in time.
|
||||||
|
@ -423,9 +414,14 @@ impl &mem_categorization_ctxt {
|
||||||
ast::def_ty_param(*) | ast::def_struct(*) |
|
ast::def_ty_param(*) | ast::def_struct(*) |
|
||||||
ast::def_typaram_binder(*) | ast::def_region(_) |
|
ast::def_typaram_binder(*) | ast::def_region(_) |
|
||||||
ast::def_label(_) | ast::def_self_ty(*) => {
|
ast::def_label(_) | ast::def_self_ty(*) => {
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat_special(sk_static_item), lp:None,
|
id:id,
|
||||||
mutbl:m_imm, ty:expr_ty}
|
span:span,
|
||||||
|
cat:cat_special(sk_static_item),
|
||||||
|
lp:None,
|
||||||
|
mutbl:m_imm,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::def_arg(vid, mode, mutbl) => {
|
ast::def_arg(vid, mode, mutbl) => {
|
||||||
|
@ -451,9 +447,14 @@ impl &mem_categorization_ctxt {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat_arg(vid), lp:lp,
|
id:id,
|
||||||
mutbl:m, ty:expr_ty}
|
span:span,
|
||||||
|
cat:cat_arg(vid),
|
||||||
|
lp:lp,
|
||||||
|
mutbl:m,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::def_self(self_id, is_implicit) => {
|
ast::def_self(self_id, is_implicit) => {
|
||||||
|
@ -466,9 +467,14 @@ impl &mem_categorization_ctxt {
|
||||||
loan_path = Some(@lp_self);
|
loan_path = Some(@lp_self);
|
||||||
};
|
};
|
||||||
|
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat, lp:loan_path,
|
id:id,
|
||||||
mutbl:m_imm, ty:expr_ty}
|
span:span,
|
||||||
|
cat:cat,
|
||||||
|
lp:loan_path,
|
||||||
|
mutbl:m_imm,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::def_upvar(_, inner, fn_node_id, _) => {
|
ast::def_upvar(_, inner, fn_node_id, _) => {
|
||||||
|
@ -477,15 +483,25 @@ impl &mem_categorization_ctxt {
|
||||||
match proto {
|
match proto {
|
||||||
ast::ProtoBorrowed => {
|
ast::ProtoBorrowed => {
|
||||||
let upcmt = self.cat_def(id, span, expr_ty, *inner);
|
let upcmt = self.cat_def(id, span, expr_ty, *inner);
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat_stack_upvar(upcmt), lp:upcmt.lp,
|
id:id,
|
||||||
mutbl:upcmt.mutbl, ty:upcmt.ty}
|
span:span,
|
||||||
|
cat:cat_stack_upvar(upcmt),
|
||||||
|
lp:upcmt.lp,
|
||||||
|
mutbl:upcmt.mutbl,
|
||||||
|
ty:upcmt.ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast::ProtoUniq | ast::ProtoBox => {
|
ast::ProtoUniq | ast::ProtoBox => {
|
||||||
// FIXME #2152 allow mutation of moved upvars
|
// FIXME #2152 allow mutation of moved upvars
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat_special(sk_heap_upvar), lp:None,
|
id:id,
|
||||||
mutbl:m_imm, ty:expr_ty}
|
span:span,
|
||||||
|
cat:cat_special(sk_heap_upvar),
|
||||||
|
lp:None,
|
||||||
|
mutbl:m_imm,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ast::ProtoBare => {
|
ast::ProtoBare => {
|
||||||
self.tcx.sess.span_bug(
|
self.tcx.sess.span_bug(
|
||||||
|
@ -497,16 +513,26 @@ impl &mem_categorization_ctxt {
|
||||||
|
|
||||||
ast::def_local(vid, mutbl) => {
|
ast::def_local(vid, mutbl) => {
|
||||||
let m = if mutbl {m_mutbl} else {m_imm};
|
let m = if mutbl {m_mutbl} else {m_imm};
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat_local(vid), lp:Some(@lp_local(vid)),
|
id:id,
|
||||||
mutbl:m, ty:expr_ty}
|
span:span,
|
||||||
|
cat:cat_local(vid),
|
||||||
|
lp:Some(@lp_local(vid)),
|
||||||
|
mutbl:m,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ast::def_binding(vid, _) => {
|
ast::def_binding(vid, _) => {
|
||||||
// by-value/by-ref bindings are local variables
|
// by-value/by-ref bindings are local variables
|
||||||
@{id:id, span:span,
|
@cmt_ {
|
||||||
cat:cat_local(vid), lp:Some(@lp_local(vid)),
|
id:id,
|
||||||
mutbl:m_imm, ty:expr_ty}
|
span:span,
|
||||||
|
cat:cat_local(vid),
|
||||||
|
lp:Some(@lp_local(vid)),
|
||||||
|
mutbl:m_imm,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -514,17 +540,25 @@ impl &mem_categorization_ctxt {
|
||||||
fn cat_variant<N: ast_node>(arg: N,
|
fn cat_variant<N: ast_node>(arg: N,
|
||||||
enum_did: ast::def_id,
|
enum_did: ast::def_id,
|
||||||
cmt: cmt) -> cmt {
|
cmt: cmt) -> cmt {
|
||||||
@{id: arg.id(), span: arg.span(),
|
@cmt_ {
|
||||||
|
id: arg.id(),
|
||||||
|
span: arg.span(),
|
||||||
cat: cat_comp(cmt, comp_variant(enum_did)),
|
cat: cat_comp(cmt, comp_variant(enum_did)),
|
||||||
lp: cmt.lp.map(|l| @lp_comp(*l, comp_variant(enum_did)) ),
|
lp: cmt.lp.map(|l| @lp_comp(*l, comp_variant(enum_did)) ),
|
||||||
mutbl: cmt.mutbl, // imm iff in an immutable context
|
mutbl: cmt.mutbl, // imm iff in an immutable context
|
||||||
ty: self.tcx.ty(arg)}
|
ty: self.tcx.ty(arg)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_rvalue<N: ast_node>(elt: N, expr_ty: ty::t) -> cmt {
|
fn cat_rvalue<N: ast_node>(elt: N, expr_ty: ty::t) -> cmt {
|
||||||
@{id:elt.id(), span:elt.span(),
|
@cmt_ {
|
||||||
cat:cat_rvalue, lp:None,
|
id:elt.id(),
|
||||||
mutbl:m_imm, ty:expr_ty}
|
span:elt.span(),
|
||||||
|
cat:cat_rvalue,
|
||||||
|
lp:None,
|
||||||
|
mutbl:m_imm,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// inherited mutability: used in cases where the mutability of a
|
/// inherited mutability: used in cases where the mutability of a
|
||||||
|
@ -559,9 +593,14 @@ impl &mem_categorization_ctxt {
|
||||||
let m = self.inherited_mutability(base_cmt.mutbl, f_mutbl);
|
let m = self.inherited_mutability(base_cmt.mutbl, f_mutbl);
|
||||||
let f_comp = comp_field(f_name, f_mutbl);
|
let f_comp = comp_field(f_name, f_mutbl);
|
||||||
let lp = base_cmt.lp.map(|lp| @lp_comp(*lp, f_comp) );
|
let lp = base_cmt.lp.map(|lp| @lp_comp(*lp, f_comp) );
|
||||||
@{id: node.id(), span: node.span(),
|
@cmt_ {
|
||||||
cat: cat_comp(base_cmt, f_comp), lp:lp,
|
id: node.id(),
|
||||||
mutbl: m, ty: self.tcx.ty(node)}
|
span: node.span(),
|
||||||
|
cat: cat_comp(base_cmt, f_comp),
|
||||||
|
lp:lp,
|
||||||
|
mutbl: m,
|
||||||
|
ty: self.tcx.ty(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_deref_fn<N:ast_node>(node: N,
|
fn cat_deref_fn<N:ast_node>(node: N,
|
||||||
|
@ -628,17 +667,27 @@ impl &mem_categorization_ctxt {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@{id:node.id(), span:node.span(),
|
@cmt_ {
|
||||||
cat:cat_deref(base_cmt, deref_cnt, ptr), lp:lp,
|
id:node.id(),
|
||||||
mutbl:m, ty:mt.ty}
|
span:node.span(),
|
||||||
|
cat:cat_deref(base_cmt, deref_cnt, ptr),
|
||||||
|
lp:lp,
|
||||||
|
mutbl:m,
|
||||||
|
ty:mt.ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deref_comp(comp) => {
|
deref_comp(comp) => {
|
||||||
let lp = base_cmt.lp.map(|l| @lp_comp(*l, comp) );
|
let lp = base_cmt.lp.map(|l| @lp_comp(*l, comp) );
|
||||||
let m = self.inherited_mutability(base_cmt.mutbl, mt.mutbl);
|
let m = self.inherited_mutability(base_cmt.mutbl, mt.mutbl);
|
||||||
@{id:node.id(), span:node.span(),
|
@cmt_ {
|
||||||
cat:cat_comp(base_cmt, comp), lp:lp,
|
id:node.id(),
|
||||||
mutbl:m, ty:mt.ty}
|
span:node.span(),
|
||||||
|
cat:cat_comp(base_cmt, comp),
|
||||||
|
lp:lp,
|
||||||
|
mutbl:m,
|
||||||
|
ty:mt.ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -675,9 +724,14 @@ impl &mem_categorization_ctxt {
|
||||||
};
|
};
|
||||||
|
|
||||||
// (c) the deref is explicit in the resulting cmt
|
// (c) the deref is explicit in the resulting cmt
|
||||||
let deref_cmt = @{id:elt.id(), span:elt.span(),
|
let deref_cmt = @cmt_ {
|
||||||
cat:cat_deref(base_cmt, 0u, ptr), lp:deref_lp,
|
id:elt.id(),
|
||||||
mutbl:m, ty:mt.ty};
|
span:elt.span(),
|
||||||
|
cat:cat_deref(base_cmt, 0u, ptr),
|
||||||
|
lp:deref_lp,
|
||||||
|
mutbl:m,
|
||||||
|
ty:mt.ty
|
||||||
|
};
|
||||||
|
|
||||||
comp(elt, deref_cmt, base_cmt.ty, m, mt.ty)
|
comp(elt, deref_cmt, base_cmt.ty, m, mt.ty)
|
||||||
}
|
}
|
||||||
|
@ -695,32 +749,48 @@ impl &mem_categorization_ctxt {
|
||||||
{
|
{
|
||||||
let comp = comp_index(vect, mutbl);
|
let comp = comp_index(vect, mutbl);
|
||||||
let index_lp = of_cmt.lp.map(|lp| @lp_comp(*lp, comp) );
|
let index_lp = of_cmt.lp.map(|lp| @lp_comp(*lp, comp) );
|
||||||
@{id:elt.id(), span:elt.span(),
|
@cmt_ {
|
||||||
cat:cat_comp(of_cmt, comp), lp:index_lp,
|
id:elt.id(),
|
||||||
mutbl:mutbl, ty:ty}
|
span:elt.span(),
|
||||||
|
cat:cat_comp(of_cmt, comp),
|
||||||
|
lp:index_lp,
|
||||||
|
mutbl:mutbl,
|
||||||
|
ty:ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_tuple_elt<N: ast_node>(elt: N, cmt: cmt) -> cmt {
|
fn cat_tuple_elt<N: ast_node>(elt: N, cmt: cmt) -> cmt {
|
||||||
@{id: elt.id(), span: elt.span(),
|
@cmt_ {
|
||||||
|
id: elt.id(),
|
||||||
|
span: elt.span(),
|
||||||
cat: cat_comp(cmt, comp_tuple),
|
cat: cat_comp(cmt, comp_tuple),
|
||||||
lp: cmt.lp.map(|l| @lp_comp(*l, comp_tuple) ),
|
lp: cmt.lp.map(|l| @lp_comp(*l, comp_tuple) ),
|
||||||
mutbl: cmt.mutbl, // imm iff in an immutable context
|
mutbl: cmt.mutbl, // imm iff in an immutable context
|
||||||
ty: self.tcx.ty(elt)}
|
ty: self.tcx.ty(elt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_anon_struct_field<N: ast_node>(elt: N, cmt: cmt) -> cmt {
|
fn cat_anon_struct_field<N: ast_node>(elt: N, cmt: cmt) -> cmt {
|
||||||
@{id: elt.id(), span: elt.span(),
|
@cmt_ {
|
||||||
|
id: elt.id(),
|
||||||
|
span: elt.span(),
|
||||||
cat: cat_comp(cmt, comp_anon_field),
|
cat: cat_comp(cmt, comp_anon_field),
|
||||||
lp: cmt.lp.map(|l| @lp_comp(*l, comp_anon_field)),
|
lp: cmt.lp.map(|l| @lp_comp(*l, comp_anon_field)),
|
||||||
mutbl: cmt.mutbl, // imm iff in an immutable context
|
mutbl: cmt.mutbl, // imm iff in an immutable context
|
||||||
ty: self.tcx.ty(elt)}
|
ty: self.tcx.ty(elt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_method_ref(expr: @ast::expr, expr_ty: ty::t) -> cmt {
|
fn cat_method_ref(expr: @ast::expr, expr_ty: ty::t) -> cmt {
|
||||||
@{id:expr.id, span:expr.span,
|
@cmt_ {
|
||||||
cat:cat_special(sk_method), lp:None,
|
id:expr.id,
|
||||||
mutbl:m_imm, ty:expr_ty}
|
span:expr.span,
|
||||||
|
cat:cat_special(sk_method),
|
||||||
|
lp:None,
|
||||||
|
mutbl:m_imm,
|
||||||
|
ty:expr_ty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) {
|
fn cat_pattern(cmt: cmt, pat: @ast::pat, op: fn(cmt, @ast::pat)) {
|
||||||
|
|
|
@ -397,17 +397,15 @@ fn resolve_crate(sess: Session, def_map: resolve::DefMap,
|
||||||
// dependencies until a fixed point is reached.
|
// dependencies until a fixed point is reached.
|
||||||
|
|
||||||
type region_paramd_items = HashMap<ast::node_id, region_variance>;
|
type region_paramd_items = HashMap<ast::node_id, region_variance>;
|
||||||
type region_dep = {ambient_variance: region_variance, id: ast::node_id};
|
|
||||||
type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
|
|
||||||
|
|
||||||
impl region_dep : cmp::Eq {
|
#[deriving_eq]
|
||||||
pure fn eq(&self, other: ®ion_dep) -> bool {
|
struct region_dep {
|
||||||
(*self).ambient_variance == (*other).ambient_variance &&
|
ambient_variance: region_variance,
|
||||||
(*self).id == (*other).id
|
id: ast::node_id
|
||||||
}
|
|
||||||
pure fn ne(&self, other: ®ion_dep) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type dep_map = HashMap<ast::node_id, @DVec<region_dep>>;
|
||||||
|
|
||||||
type determine_rp_ctxt_ = {
|
type determine_rp_ctxt_ = {
|
||||||
sess: Session,
|
sess: Session,
|
||||||
ast_map: ast_map::map,
|
ast_map: ast_map::map,
|
||||||
|
@ -511,7 +509,10 @@ impl determine_rp_ctxt {
|
||||||
vec
|
vec
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let dep = {ambient_variance: self.ambient_variance, id: self.item_id};
|
let dep = region_dep {
|
||||||
|
ambient_variance: self.ambient_variance,
|
||||||
|
id: self.item_id
|
||||||
|
};
|
||||||
if !vec.contains(&dep) { vec.push(dep); }
|
if !vec.contains(&dep) { vec.push(dep); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -910,7 +910,8 @@ fn root_pats_as_necessary(bcx: block,
|
||||||
for vec::each(m) |br| {
|
for vec::each(m) |br| {
|
||||||
let pat_id = br.pats[col].id;
|
let pat_id = br.pats[col].id;
|
||||||
|
|
||||||
match bcx.ccx().maps.root_map.find({id:pat_id, derefs:0u}) {
|
let key = root_map_key {id: pat_id, derefs: 0u };
|
||||||
|
match bcx.ccx().maps.root_map.find(key) {
|
||||||
None => (),
|
None => (),
|
||||||
Some(root_info) => {
|
Some(root_info) => {
|
||||||
// Note: the scope_id will always be the id of the match. See
|
// Note: the scope_id will always be the id of the match. See
|
||||||
|
|
|
@ -61,6 +61,7 @@ use middle::trans::reachable;
|
||||||
use middle::trans::shape::*;
|
use middle::trans::shape::*;
|
||||||
use middle::trans::tvec;
|
use middle::trans::tvec;
|
||||||
use middle::trans::type_of::*;
|
use middle::trans::type_of::*;
|
||||||
|
use middle::ty::arg;
|
||||||
use util::common::indenter;
|
use util::common::indenter;
|
||||||
use util::ppaux::{ty_to_str, ty_to_short_str};
|
use util::ppaux::{ty_to_str, ty_to_short_str};
|
||||||
use util::ppaux;
|
use util::ppaux;
|
||||||
|
@ -2198,9 +2199,12 @@ fn create_main_wrapper(ccx: @crate_ctxt, _sp: span, main_llfn: ValueRef) {
|
||||||
fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef) -> ValueRef {
|
fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef) -> ValueRef {
|
||||||
let unit_ty = ty::mk_estr(ccx.tcx, ty::vstore_uniq);
|
let unit_ty = ty::mk_estr(ccx.tcx, ty::vstore_uniq);
|
||||||
let vecarg_ty: ty::arg =
|
let vecarg_ty: ty::arg =
|
||||||
{mode: ast::expl(ast::by_val),
|
arg {
|
||||||
ty: ty::mk_evec(ccx.tcx, ty::mt {ty: unit_ty, mutbl: ast::m_imm},
|
mode: ast::expl(ast::by_val),
|
||||||
ty::vstore_uniq)};
|
ty: ty::mk_evec(ccx.tcx,
|
||||||
|
ty::mt {ty: unit_ty, mutbl: ast::m_imm},
|
||||||
|
ty::vstore_uniq)
|
||||||
|
};
|
||||||
let nt = ty::mk_nil(ccx.tcx);
|
let nt = ty::mk_nil(ccx.tcx);
|
||||||
let llfty = type_of_fn(ccx, ~[vecarg_ty], nt);
|
let llfty = type_of_fn(ccx, ~[vecarg_ty], nt);
|
||||||
let llfdecl = decl_fn(ccx.llmod, ~"_rust_main",
|
let llfdecl = decl_fn(ccx.llmod, ~"_rust_main",
|
||||||
|
|
|
@ -39,6 +39,7 @@ use middle::trans::reachable;
|
||||||
use middle::trans::shape;
|
use middle::trans::shape;
|
||||||
use middle::trans::type_of;
|
use middle::trans::type_of;
|
||||||
use middle::trans::type_use;
|
use middle::trans::type_use;
|
||||||
|
use middle::ty::substs;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck;
|
use middle::typeck;
|
||||||
use util::ppaux::{expr_repr, ty_to_str};
|
use util::ppaux::{expr_repr, ty_to_str};
|
||||||
|
@ -1459,9 +1460,11 @@ fn find_vtable(tcx: ty::ctxt, ps: ¶m_substs,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dummy_substs(+tps: ~[ty::t]) -> ty::substs {
|
fn dummy_substs(+tps: ~[ty::t]) -> ty::substs {
|
||||||
{self_r: Some(ty::re_bound(ty::br_self)),
|
substs {
|
||||||
|
self_r: Some(ty::re_bound(ty::br_self)),
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: tps}
|
tps: tps
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn struct_field(index: uint) -> [uint * 3] {
|
fn struct_field(index: uint) -> [uint * 3] {
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use lib::llvm::ValueRef;
|
use lib::llvm::ValueRef;
|
||||||
use middle::borrowck::RootInfo;
|
use middle::borrowck::{RootInfo, root_map_key};
|
||||||
use middle::trans::base::*;
|
use middle::trans::base::*;
|
||||||
use middle::trans::build::*;
|
use middle::trans::build::*;
|
||||||
use middle::trans::common::*;
|
use middle::trans::common::*;
|
||||||
|
@ -652,7 +652,7 @@ impl Datum {
|
||||||
// root the autoderef'd value, if necessary:
|
// root the autoderef'd value, if necessary:
|
||||||
//
|
//
|
||||||
// (Note: root'd values are always boxes)
|
// (Note: root'd values are always boxes)
|
||||||
let key = {id:expr_id, derefs:derefs};
|
let key = root_map_key { id: expr_id, derefs: derefs };
|
||||||
let bcx = match ccx.maps.root_map.find(key) {
|
let bcx = match ccx.maps.root_map.find(key) {
|
||||||
None => bcx,
|
None => bcx,
|
||||||
Some(root_info) => self.root(bcx, root_info)
|
Some(root_info) => self.root(bcx, root_info)
|
||||||
|
|
|
@ -114,6 +114,7 @@ lvalues are *never* stored by value.
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use lib::llvm::ValueRef;
|
use lib::llvm::ValueRef;
|
||||||
|
use middle::borrowck::root_map_key;
|
||||||
use middle::resolve;
|
use middle::resolve;
|
||||||
use middle::trans::base::*;
|
use middle::trans::base::*;
|
||||||
use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
|
use middle::trans::callee::{AutorefArg, DoAutorefArg, DontAutorefArg};
|
||||||
|
@ -757,7 +758,7 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
|
||||||
// If the lvalue must remain rooted, create a scratch datum, copy
|
// If the lvalue must remain rooted, create a scratch datum, copy
|
||||||
// the lvalue in there, and then arrange for it to be cleaned up
|
// the lvalue in there, and then arrange for it to be cleaned up
|
||||||
// at the end of the scope with id `scope_id`:
|
// at the end of the scope with id `scope_id`:
|
||||||
let root_key = {id:expr.id, derefs:0u};
|
let root_key = root_map_key { id: expr.id, derefs: 0u };
|
||||||
for bcx.ccx().maps.root_map.find(root_key).each |&root_info| {
|
for bcx.ccx().maps.root_map.find(root_key).each |&root_info| {
|
||||||
bcx = unrooted_datum.root(bcx, root_info);
|
bcx = unrooted_datum.root(bcx, root_info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ use middle::trans::machine;
|
||||||
use middle::trans::shape;
|
use middle::trans::shape;
|
||||||
use middle::trans::type_of::*;
|
use middle::trans::type_of::*;
|
||||||
use middle::trans::type_of;
|
use middle::trans::type_of;
|
||||||
use middle::ty::{FnTyBase, FnMeta, FnSig};
|
use middle::ty::{FnTyBase, FnMeta, FnSig, arg};
|
||||||
use util::ppaux::ty_to_str;
|
use util::ppaux::ty_to_str;
|
||||||
|
|
||||||
use core::libc::c_uint;
|
use core::libc::c_uint;
|
||||||
|
@ -546,7 +546,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::foreign_item,
|
||||||
onceness: ast::Many,
|
onceness: ast::Many,
|
||||||
region: ty::re_bound(ty::br_anon(0)),
|
region: ty::re_bound(ty::br_anon(0)),
|
||||||
bounds: @~[]},
|
bounds: @~[]},
|
||||||
sig: FnSig {inputs: ~[{mode: ast::expl(ast::by_val),
|
sig: FnSig {inputs: ~[arg {mode: ast::expl(ast::by_val),
|
||||||
ty: star_u8}],
|
ty: star_u8}],
|
||||||
output: ty::mk_nil(bcx.tcx())}
|
output: ty::mk_nil(bcx.tcx())}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
use middle::trans::common::*;
|
use middle::trans::common::*;
|
||||||
use middle::trans::type_of;
|
use middle::trans::type_of;
|
||||||
|
use middle::ty::field;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
|
|
||||||
use syntax::parse::token::special_idents;
|
use syntax::parse::token::special_idents;
|
||||||
|
@ -44,13 +45,17 @@ pub fn simplify_type(tcx: ty::ctxt, typ: ty::t) -> ty::t {
|
||||||
ty::ty_struct(did, ref substs) => {
|
ty::ty_struct(did, ref substs) => {
|
||||||
let simpl_fields = (if ty::ty_dtor(tcx, did).is_present() {
|
let simpl_fields = (if ty::ty_dtor(tcx, did).is_present() {
|
||||||
// remember the drop flag
|
// remember the drop flag
|
||||||
~[{ident: special_idents::dtor,
|
~[field {
|
||||||
mt: ty::mt {ty: ty::mk_u8(tcx), mutbl: ast::m_mutbl}}] }
|
ident: special_idents::dtor,
|
||||||
|
mt: ty::mt {ty: ty::mk_u8(tcx), mutbl: ast::m_mutbl}
|
||||||
|
}] }
|
||||||
else { ~[] }) +
|
else { ~[] }) +
|
||||||
do ty::lookup_struct_fields(tcx, did).map |f| {
|
do ty::lookup_struct_fields(tcx, did).map |f| {
|
||||||
let t = ty::lookup_field_type(tcx, did, f.id, substs);
|
let t = ty::lookup_field_type(tcx, did, f.id, substs);
|
||||||
{ident: f.ident,
|
field {
|
||||||
mt: ty::mt {ty: simplify_type(tcx, t), mutbl: ast::m_const}}
|
ident: f.ident,
|
||||||
|
mt: ty::mt {ty: simplify_type(tcx, t), mutbl: ast::m_const
|
||||||
|
}}
|
||||||
};
|
};
|
||||||
ty::mk_rec(tcx, simpl_fields)
|
ty::mk_rec(tcx, simpl_fields)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ use middle::trans::glue;
|
||||||
use middle::trans::inline;
|
use middle::trans::inline;
|
||||||
use middle::trans::monomorphize;
|
use middle::trans::monomorphize;
|
||||||
use middle::trans::type_of::*;
|
use middle::trans::type_of::*;
|
||||||
|
use middle::ty::arg;
|
||||||
use middle::typeck;
|
use middle::typeck;
|
||||||
use util::ppaux::{ty_to_str, tys_to_str};
|
use util::ppaux::{ty_to_str, tys_to_str};
|
||||||
|
|
||||||
|
@ -154,8 +155,10 @@ fn trans_self_arg(bcx: block,
|
||||||
let mut temp_cleanups = ~[];
|
let mut temp_cleanups = ~[];
|
||||||
|
|
||||||
// Compute the mode and type of self.
|
// Compute the mode and type of self.
|
||||||
let self_arg = {mode: mentry.self_arg.mode,
|
let self_arg = arg {
|
||||||
ty: monomorphize_type(bcx, mentry.self_arg.ty)};
|
mode: mentry.self_arg.mode,
|
||||||
|
ty: monomorphize_type(bcx, mentry.self_arg.ty)
|
||||||
|
};
|
||||||
|
|
||||||
let result = trans_arg_expr(bcx, self_arg, base,
|
let result = trans_arg_expr(bcx, self_arg, base,
|
||||||
&mut temp_cleanups, None, DontAutorefArg);
|
&mut temp_cleanups, None, DontAutorefArg);
|
||||||
|
|
|
@ -242,14 +242,23 @@ export AutoRefKind, AutoPtr, AutoBorrowVec, AutoBorrowVecRef, AutoBorrowFn;
|
||||||
export iter_bound_traits_and_supertraits;
|
export iter_bound_traits_and_supertraits;
|
||||||
export count_traits_and_supertraits;
|
export count_traits_and_supertraits;
|
||||||
export IntVarValue, IntType, UintType;
|
export IntVarValue, IntType, UintType;
|
||||||
|
export creader_cache_key;
|
||||||
|
|
||||||
// Data types
|
// Data types
|
||||||
|
|
||||||
// Note: after typeck, you should use resolved_mode() to convert this mode
|
// Note: after typeck, you should use resolved_mode() to convert this mode
|
||||||
// into an rmode, which will take into account the results of mode inference.
|
// into an rmode, which will take into account the results of mode inference.
|
||||||
type arg = {mode: ast::mode, ty: t};
|
#[deriving_eq]
|
||||||
|
struct arg {
|
||||||
|
mode: ast::mode,
|
||||||
|
ty: t
|
||||||
|
}
|
||||||
|
|
||||||
type field = {ident: ast::ident, mt: mt};
|
#[deriving_eq]
|
||||||
|
struct field {
|
||||||
|
ident: ast::ident,
|
||||||
|
mt: mt
|
||||||
|
}
|
||||||
|
|
||||||
type param_bounds = @~[param_bound];
|
type param_bounds = @~[param_bound];
|
||||||
|
|
||||||
|
@ -292,19 +301,14 @@ pub enum ValueMode {
|
||||||
|
|
||||||
// Contains information needed to resolve types and (in the future) look up
|
// Contains information needed to resolve types and (in the future) look up
|
||||||
// the types of AST nodes.
|
// the types of AST nodes.
|
||||||
type creader_cache_key = {cnum: int, pos: uint, len: uint};
|
#[deriving_eq]
|
||||||
type creader_cache = HashMap<creader_cache_key, t>;
|
struct creader_cache_key {
|
||||||
|
cnum: int,
|
||||||
|
pos: uint,
|
||||||
|
len: uint
|
||||||
|
}
|
||||||
|
|
||||||
impl creader_cache_key : cmp::Eq {
|
type creader_cache = HashMap<creader_cache_key, t>;
|
||||||
pure fn eq(&self, other: &creader_cache_key) -> bool {
|
|
||||||
(*self).cnum == (*other).cnum &&
|
|
||||||
(*self).pos == (*other).pos &&
|
|
||||||
(*self).len == (*other).len
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &creader_cache_key) -> bool {
|
|
||||||
!((*self) == (*other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl creader_cache_key : to_bytes::IterBytes {
|
impl creader_cache_key : to_bytes::IterBytes {
|
||||||
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
|
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
|
||||||
|
@ -312,15 +316,23 @@ impl creader_cache_key : to_bytes::IterBytes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type intern_key = {sty: *sty, o_def_id: Option<ast::def_id>};
|
struct intern_key {
|
||||||
|
sty: *sty,
|
||||||
|
o_def_id: Option<ast::def_id>
|
||||||
|
}
|
||||||
|
|
||||||
|
// NB: Do not replace this with #[deriving_eq]. The automatically-derived
|
||||||
|
// implementation will not recurse through sty and you will get stack
|
||||||
|
// exhaustion.
|
||||||
impl intern_key : cmp::Eq {
|
impl intern_key : cmp::Eq {
|
||||||
pure fn eq(&self, other: &intern_key) -> bool {
|
pure fn eq(&self, other: &intern_key) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
*self.sty == *other.sty && self.o_def_id == other.o_def_id
|
*self.sty == *other.sty && self.o_def_id == other.o_def_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pure fn ne(&self, other: &intern_key) -> bool { !(*self).eq(other) }
|
pure fn ne(&self, other: &intern_key) -> bool {
|
||||||
|
!self.eq(other)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl intern_key : to_bytes::IterBytes {
|
impl intern_key : to_bytes::IterBytes {
|
||||||
|
@ -570,13 +582,10 @@ impl<M: to_bytes::IterBytes> FnTyBase<M> : to_bytes::IterBytes {
|
||||||
|
|
||||||
type FnTy = FnTyBase<FnMeta>;
|
type FnTy = FnTyBase<FnMeta>;
|
||||||
|
|
||||||
type param_ty = {idx: uint, def_id: def_id};
|
#[deriving_eq]
|
||||||
|
struct param_ty {
|
||||||
impl param_ty : cmp::Eq {
|
idx: uint,
|
||||||
pure fn eq(&self, other: ¶m_ty) -> bool {
|
def_id: def_id
|
||||||
(*self).idx == (*other).idx && (*self).def_id == (*other).def_id
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: ¶m_ty) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl param_ty : to_bytes::IterBytes {
|
impl param_ty : to_bytes::IterBytes {
|
||||||
|
@ -662,11 +671,12 @@ type opt_region = Option<Region>;
|
||||||
* - `self_ty` is the type to which `self` should be remapped, if any. The
|
* - `self_ty` is the type to which `self` should be remapped, if any. The
|
||||||
* `self` type is rather funny in that it can only appear on traits and is
|
* `self` type is rather funny in that it can only appear on traits and is
|
||||||
* always substituted away to the implementing type for a trait. */
|
* always substituted away to the implementing type for a trait. */
|
||||||
type substs = {
|
#[deriving_eq]
|
||||||
|
struct substs {
|
||||||
self_r: opt_region,
|
self_r: opt_region,
|
||||||
self_ty: Option<ty::t>,
|
self_ty: Option<ty::t>,
|
||||||
tps: ~[t]
|
tps: ~[t]
|
||||||
};
|
}
|
||||||
|
|
||||||
// NB: If you change this, you'll probably want to change the corresponding
|
// NB: If you change this, you'll probably want to change the corresponding
|
||||||
// AST structure in libsyntax/ast.rs as well.
|
// AST structure in libsyntax/ast.rs as well.
|
||||||
|
@ -1051,7 +1061,7 @@ fn mk_t(cx: ctxt, +st: sty) -> t { mk_t_with_id(cx, st, None) }
|
||||||
// Interns a type/name combination, stores the resulting box in cx.interner,
|
// Interns a type/name combination, stores the resulting box in cx.interner,
|
||||||
// and returns the box as cast to an unsafe ptr (see comments for t above).
|
// and returns the box as cast to an unsafe ptr (see comments for t above).
|
||||||
fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
|
fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
|
||||||
let key = {sty: to_unsafe_ptr(&st), o_def_id: o_def_id};
|
let key = intern_key { sty: to_unsafe_ptr(&st), o_def_id: o_def_id };
|
||||||
match cx.interner.find(key) {
|
match cx.interner.find(key) {
|
||||||
Some(t) => unsafe { return cast::reinterpret_cast(&t); },
|
Some(t) => unsafe { return cast::reinterpret_cast(&t); },
|
||||||
_ => ()
|
_ => ()
|
||||||
|
@ -1110,7 +1120,7 @@ fn mk_t_with_id(cx: ctxt, +st: sty, o_def_id: Option<ast::def_id>) -> t {
|
||||||
|
|
||||||
let t = @{sty: move st, id: cx.next_id, flags: flags, o_def_id: o_def_id};
|
let t = @{sty: move st, id: cx.next_id, flags: flags, o_def_id: o_def_id};
|
||||||
|
|
||||||
let key = {sty: to_unsafe_ptr(&t.sty), o_def_id: o_def_id};
|
let key = intern_key {sty: to_unsafe_ptr(&t.sty), o_def_id: o_def_id};
|
||||||
cx.interner.insert(move key, t);
|
cx.interner.insert(move key, t);
|
||||||
|
|
||||||
cx.next_id += 1u;
|
cx.next_id += 1u;
|
||||||
|
@ -1243,7 +1253,7 @@ fn mk_infer(cx: ctxt, +it: InferTy) -> t { mk_t(cx, ty_infer(it)) }
|
||||||
fn mk_self(cx: ctxt) -> t { mk_t(cx, ty_self) }
|
fn mk_self(cx: ctxt) -> t { mk_t(cx, ty_self) }
|
||||||
|
|
||||||
fn mk_param(cx: ctxt, n: uint, k: def_id) -> t {
|
fn mk_param(cx: ctxt, n: uint, k: def_id) -> t {
|
||||||
mk_t(cx, ty_param({idx: n, def_id: k}))
|
mk_t(cx, ty_param(param_ty { idx: n, def_id: k }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) }
|
fn mk_type(cx: ctxt) -> t { mk_t(cx, ty_type) }
|
||||||
|
@ -1359,7 +1369,7 @@ fn fold_sty_to_ty(tcx: ty::ctxt, sty: &sty, foldop: fn(t) -> t) -> t {
|
||||||
|
|
||||||
fn fold_sig(sig: &FnSig, fldop: fn(t) -> t) -> FnSig {
|
fn fold_sig(sig: &FnSig, fldop: fn(t) -> t) -> FnSig {
|
||||||
let args = do sig.inputs.map |arg| {
|
let args = do sig.inputs.map |arg| {
|
||||||
{ mode: arg.mode, ty: fldop(arg.ty) }
|
arg { mode: arg.mode, ty: fldop(arg.ty) }
|
||||||
};
|
};
|
||||||
|
|
||||||
FnSig {
|
FnSig {
|
||||||
|
@ -1370,7 +1380,7 @@ fn fold_sig(sig: &FnSig, fldop: fn(t) -> t) -> FnSig {
|
||||||
|
|
||||||
fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||||
fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs {
|
fn fold_substs(substs: &substs, fldop: fn(t) -> t) -> substs {
|
||||||
{self_r: substs.self_r,
|
substs {self_r: substs.self_r,
|
||||||
self_ty: substs.self_ty.map(|t| fldop(*t)),
|
self_ty: substs.self_ty.map(|t| fldop(*t)),
|
||||||
tps: substs.tps.map(|t| fldop(*t))}
|
tps: substs.tps.map(|t| fldop(*t))}
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1411,7 @@ fn fold_sty(sty: &sty, fldop: fn(t) -> t) -> sty {
|
||||||
let new_fields = do vec::map(fields) |fl| {
|
let new_fields = do vec::map(fields) |fl| {
|
||||||
let new_ty = fldop(fl.mt.ty);
|
let new_ty = fldop(fl.mt.ty);
|
||||||
let new_mt = mt { ty: new_ty, mutbl: fl.mt.mutbl };
|
let new_mt = mt { ty: new_ty, mutbl: fl.mt.mutbl };
|
||||||
{ident: fl.ident, mt: new_mt}
|
field { ident: fl.ident, mt: new_mt }
|
||||||
};
|
};
|
||||||
ty_rec(new_fields)
|
ty_rec(new_fields)
|
||||||
}
|
}
|
||||||
|
@ -1458,11 +1468,13 @@ fn fold_regions_and_ty(
|
||||||
fn fold_substs(
|
fn fold_substs(
|
||||||
substs: &substs,
|
substs: &substs,
|
||||||
fldr: fn(r: Region) -> Region,
|
fldr: fn(r: Region) -> Region,
|
||||||
fldt: fn(t: t) -> t) -> substs
|
fldt: fn(t: t) -> t)
|
||||||
{
|
-> substs {
|
||||||
{self_r: substs.self_r.map(|r| fldr(*r)),
|
substs {
|
||||||
|
self_r: substs.self_r.map(|r| fldr(*r)),
|
||||||
self_ty: substs.self_ty.map(|t| fldt(*t)),
|
self_ty: substs.self_ty.map(|t| fldt(*t)),
|
||||||
tps: substs.tps.map(|t| fldt(*t))}
|
tps: substs.tps.map(|t| fldt(*t))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let tb = ty::get(ty);
|
let tb = ty::get(ty);
|
||||||
|
@ -1678,7 +1690,7 @@ fn subst(cx: ctxt,
|
||||||
// Performs substitutions on a set of substitutions (result = sup(sub)) to
|
// Performs substitutions on a set of substitutions (result = sup(sub)) to
|
||||||
// yield a new set of substitutions. This is used in trait inheritance.
|
// yield a new set of substitutions. This is used in trait inheritance.
|
||||||
fn subst_substs(cx: ctxt, sup: &substs, sub: &substs) -> substs {
|
fn subst_substs(cx: ctxt, sup: &substs, sub: &substs) -> substs {
|
||||||
{
|
substs {
|
||||||
self_r: sup.self_r,
|
self_r: sup.self_r,
|
||||||
self_ty: sup.self_ty.map(|typ| subst(cx, sub, *typ)),
|
self_ty: sup.self_ty.map(|typ| subst(cx, sub, *typ)),
|
||||||
tps: sup.tps.map(|typ| subst(cx, sub, *typ))
|
tps: sup.tps.map(|typ| subst(cx, sub, *typ))
|
||||||
|
@ -4159,7 +4171,7 @@ fn struct_item_fields(cx:ctxt,
|
||||||
do lookup_struct_fields(cx, did).map |f| {
|
do lookup_struct_fields(cx, did).map |f| {
|
||||||
// consider all instance vars mut, because the
|
// consider all instance vars mut, because the
|
||||||
// constructor may mutate all vars
|
// constructor may mutate all vars
|
||||||
{
|
field {
|
||||||
ident: f.ident,
|
ident: f.ident,
|
||||||
mt: mt {
|
mt: mt {
|
||||||
ty: lookup_field_type(cx, did, f.id, substs),
|
ty: lookup_field_type(cx, did, f.id, substs),
|
||||||
|
@ -4288,9 +4300,11 @@ fn normalize_ty(cx: ctxt, t: t) -> t {
|
||||||
Some(_) =>
|
Some(_) =>
|
||||||
// Use re_static since trans doesn't care about regions
|
// Use re_static since trans doesn't care about regions
|
||||||
mk_enum(cx, did,
|
mk_enum(cx, did,
|
||||||
{self_r: Some(ty::re_static),
|
substs {
|
||||||
|
self_r: Some(ty::re_static),
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: /*bad*/copy (*r).tps}),
|
tps: /*bad*/copy (*r).tps
|
||||||
|
}),
|
||||||
None =>
|
None =>
|
||||||
t
|
t
|
||||||
},
|
},
|
||||||
|
@ -4299,7 +4313,7 @@ fn normalize_ty(cx: ctxt, t: t) -> t {
|
||||||
match (*r).self_r {
|
match (*r).self_r {
|
||||||
Some(_) =>
|
Some(_) =>
|
||||||
// Ditto.
|
// Ditto.
|
||||||
mk_struct(cx, did, {self_r: Some(ty::re_static),
|
mk_struct(cx, did, substs {self_r: Some(ty::re_static),
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: /*bad*/copy (*r).tps}),
|
tps: /*bad*/copy (*r).tps}),
|
||||||
None =>
|
None =>
|
||||||
|
@ -4421,20 +4435,6 @@ impl mt : cmp::Eq {
|
||||||
pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
|
pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl arg : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &arg) -> bool {
|
|
||||||
(*self).mode == (*other).mode && (*self).ty == (*other).ty
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &arg) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl field : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &field) -> bool {
|
|
||||||
(*self).ident == (*other).ident && (*self).mt == (*other).mt
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &field) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl vstore : cmp::Eq {
|
impl vstore : cmp::Eq {
|
||||||
pure fn eq(&self, other: &vstore) -> bool {
|
pure fn eq(&self, other: &vstore) -> bool {
|
||||||
match (*self) {
|
match (*self) {
|
||||||
|
@ -4543,15 +4543,6 @@ impl bound_region : cmp::Eq {
|
||||||
pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
|
pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl substs : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &substs) -> bool {
|
|
||||||
(*self).self_r == (*other).self_r &&
|
|
||||||
(*self).self_ty == (*other).self_ty &&
|
|
||||||
(*self).tps == (*other).tps
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &substs) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl sty : cmp::Eq {
|
impl sty : cmp::Eq {
|
||||||
pure fn eq(&self, other: &sty) -> bool {
|
pure fn eq(&self, other: &sty) -> bool {
|
||||||
match (/*bad*/copy *self) {
|
match (/*bad*/copy *self) {
|
||||||
|
|
|
@ -55,7 +55,8 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::pat_util::pat_id_map;
|
use middle::pat_util::pat_id_map;
|
||||||
use middle::ty::{FnTyBase, FnMeta, FnSig, ty_param_substs_and_ty};
|
use middle::ty::{FnTyBase, FnMeta, FnSig, arg, field, substs};
|
||||||
|
use middle::ty::{ty_param_substs_and_ty};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::check::fn_ctxt;
|
use middle::typeck::check::fn_ctxt;
|
||||||
use middle::typeck::collect;
|
use middle::typeck::collect;
|
||||||
|
@ -151,7 +152,7 @@ fn ast_path_to_substs_and_ty<AC: ast_conv, RS: region_scope Copy Durable>(
|
||||||
}
|
}
|
||||||
let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, *a_t));
|
let tps = path.types.map(|a_t| ast_ty_to_ty(self, rscope, *a_t));
|
||||||
|
|
||||||
let substs = {self_r:self_r, self_ty:None, tps:tps};
|
let substs = substs {self_r:self_r, self_ty:None, tps:tps};
|
||||||
let ty = ty::subst(tcx, &substs, decl_ty);
|
let ty = ty::subst(tcx, &substs, decl_ty);
|
||||||
{substs: substs, ty: ty}
|
{substs: substs, ty: ty}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +316,7 @@ fn ast_ty_to_ty<AC: ast_conv, RS: region_scope Copy Durable>(
|
||||||
ast::ty_rec(ref fields) => {
|
ast::ty_rec(ref fields) => {
|
||||||
let flds = do (*fields).map |f| {
|
let flds = do (*fields).map |f| {
|
||||||
let tm = ast_mt_to_mt(self, rscope, f.node.mt);
|
let tm = ast_mt_to_mt(self, rscope, f.node.mt);
|
||||||
{ident: f.node.ident, mt: tm}
|
field {ident: f.node.ident, mt: tm}
|
||||||
};
|
};
|
||||||
ty::mk_rec(tcx, flds)
|
ty::mk_rec(tcx, flds)
|
||||||
}
|
}
|
||||||
|
@ -447,7 +448,7 @@ fn ty_of_arg<AC: ast_conv, RS: region_scope Copy Durable>(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{mode: mode, ty: ty}
|
arg {mode: mode, ty: ty}
|
||||||
}
|
}
|
||||||
|
|
||||||
type expected_tys = Option<{inputs: ~[ty::arg],
|
type expected_tys = Option<{inputs: ~[ty::arg],
|
||||||
|
|
|
@ -295,7 +295,11 @@ impl LookupContext {
|
||||||
let self_did = self.fcx.self_info.expect(
|
let self_did = self.fcx.self_info.expect(
|
||||||
~"self_impl_def_id is undefined (`self` may not \
|
~"self_impl_def_id is undefined (`self` may not \
|
||||||
be in scope here").def_id;
|
be in scope here").def_id;
|
||||||
let substs = {self_r: None, self_ty: None, tps: ~[]};
|
let substs = substs {
|
||||||
|
self_r: None,
|
||||||
|
self_ty: None,
|
||||||
|
tps: ~[]
|
||||||
|
};
|
||||||
self.push_inherent_candidates_from_self(
|
self.push_inherent_candidates_from_self(
|
||||||
self_ty, self_did, &substs);
|
self_ty, self_did, &substs);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +396,10 @@ impl LookupContext {
|
||||||
// impl or class (where the self type is not permitted),
|
// impl or class (where the self type is not permitted),
|
||||||
// or from a trait type (in which case methods that refer
|
// or from a trait type (in which case methods that refer
|
||||||
// to self are not permitted).
|
// to self are not permitted).
|
||||||
let init_substs = {self_ty: Some(rcvr_ty), ..init_substs};
|
let init_substs = substs {
|
||||||
|
self_ty: Some(rcvr_ty),
|
||||||
|
..init_substs
|
||||||
|
};
|
||||||
|
|
||||||
worklist.push((init_trait_ty, init_substs));
|
worklist.push((init_trait_ty, init_substs));
|
||||||
|
|
||||||
|
@ -416,7 +423,10 @@ impl LookupContext {
|
||||||
&init_substs);
|
&init_substs);
|
||||||
|
|
||||||
// Again replacing the self type
|
// Again replacing the self type
|
||||||
let new_substs = {self_ty: Some(rcvr_ty), ..new_substs};
|
let new_substs = substs {
|
||||||
|
self_ty: Some(rcvr_ty),
|
||||||
|
..new_substs
|
||||||
|
};
|
||||||
|
|
||||||
worklist.push((supertrait.tpt.ty, new_substs));
|
worklist.push((supertrait.tpt.ty, new_substs));
|
||||||
}
|
}
|
||||||
|
@ -506,7 +516,10 @@ impl LookupContext {
|
||||||
// `trait_ty` for `self` here, because it allows the compiler
|
// `trait_ty` for `self` here, because it allows the compiler
|
||||||
// to soldier on. An error will be reported should this
|
// to soldier on. An error will be reported should this
|
||||||
// candidate be selected if the method refers to `self`.
|
// candidate be selected if the method refers to `self`.
|
||||||
let rcvr_substs = {self_ty: Some(self_ty), ../*bad*/copy *substs};
|
let rcvr_substs = substs {
|
||||||
|
self_ty: Some(self_ty),
|
||||||
|
../*bad*/copy *substs
|
||||||
|
};
|
||||||
|
|
||||||
let (rcvr_ty, rcvr_substs) =
|
let (rcvr_ty, rcvr_substs) =
|
||||||
self.create_rcvr_ty_and_substs_for_method(method.self_ty,
|
self.create_rcvr_ty_and_substs_for_method(method.self_ty,
|
||||||
|
@ -537,7 +550,10 @@ impl LookupContext {
|
||||||
}
|
}
|
||||||
let method = &methods[index];
|
let method = &methods[index];
|
||||||
|
|
||||||
let rcvr_substs = { self_ty: Some(self_ty), ../*bad*/copy *substs };
|
let rcvr_substs = substs {
|
||||||
|
self_ty: Some(self_ty),
|
||||||
|
../*bad*/copy *substs
|
||||||
|
};
|
||||||
let (rcvr_ty, rcvr_substs) =
|
let (rcvr_ty, rcvr_substs) =
|
||||||
self.create_rcvr_ty_and_substs_for_method(
|
self.create_rcvr_ty_and_substs_for_method(
|
||||||
method.self_ty,
|
method.self_ty,
|
||||||
|
@ -628,7 +644,11 @@ impl LookupContext {
|
||||||
candidate");
|
candidate");
|
||||||
|
|
||||||
// XXX: Needs to support generics.
|
// XXX: Needs to support generics.
|
||||||
let dummy_substs = { self_r: None, self_ty: None, tps: ~[] };
|
let dummy_substs = substs {
|
||||||
|
self_r: None,
|
||||||
|
self_ty: None,
|
||||||
|
tps: ~[]
|
||||||
|
};
|
||||||
let (impl_ty, impl_substs) =
|
let (impl_ty, impl_substs) =
|
||||||
self.create_rcvr_ty_and_substs_for_method(
|
self.create_rcvr_ty_and_substs_for_method(
|
||||||
provided_method_info.method_info.self_type,
|
provided_method_info.method_info.self_type,
|
||||||
|
@ -673,11 +693,13 @@ impl LookupContext {
|
||||||
move self_substs
|
move self_substs
|
||||||
}
|
}
|
||||||
sty_region(_) => {
|
sty_region(_) => {
|
||||||
{self_r:
|
substs {
|
||||||
|
self_r:
|
||||||
Some(self.infcx().next_region_var(
|
Some(self.infcx().next_region_var(
|
||||||
self.expr.span,
|
self.expr.span,
|
||||||
self.expr.id)),
|
self.expr.id)),
|
||||||
..self_substs}
|
..self_substs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1058,7 +1080,7 @@ impl LookupContext {
|
||||||
|
|
||||||
// Construct the full set of type parameters for the method,
|
// Construct the full set of type parameters for the method,
|
||||||
// which is equal to the class tps + the method tps.
|
// which is equal to the class tps + the method tps.
|
||||||
let all_substs = {
|
let all_substs = substs {
|
||||||
tps: vec::append(/*bad*/copy candidate.rcvr_substs.tps,
|
tps: vec::append(/*bad*/copy candidate.rcvr_substs.tps,
|
||||||
m_substs),
|
m_substs),
|
||||||
../*bad*/copy candidate.rcvr_substs
|
../*bad*/copy candidate.rcvr_substs
|
||||||
|
@ -1066,7 +1088,7 @@ impl LookupContext {
|
||||||
|
|
||||||
self.fcx.write_ty_substs(self.callee_id, fty, all_substs);
|
self.fcx.write_ty_substs(self.callee_id, fty, all_substs);
|
||||||
method_map_entry {
|
method_map_entry {
|
||||||
self_arg: {
|
self_arg: arg {
|
||||||
mode: ast::expl(candidate.self_mode),
|
mode: ast::expl(candidate.self_mode),
|
||||||
ty: candidate.rcvr_ty,
|
ty: candidate.rcvr_ty,
|
||||||
},
|
},
|
||||||
|
|
|
@ -84,7 +84,7 @@ use middle::pat_util::pat_id_map;
|
||||||
use middle::pat_util;
|
use middle::pat_util;
|
||||||
use middle::ty::{TyVid, Vid, FnTyBase, FnMeta, FnSig, VariantInfo_, field};
|
use middle::ty::{TyVid, Vid, FnTyBase, FnMeta, FnSig, VariantInfo_, field};
|
||||||
use middle::ty::{ty_param_bounds_and_ty, ty_param_substs_and_ty};
|
use middle::ty::{ty_param_bounds_and_ty, ty_param_substs_and_ty};
|
||||||
use middle::ty::{re_bound, br_cap_avoid};
|
use middle::ty::{re_bound, br_cap_avoid, substs, arg, param_ty};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::astconv::{ast_conv, ast_path_to_ty};
|
use middle::typeck::astconv::{ast_conv, ast_path_to_ty};
|
||||||
use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty};
|
use middle::typeck::astconv::{ast_region_to_region, ast_ty_to_ty};
|
||||||
|
@ -1059,9 +1059,11 @@ pub fn impl_self_ty(vcx: &VtableContext,
|
||||||
{n_tps: ts.len(),
|
{n_tps: ts.len(),
|
||||||
region_param: region_param,
|
region_param: region_param,
|
||||||
raw_ty: ty::mk_struct(tcx, local_def(class_id),
|
raw_ty: ty::mk_struct(tcx, local_def(class_id),
|
||||||
{self_r: rscope::bound_self_region(region_param),
|
substs {
|
||||||
|
self_r: rscope::bound_self_region(region_param),
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: ty::ty_params_to_tys(tcx, /*bad*/copy *ts)})}
|
tps: ty::ty_params_to_tys(tcx, /*bad*/copy *ts)
|
||||||
|
})}
|
||||||
}
|
}
|
||||||
_ => { tcx.sess.bug(~"impl_self_ty: unbound item or item that \
|
_ => { tcx.sess.bug(~"impl_self_ty: unbound item or item that \
|
||||||
doesn't have a self_ty"); }
|
doesn't have a self_ty"); }
|
||||||
|
@ -1081,7 +1083,7 @@ pub fn impl_self_ty(vcx: &VtableContext,
|
||||||
};
|
};
|
||||||
let tps = vcx.infcx.next_ty_vars(n_tps);
|
let tps = vcx.infcx.next_ty_vars(n_tps);
|
||||||
|
|
||||||
let substs = {self_r: self_r, self_ty: None, tps: tps};
|
let substs = substs { self_r: self_r, self_ty: None, tps: tps };
|
||||||
let substd_ty = ty::subst(tcx, &substs, raw_ty);
|
let substd_ty = ty::subst(tcx, &substs, raw_ty);
|
||||||
{substs: substs, ty: substd_ty}
|
{substs: substs, ty: substd_ty}
|
||||||
}
|
}
|
||||||
|
@ -1814,7 +1816,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||||
let self_region =
|
let self_region =
|
||||||
bound_self_region(region_parameterized);
|
bound_self_region(region_parameterized);
|
||||||
|
|
||||||
raw_type = ty::mk_struct(tcx, class_id, {
|
raw_type = ty::mk_struct(tcx, class_id, substs {
|
||||||
self_r: self_region,
|
self_r: self_region,
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: ty::ty_params_to_tys(
|
tps: ty::ty_params_to_tys(
|
||||||
|
@ -1840,7 +1842,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||||
span,
|
span,
|
||||||
ty::re_scope(id));
|
ty::re_scope(id));
|
||||||
let type_parameters = fcx.infcx().next_ty_vars(type_parameter_count);
|
let type_parameters = fcx.infcx().next_ty_vars(type_parameter_count);
|
||||||
let substitutions = {
|
let substitutions = substs {
|
||||||
self_r: self_region,
|
self_r: self_region,
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: type_parameters
|
tps: type_parameters
|
||||||
|
@ -1897,7 +1899,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||||
let self_region =
|
let self_region =
|
||||||
bound_self_region(region_parameterized);
|
bound_self_region(region_parameterized);
|
||||||
|
|
||||||
raw_type = ty::mk_enum(tcx, enum_id, {
|
raw_type = ty::mk_enum(tcx, enum_id, substs {
|
||||||
self_r: self_region,
|
self_r: self_region,
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: ty::ty_params_to_tys(
|
tps: ty::ty_params_to_tys(
|
||||||
|
@ -1923,7 +1925,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||||
span,
|
span,
|
||||||
ty::re_scope(id));
|
ty::re_scope(id));
|
||||||
let type_parameters = fcx.infcx().next_ty_vars(type_parameter_count);
|
let type_parameters = fcx.infcx().next_ty_vars(type_parameter_count);
|
||||||
let substitutions = {
|
let substitutions = substs {
|
||||||
self_r: self_region,
|
self_r: self_region,
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: type_parameters
|
tps: type_parameters
|
||||||
|
@ -2434,7 +2436,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
|
||||||
let expr_mt = ty::mt {ty: expr_t, mutbl: f.node.mutbl};
|
let expr_mt = ty::mt {ty: expr_t, mutbl: f.node.mutbl};
|
||||||
// for the most precise error message,
|
// for the most precise error message,
|
||||||
// should be f.node.expr.span, not f.span
|
// should be f.node.expr.span, not f.span
|
||||||
respan(f.node.expr.span, {ident: f.node.ident, mt: expr_mt})
|
respan(f.node.expr.span, field {ident: f.node.ident, mt: expr_mt})
|
||||||
});
|
});
|
||||||
match base {
|
match base {
|
||||||
None => {
|
None => {
|
||||||
|
@ -2951,7 +2953,7 @@ fn instantiate_path(fcx: @fn_ctxt,
|
||||||
pth.types.map(|aty| fcx.to_ty(*aty))
|
pth.types.map(|aty| fcx.to_ty(*aty))
|
||||||
};
|
};
|
||||||
|
|
||||||
let substs = {self_r: self_r, self_ty: None, tps: tps};
|
let substs = substs { self_r: self_r, self_ty: None, tps: tps };
|
||||||
fcx.write_ty_substs(node_id, tpt.ty, substs);
|
fcx.write_ty_substs(node_id, tpt.ty, substs);
|
||||||
|
|
||||||
debug!("<<<");
|
debug!("<<<");
|
||||||
|
@ -3050,7 +3052,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
|
||||||
|_r| {},
|
|_r| {},
|
||||||
|t| {
|
|t| {
|
||||||
match ty::get(t).sty {
|
match ty::get(t).sty {
|
||||||
ty::ty_param({idx, _}) => {
|
ty::ty_param(param_ty {idx, _}) => {
|
||||||
debug!("Found use of ty param #%u", idx);
|
debug!("Found use of ty param #%u", idx);
|
||||||
tps_used[idx] = true;
|
tps_used[idx] = true;
|
||||||
}
|
}
|
||||||
|
@ -3073,7 +3075,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
||||||
ty::mk_param(ccx.tcx, n, local_def(0))
|
ty::mk_param(ccx.tcx, n, local_def(0))
|
||||||
}
|
}
|
||||||
fn arg(m: ast::rmode, ty: ty::t) -> ty::arg {
|
fn arg(m: ast::rmode, ty: ty::t) -> ty::arg {
|
||||||
{mode: ast::expl(m), ty: ty}
|
arg {mode: ast::expl(m), ty: ty}
|
||||||
}
|
}
|
||||||
let tcx = ccx.tcx;
|
let tcx = ccx.tcx;
|
||||||
let (n_tps, inputs, output) = match ccx.tcx.sess.str_of(it.ident) {
|
let (n_tps, inputs, output) = match ccx.tcx.sess.str_of(it.ident) {
|
||||||
|
@ -3136,7 +3138,9 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::foreign_item) {
|
||||||
onceness: ast::Once,
|
onceness: ast::Once,
|
||||||
region: ty::re_bound(ty::br_anon(0)),
|
region: ty::re_bound(ty::br_anon(0)),
|
||||||
bounds: @~[]},
|
bounds: @~[]},
|
||||||
sig: FnSig {inputs: ~[{mode: ast::expl(ast::by_val),
|
sig: FnSig {
|
||||||
|
inputs: ~[arg {
|
||||||
|
mode: ast::expl(ast::by_val),
|
||||||
ty: ty::mk_imm_ptr(
|
ty: ty::mk_imm_ptr(
|
||||||
ccx.tcx,
|
ccx.tcx,
|
||||||
ty::mk_mach_uint(ccx.tcx, ast::ty_u8))
|
ty::mk_mach_uint(ccx.tcx, ast::ty_u8))
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::resolve;
|
use middle::resolve;
|
||||||
|
use middle::ty::{param_ty, substs};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::check::{fn_ctxt, impl_self_ty};
|
use middle::typeck::check::{fn_ctxt, impl_self_ty};
|
||||||
use middle::typeck::check::{structurally_resolved_type};
|
use middle::typeck::check::{structurally_resolved_type};
|
||||||
|
@ -103,7 +104,10 @@ fn lookup_vtables(vcx: &VtableContext,
|
||||||
ppaux::ty_to_str(tcx, trait_ty),
|
ppaux::ty_to_str(tcx, trait_ty),
|
||||||
ty::substs_to_str(tcx, substs));
|
ty::substs_to_str(tcx, substs));
|
||||||
|
|
||||||
let new_substs = {self_ty: Some(*ty), ../*bad*/copy *substs};
|
let new_substs = substs {
|
||||||
|
self_ty: Some(*ty),
|
||||||
|
../*bad*/copy *substs
|
||||||
|
};
|
||||||
let trait_ty = ty::subst(tcx, &new_substs, trait_ty);
|
let trait_ty = ty::subst(tcx, &new_substs, trait_ty);
|
||||||
|
|
||||||
debug!("after subst: %?",
|
debug!("after subst: %?",
|
||||||
|
@ -189,7 +193,7 @@ fn lookup_vtable(vcx: &VtableContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
match ty::get(ty).sty {
|
match ty::get(ty).sty {
|
||||||
ty::ty_param({idx: n, def_id: did}) => {
|
ty::ty_param(param_ty {idx: n, def_id: did}) => {
|
||||||
let mut n_bound = 0;
|
let mut n_bound = 0;
|
||||||
let bounds = tcx.ty_param_bounds.get(did.node);
|
let bounds = tcx.ty_param_bounds.get(did.node);
|
||||||
for ty::iter_bound_traits_and_supertraits(
|
for ty::iter_bound_traits_and_supertraits(
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::pat_util;
|
use middle::pat_util;
|
||||||
|
use middle::ty::arg;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::check::{fn_ctxt, self_info};
|
use middle::typeck::check::{fn_ctxt, self_info};
|
||||||
use middle::typeck::infer::{force_all, resolve_all, resolve_region};
|
use middle::typeck::infer::{force_all, resolve_all, resolve_region};
|
||||||
|
@ -65,7 +66,7 @@ fn resolve_method_map_entry(fcx: @fn_ctxt, sp: span, id: ast::node_id)
|
||||||
fcx.ccx.method_map.insert(
|
fcx.ccx.method_map.insert(
|
||||||
id,
|
id,
|
||||||
method_map_entry {
|
method_map_entry {
|
||||||
self_arg: {mode: mme.self_arg.mode, ty: *t},
|
self_arg: arg {mode: mme.self_arg.mode, ty: *t},
|
||||||
.. *mme
|
.. *mme
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,8 +25,8 @@ use metadata::decoder::{dl_def, dl_field, dl_impl};
|
||||||
use middle::resolve::{Impl, MethodInfo};
|
use middle::resolve::{Impl, MethodInfo};
|
||||||
use middle::ty::{ProvidedMethodSource, ProvidedMethodInfo, bound_copy, get};
|
use middle::ty::{ProvidedMethodSource, ProvidedMethodInfo, bound_copy, get};
|
||||||
use middle::ty::{kind_can_be_copied, lookup_item_type, param_bounds, subst};
|
use middle::ty::{kind_can_be_copied, lookup_item_type, param_bounds, subst};
|
||||||
use middle::ty::{t, ty_bool, ty_bot, ty_box, ty_enum, ty_err, ty_estr};
|
use middle::ty::{substs, t, ty_bool, ty_bot, ty_box, ty_enum, ty_err};
|
||||||
use middle::ty::{ty_evec, ty_float, ty_fn, ty_infer, ty_int, ty_nil};
|
use middle::ty::{ty_estr, ty_evec, ty_float, ty_fn, ty_infer, ty_int, ty_nil};
|
||||||
use middle::ty::{ty_opaque_box, ty_param, ty_param_bounds_and_ty, ty_ptr};
|
use middle::ty::{ty_opaque_box, ty_param, ty_param_bounds_and_ty, ty_ptr};
|
||||||
use middle::ty::{ty_rec, ty_rptr, ty_self, ty_struct, ty_trait, ty_tup};
|
use middle::ty::{ty_rec, ty_rptr, ty_self, ty_struct, ty_trait, ty_tup};
|
||||||
use middle::ty::{ty_type, ty_uint, ty_uniq};
|
use middle::ty::{ty_type, ty_uint, ty_uniq};
|
||||||
|
@ -34,6 +34,7 @@ use middle::ty::{ty_opaque_closure_ptr, ty_unboxed_vec, type_kind_ext};
|
||||||
use middle::ty::{type_is_ty_var};
|
use middle::ty::{type_is_ty_var};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::crate_ctxt;
|
use middle::typeck::crate_ctxt;
|
||||||
|
use middle::typeck::infer::combine::Combine;
|
||||||
use middle::typeck::infer::{InferCtxt, can_mk_subty};
|
use middle::typeck::infer::{InferCtxt, can_mk_subty};
|
||||||
use middle::typeck::infer::{new_infer_ctxt, resolve_ivar};
|
use middle::typeck::infer::{new_infer_ctxt, resolve_ivar};
|
||||||
use middle::typeck::infer::{resolve_nested_tvar, resolve_type};
|
use middle::typeck::infer::{resolve_nested_tvar, resolve_type};
|
||||||
|
@ -286,8 +287,8 @@ impl CoherenceChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the implementation to the mapping from implementation to base
|
// Add the implementation to the mapping from implementation to base
|
||||||
// type def ID, if there is a base type for this implementation.
|
// type def ID, if there is a base type for this implementation and
|
||||||
|
// the implementation does not have any associated traits.
|
||||||
match get_base_type_def_id(self.inference_context,
|
match get_base_type_def_id(self.inference_context,
|
||||||
item.span,
|
item.span,
|
||||||
self_type.ty) {
|
self_type.ty) {
|
||||||
|
@ -296,6 +297,7 @@ impl CoherenceChecker {
|
||||||
}
|
}
|
||||||
Some(base_type_def_id) => {
|
Some(base_type_def_id) => {
|
||||||
// XXX: Gather up default methods?
|
// XXX: Gather up default methods?
|
||||||
|
if associated_traits.len() == 0 {
|
||||||
let implementation;
|
let implementation;
|
||||||
match implementation_opt {
|
match implementation_opt {
|
||||||
None => {
|
None => {
|
||||||
|
@ -305,7 +307,9 @@ impl CoherenceChecker {
|
||||||
implementation = existing_implementation;
|
implementation = existing_implementation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.add_inherent_method(base_type_def_id, implementation);
|
self.add_inherent_method(base_type_def_id,
|
||||||
|
implementation);
|
||||||
|
}
|
||||||
|
|
||||||
self.base_type_def_ids.insert(local_def(item.id),
|
self.base_type_def_ids.insert(local_def(item.id),
|
||||||
base_type_def_id);
|
base_type_def_id);
|
||||||
|
@ -510,7 +514,7 @@ impl CoherenceChecker {
|
||||||
let type_parameters =
|
let type_parameters =
|
||||||
self.inference_context.next_ty_vars(bounds_count);
|
self.inference_context.next_ty_vars(bounds_count);
|
||||||
|
|
||||||
let substitutions = {
|
let substitutions = substs {
|
||||||
self_r: self_region,
|
self_r: self_region,
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
tps: type_parameters
|
tps: type_parameters
|
||||||
|
@ -520,7 +524,8 @@ impl CoherenceChecker {
|
||||||
polytype.ty);
|
polytype.ty);
|
||||||
|
|
||||||
// Get our type parameters back.
|
// Get our type parameters back.
|
||||||
let { self_r: _, self_ty: _, tps: type_parameters } = substitutions;
|
let substs { self_r: _, self_ty: _, tps: type_parameters } =
|
||||||
|
substitutions;
|
||||||
|
|
||||||
UniversalQuantificationResult {
|
UniversalQuantificationResult {
|
||||||
monotype: monotype,
|
monotype: monotype,
|
||||||
|
@ -597,6 +602,7 @@ impl CoherenceChecker {
|
||||||
visit_mod(module_, item.span, item.id, (), visitor);
|
visit_mod(module_, item.span, item.id, (), visitor);
|
||||||
}
|
}
|
||||||
item_impl(_, opt_trait, _, _) => {
|
item_impl(_, opt_trait, _, _) => {
|
||||||
|
let mut ok = false;
|
||||||
match self.base_type_def_ids.find(
|
match self.base_type_def_ids.find(
|
||||||
local_def(item.id)) {
|
local_def(item.id)) {
|
||||||
|
|
||||||
|
@ -611,57 +617,50 @@ impl CoherenceChecker {
|
||||||
// Record that this implementation is OK.
|
// Record that this implementation is OK.
|
||||||
self.privileged_implementations.insert
|
self.privileged_implementations.insert
|
||||||
(item.id, ());
|
(item.id, ());
|
||||||
} else {
|
ok = true;
|
||||||
// This implementation is not in scope of
|
}
|
||||||
// its base type. This still might be OK
|
}
|
||||||
// if the traits are defined in the same
|
}
|
||||||
// crate.
|
|
||||||
|
if !ok {
|
||||||
|
// This implementation is not in scope of its base
|
||||||
|
// type. This still might be OK if the trait is
|
||||||
|
// defined in the same crate.
|
||||||
|
|
||||||
match opt_trait {
|
match opt_trait {
|
||||||
None => {
|
None => {
|
||||||
// There is no trait to implement, so
|
// There is no trait to implement, so
|
||||||
// this is an error.
|
// this is an error.
|
||||||
|
|
||||||
let session =
|
let session = self.crate_context.tcx.sess;
|
||||||
self.crate_context.tcx.sess;
|
|
||||||
session.span_err(item.span,
|
session.span_err(item.span,
|
||||||
~"cannot implement \
|
~"cannot implement \
|
||||||
inherent methods \
|
inherent methods for a \
|
||||||
for a type outside \
|
type outside the crate \
|
||||||
the crate the type \
|
the type was defined \
|
||||||
was defined in; \
|
in; define and \
|
||||||
define and \
|
implement a trait or \
|
||||||
implement a trait \
|
new type instead");
|
||||||
or new type \
|
|
||||||
instead");
|
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
||||||
do opt_trait.iter() |trait_ref| {
|
do opt_trait.iter() |trait_ref| {
|
||||||
// This is OK if and only if the
|
// This is OK if and only if the trait was
|
||||||
// trait was defined in this
|
// defined in this crate.
|
||||||
// crate.
|
|
||||||
|
|
||||||
let trait_def_id =
|
let trait_def_id =
|
||||||
self.trait_ref_to_trait_def_id(
|
self.trait_ref_to_trait_def_id(
|
||||||
*trait_ref);
|
*trait_ref);
|
||||||
|
|
||||||
if trait_def_id.crate != local_crate {
|
if trait_def_id.crate != local_crate {
|
||||||
let session =
|
let session = self.crate_context.tcx.sess;
|
||||||
self.crate_context.tcx.sess;
|
|
||||||
session.span_err(item.span,
|
session.span_err(item.span,
|
||||||
~"cannot \
|
~"cannot provide an \
|
||||||
provide an \
|
|
||||||
extension \
|
extension \
|
||||||
implementa\
|
implementation for a \
|
||||||
tion \
|
trait not defined in \
|
||||||
for a trait \
|
this crate");
|
||||||
not defined \
|
|
||||||
in this \
|
|
||||||
crate");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,8 @@ are represented as `ty_param()` instances.
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use metadata::csearch;
|
use metadata::csearch;
|
||||||
use middle::ty::{FnMeta, FnSig, FnTyBase, InstantiatedTraitRef};
|
use middle::ty::{FnMeta, FnSig, FnTyBase, InstantiatedTraitRef, arg};
|
||||||
use middle::ty::{ty_param_substs_and_ty};
|
use middle::ty::{substs, ty_param_substs_and_ty};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::astconv::{ast_conv, ty_of_fn_decl, ty_of_arg};
|
use middle::typeck::astconv::{ast_conv, ty_of_fn_decl, ty_of_arg};
|
||||||
use middle::typeck::astconv::{ast_ty_to_ty};
|
use middle::typeck::astconv::{ast_ty_to_ty};
|
||||||
|
@ -75,7 +75,11 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
|
||||||
for m.items.each |intrinsic_item| {
|
for m.items.each |intrinsic_item| {
|
||||||
let def_id = ast::def_id { crate: ast::local_crate,
|
let def_id = ast::def_id { crate: ast::local_crate,
|
||||||
node: intrinsic_item.id };
|
node: intrinsic_item.id };
|
||||||
let substs = {self_r: None, self_ty: None, tps: ~[]};
|
let substs = substs {
|
||||||
|
self_r: None,
|
||||||
|
self_ty: None,
|
||||||
|
tps: ~[]
|
||||||
|
};
|
||||||
|
|
||||||
match intrinsic_item.node {
|
match intrinsic_item.node {
|
||||||
ast::item_trait(*) => {
|
ast::item_trait(*) => {
|
||||||
|
@ -164,7 +168,7 @@ fn get_enum_variant_types(ccx: @crate_ctxt,
|
||||||
let rs = type_rscope(rp);
|
let rs = type_rscope(rp);
|
||||||
let args = args.map(|va| {
|
let args = args.map(|va| {
|
||||||
let arg_ty = ccx.to_ty(rs, va.ty);
|
let arg_ty = ccx.to_ty(rs, va.ty);
|
||||||
{mode: ast::expl(ast::by_copy), ty: arg_ty}
|
arg { mode: ast::expl(ast::by_copy), ty: arg_ty }
|
||||||
});
|
});
|
||||||
result_ty = Some(ty::mk_fn(tcx, FnTyBase {
|
result_ty = Some(ty::mk_fn(tcx, FnTyBase {
|
||||||
meta: FnMeta {purity: ast::pure_fn,
|
meta: FnMeta {purity: ast::pure_fn,
|
||||||
|
@ -195,8 +199,9 @@ fn get_enum_variant_types(ccx: @crate_ctxt,
|
||||||
variant.node.id);
|
variant.node.id);
|
||||||
// Compute the ctor arg types from the struct fields
|
// Compute the ctor arg types from the struct fields
|
||||||
let struct_fields = do struct_def.fields.map |struct_field| {
|
let struct_fields = do struct_def.fields.map |struct_field| {
|
||||||
{mode: ast::expl(ast::by_val),
|
arg {
|
||||||
ty: ty::node_id_to_type(ccx.tcx, (*struct_field).node.id)
|
mode: ast::expl(ast::by_val),
|
||||||
|
ty: ty::node_id_to_type(ccx.tcx, struct_field.node.id)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
result_ty = Some(ty::mk_fn(tcx, FnTyBase {
|
result_ty = Some(ty::mk_fn(tcx, FnTyBase {
|
||||||
|
@ -265,8 +270,11 @@ fn ensure_trait_methods(ccx: @crate_ctxt, id: ast::node_id, trait_ty: ty::t) {
|
||||||
ty::mk_param(ccx.tcx, i + 1, dummy_defid)
|
ty::mk_param(ccx.tcx, i + 1, dummy_defid)
|
||||||
};
|
};
|
||||||
|
|
||||||
let substs = { self_r: None, self_ty: Some(self_param),
|
let substs = substs {
|
||||||
tps: non_shifted_trait_tps + shifted_method_tps };
|
self_r: None,
|
||||||
|
self_ty: Some(self_param),
|
||||||
|
tps: non_shifted_trait_tps + shifted_method_tps
|
||||||
|
};
|
||||||
let ty = ty::subst(ccx.tcx,
|
let ty = ty::subst(ccx.tcx,
|
||||||
&substs,
|
&substs,
|
||||||
ty::mk_fn(ccx.tcx, /*bad*/copy m.fty));
|
ty::mk_fn(ccx.tcx, /*bad*/copy m.fty));
|
||||||
|
@ -462,7 +470,7 @@ fn compare_impl_method(tcx: ty::ctxt,
|
||||||
};
|
};
|
||||||
let trait_tps = trait_substs.tps.map(
|
let trait_tps = trait_substs.tps.map(
|
||||||
|t| replace_bound_self(tcx, *t, dummy_self_r));
|
|t| replace_bound_self(tcx, *t, dummy_self_r));
|
||||||
let substs = {
|
let substs = substs {
|
||||||
self_r: Some(dummy_self_r),
|
self_r: Some(dummy_self_r),
|
||||||
self_ty: Some(self_ty),
|
self_ty: Some(self_ty),
|
||||||
tps: vec::append(trait_tps, dummy_tps)
|
tps: vec::append(trait_tps, dummy_tps)
|
||||||
|
@ -705,7 +713,7 @@ fn convert_struct(ccx: @crate_ctxt,
|
||||||
},
|
},
|
||||||
sig: FnSig {
|
sig: FnSig {
|
||||||
inputs: do struct_def.fields.map |field| {
|
inputs: do struct_def.fields.map |field| {
|
||||||
{
|
arg {
|
||||||
mode: ast::expl(ast::by_copy),
|
mode: ast::expl(ast::by_copy),
|
||||||
ty: ccx.tcx.tcache.get
|
ty: ccx.tcx.tcache.get
|
||||||
(local_def(field.node.id)).ty
|
(local_def(field.node.id)).ty
|
||||||
|
@ -1002,5 +1010,8 @@ fn mk_substs(ccx: @crate_ctxt,
|
||||||
-> {bounds: @~[ty::param_bounds], substs: ty::substs} {
|
-> {bounds: @~[ty::param_bounds], substs: ty::substs} {
|
||||||
let {bounds, params} = mk_ty_params(ccx, atps);
|
let {bounds, params} = mk_ty_params(ccx, atps);
|
||||||
let self_r = rscope::bound_self_region(rp);
|
let self_r = rscope::bound_self_region(rp);
|
||||||
{bounds: bounds, substs: {self_r: self_r, self_ty: None, tps: params}}
|
{
|
||||||
|
bounds: bounds,
|
||||||
|
substs: substs { self_r: self_r, self_ty: None, tps: params }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use middle::ty::{FloatVar, FnTyBase, FnMeta, FnSig, IntVar, TyVar};
|
use middle::ty::{FloatVar, FnTyBase, FnMeta, FnSig, IntVar, TyVar};
|
||||||
use middle::ty::{IntType, UintType};
|
use middle::ty::{IntType, UintType, arg, substs};
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::infer::glb::Glb;
|
use middle::typeck::infer::glb::Glb;
|
||||||
use middle::typeck::infer::lub::Lub;
|
use middle::typeck::infer::lub::Lub;
|
||||||
|
@ -233,7 +233,11 @@ fn super_substs<C:Combine>(
|
||||||
do relate_region_param(self, did,
|
do relate_region_param(self, did,
|
||||||
a.self_r, b.self_r).chain |self_r|
|
a.self_r, b.self_r).chain |self_r|
|
||||||
{
|
{
|
||||||
Ok({self_r: self_r, self_ty: self_ty, tps: /*bad*/copy tps})
|
Ok(substs {
|
||||||
|
self_r: self_r,
|
||||||
|
self_ty: self_ty,
|
||||||
|
tps: /*bad*/copy tps
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,7 +299,7 @@ fn super_flds<C:Combine>(
|
||||||
|
|
||||||
if a.ident == b.ident {
|
if a.ident == b.ident {
|
||||||
self.mts(a.mt, b.mt)
|
self.mts(a.mt, b.mt)
|
||||||
.chain(|mt| Ok({ident: a.ident, mt: mt}) )
|
.chain(|mt| Ok(ty::field {ident: a.ident, mt: mt}) )
|
||||||
.chain_err(|e| Err(ty::terr_in_field(@e, a.ident)) )
|
.chain_err(|e| Err(ty::terr_in_field(@e, a.ident)) )
|
||||||
} else {
|
} else {
|
||||||
Err(ty::terr_record_fields(
|
Err(ty::terr_record_fields(
|
||||||
|
@ -317,7 +321,7 @@ fn super_args<C:Combine>(
|
||||||
|
|
||||||
do self.modes(a.mode, b.mode).chain |m| {
|
do self.modes(a.mode, b.mode).chain |m| {
|
||||||
do self.contratys(a.ty, b.ty).chain |t| {
|
do self.contratys(a.ty, b.ty).chain |t| {
|
||||||
Ok({mode: m, ty: t})
|
Ok(arg {mode: m, ty: t})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ use middle::ty::IntVarValue;
|
||||||
use middle::ty;
|
use middle::ty;
|
||||||
use middle::typeck::check::regionmanip::{replace_bound_regions_in_fn_sig};
|
use middle::typeck::check::regionmanip::{replace_bound_regions_in_fn_sig};
|
||||||
use middle::typeck::infer::coercion::Coerce;
|
use middle::typeck::infer::coercion::Coerce;
|
||||||
use middle::typeck::infer::combine::{CombineFields, eq_tys};
|
use middle::typeck::infer::combine::{Combine, CombineFields, eq_tys};
|
||||||
use middle::typeck::infer::glb::Glb;
|
use middle::typeck::infer::glb::Glb;
|
||||||
use middle::typeck::infer::lub::Lub;
|
use middle::typeck::infer::lub::Lub;
|
||||||
use middle::typeck::infer::region_inference::{RegionVarBindings};
|
use middle::typeck::infer::region_inference::{RegionVarBindings};
|
||||||
|
|
|
@ -17,7 +17,7 @@ use middle::ty::{bound_copy, bound_const, bound_durable, bound_owned,
|
||||||
use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid,
|
use middle::ty::{bound_region, br_anon, br_named, br_self, br_cap_avoid,
|
||||||
br_fresh};
|
br_fresh};
|
||||||
use middle::ty::{ctxt, field, method};
|
use middle::ty::{ctxt, field, method};
|
||||||
use middle::ty::{mt, t, param_bound};
|
use middle::ty::{mt, t, param_bound, param_ty};
|
||||||
use middle::ty::{re_bound, re_free, re_scope, re_infer, re_static, Region};
|
use middle::ty::{re_bound, re_free, re_scope, re_infer, re_static, Region};
|
||||||
use middle::ty::{ReSkolemized, ReVar};
|
use middle::ty::{ReSkolemized, ReVar};
|
||||||
use middle::ty::{ty_bool, ty_bot, ty_box, ty_struct, ty_enum};
|
use middle::ty::{ty_bool, ty_bot, ty_box, ty_struct, ty_enum};
|
||||||
|
@ -292,9 +292,8 @@ fn fn_sig_to_str(cx: ctxt, typ: &ty::FnSig) -> ~str {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
||||||
fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) ->
|
fn fn_input_to_str(cx: ctxt, input: ty::arg) -> ~str {
|
||||||
~str {
|
let ty::arg {mode: mode, ty: ty} = input;
|
||||||
let {mode, ty} = input;
|
|
||||||
let modestr = match canon_mode(cx, mode) {
|
let modestr = match canon_mode(cx, mode) {
|
||||||
ast::infer(_) => ~"",
|
ast::infer(_) => ~"",
|
||||||
ast::expl(m) => {
|
ast::expl(m) => {
|
||||||
|
@ -423,7 +422,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> ~str {
|
||||||
}
|
}
|
||||||
ty_infer(infer_ty) => infer_ty.to_str(),
|
ty_infer(infer_ty) => infer_ty.to_str(),
|
||||||
ty_err => ~"[type error]",
|
ty_err => ~"[type error]",
|
||||||
ty_param({idx: id, _}) => {
|
ty_param(param_ty {idx: id, _}) => {
|
||||||
~"'" + str::from_bytes(~[('a' as u8) + (id as u8)])
|
~"'" + str::from_bytes(~[('a' as u8) + (id as u8)])
|
||||||
}
|
}
|
||||||
ty_self => ~"self",
|
ty_self => ~"self",
|
||||||
|
|
|
@ -155,9 +155,9 @@ fn build_error_handlers(
|
||||||
codemap: @codemap::CodeMap
|
codemap: @codemap::CodeMap
|
||||||
) -> ErrorHandlers {
|
) -> ErrorHandlers {
|
||||||
|
|
||||||
type DiagnosticHandler = {
|
struct DiagnosticHandler {
|
||||||
inner: diagnostic::handler,
|
inner: diagnostic::handler,
|
||||||
};
|
}
|
||||||
|
|
||||||
impl DiagnosticHandler: diagnostic::handler {
|
impl DiagnosticHandler: diagnostic::handler {
|
||||||
fn fatal(msg: &str) -> ! { self.inner.fatal(msg) }
|
fn fatal(msg: &str) -> ! { self.inner.fatal(msg) }
|
||||||
|
@ -182,7 +182,7 @@ fn build_error_handlers(
|
||||||
diagnostic::emit(cmsp, msg, lvl);
|
diagnostic::emit(cmsp, msg, lvl);
|
||||||
};
|
};
|
||||||
let inner_handler = diagnostic::mk_handler(Some(emitter));
|
let inner_handler = diagnostic::mk_handler(Some(emitter));
|
||||||
let handler = {
|
let handler = DiagnosticHandler {
|
||||||
inner: inner_handler,
|
inner: inner_handler,
|
||||||
};
|
};
|
||||||
let span_handler = diagnostic::mk_span_handler(
|
let span_handler = diagnostic::mk_span_handler(
|
||||||
|
|
|
@ -69,9 +69,9 @@ fn fold_crate(
|
||||||
attr_parser::parse_crate(attrs)
|
attr_parser::parse_crate(attrs)
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
doc::CrateDoc {
|
||||||
topmod: doc::ModDoc_({
|
topmod: doc::ModDoc_(doc::ModDoc_ {
|
||||||
item: {
|
item: doc::ItemDoc {
|
||||||
name: option::get_or_default(attrs.name, doc.topmod.name()),
|
name: option::get_or_default(attrs.name, doc.topmod.name()),
|
||||||
.. doc.topmod.item
|
.. doc.topmod.item
|
||||||
},
|
},
|
||||||
|
@ -103,7 +103,7 @@ fn fold_item(
|
||||||
parse_item_attrs(srv, doc.id, attr_parser::parse_desc)
|
parse_item_attrs(srv, doc.id, attr_parser::parse_desc)
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
doc::ItemDoc {
|
||||||
desc: desc,
|
desc: desc,
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ fn fold_enum(
|
||||||
let doc_id = doc.id();
|
let doc_id = doc.id();
|
||||||
let doc = fold::default_seq_fold_enum(fold, doc);
|
let doc = fold::default_seq_fold_enum(fold, doc);
|
||||||
|
|
||||||
{
|
doc::EnumDoc {
|
||||||
variants: do par::map(doc.variants) |variant| {
|
variants: do par::map(doc.variants) |variant| {
|
||||||
let variant = *variant;
|
let variant = *variant;
|
||||||
let desc = do astsrv::exec(srv) |ctxt| {
|
let desc = do astsrv::exec(srv) |ctxt| {
|
||||||
|
@ -182,7 +182,7 @@ fn fold_enum(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
doc::VariantDoc {
|
||||||
desc: desc,
|
desc: desc,
|
||||||
.. variant
|
.. variant
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ fn fold_trait(
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||||
|
|
||||||
{
|
doc::TraitDoc {
|
||||||
methods: merge_method_attrs(srv, doc.id(), doc.methods),
|
methods: merge_method_attrs(srv, doc.id(), doc.methods),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ fn merge_method_attrs(
|
||||||
assert doc.name == attrs.first();
|
assert doc.name == attrs.first();
|
||||||
let desc = attrs.second();
|
let desc = attrs.second();
|
||||||
|
|
||||||
{
|
doc::MethodDoc {
|
||||||
desc: desc,
|
desc: desc,
|
||||||
..*doc
|
..*doc
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ fn fold_impl(
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||||
|
|
||||||
{
|
doc::ImplDoc {
|
||||||
methods: merge_method_attrs(srv, doc.id(), doc.methods),
|
methods: merge_method_attrs(srv, doc.id(), doc.methods),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,13 +50,13 @@ impl OutputStyle : cmp::Eq {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The configuration for a rustdoc session
|
/// The configuration for a rustdoc session
|
||||||
pub type Config = {
|
pub struct Config {
|
||||||
input_crate: Path,
|
input_crate: Path,
|
||||||
output_dir: Path,
|
output_dir: Path,
|
||||||
output_format: OutputFormat,
|
output_format: OutputFormat,
|
||||||
output_style: OutputStyle,
|
output_style: OutputStyle,
|
||||||
pandoc_cmd: Option<~str>
|
pandoc_cmd: Option<~str>
|
||||||
};
|
}
|
||||||
|
|
||||||
pub impl Config: Clone {
|
pub impl Config: Clone {
|
||||||
fn clone(&self) -> Config { copy *self }
|
fn clone(&self) -> Config { copy *self }
|
||||||
|
@ -95,7 +95,7 @@ pub fn usage() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_config(input_crate: &Path) -> Config {
|
pub fn default_config(input_crate: &Path) -> Config {
|
||||||
{
|
Config {
|
||||||
input_crate: *input_crate,
|
input_crate: *input_crate,
|
||||||
output_dir: Path("."),
|
output_dir: Path("."),
|
||||||
output_format: PandocHtml,
|
output_format: PandocHtml,
|
||||||
|
@ -155,7 +155,7 @@ fn config_from_opts(
|
||||||
let result = do result::chain(result) |config| {
|
let result = do result::chain(result) |config| {
|
||||||
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
|
let output_dir = getopts::opt_maybe_str(matches, opt_output_dir());
|
||||||
let output_dir = output_dir.map(|s| Path(*s));
|
let output_dir = output_dir.map(|s| Path(*s));
|
||||||
result::Ok({
|
result::Ok(Config {
|
||||||
output_dir: output_dir.get_or_default(config.output_dir),
|
output_dir: output_dir.get_or_default(config.output_dir),
|
||||||
.. config
|
.. config
|
||||||
})
|
})
|
||||||
|
@ -168,7 +168,7 @@ fn config_from_opts(
|
||||||
do result::chain(parse_output_format(*output_format))
|
do result::chain(parse_output_format(*output_format))
|
||||||
|output_format| {
|
|output_format| {
|
||||||
|
|
||||||
result::Ok({
|
result::Ok(Config {
|
||||||
output_format: output_format,
|
output_format: output_format,
|
||||||
.. config
|
.. config
|
||||||
})
|
})
|
||||||
|
@ -182,7 +182,7 @@ fn config_from_opts(
|
||||||
|output_style| {
|
|output_style| {
|
||||||
do result::chain(parse_output_style(*output_style))
|
do result::chain(parse_output_style(*output_style))
|
||||||
|output_style| {
|
|output_style| {
|
||||||
result::Ok({
|
result::Ok(Config {
|
||||||
output_style: output_style,
|
output_style: output_style,
|
||||||
.. config
|
.. config
|
||||||
})
|
})
|
||||||
|
@ -195,7 +195,7 @@ fn config_from_opts(
|
||||||
let pandoc_cmd = maybe_find_pandoc(
|
let pandoc_cmd = maybe_find_pandoc(
|
||||||
&config, pandoc_cmd, move program_output.take());
|
&config, pandoc_cmd, move program_output.take());
|
||||||
do result::chain(pandoc_cmd) |pandoc_cmd| {
|
do result::chain(pandoc_cmd) |pandoc_cmd| {
|
||||||
result::Ok({
|
result::Ok(Config {
|
||||||
pandoc_cmd: pandoc_cmd,
|
pandoc_cmd: pandoc_cmd,
|
||||||
.. config
|
.. config
|
||||||
})
|
})
|
||||||
|
|
|
@ -51,7 +51,7 @@ pub fn run(
|
||||||
fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||||
let doc = fold::default_seq_fold_item(fold, doc);
|
let doc = fold::default_seq_fold_item(fold, doc);
|
||||||
|
|
||||||
{
|
doc::ItemDoc {
|
||||||
brief: extract(doc.desc),
|
brief: extract(doc.desc),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||||
fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||||
let doc =fold::default_seq_fold_trait(fold, doc);
|
let doc =fold::default_seq_fold_trait(fold, doc);
|
||||||
|
|
||||||
{
|
doc::TraitDoc {
|
||||||
methods: par::map(doc.methods, |doc| {
|
methods: par::map(doc.methods, |doc| doc::MethodDoc {
|
||||||
brief: extract(doc.desc),
|
brief: extract(doc.desc),
|
||||||
.. *doc
|
.. *doc
|
||||||
}),
|
}),
|
||||||
|
@ -72,8 +72,8 @@ fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||||
fn fold_impl(fold: &fold::Fold<()>, +doc: doc::ImplDoc) -> doc::ImplDoc {
|
fn fold_impl(fold: &fold::Fold<()>, +doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||||
let doc =fold::default_seq_fold_impl(fold, doc);
|
let doc =fold::default_seq_fold_impl(fold, doc);
|
||||||
|
|
||||||
{
|
doc::ImplDoc {
|
||||||
methods: par::map(doc.methods, |doc| {
|
methods: par::map(doc.methods, |doc| doc::MethodDoc {
|
||||||
brief: extract(doc.desc),
|
brief: extract(doc.desc),
|
||||||
.. *doc
|
.. *doc
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -21,94 +21,47 @@ use core::vec;
|
||||||
|
|
||||||
pub type AstId = int;
|
pub type AstId = int;
|
||||||
|
|
||||||
pub type Doc_ = {
|
#[deriving_eq]
|
||||||
|
pub struct Doc_ {
|
||||||
pages: ~[Page]
|
pages: ~[Page]
|
||||||
};
|
|
||||||
|
|
||||||
impl Doc_ : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &Doc_) -> bool {
|
|
||||||
(*self).pages == (*other).pages
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Doc_) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
pub enum Doc {
|
pub enum Doc {
|
||||||
Doc_(Doc_)
|
Doc_(Doc_)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Doc : cmp::Eq {
|
#[deriving_eq]
|
||||||
pure fn eq(&self, other: &Doc) -> bool { *(*self) == *(*other) }
|
|
||||||
pure fn ne(&self, other: &Doc) -> bool { *(*self) != *(*other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum Page {
|
pub enum Page {
|
||||||
CratePage(CrateDoc),
|
CratePage(CrateDoc),
|
||||||
ItemPage(ItemTag)
|
ItemPage(ItemTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Page : cmp::Eq {
|
#[deriving_eq]
|
||||||
pure fn eq(&self, other: &Page) -> bool {
|
|
||||||
match (*self) {
|
|
||||||
CratePage(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
CratePage(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ItemPage(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
ItemPage(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Page) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum Implementation {
|
pub enum Implementation {
|
||||||
Required,
|
Required,
|
||||||
Provided,
|
Provided,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Implementation : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &Implementation) -> bool {
|
|
||||||
((*self) as uint) == ((*other) as uint)
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Implementation) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Most rustdocs can be parsed into 'sections' according to their markdown
|
* Most rustdocs can be parsed into 'sections' according to their markdown
|
||||||
* headers
|
* headers
|
||||||
*/
|
*/
|
||||||
pub type Section = {
|
#[deriving_eq]
|
||||||
|
pub struct Section {
|
||||||
header: ~str,
|
header: ~str,
|
||||||
body: ~str
|
body: ~str
|
||||||
};
|
|
||||||
|
|
||||||
impl Section : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &Section) -> bool {
|
|
||||||
(*self).header == (*other).header && (*self).body == (*other).body
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Section) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME (#2596): We currently give topmod the name of the crate. There
|
// FIXME (#2596): We currently give topmod the name of the crate. There
|
||||||
// would probably be fewer special cases if the crate had its own name
|
// would probably be fewer special cases if the crate had its own name
|
||||||
// and topmod's name was the empty string.
|
// and topmod's name was the empty string.
|
||||||
pub type CrateDoc = {
|
#[deriving_eq]
|
||||||
topmod: ModDoc,
|
pub struct CrateDoc {
|
||||||
};
|
topmod: ModDoc
|
||||||
|
|
||||||
impl CrateDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &CrateDoc) -> bool {
|
|
||||||
(*self).topmod == (*other).topmod
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &CrateDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
pub enum ItemTag {
|
pub enum ItemTag {
|
||||||
ModTag(ModDoc),
|
ModTag(ModDoc),
|
||||||
NmodTag(NmodDoc),
|
NmodTag(NmodDoc),
|
||||||
|
@ -121,69 +74,8 @@ pub enum ItemTag {
|
||||||
StructTag(StructDoc)
|
StructTag(StructDoc)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ItemTag : cmp::Eq {
|
#[deriving_eq]
|
||||||
pure fn eq(&self, other: &ItemTag) -> bool {
|
pub struct ItemDoc {
|
||||||
match (*self) {
|
|
||||||
ModTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
ModTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NmodTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
NmodTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ConstTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
ConstTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FnTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
FnTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EnumTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
EnumTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TraitTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
TraitTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ImplTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
ImplTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TyTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
TyTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
StructTag(e0a) => {
|
|
||||||
match (*other) {
|
|
||||||
StructTag(e0b) => e0a == e0b,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &ItemTag) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type ItemDoc = {
|
|
||||||
id: AstId,
|
id: AstId,
|
||||||
name: ~str,
|
name: ~str,
|
||||||
path: ~[~str],
|
path: ~[~str],
|
||||||
|
@ -192,179 +84,86 @@ pub type ItemDoc = {
|
||||||
sections: ~[Section],
|
sections: ~[Section],
|
||||||
// Indicates that this node is a reexport of a different item
|
// Indicates that this node is a reexport of a different item
|
||||||
reexport: bool
|
reexport: bool
|
||||||
};
|
|
||||||
|
|
||||||
impl ItemDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &ItemDoc) -> bool {
|
|
||||||
(*self).id == (*other).id &&
|
|
||||||
(*self).name == (*other).name &&
|
|
||||||
(*self).path == (*other).path &&
|
|
||||||
(*self).brief == (*other).brief &&
|
|
||||||
(*self).desc == (*other).desc &&
|
|
||||||
(*self).sections == (*other).sections &&
|
|
||||||
(*self).reexport == (*other).reexport
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &ItemDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type SimpleItemDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct SimpleItemDoc {
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
sig: Option<~str>
|
sig: Option<~str>
|
||||||
};
|
|
||||||
|
|
||||||
impl SimpleItemDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &SimpleItemDoc) -> bool {
|
|
||||||
(*self).item == (*other).item && (*self).sig == (*other).sig
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &SimpleItemDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ModDoc_ = {
|
#[deriving_eq]
|
||||||
|
pub struct ModDoc_ {
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
items: ~[ItemTag],
|
items: ~[ItemTag],
|
||||||
index: Option<Index>
|
index: Option<Index>
|
||||||
};
|
|
||||||
|
|
||||||
impl ModDoc_ : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &ModDoc_) -> bool {
|
|
||||||
(*self).item == (*other).item &&
|
|
||||||
(*self).items == (*other).items &&
|
|
||||||
(*self).index == (*other).index
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &ModDoc_) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
pub enum ModDoc {
|
pub enum ModDoc {
|
||||||
ModDoc_(ModDoc_)
|
ModDoc_(ModDoc_)
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ModDoc : cmp::Eq {
|
#[deriving_eq]
|
||||||
pure fn eq(&self, other: &ModDoc) -> bool { *(*self) == *(*other) }
|
pub struct NmodDoc {
|
||||||
pure fn ne(&self, other: &ModDoc) -> bool { *(*self) != *(*other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type NmodDoc = {
|
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
fns: ~[FnDoc],
|
fns: ~[FnDoc],
|
||||||
index: Option<Index>
|
index: Option<Index>
|
||||||
};
|
|
||||||
|
|
||||||
impl NmodDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &NmodDoc) -> bool {
|
|
||||||
(*self).item == (*other).item &&
|
|
||||||
(*self).fns == (*other).fns &&
|
|
||||||
(*self).index == (*other).index
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &NmodDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ConstDoc = SimpleItemDoc;
|
pub type ConstDoc = SimpleItemDoc;
|
||||||
|
|
||||||
pub type FnDoc = SimpleItemDoc;
|
pub type FnDoc = SimpleItemDoc;
|
||||||
|
|
||||||
pub type EnumDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct EnumDoc {
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
variants: ~[VariantDoc]
|
variants: ~[VariantDoc]
|
||||||
};
|
|
||||||
|
|
||||||
impl EnumDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &EnumDoc) -> bool {
|
|
||||||
(*self).item == (*other).item && (*self).variants == (*other).variants
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &EnumDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type VariantDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct VariantDoc {
|
||||||
name: ~str,
|
name: ~str,
|
||||||
desc: Option<~str>,
|
desc: Option<~str>,
|
||||||
sig: Option<~str>
|
sig: Option<~str>
|
||||||
};
|
|
||||||
|
|
||||||
impl VariantDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &VariantDoc) -> bool {
|
|
||||||
(*self).name == (*other).name &&
|
|
||||||
(*self).desc == (*other).desc &&
|
|
||||||
(*self).sig == (*other).sig
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &VariantDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TraitDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct TraitDoc {
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
methods: ~[MethodDoc]
|
methods: ~[MethodDoc]
|
||||||
};
|
|
||||||
|
|
||||||
impl TraitDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &TraitDoc) -> bool {
|
|
||||||
(*self).item == (*other).item && (*self).methods == (*other).methods
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &TraitDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MethodDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct MethodDoc {
|
||||||
name: ~str,
|
name: ~str,
|
||||||
brief: Option<~str>,
|
brief: Option<~str>,
|
||||||
desc: Option<~str>,
|
desc: Option<~str>,
|
||||||
sections: ~[Section],
|
sections: ~[Section],
|
||||||
sig: Option<~str>,
|
sig: Option<~str>,
|
||||||
implementation: Implementation,
|
implementation: Implementation,
|
||||||
};
|
|
||||||
|
|
||||||
impl MethodDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &MethodDoc) -> bool {
|
|
||||||
(*self).name == (*other).name &&
|
|
||||||
(*self).brief == (*other).brief &&
|
|
||||||
(*self).desc == (*other).desc &&
|
|
||||||
(*self).sections == (*other).sections &&
|
|
||||||
(*self).sig == (*other).sig &&
|
|
||||||
(*self).implementation == (*other).implementation
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &MethodDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ImplDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct ImplDoc {
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
trait_types: ~[~str],
|
trait_types: ~[~str],
|
||||||
self_ty: Option<~str>,
|
self_ty: Option<~str>,
|
||||||
methods: ~[MethodDoc]
|
methods: ~[MethodDoc]
|
||||||
};
|
|
||||||
|
|
||||||
impl ImplDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &ImplDoc) -> bool {
|
|
||||||
(*self).item == (*other).item &&
|
|
||||||
(*self).trait_types == (*other).trait_types &&
|
|
||||||
(*self).self_ty == (*other).self_ty &&
|
|
||||||
(*self).methods == (*other).methods
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &ImplDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type TyDoc = SimpleItemDoc;
|
pub type TyDoc = SimpleItemDoc;
|
||||||
|
|
||||||
pub type StructDoc = {
|
#[deriving_eq]
|
||||||
|
pub struct StructDoc {
|
||||||
item: ItemDoc,
|
item: ItemDoc,
|
||||||
fields: ~[~str],
|
fields: ~[~str],
|
||||||
sig: Option<~str>
|
sig: Option<~str>
|
||||||
};
|
|
||||||
|
|
||||||
impl StructDoc : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &StructDoc) -> bool {
|
|
||||||
return (*self).item == other.item
|
|
||||||
&& (*self).fields == other.fields
|
|
||||||
&& (*self).sig == other.sig;
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &StructDoc) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Index = {
|
#[deriving_eq]
|
||||||
|
pub struct Index {
|
||||||
entries: ~[IndexEntry]
|
entries: ~[IndexEntry]
|
||||||
};
|
|
||||||
|
|
||||||
impl Index : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &Index) -> bool {
|
|
||||||
(*self).entries == (*other).entries
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Index) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -377,21 +176,12 @@ impl Index : cmp::Eq {
|
||||||
* * brief - The brief description
|
* * brief - The brief description
|
||||||
* * link - A format-specific string representing the link target
|
* * link - A format-specific string representing the link target
|
||||||
*/
|
*/
|
||||||
pub type IndexEntry = {
|
#[deriving_eq]
|
||||||
|
pub struct IndexEntry {
|
||||||
kind: ~str,
|
kind: ~str,
|
||||||
name: ~str,
|
name: ~str,
|
||||||
brief: Option<~str>,
|
brief: Option<~str>,
|
||||||
link: ~str
|
link: ~str
|
||||||
};
|
|
||||||
|
|
||||||
impl IndexEntry : cmp::Eq {
|
|
||||||
pure fn eq(&self, other: &IndexEntry) -> bool {
|
|
||||||
(*self).kind == (*other).kind &&
|
|
||||||
(*self).name == (*other).name &&
|
|
||||||
(*self).brief == (*other).brief &&
|
|
||||||
(*self).link == (*other).link
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &IndexEntry) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Doc {
|
impl Doc {
|
||||||
|
@ -411,7 +201,6 @@ impl Doc {
|
||||||
|
|
||||||
/// Some helper methods on ModDoc, mostly for testing
|
/// Some helper methods on ModDoc, mostly for testing
|
||||||
impl ModDoc {
|
impl ModDoc {
|
||||||
|
|
||||||
fn mods() -> ~[ModDoc] {
|
fn mods() -> ~[ModDoc] {
|
||||||
do vec::filter_map(self.items) |itemtag| {
|
do vec::filter_map(self.items) |itemtag| {
|
||||||
match *itemtag {
|
match *itemtag {
|
||||||
|
|
|
@ -57,9 +57,9 @@ pub fn extract(
|
||||||
crate: @ast::crate,
|
crate: @ast::crate,
|
||||||
+default_name: ~str
|
+default_name: ~str
|
||||||
) -> doc::Doc {
|
) -> doc::Doc {
|
||||||
doc::Doc_({
|
doc::Doc_(doc::Doc_ {
|
||||||
pages: ~[
|
pages: ~[
|
||||||
doc::CratePage({
|
doc::CratePage(doc::CrateDoc {
|
||||||
topmod: top_moddoc_from_crate(crate, default_name),
|
topmod: top_moddoc_from_crate(crate, default_name),
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
@ -75,7 +75,7 @@ fn top_moddoc_from_crate(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_itemdoc(id: ast::node_id, +name: ~str) -> doc::ItemDoc {
|
fn mk_itemdoc(id: ast::node_id, +name: ~str) -> doc::ItemDoc {
|
||||||
{
|
doc::ItemDoc {
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
path: ~[],
|
path: ~[],
|
||||||
|
@ -90,7 +90,7 @@ fn moddoc_from_mod(
|
||||||
+itemdoc: doc::ItemDoc,
|
+itemdoc: doc::ItemDoc,
|
||||||
module_: ast::_mod
|
module_: ast::_mod
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
items: do vec::filter_map(module_.items) |item| {
|
items: do vec::filter_map(module_.items) |item| {
|
||||||
let ItemDoc = mk_itemdoc(item.id, to_str(item.ident));
|
let ItemDoc = mk_itemdoc(item.id, to_str(item.ident));
|
||||||
|
@ -161,7 +161,7 @@ fn nmoddoc_from_mod(
|
||||||
ast::foreign_item_const(*) => {} // XXX: Not implemented.
|
ast::foreign_item_const(*) => {} // XXX: Not implemented.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
doc:: NmodDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
fns: fns,
|
fns: fns,
|
||||||
index: None
|
index: None
|
||||||
|
@ -169,14 +169,14 @@ fn nmoddoc_from_mod(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fndoc_from_fn(+itemdoc: doc::ItemDoc) -> doc::FnDoc {
|
fn fndoc_from_fn(+itemdoc: doc::ItemDoc) -> doc::FnDoc {
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
sig: None
|
sig: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn constdoc_from_const(+itemdoc: doc::ItemDoc) -> doc::ConstDoc {
|
fn constdoc_from_const(+itemdoc: doc::ItemDoc) -> doc::ConstDoc {
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
sig: None
|
sig: None
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ fn enumdoc_from_enum(
|
||||||
+itemdoc: doc::ItemDoc,
|
+itemdoc: doc::ItemDoc,
|
||||||
+variants: ~[ast::variant]
|
+variants: ~[ast::variant]
|
||||||
) -> doc::EnumDoc {
|
) -> doc::EnumDoc {
|
||||||
{
|
doc::EnumDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
variants: variantdocs_from_variants(variants)
|
variants: variantdocs_from_variants(variants)
|
||||||
}
|
}
|
||||||
|
@ -206,8 +206,7 @@ fn variantdocs_from_variants(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn variantdoc_from_variant(variant: &ast::variant) -> doc::VariantDoc {
|
fn variantdoc_from_variant(variant: &ast::variant) -> doc::VariantDoc {
|
||||||
|
doc::VariantDoc {
|
||||||
{
|
|
||||||
name: to_str(variant.node.name),
|
name: to_str(variant.node.name),
|
||||||
desc: None,
|
desc: None,
|
||||||
sig: None
|
sig: None
|
||||||
|
@ -231,12 +230,12 @@ fn traitdoc_from_trait(
|
||||||
+itemdoc: doc::ItemDoc,
|
+itemdoc: doc::ItemDoc,
|
||||||
+methods: ~[ast::trait_method]
|
+methods: ~[ast::trait_method]
|
||||||
) -> doc::TraitDoc {
|
) -> doc::TraitDoc {
|
||||||
{
|
doc::TraitDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
methods: do vec::map(methods) |method| {
|
methods: do vec::map(methods) |method| {
|
||||||
match *method {
|
match *method {
|
||||||
ast::required(ty_m) => {
|
ast::required(ty_m) => {
|
||||||
{
|
doc::MethodDoc {
|
||||||
name: to_str(ty_m.ident),
|
name: to_str(ty_m.ident),
|
||||||
brief: None,
|
brief: None,
|
||||||
desc: None,
|
desc: None,
|
||||||
|
@ -246,7 +245,7 @@ fn traitdoc_from_trait(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::provided(m) => {
|
ast::provided(m) => {
|
||||||
{
|
doc::MethodDoc {
|
||||||
name: to_str(m.ident),
|
name: to_str(m.ident),
|
||||||
brief: None,
|
brief: None,
|
||||||
desc: None,
|
desc: None,
|
||||||
|
@ -276,12 +275,12 @@ fn impldoc_from_impl(
|
||||||
+itemdoc: doc::ItemDoc,
|
+itemdoc: doc::ItemDoc,
|
||||||
methods: ~[@ast::method]
|
methods: ~[@ast::method]
|
||||||
) -> doc::ImplDoc {
|
) -> doc::ImplDoc {
|
||||||
{
|
doc::ImplDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
trait_types: ~[],
|
trait_types: ~[],
|
||||||
self_ty: None,
|
self_ty: None,
|
||||||
methods: do vec::map(methods) |method| {
|
methods: do vec::map(methods) |method| {
|
||||||
{
|
doc::MethodDoc {
|
||||||
name: to_str(method.ident),
|
name: to_str(method.ident),
|
||||||
brief: None,
|
brief: None,
|
||||||
desc: None,
|
desc: None,
|
||||||
|
@ -302,7 +301,7 @@ fn should_extract_impl_methods() {
|
||||||
fn tydoc_from_ty(
|
fn tydoc_from_ty(
|
||||||
+itemdoc: doc::ItemDoc
|
+itemdoc: doc::ItemDoc
|
||||||
) -> doc::TyDoc {
|
) -> doc::TyDoc {
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
sig: None
|
sig: None
|
||||||
}
|
}
|
||||||
|
@ -318,7 +317,7 @@ fn structdoc_from_struct(
|
||||||
+itemdoc: doc::ItemDoc,
|
+itemdoc: doc::ItemDoc,
|
||||||
struct_def: @ast::struct_def
|
struct_def: @ast::struct_def
|
||||||
) -> doc::StructDoc {
|
) -> doc::StructDoc {
|
||||||
{
|
doc::StructDoc {
|
||||||
item: itemdoc,
|
item: itemdoc,
|
||||||
fields: do struct_def.fields.map |field| {
|
fields: do struct_def.fields.map |field| {
|
||||||
match field.node.kind {
|
match field.node.kind {
|
||||||
|
|
|
@ -158,7 +158,7 @@ pub fn default_par_fold<T:Owned Clone>(+ctxt: T) -> Fold<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_seq_fold_doc<T>(fold: &Fold<T>, +doc: doc::Doc) -> doc::Doc {
|
pub fn default_seq_fold_doc<T>(fold: &Fold<T>, +doc: doc::Doc) -> doc::Doc {
|
||||||
doc::Doc_({
|
doc::Doc_(doc::Doc_ {
|
||||||
pages: do vec::map(doc.pages) |page| {
|
pages: do vec::map(doc.pages) |page| {
|
||||||
match *page {
|
match *page {
|
||||||
doc::CratePage(doc) => {
|
doc::CratePage(doc) => {
|
||||||
|
@ -177,7 +177,7 @@ pub fn default_seq_fold_crate<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::CrateDoc
|
+doc: doc::CrateDoc
|
||||||
) -> doc::CrateDoc {
|
) -> doc::CrateDoc {
|
||||||
{
|
doc::CrateDoc {
|
||||||
topmod: (fold.fold_mod)(fold, doc.topmod)
|
topmod: (fold.fold_mod)(fold, doc.topmod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ pub fn default_any_fold_mod<T:Owned Clone>(
|
||||||
+doc: doc::ModDoc
|
+doc: doc::ModDoc
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
let fold_copy = fold.clone();
|
let fold_copy = fold.clone();
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
items: par::map(doc.items, |ItemTag, move fold_copy| {
|
items: par::map(doc.items, |ItemTag, move fold_copy| {
|
||||||
fold_ItemTag(&fold_copy, *ItemTag)
|
fold_ItemTag(&fold_copy, *ItemTag)
|
||||||
|
@ -207,7 +207,7 @@ pub fn default_seq_fold_mod<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::ModDoc
|
+doc: doc::ModDoc
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
items: vec::map(doc.items, |ItemTag| {
|
items: vec::map(doc.items, |ItemTag| {
|
||||||
fold_ItemTag(fold, *ItemTag)
|
fold_ItemTag(fold, *ItemTag)
|
||||||
|
@ -221,7 +221,7 @@ pub fn default_par_fold_mod<T:Owned Clone>(
|
||||||
+doc: doc::ModDoc
|
+doc: doc::ModDoc
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
let fold_copy = fold.clone();
|
let fold_copy = fold.clone();
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
items: par::map(doc.items, |ItemTag, move fold_copy| {
|
items: par::map(doc.items, |ItemTag, move fold_copy| {
|
||||||
fold_ItemTag(&fold_copy, *ItemTag)
|
fold_ItemTag(&fold_copy, *ItemTag)
|
||||||
|
@ -235,7 +235,7 @@ pub fn default_any_fold_nmod<T:Owned Clone>(
|
||||||
+doc: doc::NmodDoc
|
+doc: doc::NmodDoc
|
||||||
) -> doc::NmodDoc {
|
) -> doc::NmodDoc {
|
||||||
let fold_copy = fold.clone();
|
let fold_copy = fold.clone();
|
||||||
{
|
doc::NmodDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
fns: par::map(doc.fns, |FnDoc, move fold_copy| {
|
fns: par::map(doc.fns, |FnDoc, move fold_copy| {
|
||||||
(fold_copy.fold_fn)(&fold_copy, *FnDoc)
|
(fold_copy.fold_fn)(&fold_copy, *FnDoc)
|
||||||
|
@ -248,7 +248,7 @@ pub fn default_seq_fold_nmod<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::NmodDoc
|
+doc: doc::NmodDoc
|
||||||
) -> doc::NmodDoc {
|
) -> doc::NmodDoc {
|
||||||
{
|
doc::NmodDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
fns: vec::map(doc.fns, |FnDoc| {
|
fns: vec::map(doc.fns, |FnDoc| {
|
||||||
(fold.fold_fn)(fold, *FnDoc)
|
(fold.fold_fn)(fold, *FnDoc)
|
||||||
|
@ -262,7 +262,7 @@ pub fn default_par_fold_nmod<T:Owned Clone>(
|
||||||
+doc: doc::NmodDoc
|
+doc: doc::NmodDoc
|
||||||
) -> doc::NmodDoc {
|
) -> doc::NmodDoc {
|
||||||
let fold_copy = fold.clone();
|
let fold_copy = fold.clone();
|
||||||
{
|
doc::NmodDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
fns: par::map(doc.fns, |FnDoc, move fold_copy| {
|
fns: par::map(doc.fns, |FnDoc, move fold_copy| {
|
||||||
(fold_copy.fold_fn)(&fold_copy, *FnDoc)
|
(fold_copy.fold_fn)(&fold_copy, *FnDoc)
|
||||||
|
@ -307,7 +307,7 @@ pub fn default_seq_fold_fn<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::FnDoc
|
+doc: doc::FnDoc
|
||||||
) -> doc::FnDoc {
|
) -> doc::FnDoc {
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -317,7 +317,7 @@ pub fn default_seq_fold_const<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::ConstDoc
|
+doc: doc::ConstDoc
|
||||||
) -> doc::ConstDoc {
|
) -> doc::ConstDoc {
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ pub fn default_seq_fold_enum<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::EnumDoc
|
+doc: doc::EnumDoc
|
||||||
) -> doc::EnumDoc {
|
) -> doc::EnumDoc {
|
||||||
{
|
doc::EnumDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ pub fn default_seq_fold_trait<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::TraitDoc
|
+doc: doc::TraitDoc
|
||||||
) -> doc::TraitDoc {
|
) -> doc::TraitDoc {
|
||||||
{
|
doc::TraitDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ pub fn default_seq_fold_impl<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::ImplDoc
|
+doc: doc::ImplDoc
|
||||||
) -> doc::ImplDoc {
|
) -> doc::ImplDoc {
|
||||||
{
|
doc::ImplDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -357,7 +357,7 @@ pub fn default_seq_fold_type<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::TyDoc
|
+doc: doc::TyDoc
|
||||||
) -> doc::TyDoc {
|
) -> doc::TyDoc {
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ pub fn default_seq_fold_struct<T>(
|
||||||
fold: &Fold<T>,
|
fold: &Fold<T>,
|
||||||
+doc: doc::StructDoc
|
+doc: doc::StructDoc
|
||||||
) -> doc::StructDoc {
|
) -> doc::StructDoc {
|
||||||
{
|
doc::StructDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn fold_mod(
|
||||||
|
|
||||||
let doc = fold::default_any_fold_mod(fold, doc);
|
let doc = fold::default_any_fold_mod(fold, doc);
|
||||||
|
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
index: Some(build_mod_index(doc, fold.ctxt)),
|
index: Some(build_mod_index(doc, fold.ctxt)),
|
||||||
.. *doc
|
.. *doc
|
||||||
})
|
})
|
||||||
|
@ -67,7 +67,7 @@ fn fold_nmod(
|
||||||
|
|
||||||
let doc = fold::default_any_fold_nmod(fold, doc);
|
let doc = fold::default_any_fold_nmod(fold, doc);
|
||||||
|
|
||||||
{
|
doc::NmodDoc {
|
||||||
index: Some(build_nmod_index(doc, fold.ctxt)),
|
index: Some(build_nmod_index(doc, fold.ctxt)),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ fn build_mod_index(
|
||||||
+doc: doc::ModDoc,
|
+doc: doc::ModDoc,
|
||||||
+config: config::Config
|
+config: config::Config
|
||||||
) -> doc::Index {
|
) -> doc::Index {
|
||||||
{
|
doc::Index {
|
||||||
entries: par::map(doc.items, |doc| {
|
entries: par::map(doc.items, |doc| {
|
||||||
item_to_entry(*doc, config)
|
item_to_entry(*doc, config)
|
||||||
})
|
})
|
||||||
|
@ -88,7 +88,7 @@ fn build_nmod_index(
|
||||||
+doc: doc::NmodDoc,
|
+doc: doc::NmodDoc,
|
||||||
+config: config::Config
|
+config: config::Config
|
||||||
) -> doc::Index {
|
) -> doc::Index {
|
||||||
{
|
doc::Index {
|
||||||
entries: par::map(doc.fns, |doc| {
|
entries: par::map(doc.fns, |doc| {
|
||||||
item_to_entry(doc::FnTag(*doc), config)
|
item_to_entry(doc::FnTag(*doc), config)
|
||||||
})
|
})
|
||||||
|
@ -109,7 +109,7 @@ fn item_to_entry(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
doc::IndexEntry {
|
||||||
kind: markdown_pass::header_kind(doc),
|
kind: markdown_pass::header_kind(doc),
|
||||||
name: markdown_pass::header_name(doc),
|
name: markdown_pass::header_name(doc),
|
||||||
brief: doc.brief(),
|
brief: doc.brief(),
|
||||||
|
|
|
@ -76,7 +76,7 @@ fn make_doc_from_pages(page_port: PagePort) -> doc::Doc {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
doc::Doc_({
|
doc::Doc_(doc::Doc_ {
|
||||||
pages: pages
|
pages: pages
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ fn fold_crate(
|
||||||
|
|
||||||
let doc = fold::default_seq_fold_crate(fold, doc);
|
let doc = fold::default_seq_fold_crate(fold, doc);
|
||||||
|
|
||||||
let page = doc::CratePage({
|
let page = doc::CratePage(doc::CrateDoc {
|
||||||
topmod: strip_mod(doc.topmod),
|
topmod: strip_mod(doc.topmod),
|
||||||
.. doc
|
.. doc
|
||||||
});
|
});
|
||||||
|
@ -128,7 +128,7 @@ fn fold_mod(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
|
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
items: do doc.items.filtered |item| {
|
items: do doc.items.filtered |item| {
|
||||||
match *item {
|
match *item {
|
||||||
doc::ModTag(_) => false,
|
doc::ModTag(_) => false,
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn run(srv: astsrv::Srv, +doc: doc::Doc) -> doc::Doc {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_item(fold: &fold::Fold<Ctxt>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
fn fold_item(fold: &fold::Fold<Ctxt>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||||
{
|
doc::ItemDoc {
|
||||||
path: fold.ctxt.path,
|
path: fold.ctxt.path,
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ fn fold_mod(fold: &fold::Fold<Ctxt>, +doc: doc::ModDoc) -> doc::ModDoc {
|
||||||
let doc = fold::default_any_fold_mod(fold, doc);
|
let doc = fold::default_any_fold_mod(fold, doc);
|
||||||
if !is_topmod { fold.ctxt.path.pop(); }
|
if !is_topmod { fold.ctxt.path.pop(); }
|
||||||
|
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. *doc
|
.. *doc
|
||||||
})
|
})
|
||||||
|
@ -79,7 +79,7 @@ fn fold_nmod(fold: &fold::Fold<Ctxt>, +doc: doc::NmodDoc) -> doc::NmodDoc {
|
||||||
let doc = fold::default_seq_fold_nmod(fold, doc);
|
let doc = fold::default_seq_fold_nmod(fold, doc);
|
||||||
fold.ctxt.path.pop();
|
fold.ctxt.path.pop();
|
||||||
|
|
||||||
{
|
doc::NmodDoc {
|
||||||
item: (fold.fold_item)(fold, doc.item),
|
item: (fold.fold_item)(fold, doc.item),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn fold_mod(
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
let doc = fold::default_any_fold_mod(fold, doc);
|
let doc = fold::default_any_fold_mod(fold, doc);
|
||||||
|
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
items: do doc.items.filtered |ItemTag| {
|
items: do doc.items.filtered |ItemTag| {
|
||||||
!is_hidden(fold.ctxt, ItemTag.item())
|
!is_hidden(fold.ctxt, ItemTag.item())
|
||||||
},
|
},
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn fold_mod(
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
let doc = fold::default_any_fold_mod(fold, doc);
|
let doc = fold::default_any_fold_mod(fold, doc);
|
||||||
|
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
items: doc.items.filtered(|ItemTag| {
|
items: doc.items.filtered(|ItemTag| {
|
||||||
is_visible(fold.ctxt, ItemTag.item())
|
is_visible(fold.ctxt, ItemTag.item())
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -46,7 +46,7 @@ fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||||
let doc = fold::default_seq_fold_item(fold, doc);
|
let doc = fold::default_seq_fold_item(fold, doc);
|
||||||
let (desc, sections) = sectionalize(doc.desc);
|
let (desc, sections) = sectionalize(doc.desc);
|
||||||
|
|
||||||
{
|
doc::ItemDoc {
|
||||||
desc: desc,
|
desc: desc,
|
||||||
sections: sections,
|
sections: sections,
|
||||||
.. doc
|
.. doc
|
||||||
|
@ -56,11 +56,11 @@ fn fold_item(fold: &fold::Fold<()>, +doc: doc::ItemDoc) -> doc::ItemDoc {
|
||||||
fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||||
|
|
||||||
{
|
doc::TraitDoc {
|
||||||
methods: do par::map(doc.methods) |method| {
|
methods: do par::map(doc.methods) |method| {
|
||||||
let (desc, sections) = sectionalize(method.desc);
|
let (desc, sections) = sectionalize(method.desc);
|
||||||
|
|
||||||
{
|
doc::MethodDoc {
|
||||||
desc: desc,
|
desc: desc,
|
||||||
sections: sections,
|
sections: sections,
|
||||||
.. *method
|
.. *method
|
||||||
|
@ -73,11 +73,11 @@ fn fold_trait(fold: &fold::Fold<()>, +doc: doc::TraitDoc) -> doc::TraitDoc {
|
||||||
fn fold_impl(fold: &fold::Fold<()>, +doc: doc::ImplDoc) -> doc::ImplDoc {
|
fn fold_impl(fold: &fold::Fold<()>, +doc: doc::ImplDoc) -> doc::ImplDoc {
|
||||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||||
|
|
||||||
{
|
doc::ImplDoc {
|
||||||
methods: do par::map(doc.methods) |method| {
|
methods: do par::map(doc.methods) |method| {
|
||||||
let (desc, sections) = sectionalize(method.desc);
|
let (desc, sections) = sectionalize(method.desc);
|
||||||
|
|
||||||
{
|
doc::MethodDoc {
|
||||||
desc: desc,
|
desc: desc,
|
||||||
sections: sections,
|
sections: sections,
|
||||||
.. *method
|
.. *method
|
||||||
|
@ -121,7 +121,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||||
if current_section.is_some() {
|
if current_section.is_some() {
|
||||||
sections += ~[current_section.get()];
|
sections += ~[current_section.get()];
|
||||||
}
|
}
|
||||||
current_section = Some({
|
current_section = Some(doc::Section {
|
||||||
header: header,
|
header: header,
|
||||||
body: ~""
|
body: ~""
|
||||||
});
|
});
|
||||||
|
@ -129,7 +129,7 @@ fn sectionalize(desc: Option<~str>) -> (Option<~str>, ~[doc::Section]) {
|
||||||
None => {
|
None => {
|
||||||
match copy current_section {
|
match copy current_section {
|
||||||
Some(section) => {
|
Some(section) => {
|
||||||
current_section = Some({
|
current_section = Some(doc::Section {
|
||||||
body: section.body + ~"\n" + *line,
|
body: section.body + ~"\n" + *line,
|
||||||
.. section
|
.. section
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,7 +55,7 @@ fn fold_mod(
|
||||||
+doc: doc::ModDoc
|
+doc: doc::ModDoc
|
||||||
) -> doc::ModDoc {
|
) -> doc::ModDoc {
|
||||||
let doc = fold::default_any_fold_mod(fold, doc);
|
let doc = fold::default_any_fold_mod(fold, doc);
|
||||||
doc::ModDoc_({
|
doc::ModDoc_(doc::ModDoc_ {
|
||||||
items: sort::merge_sort(doc.items, fold.ctxt.op),
|
items: sort::merge_sort(doc.items, fold.ctxt.op),
|
||||||
.. *doc
|
.. *doc
|
||||||
})
|
})
|
||||||
|
|
|
@ -62,7 +62,7 @@ fn fold_item(
|
||||||
) -> doc::ItemDoc {
|
) -> doc::ItemDoc {
|
||||||
let doc = fold::default_seq_fold_item(fold, doc);
|
let doc = fold::default_seq_fold_item(fold, doc);
|
||||||
|
|
||||||
{
|
doc::ItemDoc {
|
||||||
brief: maybe_apply_op(fold.ctxt, doc.brief),
|
brief: maybe_apply_op(fold.ctxt, doc.brief),
|
||||||
desc: maybe_apply_op(fold.ctxt, doc.desc),
|
desc: maybe_apply_op(fold.ctxt, doc.desc),
|
||||||
sections: apply_to_sections(fold.ctxt, doc.sections),
|
sections: apply_to_sections(fold.ctxt, doc.sections),
|
||||||
|
@ -74,7 +74,7 @@ fn apply_to_sections(
|
||||||
op: NominalOp<Op>,
|
op: NominalOp<Op>,
|
||||||
sections: ~[doc::Section]
|
sections: ~[doc::Section]
|
||||||
) -> ~[doc::Section] {
|
) -> ~[doc::Section] {
|
||||||
par::map(sections, |section, copy op| {
|
par::map(sections, |section, copy op| doc::Section {
|
||||||
header: (op.op)(section.header),
|
header: (op.op)(section.header),
|
||||||
body: (op.op)(section.body)
|
body: (op.op)(section.body)
|
||||||
})
|
})
|
||||||
|
@ -86,9 +86,9 @@ fn fold_enum(
|
||||||
let doc = fold::default_seq_fold_enum(fold, doc);
|
let doc = fold::default_seq_fold_enum(fold, doc);
|
||||||
let fold_copy = copy *fold;
|
let fold_copy = copy *fold;
|
||||||
|
|
||||||
{
|
doc::EnumDoc {
|
||||||
variants: do par::map(doc.variants) |variant, copy fold_copy| {
|
variants: do par::map(doc.variants) |variant, copy fold_copy| {
|
||||||
{
|
doc::VariantDoc {
|
||||||
desc: maybe_apply_op(fold_copy.ctxt, variant.desc),
|
desc: maybe_apply_op(fold_copy.ctxt, variant.desc),
|
||||||
.. *variant
|
.. *variant
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ fn fold_trait(
|
||||||
) -> doc::TraitDoc {
|
) -> doc::TraitDoc {
|
||||||
let doc = fold::default_seq_fold_trait(fold, doc);
|
let doc = fold::default_seq_fold_trait(fold, doc);
|
||||||
|
|
||||||
{
|
doc::TraitDoc {
|
||||||
methods: apply_to_methods(fold.ctxt, doc.methods),
|
methods: apply_to_methods(fold.ctxt, doc.methods),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ fn apply_to_methods(
|
||||||
docs: ~[doc::MethodDoc]
|
docs: ~[doc::MethodDoc]
|
||||||
) -> ~[doc::MethodDoc] {
|
) -> ~[doc::MethodDoc] {
|
||||||
do par::map(docs) |doc, copy op| {
|
do par::map(docs) |doc, copy op| {
|
||||||
{
|
doc::MethodDoc {
|
||||||
brief: maybe_apply_op(op, doc.brief),
|
brief: maybe_apply_op(op, doc.brief),
|
||||||
desc: maybe_apply_op(op, doc.desc),
|
desc: maybe_apply_op(op, doc.desc),
|
||||||
sections: apply_to_sections(op, doc.sections),
|
sections: apply_to_sections(op, doc.sections),
|
||||||
|
@ -129,7 +129,7 @@ fn fold_impl(
|
||||||
) -> doc::ImplDoc {
|
) -> doc::ImplDoc {
|
||||||
let doc = fold::default_seq_fold_impl(fold, doc);
|
let doc = fold::default_seq_fold_impl(fold, doc);
|
||||||
|
|
||||||
{
|
doc::ImplDoc {
|
||||||
methods: apply_to_methods(fold.ctxt, doc.methods),
|
methods: apply_to_methods(fold.ctxt, doc.methods),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ fn fold_fn(
|
||||||
|
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
sig: get_fn_sig(srv, doc.id()),
|
sig: get_fn_sig(srv, doc.id()),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ fn fold_const(
|
||||||
) -> doc::ConstDoc {
|
) -> doc::ConstDoc {
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
sig: Some(do astsrv::exec(srv) |ctxt| {
|
sig: Some(do astsrv::exec(srv) |ctxt| {
|
||||||
match ctxt.ast_map.get(doc.id()) {
|
match ctxt.ast_map.get(doc.id()) {
|
||||||
ast_map::node_item(@ast::item {
|
ast_map::node_item(@ast::item {
|
||||||
|
@ -129,7 +129,7 @@ fn fold_enum(
|
||||||
let doc_id = doc.id();
|
let doc_id = doc.id();
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
doc::EnumDoc {
|
||||||
variants: do par::map(doc.variants) |variant| {
|
variants: do par::map(doc.variants) |variant| {
|
||||||
let variant = *variant;
|
let variant = *variant;
|
||||||
let sig = do astsrv::exec(srv) |ctxt| {
|
let sig = do astsrv::exec(srv) |ctxt| {
|
||||||
|
@ -148,7 +148,7 @@ fn fold_enum(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
doc::VariantDoc {
|
||||||
sig: Some(sig),
|
sig: Some(sig),
|
||||||
.. variant
|
.. variant
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ fn fold_trait(
|
||||||
fold: &fold::Fold<astsrv::Srv>,
|
fold: &fold::Fold<astsrv::Srv>,
|
||||||
+doc: doc::TraitDoc
|
+doc: doc::TraitDoc
|
||||||
) -> doc::TraitDoc {
|
) -> doc::TraitDoc {
|
||||||
{
|
doc::TraitDoc {
|
||||||
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
||||||
.. doc
|
.. doc
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ fn merge_methods(
|
||||||
docs: ~[doc::MethodDoc]
|
docs: ~[doc::MethodDoc]
|
||||||
) -> ~[doc::MethodDoc] {
|
) -> ~[doc::MethodDoc] {
|
||||||
do par::map(docs) |doc| {
|
do par::map(docs) |doc| {
|
||||||
{
|
doc::MethodDoc {
|
||||||
sig: get_method_sig(srv, item_id, doc.name),
|
sig: get_method_sig(srv, item_id, doc.name),
|
||||||
.. *doc
|
.. *doc
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ fn fold_impl(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
{
|
doc::ImplDoc {
|
||||||
trait_types: trait_types,
|
trait_types: trait_types,
|
||||||
self_ty: self_ty,
|
self_ty: self_ty,
|
||||||
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
methods: merge_methods(fold.ctxt, doc.id(), doc.methods),
|
||||||
|
@ -316,7 +316,7 @@ fn fold_type(
|
||||||
|
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
doc::SimpleItemDoc {
|
||||||
sig: do astsrv::exec(srv) |ctxt| {
|
sig: do astsrv::exec(srv) |ctxt| {
|
||||||
match ctxt.ast_map.get(doc.id()) {
|
match ctxt.ast_map.get(doc.id()) {
|
||||||
ast_map::node_item(@ast::item {
|
ast_map::node_item(@ast::item {
|
||||||
|
@ -349,7 +349,7 @@ fn fold_struct(
|
||||||
) -> doc::StructDoc {
|
) -> doc::StructDoc {
|
||||||
let srv = fold.ctxt;
|
let srv = fold.ctxt;
|
||||||
|
|
||||||
{
|
doc::StructDoc {
|
||||||
sig: do astsrv::exec(srv) |ctxt| {
|
sig: do astsrv::exec(srv) |ctxt| {
|
||||||
match ctxt.ast_map.get(doc.id()) {
|
match ctxt.ast_map.get(doc.id()) {
|
||||||
ast_map::node_item(item, _) => {
|
ast_map::node_item(item, _) => {
|
||||||
|
|
|
@ -17,7 +17,7 @@ A BigInt is a combination of BigUint and Sign.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use core::cmp::{Eq, Ord};
|
use core::cmp::{Eq, Ord};
|
||||||
use core::num::{Num, Zero, One};
|
use core::num::{IntConvertible, Zero, One};
|
||||||
use core::*;
|
use core::*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +121,7 @@ impl BigUint : One {
|
||||||
static pub pure fn one() -> BigUint { BigUint::new(~[1]) }
|
static pub pure fn one() -> BigUint { BigUint::new(~[1]) }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BigUint : Num {
|
impl BigUint : Add<BigUint, BigUint> {
|
||||||
pure fn add(&self, other: &BigUint) -> BigUint {
|
pure fn add(&self, other: &BigUint) -> BigUint {
|
||||||
let new_len = uint::max(self.data.len(), other.data.len());
|
let new_len = uint::max(self.data.len(), other.data.len());
|
||||||
|
|
||||||
|
@ -138,7 +138,9 @@ impl BigUint : Num {
|
||||||
if carry == 0 { return BigUint::new(sum) };
|
if carry == 0 { return BigUint::new(sum) };
|
||||||
return BigUint::new(sum + [carry]);
|
return BigUint::new(sum + [carry]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigUint : Sub<BigUint, BigUint> {
|
||||||
pure fn sub(&self, other: &BigUint) -> BigUint {
|
pure fn sub(&self, other: &BigUint) -> BigUint {
|
||||||
let new_len = uint::max(self.data.len(), other.data.len());
|
let new_len = uint::max(self.data.len(), other.data.len());
|
||||||
|
|
||||||
|
@ -161,7 +163,9 @@ impl BigUint : Num {
|
||||||
assert borrow == 0; // <=> assert (self >= other);
|
assert borrow == 0; // <=> assert (self >= other);
|
||||||
return BigUint::new(diff);
|
return BigUint::new(diff);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigUint : Mul<BigUint, BigUint> {
|
||||||
pure fn mul(&self, other: &BigUint) -> BigUint {
|
pure fn mul(&self, other: &BigUint) -> BigUint {
|
||||||
if self.is_zero() || other.is_zero() { return Zero::zero(); }
|
if self.is_zero() || other.is_zero() { return Zero::zero(); }
|
||||||
|
|
||||||
|
@ -224,18 +228,27 @@ impl BigUint : Num {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigUint : Div<BigUint, BigUint> {
|
||||||
pure fn div(&self, other: &BigUint) -> BigUint {
|
pure fn div(&self, other: &BigUint) -> BigUint {
|
||||||
let (d, _) = self.divmod(other);
|
let (d, _) = self.divmod(other);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigUint : Modulo<BigUint, BigUint> {
|
||||||
pure fn modulo(&self, other: &BigUint) -> BigUint {
|
pure fn modulo(&self, other: &BigUint) -> BigUint {
|
||||||
let (_, m) = self.divmod(other);
|
let (_, m) = self.divmod(other);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigUint : Neg<BigUint> {
|
||||||
pure fn neg(&self) -> BigUint { fail }
|
pure fn neg(&self) -> BigUint { fail }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigUint : IntConvertible {
|
||||||
pure fn to_int(&self) -> int {
|
pure fn to_int(&self) -> int {
|
||||||
uint::min(self.to_uint(), int::max_value as uint) as int
|
uint::min(self.to_uint(), int::max_value as uint) as int
|
||||||
}
|
}
|
||||||
|
@ -625,7 +638,7 @@ impl BigInt : One {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BigInt : Num {
|
impl BigInt : Add<BigInt, BigInt> {
|
||||||
pure fn add(&self, other: &BigInt) -> BigInt {
|
pure fn add(&self, other: &BigInt) -> BigInt {
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(Zero, _) => copy *other,
|
(Zero, _) => copy *other,
|
||||||
|
@ -637,6 +650,9 @@ impl BigInt : Num {
|
||||||
(Minus, Minus) => -((-self) + (-*other))
|
(Minus, Minus) => -((-self) + (-*other))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigInt : Sub<BigInt, BigInt> {
|
||||||
pure fn sub(&self, other: &BigInt) -> BigInt {
|
pure fn sub(&self, other: &BigInt) -> BigInt {
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(Zero, _) => -other,
|
(Zero, _) => -other,
|
||||||
|
@ -654,6 +670,9 @@ impl BigInt : Num {
|
||||||
(Minus, Minus) => (-other) - (-*self)
|
(Minus, Minus) => (-other) - (-*self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigInt : Mul<BigInt, BigInt> {
|
||||||
pure fn mul(&self, other: &BigInt) -> BigInt {
|
pure fn mul(&self, other: &BigInt) -> BigInt {
|
||||||
match (self.sign, other.sign) {
|
match (self.sign, other.sign) {
|
||||||
(Zero, _) | (_, Zero) => Zero::zero(),
|
(Zero, _) | (_, Zero) => Zero::zero(),
|
||||||
|
@ -665,18 +684,29 @@ impl BigInt : Num {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigInt : Div<BigInt, BigInt> {
|
||||||
pure fn div(&self, other: &BigInt) -> BigInt {
|
pure fn div(&self, other: &BigInt) -> BigInt {
|
||||||
let (d, _) = self.divmod(other);
|
let (d, _) = self.divmod(other);
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigInt : Modulo<BigInt, BigInt> {
|
||||||
pure fn modulo(&self, other: &BigInt) -> BigInt {
|
pure fn modulo(&self, other: &BigInt) -> BigInt {
|
||||||
let (_, m) = self.divmod(other);
|
let (_, m) = self.divmod(other);
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigInt : Neg<BigInt> {
|
||||||
pure fn neg(&self) -> BigInt {
|
pure fn neg(&self) -> BigInt {
|
||||||
BigInt::from_biguint(self.sign.neg(), copy self.data)
|
BigInt::from_biguint(self.sign.neg(), copy self.data)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BigInt : IntConvertible {
|
||||||
pure fn to_int(&self) -> int {
|
pure fn to_int(&self) -> int {
|
||||||
match self.sign {
|
match self.sign {
|
||||||
Plus => uint::min(self.to_uint(), int::max_value as uint) as int,
|
Plus => uint::min(self.to_uint(), int::max_value as uint) as int,
|
||||||
|
@ -834,7 +864,7 @@ pub impl BigInt {
|
||||||
mod biguint_tests {
|
mod biguint_tests {
|
||||||
|
|
||||||
use core::*;
|
use core::*;
|
||||||
use core::num::{Num, Zero, One};
|
use num::{IntConvertible, Zero, One};
|
||||||
use super::{BigInt, BigUint, BigDigit};
|
use super::{BigInt, BigUint, BigDigit};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -974,7 +1004,7 @@ mod biguint_tests {
|
||||||
fn test_convert_int() {
|
fn test_convert_int() {
|
||||||
fn check(v: ~[BigDigit], i: int) {
|
fn check(v: ~[BigDigit], i: int) {
|
||||||
let b = BigUint::new(v);
|
let b = BigUint::new(v);
|
||||||
assert b == Num::from_int(i);
|
assert b == IntConvertible::from_int(i);
|
||||||
assert b.to_int() == i;
|
assert b.to_int() == i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1244,7 +1274,7 @@ mod bigint_tests {
|
||||||
use super::{BigInt, BigUint, BigDigit, Sign, Minus, Zero, Plus};
|
use super::{BigInt, BigUint, BigDigit, Sign, Minus, Zero, Plus};
|
||||||
|
|
||||||
use core::*;
|
use core::*;
|
||||||
use core::num::{Num, Zero, One};
|
use core::num::{IntConvertible, Zero, One};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_biguint() {
|
fn test_from_biguint() {
|
||||||
|
@ -1303,7 +1333,7 @@ mod bigint_tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_convert_int() {
|
fn test_convert_int() {
|
||||||
fn check(b: BigInt, i: int) {
|
fn check(b: BigInt, i: int) {
|
||||||
assert b == Num::from_int(i);
|
assert b == IntConvertible::from_int(i);
|
||||||
assert b.to_int() == i;
|
assert b.to_int() == i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1563,7 +1593,8 @@ mod bigint_tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_to_str_radix() {
|
fn test_to_str_radix() {
|
||||||
fn check(n: int, ans: &str) {
|
fn check(n: int, ans: &str) {
|
||||||
assert ans == Num::from_int::<BigInt>(n).to_str_radix(10);
|
assert ans == IntConvertible::from_int::<BigInt>(
|
||||||
|
n).to_str_radix(10);
|
||||||
}
|
}
|
||||||
check(10, "10");
|
check(10, "10");
|
||||||
check(1, "1");
|
check(1, "1");
|
||||||
|
@ -1576,7 +1607,7 @@ mod bigint_tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_from_str_radix() {
|
fn test_from_str_radix() {
|
||||||
fn check(s: &str, ans: Option<int>) {
|
fn check(s: &str, ans: Option<int>) {
|
||||||
let ans = ans.map(|&n| Num::from_int(n));
|
let ans = ans.map(|&n| IntConvertible::from_int(n));
|
||||||
assert BigInt::from_str_radix(s, 10) == ans;
|
assert BigInt::from_str_radix(s, 10) == ans;
|
||||||
}
|
}
|
||||||
check("10", Some(10));
|
check("10", Some(10));
|
||||||
|
|
|
@ -249,69 +249,19 @@ mod tests {
|
||||||
assert deq.get(3) == d;
|
assert deq.get(3) == d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
enum Taggy { One(int), Two(int, int), Three(int, int, int), }
|
enum Taggy { One(int), Two(int, int), Three(int, int, int), }
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
enum Taggypar<T> {
|
enum Taggypar<T> {
|
||||||
Onepar(int), Twopar(int, int), Threepar(int, int, int),
|
Onepar(int), Twopar(int, int), Threepar(int, int, int),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[deriving_eq]
|
||||||
struct RecCy {
|
struct RecCy {
|
||||||
x: int,
|
x: int,
|
||||||
y: int,
|
y: int,
|
||||||
t: Taggy,
|
t: Taggy
|
||||||
}
|
|
||||||
|
|
||||||
impl Taggy : Eq {
|
|
||||||
pure fn eq(&self, other: &Taggy) -> bool {
|
|
||||||
match (*self) {
|
|
||||||
One(a1) => match (*other) {
|
|
||||||
One(b1) => return a1 == b1,
|
|
||||||
_ => return false
|
|
||||||
},
|
|
||||||
Two(a1, a2) => match (*other) {
|
|
||||||
Two(b1, b2) => return a1 == b1 && a2 == b2,
|
|
||||||
_ => return false
|
|
||||||
},
|
|
||||||
Three(a1, a2, a3) => match (*other) {
|
|
||||||
Three(b1, b2, b3) => return a1 == b1 && a2 == b2 && a3 == b3,
|
|
||||||
_ => return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Taggy) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Taggypar<int> : Eq {
|
|
||||||
//let eq4: EqFn<Taggypar<int>> = |x,y| taggypareq::<int>(x, y);
|
|
||||||
pure fn eq(&self, other: &Taggypar<int>) -> bool {
|
|
||||||
match (*self) {
|
|
||||||
Onepar::<int>(a1) => match (*other) {
|
|
||||||
Onepar::<int>(b1) => return a1 == b1,
|
|
||||||
_ => return false
|
|
||||||
},
|
|
||||||
Twopar::<int>(a1, a2) => match (*other) {
|
|
||||||
Twopar::<int>(b1, b2) => return a1 == b1 && a2 == b2,
|
|
||||||
_ => return false
|
|
||||||
},
|
|
||||||
Threepar::<int>(a1, a2, a3) => match (*other) {
|
|
||||||
Threepar::<int>(b1, b2, b3) => {
|
|
||||||
return a1 == b1 && a2 == b2 && a3 == b3
|
|
||||||
}
|
|
||||||
_ => return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Taggypar<int>) -> bool {
|
|
||||||
!(*self).eq(other)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RecCy : Eq {
|
|
||||||
pure fn eq(&self, other: &RecCy) -> bool {
|
|
||||||
return (*self).x == (*other).x && (*self).y == (*other).y &&
|
|
||||||
(*self).t == (*other).t;
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &RecCy) -> bool { !(*self).eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -676,6 +676,7 @@ pub mod writer {
|
||||||
mod tests {
|
mod tests {
|
||||||
use ebml::reader;
|
use ebml::reader;
|
||||||
use ebml::writer;
|
use ebml::writer;
|
||||||
|
use serialize::Encodable;
|
||||||
use serialize;
|
use serialize;
|
||||||
|
|
||||||
use core::io;
|
use core::io;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
//! json serialization
|
//! json serialization
|
||||||
|
|
||||||
|
use serialize::Encodable;
|
||||||
use serialize;
|
use serialize;
|
||||||
use sort::Sort;
|
use sort::Sort;
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub type Set<K:Eq IterBytes Hash> = HashMap<K, ()>;
|
||||||
|
|
||||||
pub type HashMap<K:Eq IterBytes Hash, V> = chained::T<K, V>;
|
pub type HashMap<K:Eq IterBytes Hash, V> = chained::T<K, V>;
|
||||||
|
|
||||||
pub trait Map<K:Eq IterBytes Hash Copy, V: Copy> {
|
pub trait StdMap<K:Eq IterBytes Hash Copy, V: Copy> {
|
||||||
/// Return the number of elements in the map
|
/// Return the number of elements in the map
|
||||||
pure fn size() -> uint;
|
pure fn size() -> uint;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ pub mod util {
|
||||||
// FIXME (#2344): package this up and export it as a datatype usable for
|
// FIXME (#2344): package this up and export it as a datatype usable for
|
||||||
// external code that doesn't want to pay the cost of a box.
|
// external code that doesn't want to pay the cost of a box.
|
||||||
pub mod chained {
|
pub mod chained {
|
||||||
use map::{Map, util};
|
use map::{StdMap, util};
|
||||||
|
|
||||||
use core::io;
|
use core::io;
|
||||||
use core::ops;
|
use core::ops;
|
||||||
|
@ -239,7 +239,7 @@ pub mod chained {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: Map<K, V> {
|
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: StdMap<K, V> {
|
||||||
pure fn size() -> uint { self.count }
|
pure fn size() -> uint { self.count }
|
||||||
|
|
||||||
pure fn contains_key(k: K) -> bool {
|
pure fn contains_key(k: K) -> bool {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#[forbid(deprecated_mode)];
|
#[forbid(deprecated_mode)];
|
||||||
|
|
||||||
use map;
|
use map;
|
||||||
use map::Map;
|
use map::StdMap;
|
||||||
|
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
use core::ops;
|
use core::ops;
|
||||||
|
@ -81,7 +81,7 @@ pub pure fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements the map::map interface for smallintmap
|
/// Implements the map::map interface for smallintmap
|
||||||
impl<V: Copy> SmallIntMap<V>: map::Map<uint, V> {
|
impl<V: Copy> SmallIntMap<V>: map::StdMap<uint, V> {
|
||||||
pure fn size() -> uint {
|
pure fn size() -> uint {
|
||||||
let mut sz = 0u;
|
let mut sz = 0u;
|
||||||
for self.v.each |item| {
|
for self.v.each |item| {
|
||||||
|
@ -165,8 +165,8 @@ impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cast the given smallintmap to a map::map
|
/// Cast the given smallintmap to a map::map
|
||||||
pub fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::Map<uint, V> {
|
pub fn as_map<V: Copy>(s: SmallIntMap<V>) -> map::StdMap<uint, V> {
|
||||||
s as map::Map::<uint, V>
|
s as map::StdMap::<uint, V>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -12,7 +12,7 @@ use core::prelude::*;
|
||||||
|
|
||||||
use ast::*;
|
use ast::*;
|
||||||
use ast;
|
use ast;
|
||||||
use ast_util::{path_to_ident, stmt_id};
|
use ast_util::{inlined_item_utils, path_to_ident, stmt_id};
|
||||||
use ast_util;
|
use ast_util;
|
||||||
use attr;
|
use attr;
|
||||||
use codemap;
|
use codemap;
|
||||||
|
|
|
@ -376,7 +376,7 @@ pure fn struct_field_visibility(field: ast::struct_field) -> visibility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait inlined_item_utils {
|
pub trait inlined_item_utils {
|
||||||
fn ident() -> ident;
|
fn ident() -> ident;
|
||||||
fn id() -> ast::node_id;
|
fn id() -> ast::node_id;
|
||||||
fn accept<E>(e: E, v: visit::vt<E>);
|
fn accept<E>(e: E, v: visit::vt<E>);
|
||||||
|
|
|
@ -33,7 +33,7 @@ use core::uint;
|
||||||
use core::vec;
|
use core::vec;
|
||||||
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
|
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||||
|
|
||||||
trait Pos {
|
pub trait Pos {
|
||||||
static pure fn from_uint(n: uint) -> self;
|
static pure fn from_uint(n: uint) -> self;
|
||||||
pure fn to_uint(&self) -> uint;
|
pure fn to_uint(&self) -> uint;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use codemap::span;
|
use codemap::{Pos, span};
|
||||||
use codemap;
|
use codemap;
|
||||||
|
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
|
|
|
@ -66,7 +66,7 @@ impl @ast::path: append_types {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ext_ctxt_ast_builder {
|
pub trait ext_ctxt_ast_builder {
|
||||||
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
|
fn ty_param(id: ast::ident, +bounds: ~[ast::ty_param_bound])
|
||||||
-> ast::ty_param;
|
-> ast::ty_param;
|
||||||
fn arg(name: ident, ty: @ast::Ty) -> ast::arg;
|
fn arg(name: ident, ty: @ast::Ty) -> ast::arg;
|
||||||
|
|
|
@ -49,6 +49,7 @@ use codemap::span;
|
||||||
use ext::base;
|
use ext::base;
|
||||||
use ext::base::ext_ctxt;
|
use ext::base::ext_ctxt;
|
||||||
use ext::pipes::parse_proto::proto_parser;
|
use ext::pipes::parse_proto::proto_parser;
|
||||||
|
use ext::pipes::pipec::gen_init;
|
||||||
use ext::pipes::proto::{visit, protocol};
|
use ext::pipes::proto::{visit, protocol};
|
||||||
use parse::lexer::{new_tt_reader, reader};
|
use parse::lexer::{new_tt_reader, reader};
|
||||||
use parse::parser::Parser;
|
use parse::parser::Parser;
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
use ast::ident;
|
use ast::ident;
|
||||||
use ast_util::dummy_sp;
|
use ast_util::dummy_sp;
|
||||||
use ext::base::ext_ctxt;
|
use ext::base::ext_ctxt;
|
||||||
use ext::pipes::ast_builder::{append_types, path, path_global};
|
use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
|
||||||
|
use ext::pipes::ast_builder::{path_global};
|
||||||
use ext::pipes::proto::*;
|
use ext::pipes::proto::*;
|
||||||
use ext::quote::rt::*;
|
use ext::quote::rt::*;
|
||||||
use parse::*;
|
use parse::*;
|
||||||
|
@ -35,7 +36,7 @@ trait to_type_decls {
|
||||||
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item];
|
fn to_endpoint_decls(cx: ext_ctxt, dir: direction) -> ~[@ast::item];
|
||||||
}
|
}
|
||||||
|
|
||||||
trait gen_init {
|
pub trait gen_init {
|
||||||
fn gen_init(cx: ext_ctxt) -> @ast::item;
|
fn gen_init(cx: ext_ctxt) -> @ast::item;
|
||||||
fn compile(cx: ext_ctxt) -> @ast::item;
|
fn compile(cx: ext_ctxt) -> @ast::item;
|
||||||
fn buffer_ty_path(cx: ext_ctxt) -> @ast::Ty;
|
fn buffer_ty_path(cx: ext_ctxt) -> @ast::Ty;
|
||||||
|
|
|
@ -13,7 +13,7 @@ use core::prelude::*;
|
||||||
use ast;
|
use ast;
|
||||||
use codemap::span;
|
use codemap::span;
|
||||||
use ext::base::ext_ctxt;
|
use ext::base::ext_ctxt;
|
||||||
use ext::pipes::ast_builder::{path, append_types};
|
use ext::pipes::ast_builder::{append_types, ext_ctxt_ast_builder, path};
|
||||||
|
|
||||||
use core::cmp;
|
use core::cmp;
|
||||||
use core::dvec::DVec;
|
use core::dvec::DVec;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
use ast;
|
use ast;
|
||||||
use attr;
|
use attr;
|
||||||
use codemap::{span, BytePos};
|
use codemap::{BytePos, Pos, span};
|
||||||
use ext::base::ext_ctxt;
|
use ext::base::ext_ctxt;
|
||||||
use ext::base;
|
use ext::base;
|
||||||
use ext::build;
|
use ext::build;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use codemap;
|
use codemap;
|
||||||
use codemap::{span, Loc, FileMap};
|
use codemap::{FileMap, Loc, Pos, span};
|
||||||
use ext::base::*;
|
use ext::base::*;
|
||||||
use ext::base;
|
use ext::base;
|
||||||
use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str};
|
use ext::build::{mk_base_vec_e, mk_uint, mk_u8, mk_base_str};
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use core::prelude::*;
|
use core::prelude::*;
|
||||||
|
|
||||||
use ast;
|
use ast;
|
||||||
use codemap::{BytePos, CharPos, CodeMap, FileMap};
|
use codemap::{BytePos, CharPos, CodeMap, FileMap, Pos};
|
||||||
use diagnostic;
|
use diagnostic;
|
||||||
use parse::lexer::{is_whitespace, get_str_from, reader};
|
use parse::lexer::{is_whitespace, get_str_from, reader};
|
||||||
use parse::lexer::{string_reader, bump, is_eof, nextch};
|
use parse::lexer::{string_reader, bump, is_eof, nextch};
|
||||||
|
|
|
@ -12,7 +12,7 @@ use core::prelude::*;
|
||||||
|
|
||||||
use ast;
|
use ast;
|
||||||
use ast_util;
|
use ast_util;
|
||||||
use codemap::{span, CodeMap, CharPos, BytePos};
|
use codemap::{BytePos, CharPos, CodeMap, Pos, span};
|
||||||
use codemap;
|
use codemap;
|
||||||
use diagnostic::span_handler;
|
use diagnostic::span_handler;
|
||||||
use ext::tt::transcribe::{tt_next_token};
|
use ext::tt::transcribe::{tt_next_token};
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
// Copyright 2012 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.
|
|
||||||
|
|
||||||
#[link(name = "b", vers = "0.1")];
|
|
||||||
#[crate_type = "lib"];
|
|
||||||
|
|
||||||
extern mod a;
|
|
||||||
use a::to_strz;
|
|
||||||
|
|
||||||
impl int: to_strz {
|
|
||||||
fn to_strz() -> ~str { fmt!("%?", self) }
|
|
||||||
}
|
|
|
@ -11,6 +11,7 @@
|
||||||
type Foo = @[u8];
|
type Foo = @[u8];
|
||||||
|
|
||||||
impl Foo : Drop { //~ ERROR the Drop trait may only be implemented
|
impl Foo : Drop { //~ ERROR the Drop trait may only be implemented
|
||||||
|
//~^ ERROR cannot provide an extension implementation
|
||||||
fn finalize(&self) {
|
fn finalize(&self) {
|
||||||
io::println("kaboom");
|
io::println("kaboom");
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,13 @@
|
||||||
extern mod std;
|
extern mod std;
|
||||||
use std::map;
|
use std::map;
|
||||||
use std::map::HashMap;
|
use std::map::HashMap;
|
||||||
use std::map::Map;
|
use std::map::StdMap;
|
||||||
|
|
||||||
// Test that trait types printed in error msgs include the type arguments.
|
// Test that trait types printed in error msgs include the type arguments.
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x: Map<~str,~str> = map::HashMap::<~str,~str>() as Map::<~str,~str>;
|
let x: StdMap<~str,~str> = map::HashMap::<~str,~str>() as
|
||||||
let y: Map<uint,~str> = x;
|
StdMap::<~str,~str>;
|
||||||
//~^ ERROR mismatched types: expected `@std::map::Map<uint,~str>`
|
let y: StdMap<uint,~str> = x;
|
||||||
|
//~^ ERROR mismatched types: expected `@std::map::StdMap<uint,~str>`
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,19 +128,16 @@ impl CLike : cmp::Eq {
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
|
#[deriving_eq]
|
||||||
struct Spanned<T> {
|
struct Spanned<T> {
|
||||||
lo: uint,
|
lo: uint,
|
||||||
hi: uint,
|
hi: uint,
|
||||||
node: T,
|
node: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T:cmp::Eq> Spanned<T> : cmp::Eq {
|
enum AnEnum {
|
||||||
pure fn eq(&self, other: &Spanned<T>) -> bool {
|
AVariant,
|
||||||
self.lo == other.lo &&
|
AnotherVariant
|
||||||
self.hi == other.hi &&
|
|
||||||
self.node == other.node
|
|
||||||
}
|
|
||||||
pure fn ne(&self, other: &Spanned<T>) -> bool { !self.eq(other) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
|
|
|
@ -51,7 +51,7 @@ impl<T: Copy> cat<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Copy> cat<T> : Map<int, T> {
|
impl<T: Copy> cat<T> : StdMap<int, T> {
|
||||||
pure fn size() -> uint { self.meows as uint }
|
pure fn size() -> uint { self.meows as uint }
|
||||||
fn insert(+k: int, +_v: T) -> bool {
|
fn insert(+k: int, +_v: T) -> bool {
|
||||||
self.meows += k;
|
self.meows += k;
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
// Copyright 2012 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.
|
|
||||||
|
|
||||||
// xfail-fast (aux-build)
|
|
||||||
// aux-build:issue_2242_a.rs
|
|
||||||
// aux-build:issue_2242_b.rs
|
|
||||||
// aux-build:issue_2242_c.rs
|
|
||||||
|
|
||||||
extern mod a;
|
|
||||||
extern mod b;
|
|
||||||
extern mod c;
|
|
||||||
|
|
||||||
use a::to_strz;
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
io::println((~"foo").to_strz());
|
|
||||||
io::println(1.to_strz());
|
|
||||||
io::println(true.to_strz());
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue