summaryrefslogtreecommitdiffstats
path: root/tests/ui-fulldeps/fluent-messages
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui-fulldeps/fluent-messages
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui-fulldeps/fluent-messages')
-rw-r--r--tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl1
-rw-r--r--tests/ui-fulldeps/fluent-messages/duplicate-a.ftl1
-rw-r--r--tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl2
-rw-r--r--tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl2
-rw-r--r--tests/ui-fulldeps/fluent-messages/missing-message.ftl1
-rw-r--r--tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl1
-rw-r--r--tests/ui-fulldeps/fluent-messages/test.rs98
-rw-r--r--tests/ui-fulldeps/fluent-messages/test.stderr98
-rw-r--r--tests/ui-fulldeps/fluent-messages/valid.ftl1
9 files changed, 205 insertions, 0 deletions
diff --git a/tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl b/tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl
new file mode 100644
index 000000000..9407c5170
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/duplicate-a-b.ftl
@@ -0,0 +1 @@
+a_b_key = Value
diff --git a/tests/ui-fulldeps/fluent-messages/duplicate-a.ftl b/tests/ui-fulldeps/fluent-messages/duplicate-a.ftl
new file mode 100644
index 000000000..9407c5170
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/duplicate-a.ftl
@@ -0,0 +1 @@
+a_b_key = Value
diff --git a/tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl b/tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl
new file mode 100644
index 000000000..016cbeef6
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/label-with-hyphens.ftl
@@ -0,0 +1,2 @@
+label_with_hyphens_some_slug = hi
+ .label-has-hyphens = test
diff --git a/tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl b/tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl
new file mode 100644
index 000000000..9bd035c1b
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/missing-crate-name.ftl
@@ -0,0 +1,2 @@
+with-hyphens = 1234
+test-crate_foo = abcd
diff --git a/tests/ui-fulldeps/fluent-messages/missing-message.ftl b/tests/ui-fulldeps/fluent-messages/missing-message.ftl
new file mode 100644
index 000000000..74b2aa1d4
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/missing-message.ftl
@@ -0,0 +1 @@
+missing_message =
diff --git a/tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl b/tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl
new file mode 100644
index 000000000..86ba9a268
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/slug-with-hyphens.ftl
@@ -0,0 +1 @@
+slug_with_hyphens_this-slug-has-hyphens = hi
diff --git a/tests/ui-fulldeps/fluent-messages/test.rs b/tests/ui-fulldeps/fluent-messages/test.rs
new file mode 100644
index 000000000..4e8147e2b
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/test.rs
@@ -0,0 +1,98 @@
+// normalize-stderr-test "note.*" -> "note: os-specific message"
+
+#![feature(rustc_private)]
+#![crate_type = "lib"]
+
+extern crate rustc_macros;
+use rustc_macros::fluent_messages;
+
+/// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it
+/// expects `crate::DiagnosticMessage` to exist.
+pub enum DiagnosticMessage {
+ FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
+}
+
+/// Copy of the relevant `SubdiagnosticMessage` variant constructed by `fluent_messages` as it
+/// expects `crate::SubdiagnosticMessage` to exist.
+pub enum SubdiagnosticMessage {
+ FluentAttr(std::borrow::Cow<'static, str>),
+}
+
+mod missing_absolute {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ missing_absolute => "/definitely_does_not_exist.ftl",
+//~^ ERROR could not open Fluent resource
+ }
+}
+
+mod missing_relative {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ missing_relative => "../definitely_does_not_exist.ftl",
+//~^ ERROR could not open Fluent resource
+ }
+}
+
+mod missing_message {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ missing_message => "./missing-message.ftl",
+//~^ ERROR could not parse Fluent resource
+ }
+}
+
+mod duplicate {
+ use super::fluent_messages;
+
+ fluent_messages! {
+//~^ ERROR the name `a_b_key` is defined multiple times
+ a => "./duplicate-a.ftl",
+ a_b => "./duplicate-a-b.ftl",
+//~^ ERROR overrides existing message: `a_b_key`
+ }
+}
+
+mod slug_with_hyphens {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ slug_with_hyphens => "./slug-with-hyphens.ftl",
+//~^ ERROR name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character
+ }
+}
+
+mod label_with_hyphens {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ label_with_hyphens => "./label-with-hyphens.ftl",
+//~^ ERROR attribute `label-has-hyphens` contains a '-' character
+ }
+}
+
+mod valid {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ valid => "./valid.ftl",
+ }
+
+ use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid_key};
+}
+
+mod missing_crate_name {
+ use super::fluent_messages;
+
+ fluent_messages! {
+ test_crate => "./missing-crate-name.ftl",
+//~^ ERROR name `test-crate_foo` contains a '-' character
+//~| ERROR name `with-hyphens` contains a '-' character
+//~| ERROR name `with-hyphens` does not start with the crate name
+ }
+
+ use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate_foo, with_hyphens};
+}
diff --git a/tests/ui-fulldeps/fluent-messages/test.stderr b/tests/ui-fulldeps/fluent-messages/test.stderr
new file mode 100644
index 000000000..d1cd4fe26
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/test.stderr
@@ -0,0 +1,98 @@
+error: could not open Fluent resource
+ --> $DIR/test.rs:25:29
+ |
+LL | missing_absolute => "/definitely_does_not_exist.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: os-specific message
+
+error: could not open Fluent resource
+ --> $DIR/test.rs:34:29
+ |
+LL | missing_relative => "../definitely_does_not_exist.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: os-specific message
+
+error: could not parse Fluent resource
+ --> $DIR/test.rs:43:28
+ |
+LL | missing_message => "./missing-message.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: see additional errors emitted
+
+error: expected a message field for "missing_message"
+ --> ./missing-message.ftl:1:1
+ |
+1 | missing_message =
+ | ^^^^^^^^^^^^^^^^^
+ |
+
+error: overrides existing message: `a_b_key`
+ --> $DIR/test.rs:54:16
+ |
+LL | a_b => "./duplicate-a-b.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^
+ |
+help: previously defined in this resource
+ --> $DIR/test.rs:53:14
+ |
+LL | a => "./duplicate-a.ftl",
+ | ^^^^^^^^^^^^^^^^^^^
+
+error[E0428]: the name `a_b_key` is defined multiple times
+ --> $DIR/test.rs:51:5
+ |
+LL | fluent_messages! {
+ | ^^^^^^^^^^^^^^^^
+ | |
+ | `a_b_key` redefined here
+ | previous definition of the value `a_b_key` here
+ |
+ = note: os-specific message
+ = note: os-specific message
+
+error: name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character
+ --> $DIR/test.rs:63:30
+ |
+LL | slug_with_hyphens => "./slug-with-hyphens.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: replace any '-'s with '_'s
+
+error: attribute `label-has-hyphens` contains a '-' character
+ --> $DIR/test.rs:72:31
+ |
+LL | label_with_hyphens => "./label-with-hyphens.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: replace any '-'s with '_'s
+
+error: name `with-hyphens` contains a '-' character
+ --> $DIR/test.rs:91:23
+ |
+LL | test_crate => "./missing-crate-name.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: replace any '-'s with '_'s
+
+error: name `with-hyphens` does not start with the crate name
+ --> $DIR/test.rs:91:23
+ |
+LL | test_crate => "./missing-crate-name.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: prepend `test_crate_` to the slug name: `test_crate_with_hyphens`
+
+error: name `test-crate_foo` contains a '-' character
+ --> $DIR/test.rs:91:23
+ |
+LL | test_crate => "./missing-crate-name.ftl",
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = help: replace any '-'s with '_'s
+
+error: aborting due to 10 previous errors
+
+For more information about this error, try `rustc --explain E0428`.
diff --git a/tests/ui-fulldeps/fluent-messages/valid.ftl b/tests/ui-fulldeps/fluent-messages/valid.ftl
new file mode 100644
index 000000000..549274306
--- /dev/null
+++ b/tests/ui-fulldeps/fluent-messages/valid.ftl
@@ -0,0 +1 @@
+valid_key = Valid!