Skip to content

impl-everywhere.rs has a weird test #55201

Closed
@Munksgaard

Description

@Munksgaard
Contributor

From #54824 (comment):

[ ] impl-everywhere.rs:// @!has foo/fn.foo.html '//section[@id="main"]//pre' "x: &'x impl Foo"

This test looks strange. The generated documentation looks like this (wrapped in pre):

pub fn foo<'x>(
    x: &'x impl Foo
) -> &'x impl Foo

so it seems like the backslash in the test is taken literally which means that it doesn't match. Is that on purpose? @GuillaumeGomez it seems like you created the test, so perhaps you can enlighten me?

Edit: To be clear, removing the backslash from the test causes the test to fail.

My understanding is that test is trying to assert that fn.foo.html doesn't contain the phrase x: &' impl Foo, but because it is erroneously escaping a quote it fails to make that assertion. Furthermore, the generated fn.foo.html file actually does contain the text being checked for, so there is a bug in rustdoc as well.

Activity

Munksgaard

Munksgaard commented on Oct 19, 2018

@Munksgaard
ContributorAuthor

This issue should be assigned to @GuillaumeGomez, as per his request in #54824 (comment)

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Oct 19, 2018
added
A-testsuiteArea: The testsuite used to check the correctness of rustc
C-bugCategory: This is a bug.
on Jul 29, 2019
liketechnik

liketechnik commented on Oct 24, 2020

@liketechnik
Contributor

@rustbot claim

liketechnik

liketechnik commented on Oct 25, 2020

@liketechnik
Contributor

I've made the following observations:

  • The current output of rustdoc for the test is the same as the output with the initial implementation used with the test (e67bba8) and also seems to match with the initial goal of the implementation in Fix missing impl trait display as ret type #53541. (I don't think the actual output of rustdoc is necessary here, but can provide that if needed).
  • The check has not been modified since its creation, I haven't been able to compare the implementations of the relevant parts in rustdoc though, due to my unfamiliarity with rustdocs code.

My interpretation is that there is no bug in rustdoc (since the output stayed the same), but the test simply never validated the output correctly, because

  • all checks validate the absence (all checks start with @!has) of an impl Type in parameters or return values, while the original goal of the implementation (see Fix missing impl trait display as ret type #53541) was to add support for impl Type in parameters and return values. Example:
    // @!has foo/fn.foo.html '//section[@id="main"]//pre' "x: &\'x impl Foo"
    // @!has foo/fn.foo.html '//section[@id="main"]//pre' "-> &\'x impl Foo {"
    pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo {
    which would generate pub fn foo<'x>(x: &'x impl Foo) -> &'x impl Foo as documentation
  • all checks expect an opening brace { after the return type, which is not generated by rustdoc. This makes the checks work, because now the 'expected' (see point 1) mismatch occurs.
  • all checks with a lifetime were erroneously escaping a quote. Again, this makes the checks work, because now the 'expected' mismatch occurs.

If my observations are correct, I would go forward by opening a pr fixing the issues listed above for the test (e. g. making the test fail for possibly incorrect output by rustdoc in the future).

jyn514

jyn514 commented on Nov 4, 2020

@jyn514
Member

@GuillaumeGomez can you confirm whether the summary above is correct?

GuillaumeGomez

GuillaumeGomez commented on Nov 4, 2020

@GuillaumeGomez
Member

Yes, it seems to be correct. Thanks for the summary @liketechnik ! Please feel free to open the PR. :)

added 2 commits that reference this issue on Nov 5, 2020

Rollup merge of rust-lang#78727 - liketechnik:issue-55201, r=Guillaum…

0878abd

Rollup merge of rust-lang#78727 - liketechnik:issue-55201, r=Guillaum…

d189cdb
added 2 commits that reference this issue on Nov 5, 2020

Rollup merge of rust-lang#78727 - liketechnik:issue-55201, r=Guillaum…

47cfe95

Rollup merge of rust-lang#78727 - liketechnik:issue-55201, r=Guillaum…

9bbb052
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-testsuiteArea: The testsuite used to check the correctness of rustcC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @Munksgaard@jonas-schievink@GuillaumeGomez@jyn514@liketechnik

    Issue actions

      impl-everywhere.rs has a weird test · Issue #55201 · rust-lang/rust