Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6085f29
support no_std with error-in-core
jordens May 16, 2024
c560bcc
exlude compiletest from no_std, fix no_std doctest
jordens May 16, 2024
ec51e63
undo Error->MyError renames
jordens May 16, 2024
f7f6c77
use __private namespace
jordens May 16, 2024
f1d9df3
add comment
jordens May 16, 2024
33b7a36
Merge branch 'master' into no-std
jordens May 17, 2024
3663fd1
use explicit doc(test(attr))
jordens May 22, 2024
61b1c17
error_in_core is stable
jordens Jun 14, 2024
3e792e0
{std -> core}:error: update docs/comment
jordens Jun 14, 2024
b278258
docs.rs: std is default
jordens Jun 14, 2024
8cbdc4e
bump MSRV to 1.81
jordens Jun 14, 2024
cc00ef8
Merge remote-tracking branch 'upstream/master' into no-std
jordens Sep 3, 2024
7fa183b
Revert "bump MSRV to 1.81"
jordens Sep 6, 2024
28ce40b
Revert "{std -> core}:error: update docs/comment"
jordens Sep 6, 2024
0b058bc
Revert "error_in_core is stable"
jordens Sep 6, 2024
e7e9341
minimalize changes, maintain MSRV for `std`
jordens Sep 6, 2024
bfd7357
test 1.81 and no_std
jordens Sep 6, 2024
706fb6a
ci no_std: not check but test, 1.81 not necessary
jordens Sep 6, 2024
a3d073b
compiletest: allow unused_attributes
jordens Sep 6, 2024
89008c0
prefer required-features
jordens Sep 9, 2024
c9cd3b9
compiletest doesn't need std
jordens Sep 9, 2024
0ef9d1b
impl hygiene: fully qualify all paths
jordens Sep 11, 2024
7182e3f
test_no_std: add strictly no_std test
jordens Sep 16, 2024
515bd36
test_{transparent,_lints}: also work with no-std lib
jordens Sep 18, 2024
2614b53
test_no_std: reduce
jordens Sep 18, 2024
44737a5
test_no_std: can't compile on old rust
jordens Sep 18, 2024
e779e1b
Merge remote-tracking branch 'upstream/master' into no-std
jordens Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test_no_std: add strictly no_std test
Tests source, from, error and hygiene, like test_source.
  • Loading branch information
jordens committed Sep 16, 2024
commit 7182e3f9df48036ac542bc31c6a7f9a2bb8ef747
56 changes: 56 additions & 0 deletions tests/test_no_std.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// There is no negative required-features to suppress this test
// for not(feature = "std").
#![cfg(not(feature = "std"))]
#![no_std]

use core::error::Error as _;
use thiserror::Error;

#[derive(Error, Debug, Default)]
#[error("io")]
pub struct IoError {}

#[derive(Error, Debug)]
#[error("implicit source")]
pub struct ImplicitSource {
source: IoError,
}

#[derive(Error, Debug)]
#[error("explicit source")]
pub struct ExplicitSource {
source: i32,
#[source]
io: IoError,
}

#[test]
fn test_implicit_source() {
let io = IoError::default();
let error = ImplicitSource { source: io };
error.source().unwrap().downcast_ref::<IoError>().unwrap();
}

#[test]
fn test_explicit_source() {
let io = IoError::default();
let error = ExplicitSource { source: 0, io };
error.source().unwrap().downcast_ref::<IoError>().unwrap();
}

macro_rules! error_from_macro {
($($variants:tt)*) => {
#[derive(Error)]
#[derive(Debug)]
pub enum MacroSource {
$($variants)*
}
}
}

// Test that we generate impls with the proper hygiene
#[rustfmt::skip]
error_from_macro! {
#[error("Something")]
Variant(#[from] IoError)
}