-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove a few actually_rustdoc
uses
#107289
Conversation
@bors try @rust-timer queue |
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @compiler-errors (or someone else) soon. Please see the contribution instructions for more information. |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit a331842812fd8111853827ac5fc158b18de4b021 with merge 7f7032a99cafd0b1752b8d0f1ffca8ebfb14e9ab... |
cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki |
// Since rustdoc doesn't care about the concrete type behind `impl Trait`, just don't look at it! | ||
// See https://github.com/rust-lang/rust/issues/75100 | ||
if tcx.sess.opts.actually_rustdoc { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there tests for this code path? If not, can you please double check that documenting async-std still works after this change? Make sure to enable all the features enabled on doc's.rs (you can use doc-like-docs.rs in @Nemo157 's dotfiles).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are tests. I'll run the try build on async-std once it finishes. Seems like rustup toolchain link
on local builds doesn't work for rustdoc as cargo +linked_thingy doc
can't find libcore and libstd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should work - try x build rustdoc library
, or just x build
without arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm weird, not sure what I was doing wrong before.
It passes fine now with --all-features
grml... |
@@ -317,6 +318,12 @@ pub(crate) fn create_config( | |||
} | |||
(rustc_interface::DEFAULT_QUERY_PROVIDERS.type_of)(tcx, def_id) | |||
}; | |||
providers.codegen_fn_attrs = |_, did| { | |||
assert!(did.is_local()); | |||
CodegenFnAttrs::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Won't it end up in us failing to include the target features in the generated docs?
cc @Amanieu , I'm not sure if this has tests.
I am not sure this is the right approach. I worry that we are allowing code to be even more broken than before, in ways that are not tested or guaranteed, but people will still depend on. |
Either rustdoc runs all checks, or rustdoc expects the crate to already pass rustc. This PR just takes the second variant further to its extreme. |
Yes, that in itself seems ok to me - my worry is that the broken code we newly accept isn't tested and we'll only know if it regresses once someone complains. See #75100 for an example. |
Oh yea, that's definitely a problem. Do you expect this to be worse due to this PR? If the fix is adding an |
/// of the same function in scope at the same time, which isn't legal Rust otherwise. See | ||
/// https://doc.rust-lang.org/beta/rustdoc/advanced-features.html#interactions-between-platform-specific-docs | ||
/// for details | ||
pub fn reset_delayed_bugs(&self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn reset_delayed_bugs(&self) { | |
pub fn reset_delayed_bugs(&self) { | |
assert!(self.opts.actually_rustdoc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆 I want to remove that flag at some point
Yes - before checks had to explicitly special case rustdoc in order to be ignored, now all checks are blanket ignored. So we are accepting strictly more code than before, and in ways that are not predictable and therefore hard to test. I suspect #79461 (and the other linked issues) will compile successfully instead of ICEing after this change. |
And from looking at what they do, I suspect the fix I would consider least invasive is to add an |
I am confused. I thought the goal of this PR was to get rid of actually_rustdoc checks, not to accept more invalid code (I don't particularly care about those linked ICEs for the reasons stated in #79496 (comment)). |
@rust-timer build 7f7032a99cafd0b1752b8d0f1ffca8ebfb14e9ab |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (7f7032a99cafd0b1752b8d0f1ffca8ebfb14e9ab): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
tcx.sess.time("item_types_checking", || { | ||
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module)) | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance improvement is almost entirely due to this change. We stop checking item signatures.
Looks great, thanks! |
/// of the same function in scope at the same time, which isn't legal Rust otherwise. See | ||
/// <https://doc.rust-lang.org/beta/rustdoc/advanced-features.html#interactions-between-platform-specific-docs> | ||
/// for details | ||
pub fn reset_delayed_bugs(&self) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to still keep a record of the fact that there was a delayed bug and if so ICE when using sess.compile_error()
but ignore this flag when using a new sess.compile_error_allow_reset_delay_bugs()
to be used in rustdoc? Or maybe even have that later method be the method that is actually responsible for ignoring delayed bugs?
|
||
#![feature(const_transmute)] | ||
|
||
const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; //~ ERROR cannot transmute between types of different sizes, or dependently-sized types | ||
const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this public to force it to be evaluated? Otherwise #79494 could regress for documented items.
#![allow(unused)] | ||
|
||
// check-pass | ||
|
||
trait Foo<T>: Sized { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this needs to be public too?
// Normalize the emitted location so this doesn't need | ||
// updating everytime someone adds or removes a line. | ||
// normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" | ||
// check-pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This no longer tests -Ztrack-diagnostics
.
☔ The latest upstream changes (presumably #106399) made this pull request unmergeable. Please resolve the merge conflicts. |
Discussed during T-compiler meeting (Zulip notes). Will need another thought in a separate conversation. @rustbot label -I-compiler-nominated |
Gonna mark this as blocked then 🤔 lemme know if I misinterpreted the current status @rustbot blocked |
do you want to kick off a rustdoc FCP? |
I am no longer on the rustdoc team. |
I'm a bit shared on this: it does improve performance but on the other hand, some code that was supposed to fail isn't failing anymore. Really not sure what to think about it... |
it's more of a general question, not specifically about this PR: Is rustdoc supposed to work with broken Rust code, because you should only run rustdoc on code that works with rustc?
I don't think the current middle ground is a good place to be in, and I'd rather find a way to get to one of the extremes. Or is there another option that I'm not thinking about? |
@oli-obk not so much a third option, but lots of delay_span_bug calls are for errors in the caller, not in the code. rustdoc already misuses the API and i think that will get worse if we silence delayed bugs. |
That's true, but if the alternative is to wrap all |
I don't think that's what would happen. There are many many delay_span_bug calls and only a small fraction special case rustdoc, usually around function bodies and impl trait. This would turn off the checking for the trait system as well, which is very likely to cause real bugs in collect_blanket_impls. |
I agree, but that's because I'm team "only allow legal Rust as Rustdoc input.". We can't keep Rustdoc from ICEing otherwise. So in my opinion that's the options we have: make Rustdoc even weirder by hiding as many failures as we can, or fix it to stop allowing broken code. I would like to move away from the current situation in either direction. |
Sorry, forgot about this. Let's see what the @rust-lang/rustdoc team thinks about this. |
That doesn’t seem okay.
The way it’s supposed to work is that rustdoc does type checking on items — but not on function bodies — because the function’s type signature completely describes its type. That’s what the book says, so that’s what rustdoc promised, but it can’t be true because the function body can change the auto traits of an async generator or RPIT.
The spot where I’m really worried is running collect_auto_traits on a TAIT. It can’t be done without type checking function bodies, and not doing it (even transitively, if a struct contains a TAIT) would be annoying for anybody who isn’t writing crates with platform-specific code using the cfg(doc) hack. Not running auto trait checks on TAIT seems like bailing on a feature at the point where it would be most useful. In short, I’m on team stop-accepting-broken-code too, because it seems like the language is changing in a direction that makes the original assumption around skipping function bodies invalid. |
started a discussion at https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/stop.20accepting.20broken.20code about what it would take to start doing this. for now i'm going to close this pr since it seems like the team doesn't want to move in the direction of accepting more broken code. |
r? @compiler-errors because it removes the hack from
cc @jyn514 this PR removes a bunch of your FIXME comments from the compiler.
Notable change in this PR is that rustdoc now ignores
delay_span_bug
in general, which I think is reasonable, considering rustdoc compiles invalid Rust code (multiple items with the same name, but from different cfgs).