diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2015-07-31 00:04:06 -0700 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2015-09-03 10:02:36 +1200 |
| commit | facdf2ebb1dce9400a8c8ef0d85d7d278654effb (patch) | |
| tree | 3ba46bd98df35b4b5d1bc5f1ba491d14adb6f373 /src/libsyntax | |
| parent | cfd76b364cd01695517467299618ef63f1c0cc07 (diff) | |
| download | rust-facdf2ebb1dce9400a8c8ef0d85d7d278654effb.tar.gz rust-facdf2ebb1dce9400a8c8ef0d85d7d278654effb.zip | |
Add an intital HIR and lowering step
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast_util.rs | 42 | ||||
| -rw-r--r-- | src/libsyntax/entry.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 2 |
3 files changed, 5 insertions, 41 deletions
diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 43476df3a8e..d024ff117f5 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -216,12 +216,6 @@ pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> { }) } -pub fn name_to_dummy_lifetime(name: Name) -> Lifetime { - Lifetime { id: DUMMY_NODE_ID, - span: codemap::DUMMY_SP, - name: name } -} - /// Generate a "pretty" name for an `impl` from its type and trait. /// This is designed so that symbols of `impl`'d methods give some /// hint of where they came from, (previously they would all just be @@ -498,7 +492,7 @@ impl<'a, 'v, O: IdVisitingOperation> Visitor<'v> for IdVisitor<'a, O> { } pub struct IdRangeComputingVisitor { - result: IdRange, + pub result: IdRange, } impl IdRangeComputingVisitor { @@ -535,40 +529,6 @@ pub fn compute_id_range_for_fn_body(fk: FnKind, id_visitor.operation.result } -pub fn walk_pat<F>(pat: &Pat, mut it: F) -> bool where F: FnMut(&Pat) -> bool { - // FIXME(#19596) this is a workaround, but there should be a better way - fn walk_pat_<G>(pat: &Pat, it: &mut G) -> bool where G: FnMut(&Pat) -> bool { - if !(*it)(pat) { - return false; - } - - match pat.node { - PatIdent(_, _, Some(ref p)) => walk_pat_(&**p, it), - PatStruct(_, ref fields, _) => { - fields.iter().all(|field| walk_pat_(&*field.node.pat, it)) - } - PatEnum(_, Some(ref s)) | PatTup(ref s) => { - s.iter().all(|p| walk_pat_(&**p, it)) - } - PatBox(ref s) | PatRegion(ref s, _) => { - walk_pat_(&**s, it) - } - PatVec(ref before, ref slice, ref after) => { - before.iter().all(|p| walk_pat_(&**p, it)) && - slice.iter().all(|p| walk_pat_(&**p, it)) && - after.iter().all(|p| walk_pat_(&**p, it)) - } - PatMac(_) => panic!("attempted to analyze unexpanded pattern"), - PatWild(_) | PatLit(_) | PatRange(_, _) | PatIdent(_, _, _) | - PatEnum(_, _) | PatQPath(_, _) => { - true - } - } - } - - walk_pat_(pat, &mut it) -} - /// Returns true if the given struct def is tuple-like; i.e. that its fields /// are unnamed. pub fn struct_def_is_tuple_like(struct_def: &ast::StructDef) -> bool { diff --git a/src/libsyntax/entry.rs b/src/libsyntax/entry.rs index b6c5d0066a2..2b4df3186de 100644 --- a/src/libsyntax/entry.rs +++ b/src/libsyntax/entry.rs @@ -19,6 +19,8 @@ pub enum EntryPointType { OtherMain, // Not an entry point, but some other function named main } +// Beware, this is duplicated in librustc/middle/entry.rs, make sure to keep +// them in sync. pub fn entry_point_type(item: &Item, depth: usize) -> EntryPointType { match item.node { ItemFn(..) => { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 78234a8efce..0c0c68c89a1 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -356,12 +356,14 @@ pub struct GatedCfg { span: Span, index: usize, } + impl Ord for GatedCfg { fn cmp(&self, other: &GatedCfg) -> cmp::Ordering { (self.span.lo.0, self.span.hi.0, self.index) .cmp(&(other.span.lo.0, other.span.hi.0, other.index)) } } + impl PartialOrd for GatedCfg { fn partial_cmp(&self, other: &GatedCfg) -> Option<cmp::Ordering> { Some(self.cmp(other)) |
