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 generates playpen links with incorrect indentation #35483

Closed
frewsxcv opened this issue Aug 8, 2016 · 6 comments
Closed

rustdoc generates playpen links with incorrect indentation #35483

frewsxcv opened this issue Aug 8, 2016 · 6 comments
Labels
C-bug Category: This is a bug. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@frewsxcv
Copy link
Member

frewsxcv commented Aug 8, 2016

Steps to reproduce:

  1. https://doc.rust-lang.org/std/env/fn.args.html
  2. Click on "Run" in the example block

Playpen opens up with this code snippet:

fn main() {
    use std::env;

// Prints each argument on a separate line
for argument in env::args() {
    println!("{}", argument);
}
}

It should instead open up with this snippet:

fn main() {
    use std::env;

    // Prints each argument on a separate line
    for argument in env::args() {
        println!("{}", argument);
    }
}
@durka
Copy link
Contributor

durka commented Aug 8, 2016

Regressed sometime between 1.9.0 and 1.10.0.

@ollie27
Copy link
Member

ollie27 commented Aug 8, 2016

This was caused by #33512 which fixed #25944. There is an open PR about this: #35012.

@frewsxcv frewsxcv added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Nov 17, 2016
@frewsxcv frewsxcv changed the title rustdoc generates playpen links with incorrect identation rustdoc generates playpen links with incorrect indentation Feb 20, 2017
@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 25, 2017
@kzys
Copy link
Contributor

kzys commented Sep 1, 2018

Note that #35012 has been closed without merging the change. Meanwhile Playground is showing the snippet like below now;

#![allow(unused)]
fn main() {
use std::env;

// Prints each argument on a separate line
for argument in env::args() {
    println!("{}", argument);
}
}

@kzys
Copy link
Contributor

kzys commented Sep 1, 2018

As @alexcrichton wrote on #35012, indenting Rust code without parsing would change the meaning of the code. So, can we fix the issue without parsing (or parsing Rust code for indentation is worthwhile?)

@QuietMisdreavus
Copy link
Member

Current status: The code that goes into playground links is generated by the same code that generates doctests, so any change to fix this issue will also affect doctests. Coincidentally enough, thanks to #54861 we run the full libsyntax parser on doctests now, so if there's a way to match items back to their place in the original string we can try to mess with the indentation that way.

@camelid camelid added the E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. label Jan 29, 2021
@ehuss ehuss removed the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label Jan 18, 2022
@fmease
Copy link
Member

fmease commented Sep 3, 2024

This now works correctly

@fmease fmease closed this as completed Sep 3, 2024
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. E-hard Call for participation: Hard difficulty. Experience needed to fix: A lot. 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

10 participants