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 doesn't highlight "&&" properly #72684

Closed
refacto opened this issue May 28, 2020 · 5 comments · Fixed by #73807
Closed

rustdoc doesn't highlight "&&" properly #72684

refacto opened this issue May 28, 2020 · 5 comments · Fixed by #73807
Assignees
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@refacto
Copy link

refacto commented May 28, 2020

I tried viewing this code with rustdoc:

// Both opts don't make sense
if matches.opt_present("m") && matches.opt_present("a") {
    print_usage(&program, opts);
    return;
}

I expected to see this happen: the && operator to be highlighted correctly

Instead, this happened:
20200528_10h35m34s_grim

Meta

rustc --version --verbose: (issue also exists with nightly, 2020-05-14)

rustc 1.43.1 (8d69840ab 2020-05-04)
binary: rustc
commit-hash: 8d69840ab92ea7f4d323420088dd8c9775f180cd
commit-date: 2020-05-04
host: x86_64-unknown-linux-musl
release: 1.43.1
LLVM version: 9.0

This issue has been assigned to @euclio via this comment.

@refacto refacto added the C-bug Category: This is a bug. label May 28, 2020
@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 28, 2020
@euclio
Copy link
Contributor

euclio commented May 29, 2020

@rustbot claim

@rustbot rustbot self-assigned this May 29, 2020
@euclio
Copy link
Contributor

euclio commented May 29, 2020

Looks like this was broken by #63709. cc @matklad

Not sure what the best course of action is here. Seems like we could move the syntax highlighting to use token trees, but I don't think that preserves whitespace information.

@GuillaumeGomez
Copy link
Member

I don't think whitespace is preserved in token trees, indeed. :-/

@euclio
Copy link
Contributor

euclio commented May 30, 2020

We may not need whitespace information after all. We can just classify a token, emit any bytes from the source up to its first span, emit the opening HTML tag, emit the token, then the closing tag. Then do the same for all remaining tokens.

@euclio
Copy link
Contributor

euclio commented Jun 27, 2020

Using token trees won't work because comments are not preserved.

Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
…e27,GuillaumeGomez

rustdoc: glue tokens before highlighting

Fixes rust-lang#72684.

This commit also modifies the signature of `Classifier::new` to avoid
copying the source being highlighted.
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
…e27,GuillaumeGomez

rustdoc: glue tokens before highlighting

Fixes rust-lang#72684.

This commit also modifies the signature of `Classifier::new` to avoid
copying the source being highlighted.
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
…e27,GuillaumeGomez

rustdoc: glue tokens before highlighting

Fixes rust-lang#72684.

This commit also modifies the signature of `Classifier::new` to avoid
copying the source being highlighted.
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 16, 2020
…e27,GuillaumeGomez

rustdoc: glue tokens before highlighting

Fixes rust-lang#72684.

This commit also modifies the signature of `Classifier::new` to avoid
copying the source being highlighted.
@bors bors closed this as completed in c3ee75d Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants