Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
da25af2
Make spans for tuple patterns in E0023 more precise
camelid Aug 17, 2021
f1e8607
Don't stabilize creation of TryReserveError instances
kornelski Aug 21, 2021
d0b482a
Add more tuple pattern too many fields test cases
camelid Aug 18, 2021
0fa3b4f
Make E0023 spans even more precise
camelid Aug 18, 2021
02ed23c
Use an exhaustive match in `Node::ident()` and add docs
camelid Aug 18, 2021
08ceac8
Add cross-crate tuple field count error test
camelid Aug 21, 2021
19f4510
Bless tests
camelid Aug 22, 2021
d933edd
Revert "Revert "Don't load all extern crates unconditionally""
jyn514 Aug 21, 2021
820e268
handle ascription type op in NLL HRTB diagnostics
lqd Aug 23, 2021
7b0e564
Update NLL HRTB type ascription blessed expectations
lqd Aug 23, 2021
a216d66
type_implements_trait consider obligation failure on overflow
arora-aman Aug 25, 2021
d7d122f
update docs for `type_implements_trait`
nikomatsakis Aug 25, 2021
88bcd44
trailing whitespace
nikomatsakis Aug 25, 2021
33c71ac
Add `c_size_t` and `c_ssize_t` to `std::os::raw`.
thomcc Aug 25, 2021
0a42dfc
Fix debugger stepping behavior around `match` expressions
wesleywiser Jul 23, 2021
8a6501d
Adjust spans
camelid Aug 25, 2021
5b25de5
Reference tracking issue
thomcc Aug 25, 2021
5df5659
Revert "Add type of a let tait test impl trait straight in let"
spastorino Aug 25, 2021
bb583f7
Add field types tait tests
spastorino Aug 25, 2021
84a2661
Add test for stepping though `match` expressions
wesleywiser Aug 6, 2021
4924e34
Add argument types tait tests
spastorino Aug 25, 2021
027db5d
RustWrapper: adapt to LLVM change 0f45c16f2caa
durin42 Aug 24, 2021
c60a370
Fix the bugs and add a regression test
jyn514 Aug 21, 2021
fb79597
Rollup merge of #87832 - wesleywiser:fix_match_step, r=davidtwco
Manishearth Aug 26, 2021
8aa46e5
Rollup merge of #88123 - camelid:tup-pat-precise-spans, r=estebank
Manishearth Aug 26, 2021
14fb87a
Rollup merge of #88215 - jyn514:lazy-loading, r=petrochenkov
Manishearth Aug 26, 2021
cf5e362
Rollup merge of #88216 - kornelski:from_layout_err, r=kennytm
Manishearth Aug 26, 2021
1e94fe1
Rollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakis
Manishearth Aug 26, 2021
dfca7b3
Rollup merge of #88289 - durin42:llvm-14-attrs, r=nikic
Manishearth Aug 26, 2021
c418a48
Rollup merge of #88320 - sexxi-goose:issue-88103, r=nikomatsakis
Manishearth Aug 26, 2021
0f7dc5d
Rollup merge of #88332 - spastorino:argument-types-tait-test, r=oli-obk
Manishearth Aug 26, 2021
e760740
Rollup merge of #88340 - thomcc:c_size_t, r=joshtriplett
Manishearth Aug 26, 2021
cb95e36
Rollup merge of #88346 - spastorino:revert-type-of-a-let2, r=jackh726
Manishearth Aug 26, 2021
af54936
Rollup merge of #88348 - spastorino:field-types-tait-test, r=oli-obk
Manishearth Aug 26, 2021
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Revert "Don't load all extern crates unconditionally""
This reverts commit 5f0c54d.
  • Loading branch information
jyn514 committed Aug 22, 2021
commit d933edd5c6ee149d53bff4558c3fef8dc68b8766
43 changes: 9 additions & 34 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use rustc_ast as ast;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{self, Lrc};
use rustc_driver::abort_on_err;
use rustc_errors::emitter::{Emitter, EmitterWriter};
use rustc_errors::json::JsonEmitter;
use rustc_feature::UnstableFeatures;
use rustc_hir::def::Namespace::TypeNS;
use rustc_hir::def::Res;
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_INDEX};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::HirId;
use rustc_hir::{
intravisit::{self, NestedVisitorMap, Visitor},
Expand All @@ -23,7 +23,7 @@ use rustc_session::DiagnosticOutput;
use rustc_session::Session;
use rustc_span::source_map;
use rustc_span::symbol::sym;
use rustc_span::{Span, DUMMY_SP};
use rustc_span::Span;

use std::cell::RefCell;
use std::mem;
Expand Down Expand Up @@ -301,41 +301,16 @@ crate fn create_config(
}

crate fn create_resolver<'a>(
externs: config::Externs,
queries: &Queries<'a>,
sess: &Session,
) -> Rc<RefCell<interface::BoxedResolver>> {
let extern_names: Vec<String> = externs
.iter()
.filter(|(_, entry)| entry.add_prelude)
.map(|(name, _)| name)
.cloned()
.collect();

let (_, resolver, _) = &*abort_on_err(queries.expansion(), sess).peek();

// Before we actually clone it, let's force all the extern'd crates to
// actually be loaded, just in case they're only referred to inside
// intra-doc links
resolver.borrow_mut().access(|resolver| {
sess.time("load_extern_crates", || {
for extern_name in &extern_names {
debug!("loading extern crate {}", extern_name);
if let Err(()) = resolver
.resolve_str_path_error(
DUMMY_SP,
extern_name,
TypeNS,
LocalDefId { local_def_index: CRATE_DEF_INDEX }.to_def_id(),
) {
warn!("unable to resolve external crate {} (do you have an unused `--extern` crate?)", extern_name)
}
}
});
});
let (krate, resolver, _) = &*abort_on_err(queries.expansion(), sess).peek();
let resolver = resolver.clone();

let mut loader = crate::passes::collect_intra_doc_links::IntraLinkCrateLoader::new(resolver);
ast::visit::walk_crate(&mut loader, krate);

// Now we're good to clone the resolver because everything should be loaded
resolver.clone()
loader.resolver
}

crate fn run_global_ctxt(
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern crate tracing;
// Dependencies listed in Cargo.toml do not need `extern crate`.

extern crate rustc_ast;
extern crate rustc_ast_lowering;
extern crate rustc_ast_pretty;
extern crate rustc_attr;
extern crate rustc_data_structures;
Expand Down Expand Up @@ -724,7 +725,6 @@ fn main_options(options: config::Options) -> MainResult {
let default_passes = options.default_passes;
let output_format = options.output_format;
// FIXME: fix this clone (especially render_options)
let externs = options.externs.clone();
let manual_passes = options.manual_passes.clone();
let render_options = options.render_options.clone();
let config = core::create_config(options);
Expand All @@ -742,7 +742,7 @@ fn main_options(options: config::Options) -> MainResult {
// We need to hold on to the complete resolver, so we cause everything to be
// cloned for the analysis passes to use. Suboptimal, but necessary in the
// current architecture.
let resolver = core::create_resolver(externs, queries, &sess);
let resolver = core::create_resolver(queries, &sess);

if sess.has_errors() {
sess.fatal("Compilation failed, aborting rustdoc");
Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ use crate::html::markdown::{markdown_links, MarkdownLink};
use crate::lint::{BROKEN_INTRA_DOC_LINKS, PRIVATE_INTRA_DOC_LINKS};
use crate::passes::Pass;

mod early;
crate use early::IntraLinkCrateLoader;

crate const COLLECT_INTRA_DOC_LINKS: Pass = Pass {
name: "collect-intra-doc-links",
run: collect_intra_doc_links,
Expand Down
63 changes: 63 additions & 0 deletions src/librustdoc/passes/collect_intra_doc_links/early.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use rustc_ast as ast;
use rustc_hir::def::Namespace::TypeNS;
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_INDEX};
use rustc_interface::interface;

use std::cell::RefCell;
use std::mem;
use std::rc::Rc;

// Letting the resolver escape at the end of the function leads to inconsistencies between the
// crates the TyCtxt sees and the resolver sees (because the resolver could load more crates
// after escaping). Hopefully `IntraLinkCrateLoader` gets all the crates we need ...
crate struct IntraLinkCrateLoader {
current_mod: DefId,
crate resolver: Rc<RefCell<interface::BoxedResolver>>,
}

impl IntraLinkCrateLoader {
crate fn new(resolver: Rc<RefCell<interface::BoxedResolver>>) -> Self {
let crate_id = LocalDefId { local_def_index: CRATE_DEF_INDEX }.to_def_id();
Self { current_mod: crate_id, resolver }
}
}

impl ast::visit::Visitor<'_> for IntraLinkCrateLoader {
fn visit_attribute(&mut self, attr: &ast::Attribute) {
use crate::html::markdown::markdown_links;
use crate::passes::collect_intra_doc_links::preprocess_link;

if let Some(doc) = attr.doc_str() {
for link in markdown_links(&doc.as_str()) {
let path_str = if let Some(Ok(x)) = preprocess_link(&link) {
x.path_str
} else {
continue;
};
self.resolver.borrow_mut().access(|resolver| {
let _ = resolver.resolve_str_path_error(
attr.span,
&path_str,
TypeNS,
self.current_mod,
);
});
}
}
ast::visit::walk_attribute(self, attr);
}

fn visit_item(&mut self, item: &ast::Item) {
use rustc_ast_lowering::ResolverAstLowering;

if let ast::ItemKind::Mod(..) = item.kind {
let new_mod =
self.resolver.borrow_mut().access(|resolver| resolver.local_def_id(item.id));
let old_mod = mem::replace(&mut self.current_mod, new_mod.to_def_id());
ast::visit::walk_item(self, item);
self.current_mod = old_mod;
} else {
ast::visit::walk_item(self, item);
}
}
}
2 changes: 1 addition & 1 deletion src/librustdoc/passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ crate use self::unindent_comments::UNINDENT_COMMENTS;
mod propagate_doc_cfg;
crate use self::propagate_doc_cfg::PROPAGATE_DOC_CFG;

mod collect_intra_doc_links;
crate mod collect_intra_doc_links;
crate use self::collect_intra_doc_links::COLLECT_INTRA_DOC_LINKS;

mod doc_test_lints;
Expand Down
17 changes: 17 additions & 0 deletions src/test/rustdoc-ui/auxiliary/panic-item.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// no-prefer-dynamic
#![crate_type = "lib"]
#![no_std]
#![feature(lang_items)]

use core::panic::PanicInfo;
use core::sync::atomic::{self, Ordering};

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
loop {
atomic::compiler_fence(Ordering::SeqCst);
}
}

#[lang = "eh_personality"]
fn foo() {}
3 changes: 3 additions & 0 deletions src/test/rustdoc-ui/unused-extern-crate.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// check-pass
// aux-crate:panic_item=panic-item.rs
// @has unused_extern_crate/index.html
2 changes: 0 additions & 2 deletions src/test/rustdoc/auxiliary/issue-66159-1.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// aux-crate:priv:issue_66159_1=issue-66159-1.rs
// aux-crate:priv:pub_struct=pub-struct.rs
// compile-flags:-Z unstable-options

// The issue was an ICE which meant that we never actually generated the docs
Expand All @@ -7,4 +7,4 @@
// verify that the struct is linked correctly.

// @has issue_66159/index.html
//! [issue_66159_1::Something]
//! [pub_struct::SomeStruct]