Skip to content

Conversation

@Swatinem
Copy link
Contributor

Instead of using with_integration, which can potentially lock on every call, we rather unsafely move the dest_log into our own Logger.

@Swatinem Swatinem requested a review from a team September 14, 2020 14:38
Instead of using `with_integration`, which can potentially lock on every call, we rather unsafely move the `dest_log` into our own Logger.
Comment on lines +56 to +58
let const_ptr = &self.dest_log as *const Option<Box<dyn log::Log>>;
let mut_ptr = const_ptr as *mut Option<Box<dyn log::Log>>;
(&mut *mut_ptr).take()
Copy link
Member

Choose a reason for hiding this comment

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

Okay, I know that I may have suggested this in a meeting, but we need to find another way to do this. If we end up breaking all integration interfaces to make them builders, I guess that is fine and a good lesson on why we should not expose fields publicly :)

To quote https://doc.rust-lang.org/nightly/nomicon/transmutes.html (UB = undefined behavior):

  • Transmuting an & to &mut is always UB.
  • No you can't do it.
  • No you're not special.

@Swatinem Swatinem marked this pull request as draft September 24, 2020 09:46
@Swatinem
Copy link
Contributor Author

closing this in favor of #268

@Swatinem Swatinem closed this Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants