Skip to content

Commit

Permalink
Use error reporting provided by Meta
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 18, 2023
1 parent cea0cef commit e33fac6
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 80 deletions.
2 changes: 1 addition & 1 deletion gen/build/Cargo.toml
Expand Up @@ -25,7 +25,7 @@ once_cell = "1.9"
proc-macro2 = { version = "1.0.39", default-features = false, features = ["span-locations"] }
quote = { version = "1.0", default-features = false }
scratch = "1.0"
syn = { version = "2.0.0", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }
syn = { version = "2.0.1", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }

[dev-dependencies]
cxx = { version = "1.0", path = "../.." }
Expand Down
2 changes: 1 addition & 1 deletion gen/cmd/Cargo.toml
Expand Up @@ -25,7 +25,7 @@ clap = { version = "4", default-features = false, features = ["error-context", "
codespan-reporting = "0.11"
proc-macro2 = { version = "1.0.39", default-features = false, features = ["span-locations"] }
quote = { version = "1.0", default-features = false }
syn = { version = "2.0.0", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }
syn = { version = "2.0.1", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
2 changes: 1 addition & 1 deletion gen/lib/Cargo.toml
Expand Up @@ -15,7 +15,7 @@ rust-version = "1.60"
codespan-reporting = "0.11"
proc-macro2 = { version = "1.0.39", default-features = false, features = ["span-locations"] }
quote = { version = "1.0", default-features = false }
syn = { version = "2.0.0", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }
syn = { version = "2.0.1", default-features = false, features = ["parsing", "printing", "clone-impls", "full"] }

[lib]
doc-scrape-examples = false
Expand Down
2 changes: 1 addition & 1 deletion macro/Cargo.toml
Expand Up @@ -23,7 +23,7 @@ experimental-enum-variants-from-header = ["clang-ast", "flate2", "memmap", "serd
[dependencies]
proc-macro2 = "1.0.39"
quote = "1.0.4"
syn = { version = "2.0.0", features = ["full"] }
syn = { version = "2.0.1", features = ["full"] }

# optional dependencies:
clang-ast = { version = "0.1", optional = true }
Expand Down
11 changes: 1 addition & 10 deletions syntax/attrs.rs
Expand Up @@ -146,7 +146,7 @@ pub fn parse(cx: &mut Errors, attrs: Vec<Attribute>, mut parser: Parser) -> Othe
} else if attr_path.is_ident("variants_from_header")
&& cfg!(feature = "experimental-enum-variants-from-header")
{
if let Err(err) = require_empty_attribute(&attr.meta) {
if let Err(err) = attr.meta.require_path_only() {
cx.push(err);
}
if let Some(variants_from_header) = &mut parser.variants_from_header {
Expand Down Expand Up @@ -310,12 +310,3 @@ impl ToTokens for OtherAttrs {
}
}
}

fn require_empty_attribute(meta: &Meta) -> Result<()> {
let error_span = match meta {
Meta::Path(_) => return Ok(()),
Meta::List(meta) => meta.delimiter.span().open(),
Meta::NameValue(meta) => meta.eq_token.span,
};
Err(Error::new(error_span, "unexpected token in cxx attribute"))
}
110 changes: 55 additions & 55 deletions third-party/BUCK

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions third-party/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion third-party/Cargo.toml
Expand Up @@ -15,4 +15,4 @@ once_cell = "1.9"
proc-macro2 = { version = "1.0.39", features = ["span-locations"] }
quote = "1.0.4"
scratch = "1"
syn = { version = "2.0.0", features = ["full"] }
syn = { version = "2.0.1", features = ["full"] }
2 changes: 1 addition & 1 deletion third-party/bazel/BUILD.bazel

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions third-party/bazel/defs.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e33fac6

Please sign in to comment.