Commit graph

689 commits

Author SHA1 Message Date
David Tolnay
24c04daea9
Support dynamically sized field in error 2024-11-08 12:19:52 -05:00
David Tolnay
8e8e27376c
Add test of dynamically sized error type
error[E0599]: the method `as_display` exists for reference `&str`, but its trait bounds were not satisfied
      --> tests/test_path.rs:26:9
       |
    26 | #[error("{tail}")]
       |         ^^^^^^^^ method cannot be called on `&str` due to unsatisfied trait bounds
       |
       = note: the following trait bounds were not satisfied:
               `str: Sized`
               which is required by `&str: AsDisplay<'_>`
2024-11-08 12:18:58 -05:00
David Tolnay
6097d61b58
Release 2.0.0 2024-11-05 21:50:34 -05:00
David Tolnay
40113bd4b5
Merge pull request #373 from dtolnay/nostd
Allow disabling std dependency on 1.81+
2024-11-05 21:48:30 -05:00
David Tolnay
d8ed5fbc2f
Allow disabling std dependency on 1.81+ 2024-11-05 21:46:11 -05:00
David Tolnay
8277ec4a73
Merge pull request #372 from dtolnay/stdbacktrace
Access Backtrace exclusively through ::thiserror
2024-11-05 21:01:34 -05:00
David Tolnay
d6d896df4c
Access Backtrace exclusively through ::thiserror 2024-11-05 20:58:53 -05:00
David Tolnay
d14adfbb60
Merge pull request #371 from dtolnay/coreprovider
Drop Provider API support in pre-1.81 nightlies
2024-11-05 19:38:07 -05:00
David Tolnay
2e99c515f3
Drop Provider API support in pre-1.81 nightlies 2024-11-05 19:26:35 -05:00
David Tolnay
bf3d6f3f48
Merge pull request #370 from dtolnay/stderror
Access Error trait exclusively through ::thiserror
2024-11-05 19:25:23 -05:00
David Tolnay
e0e994314b
Access Error trait exclusively through ::thiserror 2024-11-05 19:22:53 -05:00
David Tolnay
db7825e956
Merge pull request #369 from dtolnay/stdpath
Access all std types through absolute path
2024-11-05 19:20:00 -05:00
David Tolnay
2f92680b5f
Access all std types through absolute path 2024-11-05 19:15:15 -05:00
David Tolnay
12b8c27f75
Merge pull request #368 from dtolnay/usethiserror
Perform imports from thiserror through absolute path
2024-11-05 19:14:48 -05:00
David Tolnay
fa2ba3a531
Perform imports from thiserror through absolute path 2024-11-05 19:06:32 -05:00
David Tolnay
184c10078e
Merge pull request #367 from dtolnay/fmt
Implement #[error(fmt = ...)]
2024-11-05 17:37:39 -05:00
David Tolnay
831138002b
Ignore trivially_copy_pass_by_ref pedantic clippy lint in test
warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
       --> tests/test_display.rs:388:16
        |
    388 |     fn pair(k: &i32, v: &i32, formatter: &mut fmt::Formatter) -> fmt::Result {
        |                ^^^^ help: consider passing by value instead: `i32`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
        = note: `-W clippy::trivially-copy-pass-by-ref` implied by `-W clippy::pedantic`
        = help: to override `-W clippy::pedantic` add `#[allow(clippy::trivially_copy_pass_by_ref)]`

    warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte)
       --> tests/test_display.rs:388:25
        |
    388 |     fn pair(k: &i32, v: &i32, formatter: &mut fmt::Formatter) -> fmt::Result {
        |                         ^^^^ help: consider passing by value instead: `i32`
        |
        = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#trivially_copy_pass_by_ref
2024-11-05 17:35:14 -05:00
David Tolnay
ba9af4522e
Implement #[error(fmt = ...)] 2024-11-05 17:22:27 -05:00
David Tolnay
5e4b7a5117
Merge pull request #366 from dtolnay/transparentvariant
Allow error(transparent) inside an enum that has error("...")
2024-11-05 17:06:38 -05:00
David Tolnay
65f1990265
Allow error(transparent) inside an enum that has error("...") 2024-11-05 17:02:49 -05:00
David Tolnay
71adf02435
Add test of transparent variant in enum with format args
error: cannot have both #[error(transparent)] and a display attribute
      --> tests/test_transparent.rs:51:5
       |
    51 |     #[error("this failed: {0}_{1}")]
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-11-05 17:02:35 -05:00
David Tolnay
02aaafc783
Merge pull request #365 from dtolnay/attrspan
Delete Attrs::span in favor of just call_site()
2024-11-05 16:18:13 -05:00
David Tolnay
7a72593ee3
Delete Attrs::span in favor of just call_site() 2024-11-05 16:14:45 -05:00
David Tolnay
a74ec44362
Merge pull request #364 from dtolnay/collidefrom
Let rustc generate diagnostic for colliding From impls
2024-11-05 00:22:45 -05:00
David Tolnay
6cac4c078e
Set span of generated From impls 2024-11-05 00:20:02 -05:00
David Tolnay
7ca67b01f3
Let rustc generate diagnostic for colliding From impls 2024-11-05 00:19:43 -05:00
David Tolnay
b7f7bfdd40
Merge pull request #363 from dtolnay/joinspan
Try joining a span for #[source] and #[from]
2024-11-05 00:17:58 -05:00
David Tolnay
b49f647299
Try joining a span for #[source] and #[from] 2024-11-05 00:14:46 -05:00
David Tolnay
8fcac53b1f
Merge pull request #362 from dtolnay/attrspans
Store span of #[source] and #[from] attribute
2024-11-05 00:14:40 -05:00
David Tolnay
5ffcf461e7
Store span of #[source] and #[from] attribute 2024-11-05 00:10:35 -05:00
David Tolnay
51fa992a70
Merge pull request #361 from dtolnay/samefrom
Add ui test of colliding From impls
2024-11-04 23:51:49 -05:00
David Tolnay
8b663dc3ea
Add ui test of colliding From impls 2024-11-04 23:47:27 -05:00
David Tolnay
1b898b8ed0
Merge pull request #360 from dtolnay/samemember
Remove same_member in favor of MemberUnraw's PartialEq impl
2024-11-04 23:33:45 -05:00
David Tolnay
9d7602e226
Remove same_member in favor of MemberUnraw's PartialEq impl 2024-11-04 23:31:14 -05:00
David Tolnay
3382a2a09c
Merge pull request #359 from dtolnay/recursion
Recognize infinite recursion caused by `{self}`
2024-11-04 22:35:18 -05:00
David Tolnay
6a0eb08569
Recognize infinite recursion caused by {self} 2024-11-04 22:28:23 -05:00
David Tolnay
e1fa5190b4
Merge pull request #358 from dtolnay/conflict
Further deconflict macro-generated format var names with user-provided ones
2024-11-04 22:11:33 -05:00
David Tolnay
e44fd92065
Further deconflict macro-generated format var names with user-provided ones 2024-11-04 22:09:13 -05:00
David Tolnay
8fa0147097
Merge pull request #357 from dtolnay/fmt
Rewrite fmt expansion to exactly preserve user-provided args
2024-11-04 22:08:36 -05:00
David Tolnay
bf6efce84d
Improve diagnostic on raw identifier in format string 2024-11-04 22:05:19 -05:00
David Tolnay
58cc36e69f
Improve diagnostic on {_} in format string 2024-11-04 22:04:59 -05:00
David Tolnay
4a79e0121e
Rewrite fmt expansion to exactly preserve user-provided args 2024-11-04 22:04:18 -05:00
David Tolnay
6590331353
Merge pull request #356 from dtolnay/numbered
Fix collision of numbered field references with user-written named arg
2024-11-04 21:21:25 -05:00
David Tolnay
f8fd1bf196
Fix collision of numbered field references with user-written named arg 2024-11-04 21:12:25 -05:00
David Tolnay
51ccdf18f5
Slightly cleaner implementation of has_trailing_comma 2024-11-04 20:48:22 -05:00
David Tolnay
b54f231ca8
Merge pull request #355 from dtolnay/tuplevariant
Improve error message to distinguish tuple struct vs tuple variant
2024-11-04 20:13:25 -05:00
David Tolnay
7e43dec573
Improve error message to distinguish tuple struct vs tuple variant 2024-11-04 20:11:01 -05:00
David Tolnay
93690a35d6
Merge pull request #354 from dtolnay/numbered
Disable numbered access to positional args on tuples
2024-11-04 20:06:28 -05:00
David Tolnay
3070b8b6c8
Work around rustc pre-1.74's possibly-uninitialized checker
error[E0381]: used binding `ahead` is possibly-uninitialized
       --> impl/src/fmt.rs:187:30
        |
    182 |         let ahead;
        |             ----- binding declared here but left uninitialized
    183 |         if *syn_full.get_or_insert_with(is_syn_full) && {
    184 |             ahead = input.fork();
        |             -----
        |             |
        |             binding initialized here in some conditions
        |             binding initialized here in some conditions
    ...
    187 |             input.advance_to(&ahead);
        |                              ^^^^^^ `ahead` used here but it is possibly-uninitialized
2024-11-04 20:00:51 -05:00
David Tolnay
d3b926132b
Disable numbered access to positional args on tuples 2024-11-04 20:00:31 -05:00