Skip to content
Myr

Specify generic params on every transmute

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 3adc96a · Browse files · 1 file+16 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−14 removed

  • other:+16 added−14 removed

1 file+16 added−14 removed

modified:src/error.rs+16 added-14 removed
52 unmodified lines
53 None => Some(Backtrace::capture()),54 };5556 unsafe {57 let obj: TraitObject = mem::transmute(&error as &dyn StdError);57 let obj = mem::transmute::<&dyn StdError, TraitObject>(&error);58 let vtable = obj.vtable;59 let inner = ErrorImpl {59 let inner = Box::new(ErrorImpl {60 vtable,61 type_id,62 backtrace,63 error,64 };64 });65 Error {66 inner: mem::transmute(Box::new(inner)),66 inner: mem::transmute::<Box<ErrorImpl<E>>, Box<ErrorImpl<()>>>(inner),67 }68 }69 }70
201 unmodified lines
272impl<M> StdError for MessageError<M> where M: Display + Debug + 'static {}273274impl ErrorImpl<()> {275 fn error(&self) -> &(dyn StdError + Send + Sync + 'static) {276 unsafe {277 mem::transmute(TraitObject {278 data: &self.error,279 vtable: self.vtable,280 })281 }276 let object = TraitObject {277 data: &self.error,278 vtable: self.vtable,279 };280281 unsafe { mem::transmute::<TraitObject, &(dyn StdError + Send + Sync + 'static)>(object) }282 }283284 fn error_mut(&mut self) -> &mut (dyn StdError + Send + Sync + 'static) {285 let object = TraitObject {286 data: &mut self.error,287 vtable: self.vtable,288 };289290 unsafe {286 mem::transmute(TraitObject {287 data: &mut self.error,288 vtable: self.vtable,289 })291 mem::transmute::<TraitObject, &mut (dyn StdError + Send + Sync + 'static)>(object)292 }293 }294}295
61 unmodified lines