Skip to content

After a hash mismatch error, emit file-system paths of crates involved. #13284

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

Merged
merged 4 commits into from
Apr 5, 2014

Conversation

pnkfelix
Copy link
Member

@pnkfelix pnkfelix commented Apr 3, 2014

Fix #13266.

There is a little bit of acrobatics in the definition of crate_paths
to avoid calling clone() on the dylib/rlib unless we actually are
going to need them.

The other oddity is that I have replaced the root_ident: Option<&str>
parameter with a root: &Option<CratePaths>, which may surprise one
who was expecting to see something like: root: Option<&CratePaths>.
I went with the approach here because I could not come up with code for
the alternative that was acceptable to the borrow checker.

Fix rust-lang#13266.

There is a little bit of acrobatics in the definition of `crate_paths`
to avoid calling `clone()` on the dylib/rlib unless we actually are
going to need them.

The other oddity is that I have replaced the `root_ident: Option<&str>`
parameter with a `root: &Option<CratePaths>`, which may surprise one
who was expecting to see something like: `root: Option<&CratePaths>`.
I went with the approach here because I could not come up with code for
the alternative that was acceptable to the borrow checker.
@@ -338,7 +371,8 @@ impl<'a> Context<'a> {
None => true,
Some(myhash) => {
if *myhash != hash {
self.rejected_via_hash = true;
self.rejected_via_hash =
Some(ViaHash{ path: libpath.clone(), });
Copy link
Member

Choose a reason for hiding this comment

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

This could also be a vector to collect all rejected candidates rather than just one (although most of the time there will only be one)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll look into doing that

@alexcrichton
Copy link
Member

This should have a test in one of the test suites. There's an example in src/test/compile-fail/changing-crates.rs which triggers this code path which could be expanded with the relevant paths.

pnkfelix added 3 commits April 5, 2014 03:46
Add way to print notes with just file:linenum prefix (preserving
integration with source lookup for e.g. vi and emacs) but don't repeat
the other span info.
(i.e. semi-generalized version of prior errorinfo gathering.)

Also revised presentation to put each path on its own line, prefixed
by file:linenum information.
All it checks, unfortunately, is that you actually printed at least
two lines for crateA paths and at least one line for crateB paths.
But that's enough to capture the spirit of the bug, I think.  I did
not bother trying to verify that the paths themselves reflected where
the crates end up.
@pnkfelix
Copy link
Member Author

pnkfelix commented Apr 5, 2014

So okay, the output now looks like this, when you run rustc on crateC from the regression test I added:

% /Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/stage1/bin/rustc --out-dir /Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match -L /Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match -L/Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match/a2 -L/Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match/a3 ../src/test/run-make/many-crates-but-no-match/crateC.rs
../src/test/run-make/many-crates-but-no-match/crateC.rs:11:1: 11:21 error: found possibly newer version of crate `crateA` which `crateB` depends on
../src/test/run-make/many-crates-but-no-match/crateC.rs:11 extern crate crateB;
                                                           ^~~~~~~~~~~~~~~~~~~~
../src/test/run-make/many-crates-but-no-match/crateC.rs:11:1: 11:21 note: perhaps this crate needs to be recompiled?
../src/test/run-make/many-crates-but-no-match/crateC.rs:11 extern crate crateB;
                                                           ^~~~~~~~~~~~~~~~~~~~
../src/test/run-make/many-crates-but-no-match/crateC.rs:11:21: 11:21 note: crate `crateA` path #1: /Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match/a3/libcrateA-2f87ccf5-0.0.rlib
../src/test/run-make/many-crates-but-no-match/crateC.rs:11:21: 11:21 note: crate `crateA` path #2: /Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match/a2/libcrateA-2f87ccf5-0.0.rlib
../src/test/run-make/many-crates-but-no-match/crateC.rs:11:21: 11:21 note: crate `crateB` path #1: /Users/fklock/Dev/Mozilla/rust.git/objdir-dbgopt/x86_64-apple-darwin/test/run-make/many-crates-but-no-match/libcrateB-38a3e48a-0.0.rlib
error: aborting due to previous error

bors added a commit that referenced this pull request Apr 5, 2014
…r=alexcrichton

Fix #13266.

There is a little bit of acrobatics in the definition of `crate_paths`
to avoid calling `clone()` on the dylib/rlib unless we actually are
going to need them.

The other oddity is that I have replaced the `root_ident: Option<&str>`
parameter with a `root: &Option<CratePaths>`, which may surprise one
who was expecting to see something like: `root: Option<&CratePaths>`.
I went with the approach here because I could not come up with code for
the alternative that was acceptable to the borrow checker.
@bors bors closed this Apr 5, 2014
@bors bors merged commit f4cde4e into rust-lang:master Apr 5, 2014
Jarcho pushed a commit to Jarcho/rust that referenced this pull request Aug 24, 2024
Improve `collapsible_match` error message syntax

fixes rust-lang#13283

changelog: none
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.

The msg "perhaps this crate needs to be recompiled?" should include paths
3 participants