Don't emit the OS error in a note

This makes it possible to make the normalization of the error message
more precise, allowing us to not normalize all notes away.
This commit is contained in:
est31 2023-03-31 03:48:35 +02:00
parent f24983222d
commit 97fb15d950
3 changed files with 12 additions and 13 deletions

View File

@ -97,9 +97,12 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
let resource_contents = match read_to_string(absolute_ftl_path) {
Ok(resource_contents) => resource_contents,
Err(e) => {
Diagnostic::spanned(resource_span, Level::Error, "could not open Fluent resource")
.note(e.to_string())
.emit();
Diagnostic::spanned(
resource_span,
Level::Error,
format!("could not open Fluent resource: {}", e.to_string()),
)
.emit();
return failed(&crate_name);
}
};

View File

@ -1,4 +1,4 @@
// normalize-stderr-test "note.*" -> "note: os-specific message"
// normalize-stderr-test "could not open Fluent resource:.*" -> "could not open Fluent resource: os-specific message"
#![feature(rustc_private)]
#![crate_type = "lib"]

View File

@ -1,18 +1,14 @@
error: could not open Fluent resource
error: could not open Fluent resource: os-specific message
--> $DIR/test.rs:24:24
|
LL | fluent_messages! { "/definitely_does_not_exist.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: os-specific message
error: could not open Fluent resource
error: could not open Fluent resource: os-specific message
--> $DIR/test.rs:31:24
|
LL | fluent_messages! { "../definitely_does_not_exist.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: os-specific message
error: could not parse Fluent resource
--> $DIR/test.rs:38:24
@ -89,7 +85,7 @@ error: invalid escape `\n` in Fluent resource
LL | fluent_messages! { "./invalid-escape.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: os-specific message
= note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)
error: invalid escape `\"` in Fluent resource
--> $DIR/test.rs:99:24
@ -97,7 +93,7 @@ error: invalid escape `\"` in Fluent resource
LL | fluent_messages! { "./invalid-escape.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: os-specific message
= note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)
error: invalid escape `\'` in Fluent resource
--> $DIR/test.rs:99:24
@ -105,7 +101,7 @@ error: invalid escape `\'` in Fluent resource
LL | fluent_messages! { "./invalid-escape.ftl" }
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: os-specific message
= note: Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)
error: aborting due to 13 previous errors