diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/rust/thiserror/tests | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/thiserror/tests')
10 files changed, 79 insertions, 35 deletions
diff --git a/third_party/rust/thiserror/tests/test_display.rs b/third_party/rust/thiserror/tests/test_display.rs index 6f603882eb..95a210f0b6 100644 --- a/third_party/rust/thiserror/tests/test_display.rs +++ b/third_party/rust/thiserror/tests/test_display.rs @@ -1,4 +1,4 @@ -#![allow(clippy::uninlined_format_args)] +#![allow(clippy::needless_raw_string_hashes, clippy::uninlined_format_args)] use std::fmt::{self, Display}; use thiserror::Error; @@ -301,3 +301,58 @@ fn test_keyword() { assert("error: 1", Error); } + +#[test] +fn test_str_special_chars() { + #[derive(Error, Debug)] + pub enum Error { + #[error("brace left {{")] + BraceLeft, + #[error("brace left 2 \x7B\x7B")] + BraceLeft2, + #[error("brace left 3 \u{7B}\u{7B}")] + BraceLeft3, + #[error("brace right }}")] + BraceRight, + #[error("brace right 2 \x7D\x7D")] + BraceRight2, + #[error("brace right 3 \u{7D}\u{7D}")] + BraceRight3, + #[error( + "new_\ +line" + )] + NewLine, + #[error("escape24 \u{78}")] + Escape24, + } + + assert("brace left {", Error::BraceLeft); + assert("brace left 2 {", Error::BraceLeft2); + assert("brace left 3 {", Error::BraceLeft3); + assert("brace right }", Error::BraceRight); + assert("brace right 2 }", Error::BraceRight2); + assert("brace right 3 }", Error::BraceRight3); + assert("new_line", Error::NewLine); + assert("escape24 x", Error::Escape24); +} + +#[test] +fn test_raw_str() { + #[derive(Error, Debug)] + pub enum Error { + #[error(r#"raw brace left {{"#)] + BraceLeft, + #[error(r#"raw brace left 2 \x7B"#)] + BraceLeft2, + #[error(r#"raw brace right }}"#)] + BraceRight, + #[error(r#"raw brace right 2 \x7D"#)] + BraceRight2, + } + + assert(r#"raw brace left {"#, Error::BraceLeft); + assert(r#"raw brace left 2 \x7B"#, Error::BraceLeft2); + assert(r#"raw brace right }"#, Error::BraceRight); + assert(r#"raw brace right 2 \x7D"#, Error::BraceRight2); +} diff --git a/third_party/rust/thiserror/tests/ui/no-display.stderr b/third_party/rust/thiserror/tests/ui/no-display.stderr index 0f47c24b62..88d0092678 100644 --- a/third_party/rust/thiserror/tests/ui/no-display.stderr +++ b/third_party/rust/thiserror/tests/ui/no-display.stderr @@ -15,3 +15,6 @@ note: the trait `std::fmt::Display` must be implemented | | pub trait Display { | ^^^^^^^^^^^^^^^^^ + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `as_display`, perhaps you need to implement it: + candidate #1: `AsDisplay` diff --git a/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr index 4c44742d54..649d77df81 100644 --- a/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/source-enum-not-error.stderr @@ -2,10 +2,7 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but it --> tests/ui/source-enum-not-error.rs:9:14 | 4 | pub struct NotError; - | ------------------- - | | - | doesn't satisfy `NotError: AsDynError<'_>` - | doesn't satisfy `NotError: std::error::Error` + | ------------------- doesn't satisfy `NotError: AsDynError<'_>` or `NotError: std::error::Error` ... 9 | Broken { source: NotError }, | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds @@ -20,3 +17,6 @@ note: the trait `std::error::Error` must be implemented | | pub trait Error: Debug + Display { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `as_dyn_error`, perhaps you need to implement it: + candidate #1: `AsDynError` diff --git a/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr index da6d225f86..a1fe2b5b53 100644 --- a/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/source-enum-unnamed-field-not-error.stderr @@ -2,10 +2,7 @@ error[E0599]: the method `as_dyn_error` exists for reference `&NotError`, but it --> tests/ui/source-enum-unnamed-field-not-error.rs:9:14 | 4 | pub struct NotError; - | ------------------- - | | - | doesn't satisfy `NotError: AsDynError<'_>` - | doesn't satisfy `NotError: std::error::Error` + | ------------------- doesn't satisfy `NotError: AsDynError<'_>` or `NotError: std::error::Error` ... 9 | Broken(#[source] NotError), | ^^^^^^ method cannot be called on `&NotError` due to unsatisfied trait bounds @@ -20,3 +17,6 @@ note: the trait `std::error::Error` must be implemented | | pub trait Error: Debug + Display { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `as_dyn_error`, perhaps you need to implement it: + candidate #1: `AsDynError` diff --git a/third_party/rust/thiserror/tests/ui/source-struct-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-struct-not-error.stderr index b98460fcbe..07cd67ac64 100644 --- a/third_party/rust/thiserror/tests/ui/source-struct-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/source-struct-not-error.stderr @@ -2,11 +2,7 @@ error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its tr --> tests/ui/source-struct-not-error.rs:9:5 | 4 | struct NotError; - | --------------- - | | - | method `as_dyn_error` not found for this struct - | doesn't satisfy `NotError: AsDynError<'_>` - | doesn't satisfy `NotError: std::error::Error` + | --------------- method `as_dyn_error` not found for this struct because it doesn't satisfy `NotError: AsDynError<'_>` or `NotError: std::error::Error` ... 9 | source: NotError, | ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds @@ -19,3 +15,6 @@ note: the trait `std::error::Error` must be implemented | | pub trait Error: Debug + Display { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `as_dyn_error`, perhaps you need to implement it: + candidate #1: `AsDynError` diff --git a/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr index a23f26823f..2022ea67cd 100644 --- a/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/source-struct-unnamed-field-not-error.stderr @@ -2,11 +2,7 @@ error[E0599]: the method `as_dyn_error` exists for struct `NotError`, but its tr --> tests/ui/source-struct-unnamed-field-not-error.rs:8:26 | 4 | struct NotError; - | --------------- - | | - | method `as_dyn_error` not found for this struct - | doesn't satisfy `NotError: AsDynError<'_>` - | doesn't satisfy `NotError: std::error::Error` + | --------------- method `as_dyn_error` not found for this struct because it doesn't satisfy `NotError: AsDynError<'_>` or `NotError: std::error::Error` ... 8 | pub struct ErrorStruct(#[source] NotError); | ^^^^^^ method cannot be called on `NotError` due to unsatisfied trait bounds @@ -19,3 +15,6 @@ note: the trait `std::error::Error` must be implemented | | pub trait Error: Debug + Display { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: items from traits can only be used if the trait is implemented and in scope + = note: the following trait defines an item `as_dyn_error`, perhaps you need to implement it: + candidate #1: `AsDynError` diff --git a/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr index 9be51434a6..bb836d4e8d 100644 --- a/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/transparent-enum-not-error.stderr @@ -7,10 +7,7 @@ error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its ::: $RUST/alloc/src/string.rs | | pub struct String { - | ----------------- - | | - | doesn't satisfy `String: AsDynError<'_>` - | doesn't satisfy `String: std::error::Error` + | ----------------- doesn't satisfy `String: AsDynError<'_>` or `String: std::error::Error` | = note: the following trait bounds were not satisfied: `String: std::error::Error` diff --git a/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr index 3d23c3a0e5..f337c592ee 100644 --- a/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/transparent-enum-unnamed-field-not-error.stderr @@ -7,10 +7,7 @@ error[E0599]: the method `as_dyn_error` exists for reference `&String`, but its ::: $RUST/alloc/src/string.rs | | pub struct String { - | ----------------- - | | - | doesn't satisfy `String: AsDynError<'_>` - | doesn't satisfy `String: std::error::Error` + | ----------------- doesn't satisfy `String: AsDynError<'_>` or `String: std::error::Error` | = note: the following trait bounds were not satisfied: `String: std::error::Error` diff --git a/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr index d67a694467..ee50d03a7b 100644 --- a/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/transparent-struct-not-error.stderr @@ -7,10 +7,7 @@ error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trai ::: $RUST/alloc/src/string.rs | | pub struct String { - | ----------------- - | | - | doesn't satisfy `String: AsDynError<'_>` - | doesn't satisfy `String: std::error::Error` + | ----------------- doesn't satisfy `String: AsDynError<'_>` or `String: std::error::Error` | = note: the following trait bounds were not satisfied: `String: std::error::Error` diff --git a/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr b/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr index f715a15175..c3d6c0023d 100644 --- a/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr +++ b/third_party/rust/thiserror/tests/ui/transparent-struct-unnamed-field-not-error.stderr @@ -7,10 +7,7 @@ error[E0599]: the method `as_dyn_error` exists for struct `String`, but its trai ::: $RUST/alloc/src/string.rs | | pub struct String { - | ----------------- - | | - | doesn't satisfy `String: AsDynError<'_>` - | doesn't satisfy `String: std::error::Error` + | ----------------- doesn't satisfy `String: AsDynError<'_>` or `String: std::error::Error` | = note: the following trait bounds were not satisfied: `String: std::error::Error` |