diff --git a/Cargo.lock b/Cargo.lock index ec5562171a..d897c1a144 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1803,6 +1803,13 @@ dependencies = [ "uniffi-fixture-regression-cdylib-dependency", ] +[[package]] +name = "uniffi-fixture-regression-doc-annotation-fails" +version = "0.22.0" +dependencies = [ + "uniffi", +] + [[package]] name = "uniffi-fixture-regression-i1015-fully-qualified-types" version = "0.22.0" diff --git a/Cargo.toml b/Cargo.toml index b2fb6d899a..4b68290da9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,6 +54,7 @@ members = [ "fixtures/regressions/unary-result-alias", "fixtures/regressions/nested-module-import", "fixtures/regressions/wrong-lower-check", + "fixtures/regressions/doc-annotation-fails", "fixtures/trait-methods", "fixtures/uitests", "fixtures/uniffi-fixture-time", diff --git a/fixtures/regressions/doc-annotation-fails/Cargo.toml b/fixtures/regressions/doc-annotation-fails/Cargo.toml new file mode 100644 index 0000000000..37a529f040 --- /dev/null +++ b/fixtures/regressions/doc-annotation-fails/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "uniffi-fixture-regression-doc-annotation-fails" +version = "0.22.0" +authors = ["Firefox Sync Team "] +edition = "2018" +license = "MPL-2.0" +publish = false + +[lib] +name = "uniffi_regression_test_doc_annotation_fails" +crate-type = ["lib", "cdylib"] + +[dependencies] +uniffi = { workspace = true } + +[build-dependencies] +uniffi = { workspace = true, features = ["build"] } + +[dev-dependencies] +uniffi = { workspace = true, features = ["bindgen-tests"] } diff --git a/fixtures/regressions/doc-annotation-fails/README.md b/fixtures/regressions/doc-annotation-fails/README.md new file mode 100644 index 0000000000..468fb35441 --- /dev/null +++ b/fixtures/regressions/doc-annotation-fails/README.md @@ -0,0 +1,13 @@ +# Doc annotation in proc-macro fails + +Reported in [#2134](https://github.com/mozilla/uniffi-rs/issues/2134): + +In v0.27 parsing of `#[doc]` annotations fail to parse if they contain anything but plain strings. + +``` +error: Cannot parse doc attribute + --> fixtures/regressions/doc-annotation-fails/src/lib.rs:5:1 + | +5 | #[doc = std::concat!("A", "has a", "B")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +``` diff --git a/fixtures/regressions/doc-annotation-fails/build.rs b/fixtures/regressions/doc-annotation-fails/build.rs new file mode 100644 index 0000000000..05b0af1433 --- /dev/null +++ b/fixtures/regressions/doc-annotation-fails/build.rs @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +fn main() { + uniffi::generate_scaffolding("src/test.udl").unwrap(); +} diff --git a/fixtures/regressions/doc-annotation-fails/src/lib.rs b/fixtures/regressions/doc-annotation-fails/src/lib.rs new file mode 100644 index 0000000000..e410fa8a40 --- /dev/null +++ b/fixtures/regressions/doc-annotation-fails/src/lib.rs @@ -0,0 +1,17 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#[doc = std::concat!("A", "has a", "B")] +#[derive(uniffi::Enum)] +pub enum ConcattedDocEnum { + B, +} + +#[doc = "A has a B"] +#[derive(uniffi::Enum)] +pub enum PlainDocAnnotation { + B, +} + +uniffi::include_scaffolding!("test"); diff --git a/fixtures/regressions/doc-annotation-fails/src/test.udl b/fixtures/regressions/doc-annotation-fails/src/test.udl new file mode 100644 index 0000000000..89d36172e5 --- /dev/null +++ b/fixtures/regressions/doc-annotation-fails/src/test.udl @@ -0,0 +1 @@ +namespace doc_annotation_fails { };