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

add new_with_user_state #2282

Closed
Closed
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion crates/wasmtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ pub struct Instance {
module: Module,
}

#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Otherwise it will report: warning: field is never read: frame_info_registration.

pub struct HostState {
frame_info_registration: Option<Arc<GlobalFrameInfoRegistration>>,
Copy link
Contributor

@bjorn3 bjorn3 Oct 8, 2020

Choose a reason for hiding this comment

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

Suggested change
frame_info_registration: Option<Arc<GlobalFrameInfoRegistration>>,
_frame_info_registration: Option<Arc<GlobalFrameInfoRegistration>>,

This suppresses the dead code warning for this field only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved #[allow(dead_code)] to above the frame_info_registration field

pub user_state: Option<Box<dyn Any>>,
}

impl Instance {
/// allows the caller to specify customimzed user_state, which can be accessed by
/// instance.host_state().downcast_ref(HostState).user_state
/// instance.host_state().downcast_ref::<HostState>.user_state
pub fn new_with_user_state(
store: &Store,
module: &Module,
Expand Down