Skip to content

Commit 33b6ec7

Browse files
committed
---
yaml --- r: 234781 b: refs/heads/tmp c: 5f66c70 h: refs/heads/master i: 234779: 5e0ca78 v: v3
1 parent d0727ed commit 33b6ec7

File tree

13 files changed

+154
-123
lines changed

13 files changed

+154
-123
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: f859507de8c410b648d934d8f5ec1c52daac971d
28+
refs/heads/tmp: 5f66c701b108bfaa65cfff175074afa008e98294
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/doc/complement-project-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Existing languages at this level of abstraction and efficiency are unsatisfactor
2222

2323
# Is any part of this thing production-ready?
2424

25-
Yes!
25+
No. Feel free to play around, but don't expect completeness or stability yet. Expect incompleteness and breakage.
2626

2727
# Is this a completely Mozilla-planned and orchestrated thing?
2828

branches/tmp/src/doc/trpl/error-handling.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn find(haystack: &str, needle: char) -> Option<usize> {
154154
}
155155
```
156156

157-
Notice that when this function finds a matching character, it doesn't just
157+
Notice that when this function finds a matching character, it doen't just
158158
return the `offset`. Instead, it returns `Some(offset)`. `Some` is a variant or
159159
a *value constructor* for the `Option` type. You can think of it as a function
160160
with the type `fn<T>(value: T) -> Option<T>`. Correspondingly, `None` is also a
@@ -840,7 +840,7 @@ example, the very last call to `map` multiplies the `Ok(...)` value (which is
840840
an `i32`) by `2`. If an error had occurred before that point, this operation
841841
would have been skipped because of how `map` is defined.
842842

843-
`map_err` is the trick that makes all of this work. `map_err` is just like
843+
`map_err` is the trick the makes all of this work. `map_err` is just like
844844
`map`, except it applies a function to the `Err(...)` value of a `Result`. In
845845
this case, we want to convert all of our errors to one type: `String`. Since
846846
both `io::Error` and `num::ParseIntError` implement `ToString`, we can call the

branches/tmp/src/libcore/ptr.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,13 @@ fnptr_impls_args! { A, B }
385385
fnptr_impls_args! { A, B, C }
386386
fnptr_impls_args! { A, B, C, D }
387387
fnptr_impls_args! { A, B, C, D, E }
388+
fnptr_impls_args! { A, B, C, D, E, F }
389+
fnptr_impls_args! { A, B, C, D, E, F, G }
390+
fnptr_impls_args! { A, B, C, D, E, F, G, H }
391+
fnptr_impls_args! { A, B, C, D, E, F, G, H, I }
392+
fnptr_impls_args! { A, B, C, D, E, F, G, H, I, J }
393+
fnptr_impls_args! { A, B, C, D, E, F, G, H, I, J, K }
394+
fnptr_impls_args! { A, B, C, D, E, F, G, H, I, J, K, L }
388395

389396
// Comparison for pointers
390397
#[stable(feature = "rust1", since = "1.0.0")]

branches/tmp/src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
13081308
match self.inh.locals.borrow().get(&nid) {
13091309
Some(&t) => t,
13101310
None => {
1311-
span_err!(self.tcx().sess, span, E0513,
1312-
"no type for local variable {}",
1313-
nid);
1311+
self.tcx().sess.span_err(
1312+
span,
1313+
&format!("no type for local variable {}", nid));
13141314
self.tcx().types.err
13151315
}
13161316
}

branches/tmp/src/librustc_typeck/diagnostics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3354,6 +3354,5 @@ register_diagnostics! {
33543354
// type because its default value `{}` references the type `Self`"
33553355
E0399, // trait items need to be implemented because the associated
33563356
// type `{}` was overridden
3357-
E0436, // functional record update requires a struct
3358-
E0513, // no type for local variable ..
3357+
E0436, // functional record update requires a struct
33593358
}

branches/tmp/src/libsyntax/ast.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub use self::Item_::*;
2828
pub use self::KleeneOp::*;
2929
pub use self::Lit_::*;
3030
pub use self::LitIntType::*;
31+
pub use self::Mac_::*;
3132
pub use self::MacStmtStyle::*;
3233
pub use self::MetaItem_::*;
3334
pub use self::Mutability::*;
@@ -1131,13 +1132,12 @@ pub type Mac = Spanned<Mac_>;
11311132
/// is being invoked, and the vector of token-trees contains the source
11321133
/// of the macro invocation.
11331134
///
1134-
/// NB: the additional ident for a macro_rules-style macro is actually
1135-
/// stored in the enclosing item. Oog.
1135+
/// There's only one flavor, now, so this could presumably be simplified.
11361136
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
1137-
pub struct Mac_ {
1138-
pub path: Path,
1139-
pub tts: Vec<TokenTree>,
1140-
pub ctxt: SyntaxContext,
1137+
pub enum Mac_ {
1138+
// NB: the additional ident for a macro_rules-style macro is actually
1139+
// stored in the enclosing item. Oog.
1140+
MacInvocTT(Path, Vec<TokenTree>, SyntaxContext), // new macro-invocation
11411141
}
11421142

11431143
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]

branches/tmp/src/libsyntax/ext/expand.rs

Lines changed: 88 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
use ast::{Block, Crate, DeclLocal, ExprMac, PatMac};
12-
use ast::{Local, Ident, Mac_};
12+
use ast::{Local, Ident, MacInvocTT};
1313
use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtDecl, StmtMac};
1414
use ast::{StmtExpr, StmtSemi};
1515
use ast::TokenTree;
@@ -509,75 +509,78 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac,
509509
F: for<'a> FnOnce(Box<MacResult+'a>) -> Option<T>,
510510
G: FnOnce(T, Mrk) -> T,
511511
{
512-
// it would almost certainly be cleaner to pass the whole
513-
// macro invocation in, rather than pulling it apart and
514-
// marking the tts and the ctxt separately. This also goes
515-
// for the other three macro invocation chunks of code
516-
// in this file.
517-
518-
let Mac_ { path: pth, tts, .. } = mac.node;
519-
if pth.segments.len() > 1 {
520-
fld.cx.span_err(pth.span,
521-
"expected macro name without module \
522-
separators");
523-
// let compilation continue
524-
return None;
525-
}
526-
let extname = pth.segments[0].identifier.name;
527-
match fld.cx.syntax_env.find(&extname) {
528-
None => {
529-
fld.cx.span_err(
530-
pth.span,
531-
&format!("macro undefined: '{}!'",
532-
&extname));
512+
match mac.node {
513+
// it would almost certainly be cleaner to pass the whole
514+
// macro invocation in, rather than pulling it apart and
515+
// marking the tts and the ctxt separately. This also goes
516+
// for the other three macro invocation chunks of code
517+
// in this file.
518+
// Token-tree macros:
519+
MacInvocTT(pth, tts, _) => {
520+
if pth.segments.len() > 1 {
521+
fld.cx.span_err(pth.span,
522+
"expected macro name without module \
523+
separators");
524+
// let compilation continue
525+
return None;
526+
}
527+
let extname = pth.segments[0].identifier.name;
528+
match fld.cx.syntax_env.find(&extname) {
529+
None => {
530+
fld.cx.span_err(
531+
pth.span,
532+
&format!("macro undefined: '{}!'",
533+
&extname));
533534

534-
// let compilation continue
535-
None
536-
}
537-
Some(rc) => match *rc {
538-
NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {
539-
fld.cx.bt_push(ExpnInfo {
540-
call_site: span,
541-
callee: NameAndSpan {
542-
format: MacroBang(extname),
543-
span: exp_span,
544-
allow_internal_unstable: allow_internal_unstable,
545-
},
546-
});
547-
let fm = fresh_mark();
548-
let marked_before = mark_tts(&tts[..], fm);
549-
550-
// The span that we pass to the expanders we want to
551-
// be the root of the call stack. That's the most
552-
// relevant span and it's the actual invocation of
553-
// the macro.
554-
let mac_span = fld.cx.original_span();
555-
556-
let opt_parsed = {
557-
let expanded = expandfun.expand(fld.cx,
558-
mac_span,
559-
&marked_before[..]);
560-
parse_thunk(expanded)
561-
};
562-
let parsed = match opt_parsed {
563-
Some(e) => e,
564-
None => {
535+
// let compilation continue
536+
None
537+
}
538+
Some(rc) => match *rc {
539+
NormalTT(ref expandfun, exp_span, allow_internal_unstable) => {
540+
fld.cx.bt_push(ExpnInfo {
541+
call_site: span,
542+
callee: NameAndSpan {
543+
format: MacroBang(extname),
544+
span: exp_span,
545+
allow_internal_unstable: allow_internal_unstable,
546+
},
547+
});
548+
let fm = fresh_mark();
549+
let marked_before = mark_tts(&tts[..], fm);
550+
551+
// The span that we pass to the expanders we want to
552+
// be the root of the call stack. That's the most
553+
// relevant span and it's the actual invocation of
554+
// the macro.
555+
let mac_span = fld.cx.original_span();
556+
557+
let opt_parsed = {
558+
let expanded = expandfun.expand(fld.cx,
559+
mac_span,
560+
&marked_before[..]);
561+
parse_thunk(expanded)
562+
};
563+
let parsed = match opt_parsed {
564+
Some(e) => e,
565+
None => {
566+
fld.cx.span_err(
567+
pth.span,
568+
&format!("non-expression macro in expression position: {}",
569+
extname
570+
));
571+
return None;
572+
}
573+
};
574+
Some(mark_thunk(parsed,fm))
575+
}
576+
_ => {
565577
fld.cx.span_err(
566578
pth.span,
567-
&format!("non-expression macro in expression position: {}",
568-
extname
569-
));
570-
return None;
579+
&format!("'{}' is not a tt-style macro",
580+
extname));
581+
None
571582
}
572-
};
573-
Some(mark_thunk(parsed,fm))
574-
}
575-
_ => {
576-
fld.cx.span_err(
577-
pth.span,
578-
&format!("'{}' is not a tt-style macro",
579-
extname));
580-
None
583+
}
581584
}
582585
}
583586
}
@@ -681,11 +684,15 @@ fn contains_macro_use(fld: &mut MacroExpander, attrs: &[ast::Attribute]) -> bool
681684
// logic as for expression-position macro invocations.
682685
pub fn expand_item_mac(it: P<ast::Item>,
683686
fld: &mut MacroExpander) -> SmallVector<P<ast::Item>> {
684-
let (extname, path_span, tts, span, attrs, ident) = it.and_then(|it| match it.node {
685-
ItemMac(codemap::Spanned { node: Mac_ { path, tts, .. }, .. }) =>
686-
(path.segments[0].identifier.name, path.span, tts, it.span, it.attrs, it.ident),
687+
let (extname, path_span, tts, span, attrs, ident) = it.and_then(|it| { match it.node {
688+
ItemMac(codemap::Spanned {
689+
node: MacInvocTT(pth, tts, _),
690+
..
691+
}) => {
692+
(pth.segments[0].identifier.name, pth.span, tts, it.span, it.attrs, it.ident)
693+
}
687694
_ => fld.cx.span_bug(it.span, "invalid item macro invocation")
688-
});
695+
}});
689696

690697
let fm = fresh_mark();
691698
let items = {
@@ -1053,7 +1060,11 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
10531060
}
10541061
p.map(|ast::Pat {node, span, ..}| {
10551062
let (pth, tts) = match node {
1056-
PatMac(mac) => (mac.node.path, mac.node.tts),
1063+
PatMac(mac) => match mac.node {
1064+
MacInvocTT(pth, tts, _) => {
1065+
(pth, tts)
1066+
}
1067+
},
10571068
_ => unreachable!()
10581069
};
10591070
if pth.segments.len() > 1 {
@@ -1635,10 +1646,12 @@ impl Folder for Marker {
16351646
}
16361647
fn fold_mac(&mut self, Spanned {node, span}: ast::Mac) -> ast::Mac {
16371648
Spanned {
1638-
node: Mac_ {
1639-
path: self.fold_path(node.path),
1640-
tts: self.fold_tts(&node.tts),
1641-
ctxt: mtwt::apply_mark(self.mark, node.ctxt),
1649+
node: match node {
1650+
MacInvocTT(path, tts, ctxt) => {
1651+
MacInvocTT(self.fold_path(path),
1652+
self.fold_tts(&tts[..]),
1653+
mtwt::apply_mark(self.mark, ctxt))
1654+
}
16421655
},
16431656
span: span,
16441657
}

branches/tmp/src/libsyntax/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ struct MacroVisitor<'a> {
666666

667667
impl<'a, 'v> Visitor<'v> for MacroVisitor<'a> {
668668
fn visit_mac(&mut self, mac: &ast::Mac) {
669-
let path = &mac.node.path;
669+
let ast::MacInvocTT(ref path, _, _) = mac.node;
670670
let id = path.segments.last().unwrap().identifier;
671671

672672
// Issue 22234: If you add a new case here, make sure to also

branches/tmp/src/libsyntax/fold.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,10 @@ pub fn noop_fold_explicit_self<T: Folder>(Spanned {span, node}: ExplicitSelf, fl
567567

568568
pub fn noop_fold_mac<T: Folder>(Spanned {node, span}: Mac, fld: &mut T) -> Mac {
569569
Spanned {
570-
node: Mac_ {
571-
path: fld.fold_path(node.path),
572-
tts: fld.fold_tts(&node.tts),
573-
ctxt: node.ctxt,
570+
node: match node {
571+
MacInvocTT(p, tts, ctxt) => {
572+
MacInvocTT(fld.fold_path(p), fld.fold_tts(&tts), ctxt)
573+
}
574574
},
575575
span: fld.new_span(span)
576576
}

branches/tmp/src/libsyntax/parse/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,10 @@ mod tests {
10901090
"foo!( fn main() { body } )".to_string(), vec![], &sess);
10911091

10921092
let tts = match expr.node {
1093-
ast::ExprMac(ref mac) => mac.node.tts.clone(),
1093+
ast::ExprMac(ref mac) => {
1094+
let ast::MacInvocTT(_, ref tts, _) = mac.node;
1095+
tts.clone()
1096+
}
10941097
_ => panic!("not a macro"),
10951098
};
10961099

0 commit comments

Comments
 (0)