Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate` rather than use an explicit cargo dependency, when it's necessary to use the same dependency version as used by rustc itself. However, this is dangerous for crates.io crates, since rustc may not pull in the dependency on some targets, or may pull in multiple versions. In both cases, the `extern crate` fails to resolve. To address this, re-export all such dependencies from the appropriate `rustc_*` crates, and use this alias from crates which would otherwise need to use `extern crate`.
This commit is contained in:
parent
e100792918
commit
c6a952159f
51 changed files with 193 additions and 151 deletions
|
|
@ -4119,6 +4119,7 @@ name = "rustc_log"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"tracing",
|
||||
"tracing-core",
|
||||
"tracing-subscriber",
|
||||
"tracing-tree",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -26,13 +26,12 @@ extern crate rustc_fs_util;
|
|||
extern crate rustc_hir;
|
||||
extern crate rustc_incremental;
|
||||
extern crate rustc_index;
|
||||
extern crate rustc_log;
|
||||
extern crate rustc_metadata;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
extern crate rustc_symbol_mangling;
|
||||
extern crate rustc_target;
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
// This prevents duplicating functions and statics that are already part of the host rustc process.
|
||||
#[allow(unused_extern_crates)]
|
||||
|
|
@ -46,6 +45,7 @@ use cranelift_codegen::isa::TargetIsa;
|
|||
use cranelift_codegen::settings::{self, Configurable};
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_codegen_ssa::{CodegenResults, TargetConfig};
|
||||
use rustc_log::tracing::info;
|
||||
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
|
||||
use rustc_session::Session;
|
||||
use rustc_session::config::OutputFilenames;
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ use rustc_codegen_ssa::traits::*;
|
|||
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
|
||||
use rustc_data_structures::memmap::Mmap;
|
||||
use rustc_errors::DiagCtxtHandle;
|
||||
use rustc_log::tracing::info;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::dep_graph::WorkProduct;
|
||||
use rustc_session::config::Lto;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use rustc_codegen_ssa::back::link::ensure_removed;
|
|||
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
|
||||
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
|
||||
use rustc_fs_util::link_or_copy;
|
||||
use rustc_log::tracing::debug;
|
||||
use rustc_session::config::OutputType;
|
||||
use rustc_target::spec::SplitDebuginfo;
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use rustc_codegen_ssa::traits::{
|
|||
use rustc_hir::attrs::Linkage;
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::def_id::LOCAL_CRATE;
|
||||
use rustc_log::tracing::trace;
|
||||
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||
use rustc_middle::mir::interpret::{
|
||||
self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
#[cfg(feature = "master")]
|
||||
use gccjit::Context;
|
||||
use rustc_codegen_ssa::target_features;
|
||||
use rustc_data_structures::smallvec::{SmallVec, smallvec};
|
||||
use rustc_session::Session;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
|
||||
fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
|
||||
target_features::retpoline_features_by_flags(sess, features);
|
||||
|
|
|
|||
|
|
@ -25,12 +25,6 @@
|
|||
#![deny(clippy::pattern_type_mismatch)]
|
||||
#![allow(clippy::needless_lifetimes, clippy::uninlined_format_args)]
|
||||
|
||||
// These crates are pulled from the sysroot because they are part of
|
||||
// rustc's public API, so we need to ensure version compatibility.
|
||||
extern crate smallvec;
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
// The rustc crates we need
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_apfloat;
|
||||
|
|
@ -44,6 +38,7 @@ extern crate rustc_hir;
|
|||
extern crate rustc_index;
|
||||
#[cfg(feature = "master")]
|
||||
extern crate rustc_interface;
|
||||
extern crate rustc_log;
|
||||
extern crate rustc_macros;
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_session;
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ use std::fmt;
|
|||
pub use atomic_ref::AtomicRef;
|
||||
pub use ena::{snapshot_vec, undo_log, unify};
|
||||
pub use rustc_index::static_assert_size;
|
||||
// Re-export some data-structure crates which are part of our public API.
|
||||
pub use {either, indexmap, smallvec, thin_vec};
|
||||
|
||||
pub mod aligned;
|
||||
pub mod base_n;
|
||||
|
|
|
|||
|
|
@ -325,6 +325,9 @@ lint_impl_trait_overcaptures = `{$self_ty}` will capture more lifetimes than pos
|
|||
lint_impl_trait_redundant_captures = all possible in-scope parameters are already captured, so `use<...>` syntax is redundant
|
||||
.suggestion = remove the `use<...>` syntax
|
||||
|
||||
lint_implicit_sysroot_crate_import = dangerous use of `extern crate {$name}` which is not guaranteed to exist exactly once in the sysroot
|
||||
.help = try using a cargo dependency or using a re-export of the dependency provided by a rustc_* crate
|
||||
|
||||
lint_implicit_unsafe_autorefs = implicit autoref creates a reference to the dereference of a raw pointer
|
||||
.note = creating a reference requires the pointer target to be valid and imposes aliasing requirements
|
||||
.raw_ptr = this raw pointer has type `{$raw_ptr_ty}`
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ use tracing::debug;
|
|||
use {rustc_ast as ast, rustc_hir as hir};
|
||||
|
||||
use crate::lints::{
|
||||
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, LintPassByHand,
|
||||
NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked, SpanUseEqCtxtDiag,
|
||||
SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind, TypeIrDirectUse,
|
||||
TypeIrInherentUsage, TypeIrTraitUsage, UntranslatableDiag,
|
||||
BadOptAccessDiag, DefaultHashTypesDiag, DiagOutOfImpl, ImplicitSysrootCrateImportDiag,
|
||||
LintPassByHand, NonGlobImportTypeIrInherent, QueryInstability, QueryUntracked,
|
||||
SpanUseEqCtxtDiag, SymbolInternStringLiteralDiag, TyQualified, TykindDiag, TykindKind,
|
||||
TypeIrDirectUse, TypeIrInherentUsage, TypeIrTraitUsage, UntranslatableDiag,
|
||||
};
|
||||
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
||||
|
||||
|
|
@ -745,3 +745,40 @@ impl<'tcx> LateLintPass<'tcx> for SymbolInternStringLiteral {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare_tool_lint! {
|
||||
/// The `implicit_sysroot_crate_import` detects use of `extern crate` to import non-sysroot crates
|
||||
/// (e.g. crates.io deps) from the sysroot, which is dangerous because these crates are not guaranteed
|
||||
/// to exist exactly once, and so may be missing entirely or appear multiple times resulting in ambiguity.
|
||||
pub rustc::IMPLICIT_SYSROOT_CRATE_IMPORT,
|
||||
Allow,
|
||||
"Forbid uses of non-sysroot crates in `extern crate`",
|
||||
report_in_external_macro: true
|
||||
}
|
||||
|
||||
declare_lint_pass!(ImplicitSysrootCrateImport => [IMPLICIT_SYSROOT_CRATE_IMPORT]);
|
||||
|
||||
impl EarlyLintPass for ImplicitSysrootCrateImport {
|
||||
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
|
||||
fn is_whitelisted(crate_name: &str) -> bool {
|
||||
// Whitelist of allowed crates.
|
||||
crate_name.starts_with("rustc_")
|
||||
|| matches!(
|
||||
crate_name,
|
||||
"test" | "self" | "core" | "alloc" | "std" | "proc_macro" | "tikv_jemalloc_sys"
|
||||
)
|
||||
}
|
||||
|
||||
if let ast::ItemKind::ExternCrate(original_name, imported_name) = &item.kind {
|
||||
let name = original_name.as_ref().unwrap_or(&imported_name.name).as_str();
|
||||
let externs = &cx.builder.sess().opts.externs;
|
||||
if externs.get(name).is_none() && !is_whitelisted(name) {
|
||||
cx.emit_span_lint(
|
||||
IMPLICIT_SYSROOT_CRATE_IMPORT,
|
||||
item.span,
|
||||
ImplicitSysrootCrateImportDiag { name },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -654,6 +654,8 @@ fn register_internals(store: &mut LintStore) {
|
|||
store.register_late_mod_pass(|_| Box::new(SpanUseEqCtxt));
|
||||
store.register_lints(&SymbolInternStringLiteral::lint_vec());
|
||||
store.register_late_mod_pass(|_| Box::new(SymbolInternStringLiteral));
|
||||
store.register_lints(&ImplicitSysrootCrateImport::lint_vec());
|
||||
store.register_early_pass(|| Box::new(ImplicitSysrootCrateImport));
|
||||
// FIXME(davidtwco): deliberately do not include `UNTRANSLATABLE_DIAGNOSTIC` and
|
||||
// `DIAGNOSTIC_OUTSIDE_OF_IMPL` here because `-Wrustc::internal` is provided to every crate and
|
||||
// these lints will trigger all of the time - change this once migration to diagnostic structs
|
||||
|
|
@ -676,6 +678,7 @@ fn register_internals(store: &mut LintStore) {
|
|||
LintId::of(BAD_OPT_ACCESS),
|
||||
LintId::of(SPAN_USE_EQ_CTXT),
|
||||
LintId::of(DIRECT_USE_OF_RUSTC_TYPE_IR),
|
||||
LintId::of(IMPLICIT_SYSROOT_CRATE_IMPORT),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -926,6 +926,13 @@ pub(crate) struct BadOptAccessDiag<'a> {
|
|||
pub msg: &'a str,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_implicit_sysroot_crate_import)]
|
||||
#[help]
|
||||
pub(crate) struct ImplicitSysrootCrateImportDiag<'a> {
|
||||
pub name: &'a str,
|
||||
}
|
||||
|
||||
// let_underscore.rs
|
||||
#[derive(LintDiagnostic)]
|
||||
pub(crate) enum NonBindingLet {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ edition = "2024"
|
|||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
tracing = "0.1.41"
|
||||
tracing-core = "0.1.34"
|
||||
tracing-subscriber = { version = "0.3.3", default-features = false, features = ["fmt", "env-filter", "smallvec", "parking_lot", "ansi"] }
|
||||
tracing-tree = "0.3.1"
|
||||
# tidy-alphabetical-end
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ use tracing_subscriber::filter::{Directive, EnvFilter, LevelFilter};
|
|||
use tracing_subscriber::fmt::FmtContext;
|
||||
use tracing_subscriber::fmt::format::{self, FormatEvent, FormatFields};
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
// Re-export tracing
|
||||
pub use {tracing, tracing_core, tracing_subscriber};
|
||||
|
||||
/// The values of all the environment variables that matter for configuring a logger.
|
||||
/// Errors are explicitly preserved so that we can share error handling.
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ use std::mem;
|
|||
use std::ops::Range;
|
||||
|
||||
use itertools::Itertools;
|
||||
/// Re-export the markdown parser used by rustdoc.
|
||||
pub use pulldown_cmark;
|
||||
use pulldown_cmark::{
|
||||
BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, Options, Parser, Tag,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet, IndexEntry};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::infer::region_constraints::{ConstraintKind, RegionConstraintData};
|
||||
use rustc_middle::bug;
|
||||
|
|
@ -6,7 +7,6 @@ use rustc_middle::ty::{self, Region, Ty, fold_regions};
|
|||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::symbol::{Symbol, kw};
|
||||
use rustc_trait_selection::traits::auto_trait::{self, RegionTarget};
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::{debug, instrument};
|
||||
|
||||
use crate::clean::{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_hir as hir;
|
||||
use rustc_infer::infer::{DefineOpaqueTypes, InferOk, TyCtxtInferExt};
|
||||
use rustc_infer::traits;
|
||||
|
|
@ -5,7 +6,6 @@ use rustc_middle::ty::{self, TypingMode, Upcast};
|
|||
use rustc_span::DUMMY_SP;
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
use crate::clean;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
use rustc_ast::ast::LitIntType;
|
||||
use rustc_ast::{MetaItemInner, MetaItemLit, Path, Safety, StrStyle};
|
||||
use rustc_data_structures::thin_vec::thin_vec;
|
||||
use rustc_span::symbol::{Ident, kw};
|
||||
use rustc_span::{DUMMY_SP, create_default_session_globals_then};
|
||||
use thin_vec::thin_vec;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use std::iter::once;
|
|||
use std::sync::Arc;
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::thin_vec::{ThinVec, thin_vec};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::Mutability;
|
||||
use rustc_hir::def::{DefKind, MacroKinds, Res};
|
||||
|
|
@ -14,7 +15,6 @@ use rustc_middle::ty::{self, TyCtxt};
|
|||
use rustc_span::def_id::LOCAL_CRATE;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::symbol::{Symbol, sym};
|
||||
use thin_vec::{ThinVec, thin_vec};
|
||||
use tracing::{debug, trace};
|
||||
|
||||
use super::{Item, extract_cfg_from_attrs};
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ use std::mem;
|
|||
use rustc_ast::token::{Token, TokenKind};
|
||||
use rustc_ast::tokenstream::{TokenStream, TokenTree};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{FatalError, struct_span_code_err};
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
|
|
@ -53,7 +54,6 @@ use rustc_span::ExpnKind;
|
|||
use rustc_span::hygiene::{AstPass, MacroKind};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_trait_selection::traits::wf::object_region_bounds;
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::{debug, instrument};
|
||||
use utils::*;
|
||||
use {rustc_ast as ast, rustc_hir as hir};
|
||||
|
|
|
|||
|
|
@ -12,9 +12,9 @@
|
|||
//! bounds by special casing scenarios such as these. Fun!
|
||||
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_data_structures::unord::UnordSet;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
use crate::clean;
|
||||
use crate::clean::{GenericArgs as PP, WherePredicate as WP};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ use arrayvec::ArrayVec;
|
|||
use itertools::Either;
|
||||
use rustc_abi::{ExternAbi, VariantIdx};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_hir::attrs::{AttributeKind, DeprecatedSince, Deprecation};
|
||||
use rustc_hir::def::{CtorKind, DefKind, Res};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE, LocalDefId};
|
||||
|
|
@ -24,7 +25,6 @@ use rustc_session::Session;
|
|||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, FileName, Loc};
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::{debug, trace};
|
||||
use {rustc_ast as ast, rustc_hir as hir};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ use std::{ascii, mem};
|
|||
|
||||
use rustc_ast::join_path_idents;
|
||||
use rustc_ast::tokenstream::TokenTree;
|
||||
use rustc_data_structures::thin_vec::{ThinVec, thin_vec};
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
|
||||
use rustc_metadata::rendered_const;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt, TypeVisitableExt};
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use thin_vec::{ThinVec, thin_vec};
|
||||
use tracing::{debug, warn};
|
||||
use {rustc_ast as ast, rustc_hir as hir};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,15 +36,15 @@ use std::str::{self, CharIndices};
|
|||
use std::sync::atomic::AtomicUsize;
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use pulldown_cmark::{
|
||||
BrokenLink, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag, TagEnd, html,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
|
||||
use rustc_errors::{Diag, DiagMessage};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
pub(crate) use rustc_resolve::rustdoc::main_body_opts;
|
||||
use rustc_resolve::rustdoc::may_be_doc_link;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{
|
||||
self, BrokenLink, CodeBlockKind, CowStr, Event, LinkType, Options, Parser, Tag, TagEnd, html,
|
||||
};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::{Span, Symbol};
|
||||
use tracing::{debug, trace};
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use std::fmt::Write as _;
|
|||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
use pulldown_cmark::{CowStr, Event, Tag, TagEnd, html};
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{CowStr, Event, Tag, TagEnd, html};
|
||||
|
||||
use super::SpannedEvent;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ use ::serde::ser::{SerializeSeq, Serializer};
|
|||
use ::serde::{Deserialize, Serialize};
|
||||
use rustc_ast::join_path_syms;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_hir::attrs::AttributeKind;
|
||||
use rustc_hir::find_attr;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
|
@ -17,7 +18,6 @@ use rustc_span::def_id::DefId;
|
|||
use rustc_span::sym;
|
||||
use rustc_span::symbol::{Symbol, kw};
|
||||
use stringdex::internals as stringdex_internals;
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::clean::types::{Function, Generics, ItemId, Type, WherePredicate};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_ast::ast;
|
||||
use rustc_data_structures::thin_vec::ThinVec;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::attrs::{self, DeprecatedSince};
|
||||
use rustc_hir::def::CtorKind;
|
||||
|
|
@ -14,7 +15,6 @@ use rustc_middle::ty::TyCtxt;
|
|||
use rustc_middle::{bug, ty};
|
||||
use rustc_span::{Pos, kw, sym};
|
||||
use rustdoc_json_types::*;
|
||||
use thin_vec::ThinVec;
|
||||
|
||||
use crate::clean::{self, ItemId};
|
||||
use crate::formats::item_type::ItemType;
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
#![warn(rustc::internal)]
|
||||
// tidy-alphabetical-end
|
||||
|
||||
extern crate thin_vec;
|
||||
|
||||
// N.B. these need `extern crate` even in 2018 edition
|
||||
// because they're loaded implicitly from the sysroot.
|
||||
// The reason they're loaded from the sysroot is because
|
||||
|
|
@ -29,7 +27,6 @@ extern crate thin_vec;
|
|||
//
|
||||
// Dependencies listed in Cargo.toml do not need `extern crate`.
|
||||
|
||||
extern crate pulldown_cmark;
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_ast_pretty;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ use std::fmt::Display;
|
|||
use std::mem;
|
||||
use std::ops::Range;
|
||||
|
||||
use pulldown_cmark::LinkType;
|
||||
use rustc_ast::util::comments::may_have_doc_links;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
|
|
@ -18,6 +17,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE};
|
|||
use rustc_hir::{Mutability, Safety};
|
||||
use rustc_middle::ty::{Ty, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug, ty};
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::LinkType;
|
||||
use rustc_resolve::rustdoc::{
|
||||
MalformedGenerics, has_primitive_or_keyword_or_attribute_docs, prepare_to_doc_link_resolution,
|
||||
source_span_for_markdown_range, strip_generics_from_path,
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ use core::ops::Range;
|
|||
use std::mem;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
use pulldown_cmark::{Event, Parser, Tag};
|
||||
use regex::Regex;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{Event, Parser, Tag};
|
||||
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
||||
use tracing::trace;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use std::ops::Range;
|
|||
use std::str::CharIndices;
|
||||
|
||||
use itertools::Itertools as _;
|
||||
use pulldown_cmark::{BrokenLink, Event, LinkType, Parser, Tag, TagEnd};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{BrokenLink, Event, LinkType, Parser, Tag, TagEnd};
|
||||
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
||||
|
||||
use crate::clean::*;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use pulldown_cmark::{
|
||||
BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, OffsetIter, Parser, Tag,
|
||||
};
|
||||
use rustc_ast::NodeId;
|
||||
use rustc_errors::SuggestionStyle;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir::def::{DefKind, DocLinkResMap, Namespace, Res};
|
||||
use rustc_lint_defs::Applicability;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{
|
||||
BrokenLink, BrokenLinkCallback, CowStr, Event, LinkType, OffsetIter, Parser, Tag,
|
||||
};
|
||||
use rustc_resolve::rustdoc::{prepare_to_doc_link_resolution, source_span_for_markdown_range};
|
||||
use rustc_span::Symbol;
|
||||
use rustc_span::def_id::DefId;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
use std::ops::Range;
|
||||
|
||||
use pulldown_cmark::{BrokenLink, Event, Parser};
|
||||
use rustc_errors::Diag;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_lint_defs::Applicability;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{BrokenLink, Event, Parser};
|
||||
use rustc_resolve::rustdoc::source_span_for_markdown_range;
|
||||
|
||||
use crate::clean::Item;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use clippy_utils::diagnostics::span_lint;
|
||||
use pulldown_cmark::BrokenLink as PullDownBrokenLink;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::BrokenLink as PullDownBrokenLink;
|
||||
use rustc_resolve::rustdoc::{DocFragment, source_span_for_markdown_range};
|
||||
use rustc_span::{BytePos, Pos, Span};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,21 @@ use clippy_config::Conf;
|
|||
use clippy_utils::attrs::is_doc_hidden;
|
||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_then};
|
||||
use clippy_utils::{is_entrypoint_fn, is_trait_impl_item};
|
||||
use pulldown_cmark::Event::{
|
||||
Code, DisplayMath, End, FootnoteReference, HardBreak, Html, InlineHtml, InlineMath, Rule, SoftBreak, Start,
|
||||
TaskListMarker, Text,
|
||||
};
|
||||
use pulldown_cmark::Tag::{BlockQuote, CodeBlock, FootnoteDefinition, Heading, Item, Link, Paragraph};
|
||||
use pulldown_cmark::{BrokenLink, CodeBlockKind, CowStr, Options, TagEnd};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Attribute, ImplItemKind, ItemKind, Node, Safety, TraitItemKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::Event::{
|
||||
Code, DisplayMath, End, FootnoteReference, HardBreak, Html, InlineHtml, InlineMath, Rule, SoftBreak, Start,
|
||||
TaskListMarker, Text,
|
||||
};
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::Tag::{
|
||||
BlockQuote, CodeBlock, FootnoteDefinition, Heading, Item, Link, Paragraph,
|
||||
};
|
||||
use rustc_resolve::rustdoc::pulldown_cmark::{BrokenLink, CodeBlockKind, CowStr, Options, TagEnd};
|
||||
use rustc_resolve::rustdoc::{
|
||||
DocFragment, add_doc_fragment, attrs_to_doc_fragments, main_body_opts, source_span_for_markdown_range,
|
||||
span_of_fragments,
|
||||
DocFragment, add_doc_fragment, attrs_to_doc_fragments, main_body_opts, pulldown_cmark,
|
||||
source_span_for_markdown_range, span_of_fragments,
|
||||
};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::Span;
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@
|
|||
rustc::internal
|
||||
)]
|
||||
|
||||
// FIXME: switch to something more ergonomic here, once available.
|
||||
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
||||
extern crate pulldown_cmark;
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_arena;
|
||||
extern crate rustc_ast;
|
||||
|
|
@ -53,8 +50,6 @@ extern crate rustc_session;
|
|||
extern crate rustc_span;
|
||||
extern crate rustc_target;
|
||||
extern crate rustc_trait_selection;
|
||||
extern crate smallvec;
|
||||
extern crate thin_vec;
|
||||
|
||||
#[macro_use]
|
||||
extern crate clippy_utils;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use clippy_utils::consts::{ConstEvalCtxt, Constant};
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_data_structures::smallvec::SmallVec;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, QPath, TyKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::sym;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use super::IP_CONSTANT;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use rustc_ast::PatKind::*;
|
|||
use rustc_ast::mut_visit::*;
|
||||
use rustc_ast::{self as ast, DUMMY_NODE_ID, Mutability, Pat, PatKind};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::thin_vec::{ThinVec, thin_vec};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::impl_lint_pass;
|
||||
|
|
@ -17,7 +18,6 @@ use rustc_span::DUMMY_SP;
|
|||
use std::boxed::Box;
|
||||
use std::cell::Cell;
|
||||
use std::mem;
|
||||
use thin_vec::{ThinVec, thin_vec};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
// FIXME: switch to something more ergonomic here, once available.
|
||||
// (Currently there is no way to opt into sysroot crates without `extern crate`.)
|
||||
extern crate indexmap;
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_ast;
|
||||
extern crate rustc_attr_parsing;
|
||||
|
|
@ -47,7 +46,6 @@ extern crate rustc_mir_dataflow;
|
|||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
extern crate rustc_trait_selection;
|
||||
extern crate smallvec;
|
||||
|
||||
pub mod ast_utils;
|
||||
pub mod attrs;
|
||||
|
|
@ -90,6 +88,7 @@ use rustc_abi::Integer;
|
|||
use rustc_ast::ast::{self, LitKind, RangeLimits};
|
||||
use rustc_ast::join_path_syms;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexmap;
|
||||
use rustc_data_structures::packed::Pu128;
|
||||
use rustc_data_structures::unhash::UnindexMap;
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk};
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ use crate::sym;
|
|||
use rustc_ast::Attribute;
|
||||
use rustc_ast::attr::AttributeExt;
|
||||
use rustc_attr_parsing::parse_version;
|
||||
use rustc_data_structures::smallvec::SmallVec;
|
||||
use rustc_hir::RustcVersion;
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::Symbol;
|
||||
use serde::Deserialize;
|
||||
use smallvec::SmallVec;
|
||||
use std::iter::once;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use std::env::{self, VarError};
|
|||
use std::str::FromStr;
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
use rustc_log::tracing;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::{CtfeBacktrace, EarlyDiagCtxt};
|
||||
|
||||
|
|
@ -72,8 +73,8 @@ fn init_logger_once(early_dcx: &EarlyDiagCtxt) {
|
|||
early_dcx,
|
||||
rustc_logger_config(),
|
||||
|| {
|
||||
tracing_subscriber::layer::SubscriberExt::with(
|
||||
tracing_subscriber::Registry::default(),
|
||||
rustc_log::tracing_subscriber::layer::SubscriberExt::with(
|
||||
rustc_log::tracing_subscriber::Registry::default(),
|
||||
chrome_layer,
|
||||
)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,12 +24,9 @@
|
|||
#![allow(warnings)]
|
||||
#![cfg(feature = "tracing")]
|
||||
|
||||
// This is here and not in src/lib.rs since it is a direct dependency of tracing_chrome.rs and
|
||||
// should not be included if the "tracing" feature is disabled.
|
||||
extern crate tracing_core;
|
||||
|
||||
use tracing_core::{field::Field, span, Event, Subscriber};
|
||||
use tracing_subscriber::{
|
||||
use rustc_log::tracing_core::{field::Field, span, Event, Subscriber};
|
||||
use rustc_log::tracing_subscriber::{
|
||||
self,
|
||||
layer::Context,
|
||||
registry::{LookupSpan, SpanRef},
|
||||
Layer,
|
||||
|
|
|
|||
|
|
@ -8,11 +8,6 @@
|
|||
rustc::untranslatable_diagnostic
|
||||
)]
|
||||
|
||||
// Some "regular" crates we want to share with rustc
|
||||
extern crate tracing;
|
||||
#[cfg(feature = "tracing")]
|
||||
extern crate tracing_subscriber;
|
||||
|
||||
// The rustc crates we need
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_data_structures;
|
||||
|
|
@ -48,6 +43,7 @@ use rustc_hir::def_id::LOCAL_CRATE;
|
|||
use rustc_hir::{self as hir, Node};
|
||||
use rustc_hir_analysis::check::check_function_signature;
|
||||
use rustc_interface::interface::Config;
|
||||
use rustc_log::tracing::debug;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::exported_symbols::{
|
||||
ExportedSymbol, SymbolExportInfo, SymbolExportKind, SymbolExportLevel,
|
||||
|
|
@ -60,7 +56,6 @@ use rustc_session::EarlyDiagCtxt;
|
|||
use rustc_session::config::{CrateType, ErrorOutputType, OptLevel};
|
||||
use rustc_session::search_paths::PathKind;
|
||||
use rustc_span::def_id::DefId;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::log::setup::{deinit_loggers, init_early_loggers, init_late_loggers};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use tracing::trace;
|
||||
use rustc_log::tracing::trace;
|
||||
|
||||
use crate::borrow_tracker::stacked_borrows::{Item, Permission};
|
||||
use crate::borrow_tracker::{AccessKind, BorTag};
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ use rustc_abi::{Align, HasDataLayout, Size};
|
|||
use rustc_ast::Mutability;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_index::{Idx, IndexVec};
|
||||
use rustc_log::tracing;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::ty::Ty;
|
||||
use rustc_span::Span;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ use std::sync::atomic::Ordering::Relaxed;
|
|||
use std::task::Poll;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use either::Either;
|
||||
use rand::seq::IteratorRandom;
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_const_eval::CTRL_C_RECEIVED;
|
||||
use rustc_data_structures::either::Either;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_index::{Idx, IndexVec};
|
||||
|
|
|
|||
|
|
@ -49,10 +49,6 @@
|
|||
// Needed for rustdoc from bootstrap (with `-Znormalize-docs`).
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
// Some "regular" crates we want to share with rustc
|
||||
extern crate either;
|
||||
extern crate tracing;
|
||||
|
||||
// The rustc crates we need
|
||||
extern crate rustc_abi;
|
||||
extern crate rustc_apfloat;
|
||||
|
|
@ -63,6 +59,7 @@ extern crate rustc_errors;
|
|||
extern crate rustc_hash;
|
||||
extern crate rustc_hir;
|
||||
extern crate rustc_index;
|
||||
extern crate rustc_log;
|
||||
extern crate rustc_middle;
|
||||
extern crate rustc_session;
|
||||
extern crate rustc_span;
|
||||
|
|
@ -96,8 +93,8 @@ pub use rustc_const_eval::interpret::*;
|
|||
// Resolve ambiguity.
|
||||
#[doc(no_inline)]
|
||||
pub use rustc_const_eval::interpret::{self, AllocMap, Provenance as _};
|
||||
use rustc_log::tracing::{self, info, trace};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use tracing::{info, trace};
|
||||
|
||||
#[cfg(all(unix, feature = "native-lib"))]
|
||||
pub mod native_lib {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||
#[allow(unused)]
|
||||
use rustc_data_structures::static_assert_size;
|
||||
use rustc_hir::attrs::InlineAttr;
|
||||
use rustc_log::tracing;
|
||||
use rustc_middle::middle::codegen_fn_attrs::TargetFeatureKind;
|
||||
use rustc_middle::mir;
|
||||
use rustc_middle::query::TyCtxtAt;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use either::Either;
|
||||
use rustc_data_structures::either::Either;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
||||
use crate::*;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ use std::sync::atomic::AtomicBool;
|
|||
use libffi::low::CodePtr;
|
||||
use libffi::middle::Type as FfiType;
|
||||
use rustc_abi::{HasDataLayout, Size};
|
||||
use rustc_data_structures::either;
|
||||
use rustc_middle::ty::layout::HasTypingEnv;
|
||||
use rustc_middle::ty::{self, IntTy, Ty, UintTy};
|
||||
use rustc_span::Symbol;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue