Skip to content

Rename one of sync::Mutex or sync::mutex::Mutex #15724

@SimonSapin

Description

@SimonSapin
Contributor

They currently have very different semantics: the former is a lock-protected container while the latter is only a lock. I just spent a few minutes very confused, looking at the docs for one of them to understand code using the other.

Combined with #15723 and libstd-as-a-facade (many items with the same name documented in different modules are in fact the same item), this really brings down the doc’s usability.

sync::Mutex vs sync::mutex::Mutex is just the example I hit today, but same-name-but-different items is a pattern we should avoid in general.

Activity

thestinger

thestinger commented on Sep 16, 2014

@thestinger
Contributor

I think using the same name for both is fine as long as the paths leading up to it make it clear that one is a low-level mutex for unsafe code and the other is a high-level abstraction.

SimonSapin

SimonSapin commented on Sep 16, 2014

@SimonSapin
ContributorAuthor

@thestinger, sync::Mutex vs sync::mutex::Mutex does not convey this at all, IMO. Worse, it is relatively common to reexport at the crate top-level things that are defined in modules: exactly the same naming pattern with a very different meaning.

thestinger

thestinger commented on Sep 16, 2014

@thestinger
Contributor

I realize that, I'm saying that it would be fine if the paths were better.

SimonSapin

SimonSapin commented on Sep 16, 2014

@SimonSapin
ContributorAuthor

I was gonna suggest that sync::mutex could move to sync::raw::mutex, but I just found out that sync::raw::Mutex is yet another different type…

huonw

huonw commented on Sep 16, 2014

@huonw
Member
aturon

aturon commented on Jan 17, 2015

@aturon
Member

This issue is no longer relevant after the sync overhaul.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @SimonSapin@aturon@huonw@thestinger

        Issue actions

          Rename one of sync::Mutex or sync::mutex::Mutex · Issue #15724 · rust-lang/rust