Skip to content

Resolve issue #22187 (ICE compiling libcore with RUST_LOG=debug). #22376

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

Closed
wants to merge 1 commit into from

Conversation

aidancully
Copy link
Contributor

The issue is that the Repr logic assumes that any trait_defs to
be represented will be non-local. This will not be the case when
compiling libcore: the compiler has a default predicate on many
types that they will be Sized, and the Sized trait is defined
in libcore.

If we allow that a Repr'ed trait_def must come from a foreign
crate, then, because the Repr logic can be used while the
trait_defs table is being built, there will be a chance that
a trait_def lookup will fail on Repr.

Handle both of these issues by defining a new try_lookup_trait_def
for use by the Repr logic that will attempt to look up a trait_def
in the local crate, and returns success/failure in an Option<>.
Callers are then responsible for making sure the trait_def is
actually present in defining the representation.

r? huonw

@rust-highfive
Copy link
Contributor

r? @brson

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

@aidancully
Copy link
Contributor Author

r? @huonw (who looked at this earlier)

@rust-highfive rust-highfive assigned huonw and unassigned brson Feb 15, 2015
@frewsxcv
Copy link
Member

Needs a rebase

@aidancully
Copy link
Contributor Author

FYI - rebased.

// pointer is valid. Furthermore, we know that the `ArcInner` structure itself is `Sync`
// because the inner data is `Sync` as well, so we're ok loaning out an immutable pointer
// to these contents.
// This unsafety is ok because while this arc is alive we're guaranteed
Copy link
Member

Choose a reason for hiding this comment

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

As much as I prefer 80 character line comments to 100 character ones, I object to people touching files solely for such changes. Please remove.

@pnkfelix
Copy link
Member

pnkfelix commented Mar 4, 2015

@aidancully sorry for the noise at the start; I was misled by the diff and thought you were making very broad changes on your own.

Please rebase with just the one commit; if you want assistance you can ping me on irc.

(And if you also change the occurrences of "{:?}" to "{}", I'll r+)

@aidancully
Copy link
Contributor Author

aidancully commented Mar 11, 2015 via email

@aidancully
Copy link
Contributor Author

@pnkfelix, I believe I've addressed the concerns? Please let me know if this version of the patch won't work.

@bors
Copy link
Collaborator

bors commented Apr 2, 2015

☔ The latest upstream changes (presumably #23955) made this pull request unmergeable. Please resolve the merge conflicts.

@aidancully aidancully force-pushed the pr22187 branch 2 times, most recently from ed8637e to 3afa481 Compare April 3, 2015 03:13
@aidancully
Copy link
Contributor Author

I've re-rebased, so this should be merge-able again.

@pnkfelix
Copy link
Member

pnkfelix commented Apr 3, 2015

@bors r+

@bors
Copy link
Collaborator

bors commented Apr 3, 2015

📌 Commit 3afa481 has been approved by pnkfelix

@bors
Copy link
Collaborator

bors commented Apr 3, 2015

⌛ Testing commit 3afa481 with merge d29518c...

@bors
Copy link
Collaborator

bors commented Apr 3, 2015

💔 Test failed - auto-mac-64-nopt-t

// defined in the local crate. Returns Option<_> because this function
// can be called while the trait_defs map is being built, so that
// looking up the trait_def in the local crate can sometimes fail.
fn try_lookup_trait_def<'tcx>(tcx: &ctxt<'tcx>, did: ast::DefId)
Copy link
Member

Choose a reason for hiding this comment

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

Ugh I totally overlooked the fact that you seem to have defined the same function twice here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, that was probably a rebase problem, i'll fix and update.

…bug).

The issue is that the Repr logic assumes that any trait_defs to
be represented will be non-local. This will not be the case when
compiling libcore: the compiler has a default predicate on many
types that they will be Sized, and the Sized trait is defined
in libcore.

If we allow that a Repr'ed trait_def must come from a foreign
crate, then, because the Repr logic can be used while the
trait_defs table is being built, there will be a chance that
a trait_def lookup will fail on Repr.

Handle both of these issues by defining a new try_lookup_trait_def
for use by the Repr logic that will attempt to look up a trait_def
in the local crate, and returns success/failure in an Option<>.
Callers are then responsible for making sure the trait_def is
actually present in defining the representation.
@pnkfelix
Copy link
Member

pnkfelix commented Apr 3, 2015

@aidancully did you pull in an older version? It seems like the {:?} crept back in.

@aidancully
Copy link
Contributor Author

@pnkfelix: {} didn't compile, I'll try to get you the error message.

/home/aidan/rust/aidancully/rust/src/librustc/util/ppaux.rs:685:50: 685:66 error: the trait `core::fmt::Display` is not implemented for the type `syntax::ast::DefId` [E0277]
/home/aidan/rust/aidancully/rust/src/librustc/util/ppaux.rs:685             format!("local_trait_not_ready({})", trait_ref.def_id)
                                                                                                                 ^~~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:26: 2:59 note: expansion site
<std macros>:1:1: 2:61 note: in expansion of format!
/home/aidan/rust/aidancully/rust/src/librustc/util/ppaux.rs:685:13: 686:10 note: expansion site
/home/aidan/rust/aidancully/rust/src/librustc/util/ppaux.rs:685:50: 685:66 note: `syntax::ast::DefId` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string
/home/aidan/rust/aidancully/rust/src/librustc/util/ppaux.rs:685             format!("local_trait_not_ready({})", trait_ref.def_id)
                                                                                                                 ^~~~~~~~~~~~~~~~
note: in expansion of format_args!
<std macros>:2:26: 2:59 note: expansion site
<std macros>:1:1: 2:61 note: in expansion of format!
/home/aidan/rust/aidancully/rust/src/librustc/util/ppaux.rs:685:13: 686:10 note: expansion site
error: aborting due to previous error
/home/aidan/rust/aidancully/rust/mk/target.mk:167: recipe for target 'x86_64-unknown-freebsd/stage0/lib/rustlib/x86_64-unknown-freebsd/lib/stamp.rustc' failed
gmake: *** [x86_64-unknown-freebsd/stage0/lib/rustlib/x86_64-unknown-freebsd/lib/stamp.rustc] Error 101

@pnkfelix
Copy link
Member

pnkfelix commented Apr 3, 2015

@aidancully (just transcribing from my suggestion on IRC) : I'd use

format!("local_trait_not_ready({})", trait_ref.def_id.local_id())

@huonw
Copy link
Member

huonw commented Apr 6, 2015

r? @pnkfelix

@rust-highfive rust-highfive assigned pnkfelix and unassigned huonw Apr 6, 2015
@aidancully
Copy link
Contributor Author

Thanks for the help, I couldn't reproduce this issue in current Rust, I think due to a6c295c. Since the patch seems to have been obsoleted, I'm closing the PR.

@aidancully aidancully closed this Apr 7, 2015
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.

7 participants