Rocket: Compile Error: error[E0432]: unresolved import `syntax::ast::SpannedIdent`

Created on 7 Apr 2018  路  6Comments  路  Source: SergioBenitez/Rocket

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 `..`.
nightly breakage

Most helpful comment

v0.3.8 has been released!

All 6 comments

I've tried to fix it in pear_codegen-0.0.14/src/lib.rs:

27,28c27
< use syntax::ast::{ItemKind, MetaItem, FnDecl, PatKind, SpannedIdent};
< use syntax::codemap::Spanned;
---
> use syntax::ast::{ItemKind, MetaItem, FnDecl, PatKind};
46c45
< fn get_input_from_decl(ecx: &ExtCtxt, decl: &FnDecl) -> SpannedIdent {
---
> fn get_input_from_decl(ecx: &ExtCtxt, decl: &FnDecl) -> Ident {
53c52
<     Spanned { node: Ident::from_str("__dummy"), span: pat.span }
---
>     Ident::from_str("__dummy").with_span_pos(pat.span)
131c130
<             let penultimate = path.segments[num_segs - 2].identifier.name.as_str();
---
>             let penultimate = path.segments[num_segs - 2].ident.name.as_str();
138c137
<         let last = path.segments[num_segs - 1].identifier.name.as_str();
---
>         let last = path.segments[num_segs - 1].ident.name.as_str();
147c146
<     let first_ident = path.segments[0].identifier.name.as_str();
---
>     let first_ident = path.segments[0].ident.name.as_str();

but with above change-set applied I get another error:

   Compiling rocket v0.3.7
error[E0425]: cannot find value `a` in this scope
  --> /home/mb/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.3.7/src/http/parse/media_type.rs:46:31
   |
46 |             let indexed_key = IndexedStr::from(key, source).expect("key");
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `a` in this scope
  --> /home/mb/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.3.7/src/http/parse/media_type.rs:47:31
   |
47 |             let indexed_val = IndexedStr::from(value, source).expect("val");
   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find value `a` in this scope
  --> /home/mb/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket-0.3.7/src/http/parse/accept.rs:27:26
   |
27 |         media_types.push(QMediaType(media_type, weight));
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0425`.
error: Could not compile `rocket`.

This is fixed in pear_codegen 0.0.15 but now rocket_codegen itself fails to build:

error[E0609]: no field `name` on type `&syntax::ast::MetaItem`                                                                    
  --> /home/corentih/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.3.7/src/utils/meta_item_ext.rs:13:57        
   |                                                                                                                              
13 |             MetaItemKind::NameValue(ref l) => Some((&mi.name, l)),                                                           
   |                                                         ^^^^                                                                 

error[E0609]: no field `node` on type `&syntax::ast::Ident`                                                                       
  --> /home/corentih/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.3.7/src/utils/arg_ext.rs:18:60              
   |                                                                                                                              
18 |             PatKind::Ident(_, ref ident, _) => Some(&ident.node),                                                            
   |                                                            ^^^^                                                              

error[E0599]: no method named `name` found for type `&syntax::ast::MetaItem` in the current scope                                 
   --> /home/corentih/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.3.7/src/parser/route.rs:173:52             
    |                                                                                                                             
173 |         if let Ok(method) = Method::from_str(&word.name().as_str()) {                                                       
    |                                                    ^^^^                                                                     
    |                                                                                                                             
    = help: items from traits can only be used if the trait is implemented and in scope                                           
    = note: the following trait defines an item `name`, perhaps you need to implement it:                                         
            candidate #1: `utils::arg_ext::ArgExt`                                                                                

error[E0599]: no method named `name` found for type `&syntax::ast::MetaItem` in the current scope                                 
   --> /home/corentih/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.3.7/src/parser/route.rs:178:72             
    |                                                                                                                             
178 |             let msg = format!("'{}' is not a valid HTTP method.", word.name());                                             
    |                                                                        ^^^^                                                 
    |                                                                                                                             
    = help: items from traits can only be used if the trait is implemented and in scope                                           
    = note: the following trait defines an item `name`, perhaps you need to implement it:                                         
            candidate #1: `utils::arg_ext::ArgExt`                                                                                

error[E0609]: no field `identifier` on type `&mut syntax::ast::PathSegment`                                                       
  --> /home/corentih/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.3.7/src/macros/mod.rs:16:18                 
   |                                                                                                                              
16 |         last_seg.identifier = last_seg.identifier.prepend(prefix);                                                           
   |                  ^^^^^^^^^^                                                                                                  

error[E0609]: no field `identifier` on type `&mut syntax::ast::PathSegment`                                                       
  --> /home/corentih/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_codegen-0.3.7/src/macros/mod.rs:16:40                 
   |                                                                                                                              
16 |         last_seg.identifier = last_seg.identifier.prepend(prefix);                                                           
   |                                        ^^^^^^^^^^                                                                            

error: aborting due to 6 previous errors                                                                                          

Some errors occurred: E0599, E0609.                                                                                               
For more information about an error, try `rustc --explain E0599`.                                                                 
error: Could not compile `rocket_codegen`.                                                                                        

To learn more, run the command again with --verbose.                                                                              

v0.3.8 has been released!

That was fast! Thanks @SergioBenitez!

Thanks a lot

well done

Was this page helpful?
0 / 5 - 0 ratings