-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Changes from all commits
393564b
8f383fb
6781998
c77ee07
1e60d58
af24901
100fed7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -511,7 +511,7 @@ impl Drop for HandlerInner { | |
self.emit_stashed_diagnostics(); | ||
|
||
if !self.has_errors() { | ||
let bugs = std::mem::replace(&mut self.delayed_span_bugs, Vec::new()); | ||
let bugs = std::mem::take(&mut self.delayed_span_bugs); | ||
self.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued"); | ||
} | ||
|
||
|
@@ -521,7 +521,7 @@ impl Drop for HandlerInner { | |
// lints can be `#[allow]`'d, potentially leading to this triggering. | ||
// Also, "good path" should be replaced with a better naming. | ||
if !self.has_any_message() && !self.suppressed_expected_diag { | ||
let bugs = std::mem::replace(&mut self.delayed_good_path_bugs, Vec::new()); | ||
let bugs = std::mem::take(&mut self.delayed_good_path_bugs); | ||
self.flush_delayed( | ||
bugs, | ||
"no warnings or errors encountered even though `delayed_good_path_bugs` issued", | ||
|
@@ -661,6 +661,19 @@ impl Handler { | |
inner.stashed_diagnostics = Default::default(); | ||
} | ||
|
||
/// Avoid failing compilation in the presence of delayed bugs. | ||
/// | ||
/// NOTE: *do not* call this function from rustc. It is only meant to be called from rustdoc. | ||
/// Rustdoc documents multiple targets at once, meaning there may be multiple versions | ||
/// 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 commentThe 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 |
||
let mut inner = self.inner.borrow_mut(); | ||
inner.delayed_span_bugs = Default::default(); | ||
inner.delayed_good_path_bugs = Default::default(); | ||
} | ||
|
||
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key. | ||
/// Retrieve a stashed diagnostic with `steal_diagnostic`. | ||
pub fn stash_diagnostic(&self, span: Span, key: StashKey, diag: Diagnostic) { | ||
|
@@ -1231,7 +1244,7 @@ impl Handler { | |
|
||
pub fn flush_delayed(&self) { | ||
let mut inner = self.inner.lock(); | ||
let bugs = std::mem::replace(&mut inner.delayed_span_bugs, Vec::new()); | ||
let bugs = std::mem::take(&mut inner.delayed_span_bugs); | ||
inner.flush_delayed(bugs, "no errors encountered even though `delay_span_bug` issued"); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -219,14 +219,6 @@ fn check_opaque(tcx: TyCtxt<'_>, id: hir::ItemId) { | |
return; | ||
}; | ||
|
||
// HACK(jynelson): trying to infer the type of `impl trait` breaks documenting | ||
// `async-std` (and `pub async fn` in general). | ||
// 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 commentThe 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That should work - try There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
} | ||
|
||
let substs = InternalSubsts::identity_for_item(tcx, item.owner_id.to_def_id()); | ||
let span = tcx.def_span(item.owner_id.def_id); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,12 @@ use rustc_errors::emitter::{Emitter, EmitterWriter}; | |
use rustc_errors::json::JsonEmitter; | ||
use rustc_feature::UnstableFeatures; | ||
use rustc_hir::def::{Namespace, Res}; | ||
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId}; | ||
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet}; | ||
use rustc_hir::intravisit::{self, Visitor}; | ||
use rustc_hir::{HirId, Path, TraitCandidate}; | ||
use rustc_interface::interface; | ||
use rustc_middle::hir::nested_filter; | ||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; | ||
use rustc_middle::ty::{ParamEnv, Ty, TyCtxt}; | ||
use rustc_resolve as resolve; | ||
use rustc_session::config::{self, CrateType, ErrorOutputType}; | ||
|
@@ -22,7 +23,6 @@ use rustc_span::{source_map, Span, Symbol}; | |
use std::cell::RefCell; | ||
use std::mem; | ||
use std::rc::Rc; | ||
use std::sync::LazyLock; | ||
|
||
use crate::clean::inline::build_external_trait; | ||
use crate::clean::{self, ItemId}; | ||
|
@@ -283,11 +283,10 @@ pub(crate) fn create_config( | |
providers.lint_mod = |_, _| {}; | ||
// Prevent `rustc_hir_analysis::check_crate` from calling `typeck` on all bodies. | ||
providers.typeck_item_bodies = |_, _| {}; | ||
providers.check_mod_item_types = | ||
|_, _| panic!("check_mod_item_types should not get called at all in rustdoc"); | ||
// hack so that `used_trait_imports` won't try to call typeck | ||
providers.used_trait_imports = |_, _| { | ||
static EMPTY_SET: LazyLock<UnordSet<LocalDefId>> = LazyLock::new(UnordSet::default); | ||
&EMPTY_SET | ||
}; | ||
providers.used_trait_imports = |_, _| Box::leak(Box::new(UnordSet::default())); | ||
// In case typeck does end up being called, don't ICE in case there were name resolution errors | ||
providers.typeck = move |tcx, def_id| { | ||
// Closures' tables come from their outermost function, | ||
|
@@ -304,6 +303,27 @@ pub(crate) fn create_config( | |
EmitIgnoredResolutionErrors::new(tcx).visit_body(body); | ||
(rustc_interface::DEFAULT_QUERY_PROVIDERS.typeck)(tcx, def_id) | ||
}; | ||
providers.type_of = |tcx, def_id| { | ||
let did = def_id.expect_local(); | ||
use rustc_hir::*; | ||
|
||
let hir_id = tcx.hir().local_def_id_to_hir_id(did); | ||
|
||
match tcx.hir().get(hir_id) { | ||
Node::Item(item) => match item.kind { | ||
ItemKind::OpaqueTy(_) => return tcx.ty_error(), | ||
_ => {} | ||
}, | ||
_ => {} | ||
} | ||
(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 commentThe 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. |
||
}; | ||
providers.supported_target_features = | ||
|_, _| panic!("supported_target_features should not get called by rustdoc"); | ||
}), | ||
make_codegen_backend: None, | ||
registry: rustc_driver::diagnostics_registry(), | ||
|
@@ -326,14 +346,8 @@ pub(crate) fn run_global_ctxt( | |
// typeck function bodies or run the default rustc lints. | ||
// (see `override_queries` in the `config`) | ||
|
||
// HACK(jynelson) this calls an _extremely_ limited subset of `typeck` | ||
// HACK(jynelson) this calls an _extremely_ limited subset of what the `analysis` query does | ||
// and might break if queries change their assumptions in the future. | ||
|
||
// NOTE: This is copy/pasted from typeck/lib.rs and should be kept in sync with those changes. | ||
tcx.sess.time("item_types_checking", || { | ||
tcx.hir().for_each_module(|module| tcx.ensure().check_mod_item_types(module)) | ||
}); | ||
Comment on lines
-333
to
-335
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
tcx.sess.abort_if_errors(); | ||
tcx.sess.time("missing_docs", || { | ||
rustc_lint::check_crate(tcx, rustc_lint::builtin::MissingDoc::new); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// only-x86_64-unknown-linux-gnu | ||
// check-pass | ||
|
||
#![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 commentThe 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. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
// should-fail | ||
|
||
#![allow(unused)] | ||
|
||
// check-pass | ||
|
||
trait Foo<T>: Sized { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this needs to be public too? |
||
fn bar(i: i32, t: T, s: &Self) -> (T, i32); | ||
} | ||
|
||
impl Foo<usize> for () { | ||
fn bar(i: _, t: _, s: _) -> _ { | ||
//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions | ||
(1, 2) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
// compile-flags: -Z track-diagnostics | ||
// error-pattern: created at | ||
|
||
// 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 commentThe reason will be displayed to describe this comment to others. Learn more. This no longer tests |
||
|
||
struct A; | ||
struct B; | ||
|
This file was deleted.
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.
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