无法构建插件示例

Cannot build plugin example

我正在尝试根据书中的内容构建 the plugin example,但它不起作用:

rustc failed to resolve: could not find `quote` in `ext`

我该怎么办?该示例甚至没有任何构建说明。这是故意的吗?

code in the unstable book and code in current source of rust不一样

在代码中,它说:

This code also appears in src/doc/unstable-book/src/language-features/plugin.md.

Please keep the two copies in sync! FIXME: have rustdoc read this file

但似乎直到现在还没有修复。

你的错误发生在不稳定书的use syntax::ext::quote::rt::Span;,目前应该是use syntax_pos::Span;

由于这本书是针对 rust 中不稳定的特性,并且根据 top page of the book,

Because this documentation relates to unstable features, we make no guarantees that what is contained here is accurate or up to date. It's developed on a best-effort basis. Each page will have a link to its tracking issue with the latest developments; you might want to check those as well.

因此本书其他代码中可能存在类似问题