Skip to content

Commit 811bbfc

Browse files
committed
rustc: de-@ ty::ParamBounds.
1 parent 1a76ac3 commit 811bbfc

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
use middle::ty;
2020

21+
use std::rc::Rc;
2122
use std::str;
2223
use std::strbuf::StrBuf;
2324
use std::uint;
@@ -563,7 +564,7 @@ fn parse_type_param_def(st: &mut PState, conv: conv_did) -> ty::TypeParameterDef
563564
ty::TypeParameterDef {
564565
ident: parse_ident(st, ':'),
565566
def_id: parse_def(st, NominalType, |x,y| conv(x,y)),
566-
bounds: @parse_bounds(st, |x,y| conv(x,y)),
567+
bounds: Rc::new(parse_bounds(st, |x,y| conv(x,y))),
567568
default: parse_opt(st, |st| parse_ty(st, |x,y| conv(x,y)))
568569
}
569570
}

src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,6 @@ fn enc_bounds(w: &mut MemWriter, cx: &ctxt, bs: &ty::ParamBounds) {
376376

377377
pub fn enc_type_param_def(w: &mut MemWriter, cx: &ctxt, v: &ty::TypeParameterDef) {
378378
mywrite!(w, "{}:{}|", token::get_ident(v.ident), (cx.ds)(v.def_id));
379-
enc_bounds(w, cx, v.bounds);
379+
enc_bounds(w, cx, &*v.bounds);
380380
enc_opt(w, v.default, |w, t| enc_ty(w, cx, t));
381381
}

src/librustc/middle/ty.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ pub enum type_err {
833833
#[deriving(Eq, TotalEq, Hash)]
834834
pub struct ParamBounds {
835835
pub builtin_bounds: BuiltinBounds,
836-
pub trait_bounds: Vec<@TraitRef> }
836+
pub trait_bounds: Vec<@TraitRef>
837+
}
837838

838839
pub type BuiltinBounds = EnumSet<BuiltinBound>;
839840

@@ -987,7 +988,7 @@ impl fmt::Show for IntVarValue {
987988
pub struct TypeParameterDef {
988989
pub ident: ast::Ident,
989990
pub def_id: ast::DefId,
990-
pub bounds: @ParamBounds,
991+
pub bounds: Rc<ParamBounds>,
991992
pub default: Option<ty::t>
992993
}
993994

src/librustc/middle/typeck/collect.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ pub fn ensure_trait_methods(ccx: &CrateCtxt, trait_id: ast::NodeId) {
342342
new_type_param_defs.push(ty::TypeParameterDef {
343343
ident: special_idents::self_,
344344
def_id: dummy_defid,
345-
bounds: @ty::ParamBounds {
345+
bounds: Rc::new(ty::ParamBounds {
346346
builtin_bounds: ty::EmptyBuiltinBounds(),
347347
trait_bounds: vec!(self_trait_ref)
348-
},
348+
}),
349349
default: None
350350
});
351351

@@ -999,24 +999,24 @@ pub fn ty_of_foreign_item(ccx: &CrateCtxt,
999999
}
10001000
}
10011001

1002-
pub fn ty_generics_for_type(ccx: &CrateCtxt,
1003-
generics: &ast::Generics)
1004-
-> ty::Generics {
1002+
fn ty_generics_for_type(ccx: &CrateCtxt,
1003+
generics: &ast::Generics)
1004+
-> ty::Generics {
10051005
ty_generics(ccx, &generics.lifetimes, &generics.ty_params, 0)
10061006
}
10071007

1008-
pub fn ty_generics_for_fn_or_method(ccx: &CrateCtxt,
1009-
generics: &ast::Generics,
1010-
base_index: uint)
1011-
-> ty::Generics {
1008+
fn ty_generics_for_fn_or_method(ccx: &CrateCtxt,
1009+
generics: &ast::Generics,
1010+
base_index: uint)
1011+
-> ty::Generics {
10121012
let early_lifetimes = resolve_lifetime::early_bound_lifetimes(generics);
10131013
ty_generics(ccx, &early_lifetimes, &generics.ty_params, base_index)
10141014
}
10151015

1016-
pub fn ty_generics(ccx: &CrateCtxt,
1017-
lifetimes: &Vec<ast::Lifetime>,
1018-
ty_params: &OwnedSlice<ast::TyParam>,
1019-
base_index: uint) -> ty::Generics {
1016+
fn ty_generics(ccx: &CrateCtxt,
1017+
lifetimes: &Vec<ast::Lifetime>,
1018+
ty_params: &OwnedSlice<ast::TyParam>,
1019+
base_index: uint) -> ty::Generics {
10201020
return ty::Generics {
10211021
region_param_defs: Rc::new(lifetimes.iter().map(|l| {
10221022
ty::RegionParameterDef { name: l.name,
@@ -1025,12 +1025,12 @@ pub fn ty_generics(ccx: &CrateCtxt,
10251025
type_param_defs: Rc::new(ty_params.iter().enumerate().map(|(offset, param)| {
10261026
let existing_def_opt = {
10271027
let ty_param_defs = ccx.tcx.ty_param_defs.borrow();
1028-
ty_param_defs.find(&param.id).map(|&def| def)
1028+
ty_param_defs.find(&param.id).map(|def| def.clone())
10291029
};
10301030
existing_def_opt.unwrap_or_else(|| {
10311031
let param_ty = ty::param_ty {idx: base_index + offset,
10321032
def_id: local_def(param.id)};
1033-
let bounds = @compute_bounds(ccx, param_ty, &param.bounds);
1033+
let bounds = Rc::new(compute_bounds(ccx, param_ty, &param.bounds));
10341034
let default = param.default.map(|path| {
10351035
let ty = ast_ty_to_ty(ccx, &ExplicitRscope, path);
10361036
let cur_idx = param_ty.idx;
@@ -1056,7 +1056,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
10561056
default: default
10571057
};
10581058
debug!("def for param: {}", def.repr(ccx.tcx));
1059-
ccx.tcx.ty_param_defs.borrow_mut().insert(param.id, def);
1059+
ccx.tcx.ty_param_defs.borrow_mut().insert(param.id, def.clone());
10601060
def
10611061
})
10621062
}).collect()),

0 commit comments

Comments
 (0)