Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use provide_any feature in error-stack #697

Merged
merged 4 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions packages/libs/error-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ All notable changes to `error-stack` will be documented in this file.

## 0.2.0 - Unreleased

### Features
### Breaking Changes

- Implement [`Termination`](https://doc.rust-lang.org/stable/std/process/trait.Termination.html) for `Report` ([#671](https://github.com/hashintel/hash/pull/671))
- Use `Provider` API from `core::any` ([#697](https://github.com/hashintel/hash/pull/697))
- Hide `futures-core` feature ([#695](https://github.com/hashintel/hash/pull/695))

### Fixes
### Features

- Hide `futures-core` feature ([#695](https://github.com/hashintel/hash/pull/695))
- Implement [`Termination`](https://doc.rust-lang.org/stable/std/process/trait.Termination.html) for `Report` ([#671](https://github.com/hashintel/hash/pull/671))

## [0.1.0](https://github.com/hashintel/hash/tree/d14efbc38559fc38d36e03ebdd499b44cb80c668/packages/libs/error-stack) - 2022-06-10

Expand Down
8 changes: 4 additions & 4 deletions packages/libs/error-stack/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use core::fmt;

#[cfg(nightly)]
use crate::provider::Demand;
use core::any::Demand;
#[cfg(all(nightly, any(feature = "std", feature = "spantrace")))]
use crate::provider::Provider;
use core::any::Provider;
use core::fmt;

use crate::Report;

/// Defines the current context of a [`Report`].
Expand Down
2 changes: 1 addition & 1 deletion packages/libs/error-stack/src/frame/attachment.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg(nightly)]
use crate::provider::{Demand, Provider};
use core::any::{Demand, Provider};

/// Wrapper around an attachment to provide the inner type.
#[repr(transparent)]
Expand Down
8 changes: 4 additions & 4 deletions packages/libs/error-stack/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ mod kind;
mod vtable;

use alloc::boxed::Box;
#[cfg(nightly)]
use core::any::{self, Demand, Provider};
use core::{fmt, mem, mem::ManuallyDrop, panic::Location, ptr::NonNull};

pub use self::kind::{AttachmentKind, FrameKind};
use self::{erasable::ErasableFrame, vtable::VTable};
#[cfg(nightly)]
use crate::provider::{self, Demand, Provider};
use crate::{frame::attachment::AttachmentProvider, Context};

/// A single context or attachment inside of a [`Report`].
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Frame {
where
T: ?Sized + 'static,
{
provider::request_ref(self)
any::request_ref(self)
}

/// Requests the value of `T` from the `Frame` if provided.
Expand All @@ -150,7 +150,7 @@ impl Frame {
where
T: 'static,
{
provider::request_value(self)
any::request_value(self)
}

/// Returns if `T` is the held context or attachment by this frame.
Expand Down
7 changes: 3 additions & 4 deletions packages/libs/error-stack/src/frame/vtable.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use alloc::boxed::Box;
#[cfg(nightly)]
use core::any::{Demand, Provider};
use core::{
any::TypeId,
fmt,
ptr::{addr_of, NonNull},
};

#[cfg(nightly)]
use crate::{
frame::attachment::AttachmentProvider,
provider::{Demand, Provider},
};
use crate::frame::attachment::AttachmentProvider;
use crate::{
frame::{kind::AttachmentKind, ErasableFrame},
Context, FrameKind,
Expand Down
8 changes: 1 addition & 7 deletions packages/libs/error-stack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,7 @@
//! return an iterator of all provided values with the specified type. The value, which was provided
//! most recently will be returned first.
//!
//! **Currently, the API has not yet landed in `core::any`, thus in the meantime it has been
//! included in the library implementation and is available at [`error_stack::provider`]. Using it
//! requires a nightly compiler.**
//!
//! [`attach`]: Report::attach
//! [`error_stack::provider`]: crate::provider
//! [`Provider` API]: https://rust-lang.github.io/rfcs/3192-dyno.html
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was only used in the above comment. If it would have been needed, the docs-test would fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on about the the [Provider API] link, not the removed line for error_stack::provider. I don't think docs-tests would fail if you add an unused link?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sure. Yes, this is already used in the first paragraph of the section:

//! This crate uses the [`Provider` API] to provide arbitrary data. This can be done either by
//! [`attach`]ing them to a [`Report`] or by providing it directly when implementing [`Context`].
//! The blanket implementation of [`Context`] for [`Error`] will provide the [`Backtrace`] to be
//! requested later.

No, it won't complain if you add unused links (sadly) 😢

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, GitHub wasn't letting me see the above code even when I clicked on the expand button :(

//!
//! ### Macros for Convenience
Expand Down Expand Up @@ -371,6 +366,7 @@
//! [`SpanTrace`]: tracing_error::SpanTrace

#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(nightly, feature(provide_any))]
#![cfg_attr(all(doc, nightly), feature(doc_auto_cfg))]
#![cfg_attr(all(nightly, feature = "std"), feature(backtrace))]
#![warn(
Expand All @@ -397,8 +393,6 @@ mod context;
mod ext;
#[cfg(feature = "hooks")]
mod hook;
#[cfg(nightly)]
pub mod provider;
#[cfg(test)]
pub(crate) mod test_helper;

Expand Down
Loading