]> git.lizzy.rs Git - rust.git/blob - src/test/ui-fulldeps/fluent-messages/test.rs
Rollup merge of #100767 - kadiwa4:escape_ascii, r=jackh726
[rust.git] / src / test / ui-fulldeps / fluent-messages / test.rs
1 // normalize-stderr-test "note.*" -> "note: os-specific message"
2
3 #![feature(rustc_private)]
4 #![crate_type = "lib"]
5
6 extern crate rustc_macros;
7 use rustc_macros::fluent_messages;
8
9 /// Copy of the relevant `DiagnosticMessage` variant constructed by `fluent_messages` as it
10 /// expects `crate::DiagnosticMessage` to exist.
11 pub enum DiagnosticMessage {
12     FluentIdentifier(std::borrow::Cow<'static, str>, Option<std::borrow::Cow<'static, str>>),
13 }
14
15 /// Copy of the relevant `SubdiagnosticMessage` variant constructed by `fluent_messages` as it
16 /// expects `crate::SubdiagnosticMessage` to exist.
17 pub enum SubdiagnosticMessage {
18     FluentAttr(std::borrow::Cow<'static, str>),
19 }
20
21 mod missing_absolute {
22     use super::fluent_messages;
23
24     fluent_messages! {
25         missing_absolute => "/definitely_does_not_exist.ftl",
26 //~^ ERROR could not open Fluent resource
27     }
28 }
29
30 mod missing_relative {
31     use super::fluent_messages;
32
33     fluent_messages! {
34         missing_relative => "../definitely_does_not_exist.ftl",
35 //~^ ERROR could not open Fluent resource
36     }
37 }
38
39 mod missing_message {
40     use super::fluent_messages;
41
42     fluent_messages! {
43         missing_message => "./missing-message.ftl",
44 //~^ ERROR could not parse Fluent resource
45     }
46 }
47
48 mod duplicate {
49     use super::fluent_messages;
50
51     fluent_messages! {
52         a => "./duplicate-a.ftl",
53         a_b => "./duplicate-a-b.ftl",
54 //~^ ERROR overrides existing message: `a_b_key`
55     }
56 }
57
58 mod slug_with_hyphens {
59     use super::fluent_messages;
60
61     fluent_messages! {
62         slug_with_hyphens => "./slug-with-hyphens.ftl",
63 //~^ ERROR name `slug_with_hyphens_this-slug-has-hyphens` contains a '-' character
64     }
65 }
66
67 mod label_with_hyphens {
68     use super::fluent_messages;
69
70     fluent_messages! {
71         label_with_hyphens => "./label-with-hyphens.ftl",
72 //~^ ERROR attribute `label-has-hyphens` contains a '-' character
73     }
74 }
75
76 mod valid {
77     use super::fluent_messages;
78
79     fluent_messages! {
80         valid => "./valid.ftl",
81     }
82
83     use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, valid::key};
84 }
85
86 mod missing_crate_name {
87     use super::fluent_messages;
88
89     fluent_messages! {
90         test_crate => "./missing-crate-name.ftl",
91 //~^ ERROR name `test-crate_foo` contains a '-' character
92 //~| ERROR name `with-hyphens` contains a '-' character
93 //~| ERROR name `with-hyphens` does not start with the crate name
94     }
95
96     use self::fluent_generated::{DEFAULT_LOCALE_RESOURCES, test_crate::{foo, with_hyphens}};
97 }