...
 
Commits (3)
......@@ -17,7 +17,7 @@ license = "MIT"
name = "binder"
[dependencies]
syntex_syntax = "0.50.0"
syntex_errors = "0.50.0"
syntex_pos = "0.50.0"
toml = "0.1.30"
syntex_syntax = "0.58.1"
syntex_errors = "0.58.1"
syntex_pos = "0.58.1"
toml = "0.4.0"
......@@ -26,16 +26,17 @@ pub fn docs_from_attrs(attrs: &[ast::Attribute], prepend: &str, append: &str) ->
let mut buffer = String::new();
for attr in attrs {
match attr.node.value.node {
ast::MetaItemKind::NameValue(ref name, ref val) if *name == "doc" => match val.node {
let name = attr.value.name;
match attr.value.node {
ast::MetaItemKind::NameValue(ref val) if name == "doc" => match val.node {
// Docstring attributes omit the trailing newline.
ast::LitKind::Str(ref docs, _) => {
let docs = &docs[3..];
ast::LitKind::Str(docs, _) => {
let docs = &docs.as_str()[3..];
buffer.push_str(&format!(
"{}{}{}\n",
prepend,
docs.trim(),
append,
"{}{}{}\n",
prepend,
docs.trim(),
append,
))
},
_ => unreachable!("docs must be literal strings"),
......@@ -185,7 +186,7 @@ where F: FnMut(&ast::Variant_) {
pub fn ty_is_generic(ty: &ast::Ty) -> bool {
match ty.node {
ast::TyKind::Path(_, ref path) => path.segments.iter().any(
|segment| !segment.parameters.is_empty()
|segment| !segment.parameters.is_none()
),
_ => false,
}
......
......@@ -272,17 +272,17 @@ fn source_file_from_cargo() -> std::result::Result<String, std::io::Error> {
let mut buf = String::new();
try!(cargo_toml.read_to_string(&mut buf));
let table = match toml::Parser::new(&buf).parse() {
Some(t) => t,
None => return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"cargo manifest could not be parsed",
)),
let table = match buf.parse::<toml::Value>() {
Ok(t) => t,
Err(e) => return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("cargo manifest could not be parsed: {}", e),
)),
};
// If not explicitly stated then defaults to `src/lib.rs`.
Ok(table.get("lib")
.and_then(|t| t.lookup("path"))
.and_then(|t| t.get("path"))
.and_then(|s| s.as_str())
.unwrap_or(default)
.into())
......
......@@ -5,6 +5,7 @@ use compiler::session::Session;
use compiler::Stop;
use compiler::utils;
use syntax::ast;
use syntax::symbol;
/// Type responsible for generating a given language's bindings.
///
......@@ -40,7 +41,7 @@ fn check_pub_use(item: &ast::Item, expected: &ast::Path) -> bool {
if let ast::Visibility::Public = item.vis {
// Easiest way to ensure all of API has been brought into scope.
if let ast::ViewPath_::ViewPathGlob(ref path) = path.node {
return path.segments == expected.segments;
return segments_sans_root(&path.segments) == segments_sans_root(&expected.segments);
}
}
}
......@@ -48,6 +49,14 @@ fn check_pub_use(item: &ast::Item, expected: &ast::Path) -> bool {
false
}
fn segments_sans_root(segments: &[ast::PathSegment]) -> Vec<ast::PathSegment> {
segments.into_iter()
.filter(|s| s.identifier != symbol::keywords::CrateRoot.ident())
// TODO: can we avoid the clone here?
.map(Clone::clone)
.collect()
}
/// Recursively call `.compile_crate()` on all compilers.
fn apply_compile_crate(krate: &ast::Crate, session: &mut Session, compilers: &mut [Generator]) -> Result<(), Stop> {
......