Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dtolnay/thiserror
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.30
Choose a base ref
...
head repository: dtolnay/thiserror
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.0.31
Choose a head ref
  • 18 commits
  • 19 files changed
  • 1 contributor

Commits on Oct 17, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    b743d8f View commit details

Commits on Nov 17, 2021

  1. Install newest build of cargo-outdated

    The old version available by default in the GitHub Actions image fails
    with:
    
        thread 'main' panicked at 'package cache lock is not currently held, Cargo forgot to call `acquire_package_cache_lock` before we got to this stack frame', /usr/share/rust/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-0.57.0/src/cargo/util/config/mod.rs:1542:9
        note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    dtolnay committed Nov 17, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    e86c024 View commit details

Commits on Nov 20, 2021

  1. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    48bbdff View commit details

Commits on Dec 8, 2021

  1. Ignore cast_lossless Clippy pedantic lint

        error: casting `bool` to `usize` is more cleanly stated with `usize::from(_)`
           --> impl/src/valid.rs:183:31
            |
        183 |         if fields.len() > 1 + has_backtrace as usize {
            |                               ^^^^^^^^^^^^^^^^^^^^^^ help: try: `usize::from(has_backtrace)`
            |
            = note: `-D clippy::cast-lossless` implied by `-D clippy::pedantic`
            = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#cast_lossless
    dtolnay committed Dec 8, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    d7664d5 View commit details
  2. Ignore iter_cloned_collect Clippy lint in test

        error: called `iter().copied().collect()` on a slice to create a `Vec`. Calling `to_vec()` is both faster and more readable
          --> tests/test_expr.rs:18:30
           |
        18 |     #[error("#error {}", (.0).iter().copied().collect::<Vec<_>>().join(" "))]
           |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `.to_vec()`
    dtolnay committed Dec 8, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    5a03b0a View commit details
  3. Ignore needless_late_init Clippy lint in test

        error: unneeded late initalization
          --> tests/test_generics.rs:90:5
           |
        90 |     let mut instance: EnumCompound<DisplayOnly, DebugOnly, NoFormat>;
           |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_late_init
        help: declare `instance` here
           |
        92 |     let mut instance: EnumCompound<DisplayOnly, DebugOnly, NoFormat> = EnumCompound::DisplayDebug(DisplayOnly, DebugOnly);
           |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    dtolnay committed Dec 8, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    604e47c View commit details

Commits on Dec 18, 2021

  1. Ignore return_self_not_must_use clippy lint

        error: missing `#[must_use]` attribute on a method returning `Self`
         --> src/display.rs:5:5
          |
        5 |     fn as_display(&self) -> Self;
          |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          |
          = note: `-D clippy::return-self-not-must-use` implied by `-D clippy::all`
          = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#return_self_not_must_use
    dtolnay committed Dec 18, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    7966eb3 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    8602ca3 View commit details
  3. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    c4d7c2b View commit details
  4. Merge pull request #164 from dtolnay/frombacktrace

    Fix miscounting fields when from and backtrace are same field
    dtolnay authored Dec 18, 2021

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    320d70f View commit details

Commits on Jan 1, 2022

  1. Detect warnings in CI

    dtolnay committed Jan 1, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    d2e2ad1 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    91333fa View commit details

Commits on Jan 15, 2022

  1. Ignore wrong_self_convention clippy lint

        error: methods called `from_*` usually take no `self`
         --> impl/src/prop.rs:5:30
          |
        5 |     pub(crate) fn from_field(&self) -> Option<&Field> {
          |                              ^^^^^
          |
          = note: `-D clippy::wrong-self-convention` implied by `-D clippy::all`
          = help: consider choosing a less ambiguous name
          = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
    
        error: methods called `from_*` usually take no `self`
          --> impl/src/prop.rs:51:30
           |
        51 |     pub(crate) fn from_field(&self) -> Option<&Field> {
           |                              ^^^^^
           |
           = help: consider choosing a less ambiguous name
           = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#wrong_self_convention
    dtolnay committed Jan 15, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    21c2690 View commit details

Commits on Apr 24, 2022

  1. Disable ui test on miri

    dtolnay committed Apr 24, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    625d349 View commit details
  2. Remove clippy deny attributes from test suite

    These were superseded by the clippy invocation made in our CI workflow:
    
        run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic
    dtolnay committed Apr 24, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    dd9206c View commit details

Commits on Apr 25, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    244edc8 View commit details

Commits on Apr 29, 2022

  1. Add a miri test job in CI

    dtolnay committed Apr 29, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    2a29fda View commit details

Commits on Apr 30, 2022

  1. Release 1.0.31

    dtolnay committed Apr 30, 2022

    Verified

    This commit was signed with the committer’s verified signature.
    dtolnay David Tolnay
    Copy the full SHA
    cbe8212 View commit details
26 changes: 20 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -5,32 +5,35 @@ on:
pull_request:
schedule: [cron: "40 1 * * *"]

env:
RUSTFLAGS: -Dwarnings

jobs:
test:
name: Rust ${{matrix.rust}}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rust: [beta, stable, 1.36.0]
rust: [beta, stable, 1.38.0]
include:
- rust: nightly
rustflags: --cfg thiserror_nightly_testing
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{matrix.rust}}
components: rust-src
- run: cargo test --all
env:
RUSTFLAGS: ${{matrix.rustflags}}
RUSTFLAGS: ${{matrix.rustflags}} ${{env.RUSTFLAGS}}

msrv:
name: Rust 1.31.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@1.31.0
- run: cargo check

@@ -39,14 +42,25 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@clippy
- run: cargo clippy --tests -- -Dclippy::all -Dclippy::pedantic

miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@miri
- run: cargo miri test
env:
MIRIFLAGS: -Zmiri-tag-raw-pointers

outdated:
name: Outdated
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: dtolnay/install@cargo-outdated
- run: cargo outdated --exit-code 1
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thiserror"
version = "1.0.30"
version = "1.0.31"
authors = ["David Tolnay <dtolnay@gmail.com>"]
edition = "2018"
rust-version = "1.31"
@@ -12,7 +12,7 @@ categories = ["rust-patterns"]
readme = "README.md"

[dependencies]
thiserror-impl = { version = "=1.0.30", path = "impl" }
thiserror-impl = { version = "=1.0.31", path = "impl" }

[dev-dependencies]
anyhow = "1.0"
2 changes: 1 addition & 1 deletion impl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "thiserror-impl"
version = "1.0.30"
version = "1.0.31"
authors = ["David Tolnay <dtolnay@gmail.com>"]
edition = "2018"
rust-version = "1.31"
4 changes: 3 additions & 1 deletion impl/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#![allow(
clippy::blocks_in_if_conditions,
clippy::cast_lossless,
clippy::cast_possible_truncation,
clippy::manual_map,
clippy::map_unwrap_or,
clippy::needless_pass_by_value,
clippy::option_if_let_else,
clippy::range_plus_one,
clippy::single_match_else,
clippy::too_many_lines
clippy::too_many_lines,
clippy::wrong_self_convention
)]

extern crate proc_macro;
6 changes: 5 additions & 1 deletion impl/src/valid.rs
Original file line number Diff line number Diff line change
@@ -180,7 +180,11 @@ fn check_field_attrs(fields: &[Field]) -> Result<()> {
}
}
if let Some(from_field) = from_field {
if fields.len() > 1 + has_backtrace as usize {
let max_expected_fields = match backtrace_field {
Some(backtrace_field) => 1 + !same_member(from_field, backtrace_field) as usize,
None => 1 + has_backtrace as usize,
};
if fields.len() > max_expected_fields {
return Err(Error::new_spanned(
from_field.attrs.from,
"deriving From requires no fields other than source and backtrace",
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -205,6 +205,7 @@
// Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7421
clippy::doc_markdown,
clippy::module_name_repetitions,
clippy::return_self_not_must_use,
)]

mod aserror;
3 changes: 1 addition & 2 deletions tests/compiletest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#![deny(clippy::all, clippy::pedantic)]

#[rustversion::attr(not(nightly), ignore)]
#[cfg_attr(miri, ignore)]
#[test]
fn ui() {
let t = trybuild::TestCases::new();
2 changes: 0 additions & 2 deletions tests/test_display.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]

use std::fmt::Display;
use thiserror::Error;

1 change: 0 additions & 1 deletion tests/test_error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]
#![allow(dead_code)]

use std::fmt::{self, Display};
3 changes: 1 addition & 2 deletions tests/test_expr.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![deny(clippy::all, clippy::pedantic)]
#![allow(clippy::option_if_let_else)]
#![allow(clippy::iter_cloned_collect, clippy::option_if_let_else)]

use std::fmt::Display;
use thiserror::Error;
2 changes: 0 additions & 2 deletions tests/test_from.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]

use std::io;
use thiserror::Error;

2 changes: 1 addition & 1 deletion tests/test_generics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![deny(clippy::all, clippy::pedantic)]
#![allow(clippy::needless_late_init)]

use std::fmt::{self, Debug, Display};
use thiserror::Error;
1 change: 0 additions & 1 deletion tests/test_option.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![cfg_attr(thiserror_nightly_testing, feature(backtrace))]
#![deny(clippy::all, clippy::pedantic)]

#[cfg(thiserror_nightly_testing)]
pub mod structs {
2 changes: 0 additions & 2 deletions tests/test_path.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]

use ref_cast::RefCast;
use std::fmt::Display;
use std::path::{Path, PathBuf};
2 changes: 0 additions & 2 deletions tests/test_source.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]

use std::error::Error as StdError;
use std::io;
use thiserror::Error;
2 changes: 0 additions & 2 deletions tests/test_transparent.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]

use anyhow::anyhow;
use std::error::Error as _;
use std::io;
2 changes: 1 addition & 1 deletion tests/ui/concat-display.stderr
Original file line number Diff line number Diff line change
@@ -5,6 +5,6 @@ error: expected string literal
| ^^^^^^
...
13 | error_type!(Error, "foo");
| -------------------------- in this macro invocation
| ------------------------- in this macro invocation
|
= note: this error originates in the macro `error_type` (in Nightly builds, run with -Z macro-backtrace for more info)
12 changes: 12 additions & 0 deletions tests/ui/from-backtrace-backtrace.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://github.com/dtolnay/thiserror/issues/163

#![feature(backtrace)]

use std::backtrace::Backtrace;
use thiserror::Error;

#[derive(Error, Debug)]
#[error("...")]
pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace);

fn main() {}
5 changes: 5 additions & 0 deletions tests/ui/from-backtrace-backtrace.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: deriving From requires no fields other than source and backtrace
--> tests/ui/from-backtrace-backtrace.rs:10:18
|
10 | pub struct Error(#[from] #[backtrace] std::io::Error, Backtrace);
| ^^^^^^^