Skip to content

Commit d80de7e

Browse files
committed
---
yaml --- r: 93164 b: refs/heads/try c: 5754848 h: refs/heads/master v: v3
1 parent e4daa03 commit d80de7e

File tree

21 files changed

+54
-44
lines changed

21 files changed

+54
-44
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: 22a5ebdc6b13089d2322d9944bdec1507d21eec2
5+
refs/heads/try: 5754848f8cd06bd3fc2bb084b5ca7bd41974e1b5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ fn get_explicit_self(item: ebml::Doc) -> ast::explicit_self_ {
975975
let explicit_self_kind = string[0];
976976
match explicit_self_kind as char {
977977
's' => { return ast::sty_static; }
978-
'v' => { return ast::sty_value; }
978+
'v' => { return ast::sty_value(get_mutability(string[1])); }
979979
'@' => { return ast::sty_box(get_mutability(string[1])); }
980980
'~' => { return ast::sty_uniq; }
981981
'&' => {

branches/try/src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ fn encode_explicit_self(ebml_w: &mut writer::Encoder, explicit_self: ast::explic
662662
sty_static => {
663663
ebml_w.writer.write(&[ 's' as u8 ]);
664664
}
665-
sty_value => {
665+
sty_value(m) => {
666666
ebml_w.writer.write(&[ 'v' as u8 ]);
667+
encode_mutability(ebml_w, m);
667668
}
668669
sty_region(_, m) => {
669670
// FIXME(#4846) encode custom lifetime

branches/try/src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl tr for ast::Def {
410410
ast::DefMethod(did0.tr(xcx), did1.map(|did1| did1.tr(xcx)))
411411
}
412412
ast::DefSelfTy(nid) => { ast::DefSelfTy(xcx.tr_id(nid)) }
413-
ast::DefSelf(nid) => { ast::DefSelf(xcx.tr_id(nid)) }
413+
ast::DefSelf(nid, m) => { ast::DefSelf(xcx.tr_id(nid), m) }
414414
ast::DefMod(did) => { ast::DefMod(did.tr(xcx)) }
415415
ast::DefForeignMod(did) => { ast::DefForeignMod(did.tr(xcx)) }
416416
ast::DefStatic(did, m) => { ast::DefStatic(did.tr(xcx), m) }

branches/try/src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ fn visit_fn(v: &mut LivenessVisitor,
392392
match *fk {
393393
visit::fk_method(_, _, method) => {
394394
match method.explicit_self.node {
395-
sty_value | sty_region(*) | sty_box(_) | sty_uniq => {
395+
sty_value(_) | sty_region(*) | sty_box(_) | sty_uniq => {
396396
fn_maps.add_variable(Arg(method.self_id,
397397
special_idents::self_));
398398
}

branches/try/src/librustc/middle/mem_categorization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,12 @@ impl mem_categorization_ctxt {
488488
}
489489
}
490490

491-
ast::DefSelf(self_id) => {
491+
ast::DefSelf(self_id, mutbl) => {
492492
@cmt_ {
493493
id:id,
494494
span:span,
495495
cat:cat_self(self_id),
496-
mutbl: McImmutable,
496+
mutbl: if mutbl { McDeclared } else { McImmutable },
497497
ty:expr_ty
498498
}
499499
}

branches/try/src/librustc/middle/moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub fn moved_variable_node_id_from_def(def: Def) -> Option<NodeId> {
227227
DefBinding(nid, _) |
228228
DefArg(nid, _) |
229229
DefLocal(nid, _) |
230-
DefSelf(nid) => Some(nid),
230+
DefSelf(nid, _) => Some(nid),
231231

232232
_ => None
233233
}

branches/try/src/librustc/middle/resolve.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ enum Mutability {
150150

151151
enum SelfBinding {
152152
NoSelfBinding,
153-
HasSelfBinding(NodeId)
153+
HasSelfBinding(NodeId, explicit_self)
154154
}
155155

156156
impl Visitor<()> for Resolver {
@@ -3799,8 +3799,12 @@ impl Resolver {
37993799
NoSelfBinding => {
38003800
// Nothing to do.
38013801
}
3802-
HasSelfBinding(self_node_id) => {
3803-
let def_like = DlDef(DefSelf(self_node_id));
3802+
HasSelfBinding(self_node_id, explicit_self) => {
3803+
let mutable = match explicit_self.node {
3804+
sty_value(m) if m == MutMutable => true,
3805+
_ => false
3806+
};
3807+
let def_like = DlDef(DefSelf(self_node_id, mutable));
38043808
*function_value_rib.self_binding = Some(def_like);
38053809
}
38063810
}
@@ -3937,7 +3941,7 @@ impl Resolver {
39373941
// we only have self ty if it is a non static method
39383942
let self_binding = match method.explicit_self.node {
39393943
sty_static => { NoSelfBinding }
3940-
_ => { HasSelfBinding(method.self_id) }
3944+
_ => { HasSelfBinding(method.self_id, method.explicit_self) }
39413945
};
39423946

39433947
self.resolve_function(rib_kind,

branches/try/src/librustc/middle/trans/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ pub fn trans_local_var(bcx: @mut Block, def: ast::Def) -> Datum {
10991099
ast::DefLocal(nid, _) | ast::DefBinding(nid, _) => {
11001100
take_local(bcx, bcx.fcx.lllocals, nid)
11011101
}
1102-
ast::DefSelf(nid) => {
1102+
ast::DefSelf(nid, _) => {
11031103
let self_info: ValSelfData = match bcx.fcx.llself {
11041104
Some(ref self_info) => *self_info,
11051105
None => {

branches/try/src/librustc/middle/trans/inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub fn maybe_instantiate_inline(ccx: @mut CrateContext, fn_id: ast::DefId)
144144
debug!("calling inline trans_fn with self_ty {}",
145145
ty_to_str(ccx.tcx, self_ty));
146146
match mth.explicit_self.node {
147-
ast::sty_value => impl_self(self_ty, ty::ByRef),
147+
ast::sty_value(_) => impl_self(self_ty, ty::ByRef),
148148
_ => impl_self(self_ty, ty::ByCopy),
149149
}
150150
}

branches/try/src/librustc/middle/trans/meth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub fn trans_method(ccx: @mut CrateContext,
120120
debug!("calling trans_fn with self_ty {}",
121121
self_ty.repr(ccx.tcx));
122122
match method.explicit_self.node {
123-
ast::sty_value => impl_self(self_ty, ty::ByRef),
123+
ast::sty_value(_) => impl_self(self_ty, ty::ByRef),
124124
_ => impl_self(self_ty, ty::ByCopy),
125125
}
126126
}

branches/try/src/librustc/middle/typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ fn ty_of_method_or_bare_fn<AC:AstConv,RS:RegionScope + Clone + 'static>(
672672
{
673673
match self_info.explicit_self.node {
674674
ast::sty_static => None,
675-
ast::sty_value => {
675+
ast::sty_value(_) => {
676676
Some(self_info.untransformed_self_ty)
677677
}
678678
ast::sty_region(ref lifetime, mutability) => {

branches/try/src/librustc/middle/typeck/check/method.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ impl<'self> LookupContext<'self> {
10821082
ast::sty_static => {
10831083
self.bug(~"static method for object type receiver");
10841084
}
1085-
ast::sty_value => {
1085+
ast::sty_value(_) => {
10861086
ty::mk_err() // error reported in `enforce_object_limitations()`
10871087
}
10881088
ast::sty_region(*) | ast::sty_box(*) | ast::sty_uniq(*) => {
@@ -1141,7 +1141,7 @@ impl<'self> LookupContext<'self> {
11411141
through an object");
11421142
}
11431143

1144-
ast::sty_value => { // reason (a) above
1144+
ast::sty_value(_) => { // reason (a) above
11451145
self.tcx().sess.span_err(
11461146
self.expr.span,
11471147
"cannot call a method with a by-value receiver \
@@ -1198,7 +1198,7 @@ impl<'self> LookupContext<'self> {
11981198
false
11991199
}
12001200

1201-
sty_value => {
1201+
sty_value(_) => {
12021202
rcvr_matches_ty(self.fcx, rcvr_ty, candidate)
12031203
}
12041204

@@ -1369,7 +1369,7 @@ impl<'self> LookupContext<'self> {
13691369

13701370
pub fn get_mode_from_explicit_self(explicit_self: ast::explicit_self_) -> SelfMode {
13711371
match explicit_self {
1372-
sty_value => ty::ByRef,
1372+
sty_value(_) => ty::ByRef,
13731373
_ => ty::ByCopy,
13741374
}
13751375
}

branches/try/src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3254,7 +3254,7 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
32543254
defn: ast::Def)
32553255
-> ty_param_bounds_and_ty {
32563256
match defn {
3257-
ast::DefArg(nid, _) | ast::DefLocal(nid, _) | ast::DefSelf(nid) |
3257+
ast::DefArg(nid, _) | ast::DefLocal(nid, _) | ast::DefSelf(nid, _) |
32583258
ast::DefBinding(nid, _) => {
32593259
let typ = fcx.local_ty(sp, nid);
32603260
return no_params(typ);

branches/try/src/librustc/middle/typeck/check/regionck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn encl_region_of_def(fcx: @mut FnCtxt, def: ast::Def) -> ty::Region {
5858
let tcx = fcx.tcx();
5959
match def {
6060
DefLocal(node_id, _) | DefArg(node_id, _) |
61-
DefSelf(node_id) | DefBinding(node_id, _) => {
61+
DefSelf(node_id, _) | DefBinding(node_id, _) => {
6262
tcx.region_maps.encl_region(node_id)
6363
}
6464
DefUpvar(_, subdef, closure_id, body_id) => {

branches/try/src/librustdoc/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ impl Clean<SelfTy> for ast::explicit_self {
388388
fn clean(&self) -> SelfTy {
389389
match self.node {
390390
ast::sty_static => SelfStatic,
391-
ast::sty_value => SelfValue,
391+
ast::sty_value(_) => SelfValue,
392392
ast::sty_uniq => SelfOwned,
393393
ast::sty_region(lt, mt) => SelfBorrowed(lt.clean(), mt.clean()),
394394
ast::sty_box(mt) => SelfManaged(mt.clean()),
@@ -1171,7 +1171,7 @@ fn resolve_type(path: Path, tpbs: Option<~[TyParamBound]>,
11711171

11721172
let (def_id, kind) = match *d {
11731173
ast::DefFn(i, _) => (i, TypeFunction),
1174-
ast::DefSelf(i) | ast::DefSelfTy(i) => return Self(i),
1174+
ast::DefSelf(i, _) | ast::DefSelfTy(i) => return Self(i),
11751175
ast::DefTy(i) => (i, TypeEnum),
11761176
ast::DefTrait(i) => {
11771177
debug!("saw DefTrait in def_to_id");

branches/try/src/libsyntax/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub enum MethodProvenance {
227227
pub enum Def {
228228
DefFn(DefId, purity),
229229
DefStaticMethod(/* method */ DefId, MethodProvenance, purity),
230-
DefSelf(NodeId),
230+
DefSelf(NodeId, bool /* is_mutbl */),
231231
DefSelfTy(/* trait id */ NodeId),
232232
DefMod(DefId),
233233
DefForeignMod(DefId),
@@ -921,8 +921,8 @@ pub enum ret_style {
921921
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
922922
pub enum explicit_self_ {
923923
sty_static, // no self
924-
sty_value, // `self`
925-
sty_region(Option<Lifetime>, Mutability), // `&'lt self`
924+
sty_value(Mutability), // `self`
925+
sty_region(Option<Lifetime>, Mutability), // `&'lt self`
926926
sty_box(Mutability), // `@self`
927927
sty_uniq // `~self`
928928
}

branches/try/src/libsyntax/ast_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn def_id_of_def(d: Def) -> DefId {
6666
DefUse(id) | DefStruct(id) | DefTrait(id) | DefMethod(id, _) => {
6767
id
6868
}
69-
DefArg(id, _) | DefLocal(id, _) | DefSelf(id) | DefSelfTy(id)
69+
DefArg(id, _) | DefLocal(id, _) | DefSelf(id, _) | DefSelfTy(id)
7070
| DefUpvar(id, _, _, _) | DefBinding(id, _) | DefRegion(id)
7171
| DefTyParamBinder(id) | DefLabel(id) => {
7272
local_def(id)

branches/try/src/libsyntax/ext/deriving/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub fn get_explicit_self(cx: @ExtCtxt, span: Span, self_ptr: &Option<PtrTy>)
240240
let self_path = cx.expr_self(span);
241241
match *self_ptr {
242242
None => {
243-
(self_path, respan(span, ast::sty_value))
243+
(self_path, respan(span, ast::sty_value(ast::MutImmutable)))
244244
}
245245
Some(ref ptr) => {
246246
let self_ty = respan(

branches/try/src/libsyntax/parse/parser.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3438,15 +3438,11 @@ impl Parser {
34383438

34393439
// parse the argument list and result type of a function
34403440
// that may have a self type.
3441-
fn parse_fn_decl_with_self(
3442-
&self,
3443-
parse_arg_fn:
3444-
&fn(&Parser) -> arg
3445-
) -> (explicit_self, fn_decl) {
3446-
fn maybe_parse_explicit_self(
3447-
cnstr: &fn(v: Mutability) -> ast::explicit_self_,
3448-
p: &Parser
3449-
) -> ast::explicit_self_ {
3441+
fn parse_fn_decl_with_self(&self, parse_arg_fn: &fn(&Parser) -> arg)
3442+
-> (explicit_self, fn_decl) {
3443+
3444+
fn maybe_parse_explicit_self(cnstr: &fn(v: Mutability) -> ast::explicit_self_,
3445+
p: &Parser) -> ast::explicit_self_ {
34503446
// We need to make sure it isn't a type
34513447
if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) ||
34523448
((p.look_ahead(1, |t| token::is_keyword(keywords::Const, t)) ||
@@ -3529,20 +3525,26 @@ impl Parser {
35293525
}
35303526
token::IDENT(*) if self.is_self_ident() => {
35313527
self.bump();
3532-
sty_value
3528+
sty_value(MutImmutable)
35333529
}
35343530
token::BINOP(token::STAR) => {
35353531
// Possibly "*self" or "*mut self" -- not supported. Try to avoid
35363532
// emitting cryptic "unexpected token" errors.
35373533
self.bump();
3538-
if self.token_is_mutability(self.token) {
3539-
self.bump();
3540-
}
3534+
let mutability = if self.token_is_mutability(self.token) {
3535+
self.parse_mutability()
3536+
} else { MutImmutable };
35413537
if self.is_self_ident() {
35423538
self.span_err(*self.span, "cannot pass self by unsafe pointer");
35433539
self.bump();
35443540
}
3545-
sty_value
3541+
sty_value(mutability)
3542+
}
3543+
_ if self.token_is_mutability(self.token) &&
3544+
self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => {
3545+
let mutability = self.parse_mutability();
3546+
self.expect_self_ident();
3547+
sty_value(mutability)
35463548
}
35473549
_ => {
35483550
sty_static

branches/try/src/libsyntax/print/pprust.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,10 @@ pub fn explicit_self_to_str(explicit_self: &ast::explicit_self_, intr: @ident_in
16861686
pub fn print_explicit_self(s: @ps, explicit_self: ast::explicit_self_) -> bool {
16871687
match explicit_self {
16881688
ast::sty_static => { return false; }
1689-
ast::sty_value => { word(s.s, "self"); }
1689+
ast::sty_value(m) => {
1690+
print_mutability(s, m);
1691+
word(s.s, "self");
1692+
}
16901693
ast::sty_uniq => { word(s.s, "~self"); }
16911694
ast::sty_region(ref lt, m) => {
16921695
word(s.s, "&");

0 commit comments

Comments
 (0)