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

Fix another ICE in rustdoc scrape_examples #90611

Merged
merged 4 commits into from
Nov 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/librustdoc/scrape_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,21 @@ where
hir::ExprKind::Call(f, _) => {
let types = tcx.typeck(ex.hir_id.owner);

match types.node_type_opt(f.hir_id) {
Some(ty) => (ty, ex.span),
None => {
return;
}
if let Some(ty) = types.node_type_opt(f.hir_id) {
(ty, ex.span)
} else {
trace!("node_type_opt({}) = None", f.hir_id);
return;
}
}
hir::ExprKind::MethodCall(_, _, _, span) => {
let types = tcx.typeck(ex.hir_id.owner);
let def_id = types.type_dependent_def_id(ex.hir_id).unwrap();
let def_id = if let Some(def_id) = types.type_dependent_def_id(ex.hir_id) {
def_id
} else {
trace!("type_dependent_def_id({}) = None", ex.hir_id);
return;
};
(tcx.type_of(def_id), span)
}
_ => {
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc-ui/scrape-examples-ice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// compile-flags: -Z unstable-options --scrape-examples-output-path t.calls --scrape-examples-target-crate foobar
Copy link
Member

Choose a reason for hiding this comment

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

I think you can just remove output-path here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think so, it will error if either of the two options are unset. Perhaps it should point to build/tmp/?

Copy link
Member

Choose a reason for hiding this comment

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

it will error if either of the two options are unset.

well that's odd ... @willcrichton is there a reason you made that a hard error instead of giving it a default value?

anyway, in the meantime, try {{build-base}}/t.calls: https://rustc-dev-guide.rust-lang.org/tests/adding.html#input-normalization

Copy link
Contributor

Choose a reason for hiding this comment

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

There isn't an obvious default value IMO. Eg doing {crate_name}.calls isn't desirable due to the many conflicting crate names in a workspace.

Copy link
Member

Choose a reason for hiding this comment

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

We could do {crate_name}-{crate_type} maybe. I don't think it has to be amazing, just some reasonable default to match --output-format json.

Copy link
Member

Choose a reason for hiding this comment

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

Any tool that cares about conflicts should be using output-path like you suggested.

// check-pass
#![no_std]
use core as _;