SergioBenitez / Pear

A pear is a fruit.
Apache License 2.0
50 stars 13 forks source link

error[E0432]: unresolved import `syntax::ast::SpannedIdent` #3

Closed zengsai closed 6 years ago

zengsai commented 6 years ago

got this error while compile rocket 0.3.7 using toolchain nightly-x86_64-apple-darwin (default) rustc 1.27.0-nightly (eeea94c11 2018-04-06):

Compiling pear_codegen v0.0.14
   Compiling cookie v0.9.2
error[E0432]: unresolved import `syntax::ast::SpannedIdent`
  --> /Users/Sai/.cargo/registry/src/github.com-1ecc6299db9ec823/pear_codegen-0.0.14/src/lib.rs:27:56
   |
27 | use syntax::ast::{ItemKind, MetaItem, FnDecl, PatKind, SpannedIdent};
   |                                                        ^^^^^^^^^^^^ no `SpannedIdent` in `ast`

error[E0609]: no field `identifier` on type `syntax::ast::PathSegment`
   --> /Users/Sai/.cargo/registry/src/github.com-1ecc6299db9ec823/pear_codegen-0.0.14/src/lib.rs:131:59
    |
131 |             let penultimate = path.segments[num_segs - 2].identifier.name.as_str();
    |                                                           ^^^^^^^^^^ unknown field
    |
    = note: available fields are: `ident`, `parameters`

error[E0609]: no field `identifier` on type `syntax::ast::PathSegment`
   --> /Users/Sai/.cargo/registry/src/github.com-1ecc6299db9ec823/pear_codegen-0.0.14/src/lib.rs:138:48
    |
138 |         let last = path.segments[num_segs - 1].identifier.name.as_str();
    |                                                ^^^^^^^^^^ unknown field
    |
    = note: available fields are: `ident`, `parameters`

error[E0609]: no field `identifier` on type `syntax::ast::PathSegment`
   --> /Users/Sai/.cargo/registry/src/github.com-1ecc6299db9ec823/pear_codegen-0.0.14/src/lib.rs:147:40
    |
147 |     let first_ident = path.segments[0].identifier.name.as_str();
    |                                        ^^^^^^^^^^ unknown field
    |
    = note: available fields are: `ident`, `parameters`

error: aborting due to 4 previous errors

Some errors occurred: E0432, E0609.
For more information about an error, try `rustc --explain E0432`.
error: Could not compile `pear_codegen`.
warning: build failed, waiting for other jobs to finish...
error: build failed

the reason is libsyntax get rid of SpannedInde:

@@ -101,11 +99,8 @@ impl fmt::Display for Path {
 impl Path {
     // convert a span and an identifier to the corresponding
...skipping...
    Get rid of `SpannedIdent`

diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index a3839a861c..652aaa795c 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -541,7 +541,7 @@ impl Pat {
         let node = match &self.node {
             PatKind::Wild => TyKind::Infer,
             PatKind::Ident(BindingMode::ByValue(Mutability::Immutable), ident, None) =>
-                TyKind::Path(None, Path::from_ident(ident.span, ident.node)),
+                TyKind::Path(None, Path::from_ident(ident.span, *ident)),
             PatKind::Path(qself, path) => TyKind::Path(qself.clone(), path.clone()),
             PatKind::Mac(mac) => TyKind::Mac(mac.clone()),
             PatKind::Ref(pat, mutbl) =>
@@ -638,7 +638,7 @@ pub enum PatKind {
     /// or a unit struct/variant pattern, or a const pattern (in the last two cases the third
     /// field must be `None`). Disambiguation cannot be done with parser alone, so it happens
     /// during name resolution.
-    Ident(BindingMode, SpannedIdent, Option<P<Pat>>),
+    Ident(BindingMode, Ident, Option<P<Pat>>),

     /// A struct or struct variant pattern, e.g. `Variant {x, y, ..}`.
     /// The `bool` is `true` in the presence of a `..`.
SergioBenitez commented 6 years ago

Fixed in a7f11169ee3a54dc92c693b865a786855f23e6b4.