Skip to content

Remove recursive dependency of libstd and move out functionality into separate crates #15974

Closed
@mneumann

Description

@mneumann

At the moment, libstd depends for example on libnative, which itself depends on libstd. So it is not possible to compile libnative without libstd. I am not sure how rust is able to compile libstd, but I think it requires an existing libstd to compile with.

My suggestion is to factor out more parts of libstd into their own crates with non-cyclic dependencies.

  • from_str: belongs to collections, because this is where string is defined?
  • path: this can be made it's own crate libpath, if we also extract some of the common macros (see below) into their own crate.
  • os: this can be made it's own crate, if we somehow factor out io::{IoResult, IoError} from libstd.
  • libio ?

After that, for example libnative would no longer depend on libstd. I haven't looked at other libraries, but I think it's possible too to de-cycle them.

What else would need to be done?

  • deriving(Clone) right now generates code with ::std::clone::Clone while it should be ::core::clone::Clone. I think this is useful in general also for other projects that solely depend on libcore. Other derivings might have to be changed to ::core as well.
  • format_args!: same here.
  • libstd/macros.rs: fail!, assert!, assert_eq!, debug_assert!, debug_assert_eq!, unreachable!, unimplemented!, format!, try!, vec!. They shouldn't live in libstd as they might be useful in other software that depend on libcore (plus fail functionality).

If this is something we want, I can come up with some patches. Clearly more discussion is needed IMHO.

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

    Issue actions