Unresolved import error [E0432]


I’m trying to make extension as in this illustration.

I got error [E0432] and read this but could not understand what shall I do!

The error thread I got is:

/Users/hasan/.cargo/bin/cargo run --color=always --package rust01
–bin rust01 Compiling rust01 v0.1.0 (file:///Users/hasan/PycharmProjects/rust01) error[E0432]: unresolved
import rustc::plugin --> src/lib.rs:6:12 | 6 | use
rustc::plugin::Registry; | ^^^^^^ Could not find plugin
in rustc

error[E0432]: unresolved import
syntax::ext::base::SyntaxExtension::Modifier --> src/lib.rs:12:5
| 12 | use syntax::ext::base::SyntaxExtension::Modifier; |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no Modifier in

error[E0432]: unresolved import syntax::parse::token::intern -->
src/lib.rs:13:5 | 13 | use syntax::parse::token::intern; |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no intern in parse::token

error: aborting due to 3 previous errors

For more information about this error, try rustc --explain E0432.
error: Could not compile rust01.

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

Process finished with exit code 101

This happened with my ode:

#![feature(plugin_registrar, rustc_private)]

extern crate syntax; extern crate rustc;

use rustc::plugin::Registry;

use syntax::ptr::P; use syntax::ast::{Item, MetaItem}; use syntax::ext::base::ExtCtxt; use syntax::codemap::Span; use syntax::ext::base::SyntaxExtension::Modifier; use syntax::parse::token::intern;

#[plugin_registrar] pub fn registrar(reg: &mut Registry) {
    reg.register_syntax_extension(intern("extension"), Modifier(Box::new(expand))); }

fn expand(_: &mut ExtCtxt, _: Span, _: &MetaItem, item: P<Item>) -> P<Item> {
    println!("Hello world!");
    return item; }

My app structure is as shown below:

The Cargo.toml at bin is:

name = "hello_world"
version = "0.1.0"
authors = ["hasan"]

extension = { path = "./extension" }

The Cargo.toml at lib is:

name = "extension"
version = "0.1.0"
authors = ["hasan"]


plugin = true