Skip to content
Snippets Groups Projects
  • Mitchell Kember's avatar
    3ac28aa1430e
    rust-annotate: do not impl Sync for Lines · 3ac28aa1430e
    Mitchell Kember authored
    I failed to notice before that bdiff_diff mutates its inputs by storing
    bookkeeping information in the `n` and `e` fields. This means &Lines can't be
    shared across threads, so Lines cannot be Sync. Fortunately nothing was using
    this. The parallel file reading and line splitting only relies on Send.
    
    The reason I didn't notice this to begin with was that Lines contains a
    *mut ffi::bdiffline, which is accessible from &Lines, so I never wrote or
    thought about &mut Lines. This pattern (using a mutable pointer stored in an
    immutable struct) would be expressed with RefCell if this was pure safe Rust.
    3ac28aa1430e
    History
    rust-annotate: do not impl Sync for Lines
    Mitchell Kember authored
    I failed to notice before that bdiff_diff mutates its inputs by storing
    bookkeeping information in the `n` and `e` fields. This means &Lines can't be
    shared across threads, so Lines cannot be Sync. Fortunately nothing was using
    this. The parallel file reading and line splitting only relies on Send.
    
    The reason I didn't notice this to begin with was that Lines contains a
    *mut ffi::bdiffline, which is accessible from &Lines, so I never wrote or
    thought about &mut Lines. This pattern (using a mutable pointer stored in an
    immutable struct) would be expressed with RefCell if this was pure safe Rust.