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

rustdoc should support --target for doc tests #16357

Closed
metajack opened this issue Aug 8, 2014 · 9 comments
Closed

rustdoc should support --target for doc tests #16357

metajack opened this issue Aug 8, 2014 · 9 comments
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@metajack
Copy link
Contributor

metajack commented Aug 8, 2014

Currently there is no way to pass arbitrary compiler flags to rustdoc. This means that I can't use rustdoc to check cross compiled libraries. For example, checking i686-unknown-linux-gnu from x86_64-unknown-linux-gnu is impossible because I can't pass --target to rustdoc.

I've worked around this issue for now by disabling doctests in Servo, but that is not ideal.

@metajack
Copy link
Contributor Author

metajack commented Aug 8, 2014

cc @SimonSapin

@metajack
Copy link
Contributor Author

metajack commented Aug 8, 2014

I also can't pass --extern so I can't run doc tests on anything that uses the new liburl.

@huonw
Copy link
Member

huonw commented Aug 9, 2014

I believe --extern should work? #15822

@metajack
Copy link
Contributor Author

metajack commented Aug 9, 2014

Hmm. I'll give that a shot.

@metajack
Copy link
Contributor Author

metajack commented Aug 9, 2014

@huonw That worked. So Servo is down to just needing --target.

@alexcrichton
Copy link
Member

Note that rustdoc does indeed support --target, it just doesn't pass it through to the test runner. I didn't think that it was particularly useful to verify that your documentation tests ran on an arbitrary target which may not be able to run on the host, but if there's a use somewhere then we may as well implement it!

I've updated the title to reflect that this just needs --target support. Ideally we wouldn't entirely duplicate the CLI interface between rustc/rustdoc except where necessary (such as this)

@alexcrichton alexcrichton changed the title rustdoc should support compiler flags rustdoc should support --target for doc tets Aug 9, 2014
@alexcrichton alexcrichton changed the title rustdoc should support --target for doc tets rustdoc should support --target for doc tests Aug 9, 2014
@metajack
Copy link
Contributor Author

metajack commented Aug 9, 2014

The test runner doesn't need it, only the compiler. If this works now, I should be able to modify the makefile to use it, but the --help doesn't mention --target at all.

@alexcrichton
Copy link
Member

You may have an older version of rustdoc, the --target functionality was added fairly recently. Also I should clarify that --target for rustdoc was implemented for html generation, but not for doc tests (this is an actual bug that should stay open).

@alexcrichton
Copy link
Member

Closing as rustdoc does support --target for generation and also #16357 (comment).

bors pushed a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
Commit 6a06f6f (Deduplicate reference search results, 2022-11-07) deduplicates references
within each definition.

There is an edge case when requesting references of a macro argument.  Apparently, our
descend_into_macros() stanza in references.rs produces a cartesian product of
- references inside the macro times
- times references outside the macro.

Since the above deduplication only applies to the references within a single definition, we
return them all, leading to many redundant references.

Work around this by deduplicating definitions as well.  Perhaps there is a better fix to not
produce this cartesian product in the first place; but I think at least for definitions the
problem would remain; a macro can contain multiple definitions of the same name, but since the
navigation target will be the unresolved location, it's the same for all of them.

We can't use unique() because we don't want to drop references that don't have a declaration
(though I dont' have an example for this case).

I discovered this working with the "bitflags" macro from the crate of the same name.

Fixes rust-lang#16357
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 25, 2024
…h-macros, r=Veykril

Deduplicate references when some of them are in macro expansions

EDIT: I wonder if this is a regression, I'll try to investigate.

Commit 6a06f6f (Deduplicate reference search results, 2022-11-07)
deduplicates references within each definition.

Apparently our descend_into_macros() stanza returns
one definition for each time a name is used in a macro.
Each of those definitions has the same set of references.
We return them all, leading to many redundant references.

Work around this by deduplicating definitions as well.  Perhaps there
is a better fix to not produce duplicate definitions in the first
place.

I discovered this working with the "bitflags" macro from the crate
of the same name.

Fixes rust-lang#16357
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants