Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustpkg should operate on a URL-like pkgid #5679

Closed
graydon opened this issue Apr 2, 2013 · 2 comments
Closed

Rustpkg should operate on a URL-like pkgid #5679

graydon opened this issue Apr 2, 2013 · 2 comments
Labels
E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Milestone

Comments

@graydon
Copy link
Contributor

graydon commented Apr 2, 2013

Sub-bug of #5677

Rustpkg and the rust driver currently have several kinds of identifier for packages and crates: the name, url and uuid fields in #[link] and extern mod as well as the putative id of a rustpkg (which is being sketched-out as a reverse-DNS-dot-path the way java packages were named). These are terribly confusing and lead people to randomly cargo-culting variants of redundant sub-naming schemes, few of which are meaningful.

We want to consolidate these as much as possible, and will be following the design of the Go package-naming system, though with a slight simplification in that our packages aren't "self identifying" -- there's no package foo; declaration in each file, for example -- so don't have a separate (default) name aside from their pkgid stem ("import path" stem, in Go-ese). Those can vary in Go but there doesn't seem to be much point to allowing it for us. They exist in Go to disambiguate exported symbols at the linkage level, but our linkage model encodes the metadata-hash (likely, eventually, just a hash of the pkgid) in each symbol, so we're solving this a different (and hopefully less confusing, more robust) way. If you absolutely need to vary the module-local name a crate is bound under when you extern mod it, you'll be able to; the default will be automatically derived from the pkgid stem. I.e. extern mod "github.com/graydon/foo"; will produce a local binding foo, and you'll have to write extern mod bar = "github.com/graydon/foo"; to get a different local name.

An example structure for holding a path is here:

https://github.com/graydon/rust/blob/rustpkg/src/librustpkg/rustpkg.rc#L1046

The main points to ensure are these:

  • A pkgid must be relative-path-like so that it has a natural mapping to both URL-space and filesystem-space
  • A pkgid must have a stem which is a single-identifier component, the final component of the path
  • The pkgid is never written down anywhere inside a file stored in the package itself. Packages are named from the outside, by the user who is operating rustpkg (i.e. from argv or by scanning RUST_PATH) or some version control tool's repo URLs. A file in a directory doesn't repeat the name of the directory holding it. The same notion holds here.

Crate names should be deduced from the directory containing them, rather than a #[link] attribute inside the crate file. This should work whether a package has one or many crates within it: the immediate containing dir provides the short identifier-name for the crate, and this just happens to be the stem of the pkgid if there is only a single crate in the package (and the crate root is found in the package root).

@ghost ghost assigned catamorphism Apr 2, 2013
catamorphism added a commit to catamorphism/rust that referenced this issue Apr 12, 2013
…to declare IDs explicitly

This is preliminary work on bringing rustpkg up to conformance with rust-lang#5679
and related issues.

This change makes rustpkg infer a package ID from its containing directory,
instead of requiring name and vers attributes in the code. Many aspects of it
are incomplete; I've only tested one package (see README.txt) and one command,
"build". So far it only works for local packages.

I also removed code for several of the package commands other than "build",
replacing them with stubs that fail, since they used package IDs in ways that
didn't jibe well with the new scheme. I will re-implement the commands one
at a time.
bors added a commit that referenced this issue Apr 12, 2013
r? @graydon This is preliminary work on bringing rustpkg up to conformance with #5679
and related issues.

This change makes rustpkg infer a package ID from its containing directory,
instead of requiring name and vers attributes in the code. Many aspects of it
are incomplete; I've only tested one package (see README.txt) and one command,
"build". So far it only works for local packages.

I also removed code for several of the package commands other than "build",
replacing them with stubs that fail, since they used package IDs in ways that
didn't jibe well with the new scheme. I will re-implement the commands one
at a time.
@catamorphism
Copy link
Contributor

#6418 will close this.

@catamorphism
Copy link
Contributor

6a9c3bd fixes this.

flip1995 pushed a commit to flip1995/rust that referenced this issue Nov 5, 2020
…r=flip1995

Add lint: from_iter_instead_of_collect

Fixes rust-lang#5679

This implements lint for `::from_iter()` from rust-lang#5679 not the general issue (`std::ops::Add::add`, etc.).
This lint checks if expression is function call with `from_iter` name and if it's implementation of the `std::iter::FromIterator` trait.

changelog: Introduce  from_iter_instead_of_collect lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot.
Projects
None yet
Development

No branches or pull requests

2 participants