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

Don't generate minification variables if not needed #59400

Conversation

GuillaumeGomez
Copy link
Member

Follow up of #59158 and #59157.

r? @QuietMisdreavus

cc @jdm

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 24, 2019
@QuietMisdreavus
Copy link
Member

I wonder if we can make a test for this. Can we use rustdoc tests to look at the search index javascript? Since the initial minification variables are always going to have the same line to initialize them, we could look for something like that. I think we can also use an auxiliary crate to test what happens when a dependency has minified the search index but a downstream crate has disabled it - from what i can tell, auxiliary doc builds use the properties from the aux file itself instead of the main test.

@GuillaumeGomez
Copy link
Member Author

I could write a test which would simply load the searchIndex file and if an error occurs, it means the generation failed. However, this would require a new test-suite since we need to build using --disable-minification.

@QuietMisdreavus
Copy link
Member

I was thinking something even simpler, doing a substring search using a @has rule in a regular rustdoc test. We can pass the --disable-minification flag in those just fine - a compile-flags:--disable-minification -Z unstable-options rule in the test should suffice.

@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Mar 27, 2019

Such a test would completely fail to trigger when a minification issue would appear. :-/

@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 1, 2019
@ollie27
Copy link
Member

ollie27 commented Apr 9, 2019

Is this added complexity worth it to save a few bytes in the none minified search-index.js?

@GuillaumeGomez
Copy link
Member Author

This is a simple change which generates less things. For me, it's totally worth it, although we can't really test it (or we'll need to create a whole new test suite, which I'd prefer to avoid).

@bors
Copy link
Contributor

bors commented Apr 14, 2019

☔ The latest upstream changes (presumably #59950) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Apr 26, 2019

☔ The latest upstream changes (presumably #60296) made this pull request unmergeable. Please resolve the merge conflicts.

@Mark-Simulacrum
Copy link
Member

@QuietMisdreavus Could we get a review/decision here either way?

I'm personally also somewhat inclined to say that we shouldn't do this as the 10-20 bytes we're saving aren't really worth the complexity introduced here in my opinion.

@GuillaumeGomez
Copy link
Member Author

Easy to say when you're not the one debugging the minified JS. :p

@GuillaumeGomez
Copy link
Member Author

Oh also, it fixes a bug currently present in the code, it doesn't add a new feature. Therefore it seems pretty worth it (but my opinion is completely biased in here since I use this feature quite heavily).

@Mark-Simulacrum
Copy link
Member

Ah, I was not aware that this fixes a bug -- I presumed that the variables don't hurt if they're unused, but I guess that's not true.

@GuillaumeGomez
Copy link
Member Author

By default, people don't have this bug since it needs a nightly-only option to be enabled. So indeed, it doesn't hurt to have unused variables if they're really not used. However, in here in some cases, the code references to them.

@Dylan-DPC-zz
Copy link

@bors: r+

@bors
Copy link
Contributor

bors commented Jun 3, 2019

📌 Commit 582c836 has been approved by Dylan-DPC

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 3, 2019
continue;
}
if line.starts_with(&format!(r#"{}["{}"]"#, key, krate)) {
if line.starts_with(MINIFIED_VARIABLES) {
is_minified = true;
Copy link
Member

Choose a reason for hiding this comment

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

This is dead code. The above:

if !line.starts_with(key) || line.starts_with(&format!(r#"{}["{}"]"#, key, krate)) {
    continue;
}

means that line.starts_with(MINIFIED_VARIABLES) can never be true. This means that the minification variables are missing if the last call to rustdoc used --disable-minification but previous ones didn't.

@ollie27
Copy link
Member

ollie27 commented Jun 3, 2019

@bors r-

Again I don't think this added complexity is worth it. Especially when it doesn't even work and has no tests.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 3, 2019
@bors
Copy link
Contributor

bors commented Jun 22, 2019

☔ The latest upstream changes (presumably #62041) made this pull request unmergeable. Please resolve the merge conflicts.

@joelpalmer
Copy link

Hi @GuillaumeGomez this is a ping from Triage. Please post an update on this PR at your earliest convenience.

@GuillaumeGomez
Copy link
Member Author

@ollie27 is against it so I guess I'll just close it...

@GuillaumeGomez GuillaumeGomez deleted the fix-disable-minification branch August 19, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants