-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
rustdoc only: duplicate lang item panic_halt
#68427
Comments
cc @rust-lang/rustdoc |
I'll try to take a look in the next days. |
Note that the stable release will be prepared on monday, so the patch should be merged by then. |
It looks like this was triggered by #66211 (cc. @kinnison). rustdoc now seems to load all crates passed by Is this issue affecting any real world code? It seems weird to list a dependency on #66211 was to fix an ICE using the intra-doc-links feature but that's only available on nightly so it should be safe to revert #66211 on beta for now if needed. |
I guess it is unlikely that this will be triggered in many real world scenarios. I came across this problem because I was experimenting with embedded programming: I had multiple panic implementations in the dependencies and then multiple binaries which were using different panic implementations (to see their different behaviors). |
If there's a way to get the metadata into |
We can revert it on the beta to prevent the crash but we definitely need a way to get the metadata from the crates. |
So after a discussion with @eddyb, it appears that @petrochenkov is one of the last person working on this part. cc @petrochenkov (at @eddyb's suggestion) |
If you don't want to resolve all crates passed with All the paths need to be resolved before the |
In other words, if you remove |
I'll need more information because none of the |
The methods are not in rustdoc, but rustdoc is their only user and they exist due to it. So, rustdoc should work similarly to rustc and organize its passes in such a way that they perform name resolution early. |
@petrochenkov My understanding is that Maybe it should have a (much simpler) AST pass that only looks for paths in markdown links in I don't think it's possible to fully push rustdoc to before AST->HIR lowering. |
@petrochenkov My question was more: "how do we do that?". I know very little about the rustc internals generally. |
This is now blocking #75176. |
Instead of |
Another idea is to store the resolver in the TyCtxt itself so that it never has to be cloned in the first place: #75176 (comment) |
I already mentioned my preferred solution:
+ eddyb's comment - #68427 (comment) |
…rochenkov rustdoc: Don't load all extern crates unconditionally Instead, only load the crates that are linked to with intra-doc links. This doesn't help very much with any of rustdoc's fundamental issues with freezing the resolver, but it at least fixes a stable-to-stable regression, and makes the crate loading model somewhat more consistent with rustc's. I tested and it unfortunately does not help at all with rust-lang#82496. Closes rust-lang#68427. Let me know if you want me to open a separate issue for not freezing the resolver. r? `@petrochenkov` cc `@eddyb` `@ollie27`
…rochenkov rustdoc: Don't load all extern crates unconditionally Instead, only load the crates that are linked to with intra-doc links. This doesn't help very much with any of rustdoc's fundamental issues with freezing the resolver, but it at least fixes a stable-to-stable regression, and makes the crate loading model somewhat more consistent with rustc's. I tested and it unfortunately does not help at all with rust-lang#82496. Closes rust-lang#68427. Let me know if you want me to open a separate issue for not freezing the resolver. r? ``@petrochenkov`` cc ``@eddyb`` ``@ollie27``
…crate-load, r=jyn514 Revert "Don't load all extern crates unconditionally" Fixes rust-lang#84738. This reverts rust-lang#83738. For the "smart" load of external crates, we need to be able to access their items in order to check their doc comments, which seems, if not impossible, quite complicated using only the AST. For some context, I first tried to extend the `IntraLinkCrateLoader` visitor by adding `visit_foreign_item`. Unfortunately, it never enters into this call, so definitely not the right place... I then added `visit_use_tree` to then check all the imports outside with something like this: ```rust let mut loader = crate::passes::collect_intra_doc_links::IntraLinkCrateLoader::new(resolver); ast::visit::walk_crate(&mut loader, krate); let mut items = Vec::new(); for import in &loader.imports_to_check { if let Some(item) = krate.items.iter().find(|i| i.id == *import) { items.push(item); } } for item in items { ast::visit::walk_item(&mut item); for attr in &item.attrs { loader.check_attribute(attr); } } ``` This was, of course, a failure. We find the items without problems, but we still can't go into the external crate to check its items' attributes. Finally, `@jyn514` suggested to look into the [`CrateLoader`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/creader/struct.CrateLoader.html), but it only seems to provide metadata (I went through [`CStore`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/creader/struct.CStore.html) and [`CrateMetadata`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_metadata/rmeta/decoder/struct.CrateMetadata.html)). I think we are too limited here (with AST only) to be able to determine the crates we actually need to import, but it's very likely that I missed something. Maybe `@petrochenkov` or `@Aaron1011` have an idea? So until we find a way to make it work completely, we need to revert it to fix the ICE. Once merged, we'll need to re-open rust-lang#68427. r? `@jyn514`
This is a regression from
rustdoc 1.40.0 (73528e339 2019-12-16)
torustdoc 1.41.0-beta.3 (fb3056216 2020-01-19)
.If rustdoc attempts to document a crate that has at least two dependencies which implement a
panic_handler
, it fails with an error similar toNote that the crate builds fine, it's just documenting that is broken.
Steps to reproduce
cargo new panic2
panic-halt = "0.2.0"
, e.g.cargo add panic-halt
cargo doc
An example of the different behavior between `stable`/`beta` and `build`/`doc`.
The text was updated successfully, but these errors were encountered: