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

Emit a warning when manifest specifies empty dependency constraints #2270

Merged
merged 1 commit into from
Jan 20, 2016
Merged

Emit a warning when manifest specifies empty dependency constraints #2270

merged 1 commit into from
Jan 20, 2016

Conversation

felixc
Copy link
Contributor

@felixc felixc commented Jan 11, 2016

This warns when encountering dependencies of either of these forms:

  [dependencies]
  foo = {}

and

  [dependencies.foo]

(with nothing further provided).

In the future, this should likely become a hard error.

Related to #2147

@rust-highfive
Copy link

r? @huonw

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -680,6 +681,12 @@ fn process_dependencies<F>(cx: &mut Context,
}
TomlDependency::Detailed(ref details) => details.clone(),
};

if details.version.is_none() && details.path.is_none() && details.git.is_none() {
warnings.push(format!("warning: Dependency ({}) specified without providing a local \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for reviewer: Is there a convention for phrasing to indicate this really should be changed and may become a hard error in the future?

Similarly, is there anything (comment, annotation, etc) that should be left here in the code as a marker for future cleanup?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah this looks ok to me, we typically avoid capital letters and ending punctuation, however

@felixc
Copy link
Contributor Author

felixc commented Jan 11, 2016

In the related bug (#2147), @alexcrichton suggests this should perhaps become a hard error (breaking change) in the future.

  1. Is there consensus on this?
  2. Is there a process to track/enact that change in a release cycle or two?

@alexcrichton
Copy link
Member

Thanks! Can you be sure to add a test for this as well?

Also, could you reword the warning to indicate that it will become a hard error in the future?

@alexcrichton
Copy link
Member

Ah and to clarify, we don't currently have a process for ensuring this becomes a hard error, but it's fine if we just wander across this in a few months and flip the switch.

@felixc
Copy link
Contributor Author

felixc commented Jan 16, 2016

I've updated the wording of the warning as suggested, but am having trouble writing a sensible test. By definition the test manifest has to list an empty dependency for us to try and compile. That means I can't create some dummy files and use path to point to them; but rather than we have to fall back to checking crates.io. Trying to download and build some arbitrary crate doesn't seem like a good idea in a small test.

Is there a better way? Or at least a designated empty test crate that's controlled by the Cargo developers and used for this kind of purpose?

For reference, I've got something like this:

test!(empty_dependencies {
    let p = project("empty_deps")
    .file("Cargo.toml", r#"
        [package]
        name = "empty_deps"
        version = "0.0.0"
        authors = []

        [dependencies]
        foo = {}
    "#)
    .file("src/main.rs", "fn main() {}");

    assert_that(p.cargo_process("build"),
                execs().with_status(0).with_stderr_contains("\
warning: dependency (foo) specified without providing a local path, Git repository, or version \
to use. This will be considered an error in future versions
"));
});

At present, this fails because foo isn't a real crate on crates.io; but I'm hesitant to actually use a real one.

@alexcrichton
Copy link
Member

Ah there are some examples throughout the test codebase for this sort of dependency. I believe you just need to do this.

This warns when encountering dependencies of either of these forms:

  [dependencies]
  foo = {}

and

  [dependencies.foo]

(with nothing further provided).

In the future, this should likely become a hard error.
@felixc
Copy link
Contributor Author

felixc commented Jan 20, 2016

Thanks for the pointer! Beautifully simple. Tests added and PR updated.

@alexcrichton
Copy link
Member

@bors: r+ 1e985cc

Thanks!

cc @brson, what do you think is the best way to make sure this gets into the release notes?

bors added a commit that referenced this pull request Jan 20, 2016
This warns when encountering dependencies of either of these forms:
```
  [dependencies]
  foo = {}
```
and
```
  [dependencies.foo]
```
(with nothing further provided).

In the future, this should likely become a hard error.

Related to #2147
@bors
Copy link
Contributor

bors commented Jan 20, 2016

⌛ Testing commit 1e985cc with merge d9e8c60...

@bors
Copy link
Contributor

bors commented Jan 20, 2016

@bors bors merged commit 1e985cc into rust-lang:master Jan 20, 2016
@felixc felixc deleted the warn-on-empty-dep branch January 20, 2016 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants