Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression test for doc annotations parsing failure #2154

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 20 additions & 0 deletions fixtures/regressions/doc-annotation-fails/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "uniffi-fixture-regression-doc-annotation-fails"
version = "0.22.0"
authors = ["Firefox Sync Team <[email protected]>"]
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"] }
13 changes: 13 additions & 0 deletions fixtures/regressions/doc-annotation-fails/README.md
Original file line number Diff line number Diff line change
@@ -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")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
7 changes: 7 additions & 0 deletions fixtures/regressions/doc-annotation-fails/build.rs
Original file line number Diff line number Diff line change
@@ -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();
}
17 changes: 17 additions & 0 deletions fixtures/regressions/doc-annotation-fails/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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");
1 change: 1 addition & 0 deletions fixtures/regressions/doc-annotation-fails/src/test.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace doc_annotation_fails { };