mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Auto merge of #117507 - nnethercote:rustc_span, r=Nilstrieb
`rustc_span` cleanups Just some things I found while looking over this crate. r? `@oli-obk`
This commit is contained in:
commit
9c20ddd956
@ -15,9 +15,10 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
use rustc_hir::definitions::DefPathData;
|
use rustc_hir::definitions::DefPathData;
|
||||||
use rustc_session::errors::report_lit_error;
|
use rustc_session::errors::report_lit_error;
|
||||||
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
|
use rustc_span::source_map::{respan, Spanned};
|
||||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
use rustc_span::{DesugaringKind, Span};
|
||||||
use thin_vec::{thin_vec, ThinVec};
|
use thin_vec::{thin_vec, ThinVec};
|
||||||
|
|
||||||
impl<'hir> LoweringContext<'_, 'hir> {
|
impl<'hir> LoweringContext<'_, 'hir> {
|
||||||
|
@ -16,9 +16,8 @@ use rustc_hir::PredicateOrigin;
|
|||||||
use rustc_index::{Idx, IndexSlice, IndexVec};
|
use rustc_index::{Idx, IndexSlice, IndexVec};
|
||||||
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
use rustc_middle::ty::{ResolverAstLowering, TyCtxt};
|
||||||
use rustc_span::edit_distance::find_best_match_for_name;
|
use rustc_span::edit_distance::find_best_match_for_name;
|
||||||
use rustc_span::source_map::DesugaringKind;
|
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
use rustc_span::{Span, Symbol};
|
use rustc_span::{DesugaringKind, Span, Symbol};
|
||||||
use rustc_target::spec::abi;
|
use rustc_target::spec::abi;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
@ -71,9 +71,8 @@ use rustc_middle::{
|
|||||||
};
|
};
|
||||||
use rustc_session::parse::{add_feature_diagnostics, feature_err};
|
use rustc_session::parse::{add_feature_diagnostics, feature_err};
|
||||||
use rustc_span::hygiene::MacroKind;
|
use rustc_span::hygiene::MacroKind;
|
||||||
use rustc_span::source_map::DesugaringKind;
|
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{Span, DUMMY_SP};
|
use rustc_span::{DesugaringKind, Span, DUMMY_SP};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::collections::hash_map::Entry;
|
use std::collections::hash_map::Entry;
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
@ -9,9 +9,8 @@ use rustc_middle::{
|
|||||||
hir::place::PlaceBase,
|
hir::place::PlaceBase,
|
||||||
mir::{self, BindingForm, Local, LocalDecl, LocalInfo, LocalKind, Location},
|
mir::{self, BindingForm, Local, LocalDecl, LocalInfo, LocalKind, Location},
|
||||||
};
|
};
|
||||||
use rustc_span::source_map::DesugaringKind;
|
|
||||||
use rustc_span::symbol::{kw, Symbol};
|
use rustc_span::symbol::{kw, Symbol};
|
||||||
use rustc_span::{sym, BytePos, Span};
|
use rustc_span::{sym, BytePos, DesugaringKind, Span};
|
||||||
use rustc_target::abi::FieldIdx;
|
use rustc_target::abi::FieldIdx;
|
||||||
|
|
||||||
use crate::diagnostics::BorrowedContentSource;
|
use crate::diagnostics::BorrowedContentSource;
|
||||||
|
@ -6,8 +6,8 @@ use crate::Upvar;
|
|||||||
use rustc_index::IndexSlice;
|
use rustc_index::IndexSlice;
|
||||||
use rustc_middle::mir::{Body, Local};
|
use rustc_middle::mir::{Body, Local};
|
||||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||||
use rustc_span::source_map::Span;
|
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
use rustc_span::Span;
|
||||||
|
|
||||||
impl<'tcx> RegionInferenceContext<'tcx> {
|
impl<'tcx> RegionInferenceContext<'tcx> {
|
||||||
pub(crate) fn get_var_name_and_span_for_region(
|
pub(crate) fn get_var_name_and_span_for_region(
|
||||||
|
@ -6,9 +6,10 @@ pub use Ty::*;
|
|||||||
use rustc_ast::ptr::P;
|
use rustc_ast::ptr::P;
|
||||||
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
|
use rustc_ast::{self as ast, Expr, GenericArg, GenericParamKind, Generics, SelfKind};
|
||||||
use rustc_expand::base::ExtCtxt;
|
use rustc_expand::base::ExtCtxt;
|
||||||
use rustc_span::source_map::{respan, DUMMY_SP};
|
use rustc_span::source_map::respan;
|
||||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
use rustc_span::DUMMY_SP;
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
|
||||||
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
|
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
|
||||||
|
@ -26,8 +26,8 @@ use rustc_middle::{bug, span_bug};
|
|||||||
use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
|
use rustc_session::config::{BranchProtection, CFGuard, CFProtection};
|
||||||
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
|
use rustc_session::config::{CrateType, DebugInfo, PAuthKey, PacRet};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::source_map::Span;
|
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{
|
use rustc_target::abi::{
|
||||||
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
|
call::FnAbi, HasDataLayout, PointeeInfo, Size, TargetDataLayout, VariantIdx,
|
||||||
};
|
};
|
||||||
|
@ -17,8 +17,7 @@ use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, ValidityRequirement};
|
|||||||
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
|
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
|
||||||
use rustc_middle::ty::{self, Instance, Ty};
|
use rustc_middle::ty::{self, Instance, Ty};
|
||||||
use rustc_session::config::OptLevel;
|
use rustc_session::config::OptLevel;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span, Symbol};
|
||||||
use rustc_span::{sym, Symbol};
|
|
||||||
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};
|
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};
|
||||||
use rustc_target::abi::{self, HasDataLayout, WrappingRange};
|
use rustc_target::abi::{self, HasDataLayout, WrappingRange};
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
@ -13,7 +13,7 @@ use rustc_middle::ty::cast::{CastTy, IntTy};
|
|||||||
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
|
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
|
||||||
use rustc_middle::ty::{self, adjustment::PointerCoercion, Instance, Ty, TyCtxt};
|
use rustc_middle::ty::{self, adjustment::PointerCoercion, Instance, Ty, TyCtxt};
|
||||||
use rustc_session::config::OptLevel;
|
use rustc_session::config::OptLevel;
|
||||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_target::abi::{self, FIRST_VARIANT};
|
use rustc_target::abi::{self, FIRST_VARIANT};
|
||||||
|
|
||||||
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
@ -10,7 +10,7 @@ use rustc_middle::traits::Reveal;
|
|||||||
use rustc_middle::ty::layout::LayoutOf;
|
use rustc_middle::ty::layout::LayoutOf;
|
||||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{self, Abi};
|
use rustc_target::abi::{self, Abi};
|
||||||
|
|
||||||
use super::{CanAccessStatics, CompileTimeEvalContext, CompileTimeInterpreter};
|
use super::{CanAccessStatics, CompileTimeEvalContext, CompileTimeInterpreter};
|
||||||
|
@ -6,7 +6,7 @@ use rustc_middle::mir;
|
|||||||
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
|
use rustc_middle::mir::interpret::{EvalToValTreeResult, GlobalId};
|
||||||
use rustc_middle::query::TyCtxtAt;
|
use rustc_middle::query::TyCtxtAt;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
mod error;
|
mod error;
|
||||||
mod eval_queries;
|
mod eval_queries;
|
||||||
|
@ -10,7 +10,7 @@ use crate::interpret::{
|
|||||||
use rustc_middle::mir;
|
use rustc_middle::mir;
|
||||||
use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout};
|
use rustc_middle::ty::layout::{LayoutCx, LayoutOf, TyAndLayout};
|
||||||
use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt};
|
use rustc_middle::ty::{self, ScalarInt, Ty, TyCtxt};
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
|
|
||||||
#[instrument(skip(ecx), level = "debug")]
|
#[instrument(skip(ecx), level = "debug")]
|
||||||
|
@ -43,8 +43,9 @@ use rustc_session::cstore::MetadataLoader;
|
|||||||
use rustc_session::getopts::{self, Matches};
|
use rustc_session::getopts::{self, Matches};
|
||||||
use rustc_session::lint::{Lint, LintId};
|
use rustc_session::lint::{Lint, LintId};
|
||||||
use rustc_session::{config, EarlyErrorHandler, Session};
|
use rustc_session::{config, EarlyErrorHandler, Session};
|
||||||
use rustc_span::source_map::{FileLoader, FileName};
|
use rustc_span::source_map::FileLoader;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
use rustc_span::FileName;
|
||||||
use rustc_target::json::ToJson;
|
use rustc_target::json::ToJson;
|
||||||
use rustc_target::spec::{Target, TargetTriple};
|
use rustc_target::spec::{Target, TargetTriple};
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ use rustc_ast::mut_visit::*;
|
|||||||
use rustc_ast::ptr::P;
|
use rustc_ast::ptr::P;
|
||||||
use rustc_ast::token::Delimiter;
|
use rustc_ast::token::Delimiter;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
|
||||||
use rustc_span::symbol::Ident;
|
use rustc_span::symbol::Ident;
|
||||||
|
use rustc_span::DUMMY_SP;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use rustc_ast as ast;
|
|||||||
use rustc_ast::tokenstream::TokenStream;
|
use rustc_ast::tokenstream::TokenStream;
|
||||||
use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream};
|
use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream};
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
use rustc_span::create_default_session_if_not_set_then;
|
use rustc_span::create_default_session_globals_then;
|
||||||
use rustc_span::source_map::{FilePathMapping, SourceMap};
|
use rustc_span::source_map::{FilePathMapping, SourceMap};
|
||||||
use rustc_span::{BytePos, Span};
|
use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ impl<T: Write> Write for Shared<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
|
fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
|
||||||
create_default_session_if_not_set_then(|_| {
|
create_default_session_globals_then(|| {
|
||||||
let (handler, source_map, output) = create_test_handler();
|
let (handler, source_map, output) = create_test_handler();
|
||||||
source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned());
|
source_map.new_source_file(Path::new("test.rs").to_owned().into(), file_text.to_owned());
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use crate::definitions::{DefKey, DefPathData, DisambiguatedDefPathData};
|
|||||||
use rustc_data_structures::stable_hasher::Hash64;
|
use rustc_data_structures::stable_hasher::Hash64;
|
||||||
use rustc_span::def_id::{DefPathHash, StableCrateId};
|
use rustc_span::def_id::{DefPathHash, StableCrateId};
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::{create_session_if_not_set_then, Symbol};
|
use rustc_span::{create_session_globals_then, Symbol};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn def_path_hash_depends_on_crate_id() {
|
fn def_path_hash_depends_on_crate_id() {
|
||||||
@ -14,7 +14,7 @@ fn def_path_hash_depends_on_crate_id() {
|
|||||||
// the crate by changing the crate disambiguator (e.g. via bumping the
|
// the crate by changing the crate disambiguator (e.g. via bumping the
|
||||||
// crate's version number).
|
// crate's version number).
|
||||||
|
|
||||||
create_session_if_not_set_then(Edition::Edition2024, |_| {
|
create_session_globals_then(Edition::Edition2024, || {
|
||||||
let id0 = StableCrateId::new(Symbol::intern("foo"), false, vec!["1".to_string()], "");
|
let id0 = StableCrateId::new(Symbol::intern("foo"), false, vec!["1".to_string()], "");
|
||||||
let id1 = StableCrateId::new(Symbol::intern("foo"), false, vec!["2".to_string()], "");
|
let id1 = StableCrateId::new(Symbol::intern("foo"), false, vec!["2".to_string()], "");
|
||||||
|
|
||||||
|
@ -90,9 +90,8 @@ use rustc_middle::ty::error::{ExpectedFound, TypeError};
|
|||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_middle::ty::{GenericArgs, GenericArgsRef};
|
use rustc_middle::ty::{GenericArgs, GenericArgsRef};
|
||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
|
||||||
use rustc_span::symbol::{kw, Ident};
|
use rustc_span::symbol::{kw, Ident};
|
||||||
use rustc_span::{self, def_id::CRATE_DEF_ID, BytePos, Span, Symbol};
|
use rustc_span::{self, def_id::CRATE_DEF_ID, BytePos, Span, Symbol, DUMMY_SP};
|
||||||
use rustc_target::abi::VariantIdx;
|
use rustc_target::abi::VariantIdx;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
|
use rustc_trait_selection::traits::error_reporting::suggestions::ReturnsVisitor;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
use rustc_middle::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor};
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use std::ops::ControlFlow;
|
use std::ops::ControlFlow;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
|
||||||
|
@ -14,8 +14,7 @@ use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
|
|||||||
use rustc_middle::ty::GenericArgs;
|
use rustc_middle::ty::GenericArgs;
|
||||||
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
|
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
use rustc_trait_selection::traits;
|
use rustc_trait_selection::traits;
|
||||||
use rustc_trait_selection::traits::error_reporting::ArgKind;
|
use rustc_trait_selection::traits::error_reporting::ArgKind;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::{self, Span, DUMMY_SP};
|
||||||
use rustc_span::{self, Span};
|
|
||||||
use std::{cmp, ops};
|
use std::{cmp, ops};
|
||||||
|
|
||||||
/// Tracks whether executing a node may exit normally (versus
|
/// Tracks whether executing a node may exit normally (versus
|
||||||
|
@ -52,8 +52,9 @@ use rustc_session::errors::ExprParenthesesNeeded;
|
|||||||
use rustc_session::parse::feature_err;
|
use rustc_session::parse::feature_err;
|
||||||
use rustc_span::edit_distance::find_best_match_for_name;
|
use rustc_span::edit_distance::find_best_match_for_name;
|
||||||
use rustc_span::hygiene::DesugaringKind;
|
use rustc_span::hygiene::DesugaringKind;
|
||||||
use rustc_span::source_map::{Span, Spanned};
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
|
use rustc_span::Span;
|
||||||
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
|
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
|
||||||
use rustc_target::spec::abi::Abi::RustIntrinsic;
|
use rustc_target::spec::abi::Abi::RustIntrinsic;
|
||||||
use rustc_trait_selection::infer::InferCtxtExt;
|
use rustc_trait_selection::infer::InferCtxtExt;
|
||||||
|
@ -17,8 +17,9 @@ use rustc_middle::ty::{self, Adt, BindingMode, Ty, TypeVisitableExt};
|
|||||||
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
use rustc_session::lint::builtin::NON_EXHAUSTIVE_OMITTED_PATTERNS;
|
||||||
use rustc_span::edit_distance::find_best_match_for_name;
|
use rustc_span::edit_distance::find_best_match_for_name;
|
||||||
use rustc_span::hygiene::DesugaringKind;
|
use rustc_span::hygiene::DesugaringKind;
|
||||||
use rustc_span::source_map::{Span, Spanned};
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
|
use rustc_span::Span;
|
||||||
use rustc_span::{BytePos, DUMMY_SP};
|
use rustc_span::{BytePos, DUMMY_SP};
|
||||||
use rustc_target::abi::FieldIdx;
|
use rustc_target::abi::FieldIdx;
|
||||||
use rustc_trait_selection::traits::{ObligationCause, Pattern};
|
use rustc_trait_selection::traits::{ObligationCause, Pattern};
|
||||||
|
@ -27,7 +27,7 @@ use rustc_index::IndexVec;
|
|||||||
use rustc_middle::ty::fold::TypeFoldable;
|
use rustc_middle::ty::fold::TypeFoldable;
|
||||||
use rustc_middle::ty::GenericArg;
|
use rustc_middle::ty::GenericArg;
|
||||||
use rustc_middle::ty::{self, List, Ty, TyCtxt};
|
use rustc_middle::ty::{self, List, Ty, TyCtxt};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
pub use rustc_middle::infer::canonical::*;
|
pub use rustc_middle::infer::canonical::*;
|
||||||
pub use substitute::CanonicalExt;
|
pub use substitute::CanonicalExt;
|
||||||
|
@ -3,7 +3,7 @@ use crate::infer::lexical_region_resolve::RegionResolutionError;
|
|||||||
use crate::infer::lexical_region_resolve::RegionResolutionError::*;
|
use crate::infer::lexical_region_resolve::RegionResolutionError::*;
|
||||||
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed};
|
||||||
use rustc_middle::ty::{self, TyCtxt};
|
use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
mod different_lifetimes;
|
mod different_lifetimes;
|
||||||
pub mod find_anon_type;
|
pub mod find_anon_type;
|
||||||
|
@ -21,8 +21,9 @@ use rustc_session::config::{
|
|||||||
use rustc_session::filesearch::sysroot_candidates;
|
use rustc_session::filesearch::sysroot_candidates;
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
use rustc_session::{lint, CompilerIO, EarlyErrorHandler, Session};
|
use rustc_session::{lint, CompilerIO, EarlyErrorHandler, Session};
|
||||||
use rustc_span::source_map::{FileLoader, FileName};
|
use rustc_span::source_map::FileLoader;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
use rustc_span::FileName;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -9,9 +9,8 @@ use rustc_session::lint::{
|
|||||||
FutureIncompatibilityReason, Level, Lint, LintId,
|
FutureIncompatibilityReason, Level, Lint, LintId,
|
||||||
};
|
};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::hygiene::MacroKind;
|
use rustc_span::hygiene::{ExpnKind, MacroKind};
|
||||||
use rustc_span::source_map::{DesugaringKind, ExpnKind};
|
use rustc_span::{symbol, DesugaringKind, Span, Symbol, DUMMY_SP};
|
||||||
use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
|
|
||||||
|
|
||||||
use crate::ty::TyCtxt;
|
use crate::ty::TyCtxt;
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ use rustc_hir::ItemId;
|
|||||||
use rustc_index::Idx;
|
use rustc_index::Idx;
|
||||||
use rustc_query_system::ich::StableHashingContext;
|
use rustc_query_system::ich::StableHashingContext;
|
||||||
use rustc_session::config::OptLevel;
|
use rustc_session::config::OptLevel;
|
||||||
use rustc_span::source_map::Span;
|
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
use rustc_span::Span;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use crate::infer::canonical::{Canonical, QueryResponse};
|
|||||||
use crate::ty::error::TypeError;
|
use crate::ty::error::TypeError;
|
||||||
use crate::ty::GenericArg;
|
use crate::ty::GenericArg;
|
||||||
use crate::ty::{self, Ty, TyCtxt};
|
use crate::ty::{self, Ty, TyCtxt};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
pub mod type_op {
|
pub mod type_op {
|
||||||
use crate::ty::fold::TypeFoldable;
|
use crate::ty::fold::TypeFoldable;
|
||||||
|
@ -186,8 +186,9 @@ use rustc_middle::{middle::codegen_fn_attrs::CodegenFnAttrFlags, mir::visit::TyC
|
|||||||
use rustc_session::config::EntryFnType;
|
use rustc_session::config::EntryFnType;
|
||||||
use rustc_session::lint::builtin::LARGE_ASSIGNMENTS;
|
use rustc_session::lint::builtin::LARGE_ASSIGNMENTS;
|
||||||
use rustc_session::Limit;
|
use rustc_session::Limit;
|
||||||
use rustc_span::source_map::{dummy_spanned, respan, Span, Spanned, DUMMY_SP};
|
use rustc_span::source_map::{dummy_spanned, respan, Spanned};
|
||||||
use rustc_span::symbol::{sym, Ident};
|
use rustc_span::symbol::{sym, Ident};
|
||||||
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_target::abi::Size;
|
use rustc_target::abi::Size;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@ use rustc_macros::Subdiagnostic;
|
|||||||
use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
|
use rustc_session::errors::{report_lit_error, ExprParenthesesNeeded};
|
||||||
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
|
use rustc_session::lint::builtin::BREAK_WITH_LABEL_AND_LOOP;
|
||||||
use rustc_session::lint::BuiltinLintDiagnostics;
|
use rustc_session::lint::BuiltinLintDiagnostics;
|
||||||
use rustc_span::source_map::{self, Span, Spanned};
|
use rustc_span::source_map::{self, Spanned};
|
||||||
use rustc_span::symbol::kw::PathRoot;
|
use rustc_span::symbol::kw::PathRoot;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::{BytePos, Pos};
|
use rustc_span::{BytePos, Pos, Span};
|
||||||
use thin_vec::{thin_vec, ThinVec};
|
use thin_vec::{thin_vec, ThinVec};
|
||||||
|
|
||||||
/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
|
/// Possibly accepts an `token::Interpolated` expression (a pre-parsed expression
|
||||||
|
@ -22,9 +22,9 @@ use rustc_errors::{
|
|||||||
};
|
};
|
||||||
use rustc_span::edit_distance::edit_distance;
|
use rustc_span::edit_distance::edit_distance;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map::{self, Span};
|
use rustc_span::source_map;
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
use rustc_span::DUMMY_SP;
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use thin_vec::{thin_vec, ThinVec};
|
use thin_vec::{thin_vec, ThinVec};
|
||||||
|
@ -36,8 +36,8 @@ use rustc_errors::{
|
|||||||
Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, IntoDiagnostic, MultiSpan,
|
Applicability, DiagnosticBuilder, ErrorGuaranteed, FatalError, IntoDiagnostic, MultiSpan,
|
||||||
};
|
};
|
||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
|
||||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||||
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::{mem, slice};
|
use std::{mem, slice};
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
@ -20,8 +20,9 @@ use rustc_ast::{
|
|||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult};
|
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, IntoDiagnostic, PResult};
|
||||||
use rustc_session::errors::ExprParenthesesNeeded;
|
use rustc_session::errors::ExprParenthesesNeeded;
|
||||||
use rustc_span::source_map::{respan, Span, Spanned};
|
use rustc_span::source_map::{respan, Spanned};
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
|
use rustc_span::Span;
|
||||||
use thin_vec::{thin_vec, ThinVec};
|
use thin_vec::{thin_vec, ThinVec};
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
|
@ -10,8 +10,8 @@ use rustc_ast::{
|
|||||||
Path, PathSegment, QSelf,
|
Path, PathSegment, QSelf,
|
||||||
};
|
};
|
||||||
use rustc_errors::{Applicability, IntoDiagnostic, PResult};
|
use rustc_errors::{Applicability, IntoDiagnostic, PResult};
|
||||||
use rustc_span::source_map::{BytePos, Span};
|
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
|
use rustc_span::{BytePos, Span};
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
@ -20,8 +20,8 @@ use rustc_ast::{AttrStyle, AttrVec, LocalKind, MacCall, MacCallStmt, MacStmtStyl
|
|||||||
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Stmt};
|
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, HasAttrs, Local, Stmt};
|
||||||
use rustc_ast::{StmtKind, DUMMY_NODE_ID};
|
use rustc_ast::{StmtKind, DUMMY_NODE_ID};
|
||||||
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
|
use rustc_errors::{Applicability, DiagnosticBuilder, ErrorGuaranteed, PResult};
|
||||||
use rustc_span::source_map::{BytePos, Span};
|
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
|
use rustc_span::{BytePos, Span};
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
@ -18,9 +18,8 @@ use rustc_ast::{
|
|||||||
TraitObjectSyntax, Ty, TyKind,
|
TraitObjectSyntax, Ty, TyKind,
|
||||||
};
|
};
|
||||||
use rustc_errors::{Applicability, PResult};
|
use rustc_errors::{Applicability, PResult};
|
||||||
use rustc_span::source_map::Span;
|
|
||||||
use rustc_span::symbol::{kw, sym, Ident};
|
use rustc_span::symbol::{kw, sym, Ident};
|
||||||
use rustc_span::Symbol;
|
use rustc_span::{Span, Symbol};
|
||||||
use thin_vec::{thin_vec, ThinVec};
|
use thin_vec::{thin_vec, ThinVec};
|
||||||
|
|
||||||
/// Any `?`, `!`, or `~const` modifiers that appear at the start of a bound.
|
/// Any `?`, `!`, or `~const` modifiers that appear at the start of a bound.
|
||||||
|
@ -18,10 +18,9 @@ use rustc_target::spec::{Target, TargetTriple, TargetWarnings, TARGETS};
|
|||||||
|
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST, LATEST_STABLE_EDITION};
|
||||||
use rustc_span::source_map::{FileName, FilePathMapping};
|
use rustc_span::source_map::FilePathMapping;
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
use rustc_span::SourceFileHashAlgorithm;
|
use rustc_span::{FileName, FileNameDisplayPreference, RealFileName, SourceFileHashAlgorithm};
|
||||||
use rustc_span::{FileNameDisplayPreference, RealFileName};
|
|
||||||
|
|
||||||
use rustc_errors::emitter::HumanReadableErrorType;
|
use rustc_errors::emitter::HumanReadableErrorType;
|
||||||
use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
|
use rustc_errors::{ColorConfig, DiagnosticArgValue, HandlerFlags, IntoDiagnosticArg};
|
||||||
|
@ -31,8 +31,8 @@ use rustc_errors::{
|
|||||||
use rustc_macros::HashStable_Generic;
|
use rustc_macros::HashStable_Generic;
|
||||||
pub use rustc_span::def_id::StableCrateId;
|
pub use rustc_span::def_id::StableCrateId;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMap, Span};
|
use rustc_span::source_map::{FileLoader, RealFileLoader, SourceMap};
|
||||||
use rustc_span::{SourceFileHashAlgorithm, Symbol};
|
use rustc_span::{SourceFileHashAlgorithm, Span, Symbol};
|
||||||
use rustc_target::asm::InlineAsmArch;
|
use rustc_target::asm::InlineAsmArch;
|
||||||
use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
|
use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
|
||||||
use rustc_target::spec::{
|
use rustc_target::spec::{
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
/// Used as a return value to signify a fatal error occurred. (It is also
|
/// Used as a return value to signify a fatal error occurred.
|
||||||
/// used as the argument to panic at the moment, but that will eventually
|
|
||||||
/// not be true.)
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct FatalError;
|
pub struct FatalError;
|
||||||
|
|
||||||
pub struct FatalErrorMarker;
|
pub struct FatalErrorMarker;
|
||||||
|
|
||||||
// Don't implement Send on FatalError. This makes it impossible to panic!(FatalError).
|
// Don't implement Send on FatalError. This makes it impossible to `panic_any!(FatalError)`.
|
||||||
// We don't want to invoke the panic handler and print a backtrace for fatal errors.
|
// We don't want to invoke the panic handler and print a backtrace for fatal errors.
|
||||||
impl !Send for FatalError {}
|
impl !Send for FatalError {}
|
||||||
|
|
||||||
|
@ -24,16 +24,13 @@
|
|||||||
// because getting it wrong can lead to nested `HygieneData::with` calls that
|
// because getting it wrong can lead to nested `HygieneData::with` calls that
|
||||||
// trigger runtime aborts. (Fortunately these are obvious and easy to fix.)
|
// trigger runtime aborts. (Fortunately these are obvious and easy to fix.)
|
||||||
|
|
||||||
|
use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||||
use crate::edition::Edition;
|
use crate::edition::Edition;
|
||||||
use crate::symbol::{kw, sym, Symbol};
|
use crate::symbol::{kw, sym, Symbol};
|
||||||
use crate::with_session_globals;
|
use crate::{with_session_globals, HashStableContext, Span, DUMMY_SP};
|
||||||
use crate::{HashStableContext, Span, DUMMY_SP};
|
|
||||||
|
|
||||||
use crate::def_id::{CrateNum, DefId, StableCrateId, CRATE_DEF_ID, LOCAL_CRATE};
|
|
||||||
use rustc_data_structures::fingerprint::Fingerprint;
|
use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_data_structures::stable_hasher::HashingControls;
|
use rustc_data_structures::stable_hasher::{Hash64, HashStable, HashingControls, StableHasher};
|
||||||
use rustc_data_structures::stable_hasher::{Hash64, HashStable, StableHasher};
|
|
||||||
use rustc_data_structures::sync::{Lock, Lrc, WorkerLocal};
|
use rustc_data_structures::sync::{Lock, Lrc, WorkerLocal};
|
||||||
use rustc_data_structures::unhash::UnhashMap;
|
use rustc_data_structures::unhash::UnhashMap;
|
||||||
use rustc_index::IndexVec;
|
use rustc_index::IndexVec;
|
||||||
@ -130,7 +127,7 @@ impl ExpnHash {
|
|||||||
|
|
||||||
/// Returns the crate-local part of the [ExpnHash].
|
/// Returns the crate-local part of the [ExpnHash].
|
||||||
///
|
///
|
||||||
/// Used for tests.
|
/// Used for assertions.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn local_hash(self) -> Hash64 {
|
pub fn local_hash(self) -> Hash64 {
|
||||||
self.0.split().1
|
self.0.split().1
|
||||||
@ -173,7 +170,7 @@ impl LocalExpnId {
|
|||||||
pub const ROOT: LocalExpnId = LocalExpnId::from_u32(0);
|
pub const ROOT: LocalExpnId = LocalExpnId::from_u32(0);
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_raw(idx: ExpnIndex) -> LocalExpnId {
|
fn from_raw(idx: ExpnIndex) -> LocalExpnId {
|
||||||
LocalExpnId::from_u32(idx.as_u32())
|
LocalExpnId::from_u32(idx.as_u32())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,11 +201,6 @@ impl LocalExpnId {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn expn_hash(self) -> ExpnHash {
|
|
||||||
HygieneData::with(|data| data.local_expn_hash(self))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn expn_data(self) -> ExpnData {
|
pub fn expn_data(self) -> ExpnData {
|
||||||
HygieneData::with(|data| data.local_expn_data(self).clone())
|
HygieneData::with(|data| data.local_expn_data(self).clone())
|
||||||
@ -239,13 +231,6 @@ impl LocalExpnId {
|
|||||||
self.to_expn_id().is_descendant_of(ancestor.to_expn_id())
|
self.to_expn_id().is_descendant_of(ancestor.to_expn_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `expn_id.outer_expn_is_descendant_of(ctxt)` is equivalent to but faster than
|
|
||||||
/// `expn_id.is_descendant_of(ctxt.outer_expn())`.
|
|
||||||
#[inline]
|
|
||||||
pub fn outer_expn_is_descendant_of(self, ctxt: SyntaxContext) -> bool {
|
|
||||||
self.to_expn_id().outer_expn_is_descendant_of(ctxt)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns span for the macro which originally caused this expansion to happen.
|
/// Returns span for the macro which originally caused this expansion to happen.
|
||||||
///
|
///
|
||||||
/// Stops backtracing at include! boundary.
|
/// Stops backtracing at include! boundary.
|
||||||
@ -253,12 +238,6 @@ impl LocalExpnId {
|
|||||||
pub fn expansion_cause(self) -> Option<Span> {
|
pub fn expansion_cause(self) -> Option<Span> {
|
||||||
self.to_expn_id().expansion_cause()
|
self.to_expn_id().expansion_cause()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
#[track_caller]
|
|
||||||
pub fn parent(self) -> LocalExpnId {
|
|
||||||
self.expn_data().parent.as_local().unwrap()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ExpnId {
|
impl ExpnId {
|
||||||
@ -333,7 +312,7 @@ impl ExpnId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct HygieneData {
|
pub(crate) struct HygieneData {
|
||||||
/// Each expansion should have an associated expansion data, but sometimes there's a delay
|
/// Each expansion should have an associated expansion data, but sometimes there's a delay
|
||||||
/// between creation of an expansion ID and obtaining its data (e.g. macros are collected
|
/// between creation of an expansion ID and obtaining its data (e.g. macros are collected
|
||||||
/// first and then resolved later), so we use an `Option` here.
|
/// first and then resolved later), so we use an `Option` here.
|
||||||
@ -384,15 +363,10 @@ impl HygieneData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with<T, F: FnOnce(&mut HygieneData) -> T>(f: F) -> T {
|
fn with<T, F: FnOnce(&mut HygieneData) -> T>(f: F) -> T {
|
||||||
with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow_mut()))
|
with_session_globals(|session_globals| f(&mut session_globals.hygiene_data.borrow_mut()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn local_expn_hash(&self, expn_id: LocalExpnId) -> ExpnHash {
|
|
||||||
self.local_expn_hashes[expn_id]
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn expn_hash(&self, expn_id: ExpnId) -> ExpnHash {
|
fn expn_hash(&self, expn_id: ExpnId) -> ExpnHash {
|
||||||
match expn_id.as_local() {
|
match expn_id.as_local() {
|
||||||
@ -746,7 +720,7 @@ impl SyntaxContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Like `SyntaxContext::adjust`, but also normalizes `self` to macros 2.0.
|
/// Like `SyntaxContext::adjust`, but also normalizes `self` to macros 2.0.
|
||||||
pub fn normalize_to_macros_2_0_and_adjust(&mut self, expn_id: ExpnId) -> Option<ExpnId> {
|
pub(crate) fn normalize_to_macros_2_0_and_adjust(&mut self, expn_id: ExpnId) -> Option<ExpnId> {
|
||||||
HygieneData::with(|data| {
|
HygieneData::with(|data| {
|
||||||
*self = data.normalize_to_macros_2_0(*self);
|
*self = data.normalize_to_macros_2_0(*self);
|
||||||
data.adjust(self, expn_id)
|
data.adjust(self, expn_id)
|
||||||
@ -779,7 +753,11 @@ impl SyntaxContext {
|
|||||||
/// ```
|
/// ```
|
||||||
/// This returns `None` if the context cannot be glob-adjusted.
|
/// This returns `None` if the context cannot be glob-adjusted.
|
||||||
/// Otherwise, it returns the scope to use when privacy checking (see `adjust` for details).
|
/// Otherwise, it returns the scope to use when privacy checking (see `adjust` for details).
|
||||||
pub fn glob_adjust(&mut self, expn_id: ExpnId, glob_span: Span) -> Option<Option<ExpnId>> {
|
pub(crate) fn glob_adjust(
|
||||||
|
&mut self,
|
||||||
|
expn_id: ExpnId,
|
||||||
|
glob_span: Span,
|
||||||
|
) -> Option<Option<ExpnId>> {
|
||||||
HygieneData::with(|data| {
|
HygieneData::with(|data| {
|
||||||
let mut scope = None;
|
let mut scope = None;
|
||||||
let mut glob_ctxt = data.normalize_to_macros_2_0(glob_span.ctxt());
|
let mut glob_ctxt = data.normalize_to_macros_2_0(glob_span.ctxt());
|
||||||
@ -803,7 +781,7 @@ impl SyntaxContext {
|
|||||||
/// assert!(self.glob_adjust(expansion, glob_ctxt) == Some(privacy_checking_scope));
|
/// assert!(self.glob_adjust(expansion, glob_ctxt) == Some(privacy_checking_scope));
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn reverse_glob_adjust(
|
pub(crate) fn reverse_glob_adjust(
|
||||||
&mut self,
|
&mut self,
|
||||||
expn_id: ExpnId,
|
expn_id: ExpnId,
|
||||||
glob_span: Span,
|
glob_span: Span,
|
||||||
@ -858,11 +836,11 @@ impl SyntaxContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn outer_mark(self) -> (ExpnId, Transparency) {
|
fn outer_mark(self) -> (ExpnId, Transparency) {
|
||||||
HygieneData::with(|data| data.outer_mark(self))
|
HygieneData::with(|data| data.outer_mark(self))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dollar_crate_name(self) -> Symbol {
|
pub(crate) fn dollar_crate_name(self) -> Symbol {
|
||||||
HygieneData::with(|data| data.syntax_context_data[self.0 as usize].dollar_crate_name)
|
HygieneData::with(|data| data.syntax_context_data[self.0 as usize].dollar_crate_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -961,12 +939,12 @@ pub struct ExpnData {
|
|||||||
/// The normal module (`mod`) in which the expanded macro was defined.
|
/// The normal module (`mod`) in which the expanded macro was defined.
|
||||||
pub parent_module: Option<DefId>,
|
pub parent_module: Option<DefId>,
|
||||||
/// Suppresses the `unsafe_code` lint for code produced by this macro.
|
/// Suppresses the `unsafe_code` lint for code produced by this macro.
|
||||||
pub allow_internal_unsafe: bool,
|
pub(crate) allow_internal_unsafe: bool,
|
||||||
/// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro.
|
/// Enables the macro helper hack (`ident!(...)` -> `$crate::ident!(...)`) for this macro.
|
||||||
pub local_inner_macros: bool,
|
pub local_inner_macros: bool,
|
||||||
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
|
/// Should debuginfo for the macro be collapsed to the outermost expansion site (in other
|
||||||
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
|
/// words, was the macro definition annotated with `#[collapse_debuginfo]`)?
|
||||||
pub collapse_debuginfo: bool,
|
pub(crate) collapse_debuginfo: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl !PartialEq for ExpnData {}
|
impl !PartialEq for ExpnData {}
|
||||||
|
@ -4,10 +4,12 @@
|
|||||||
//!
|
//!
|
||||||
//! - the *span*, represented by [`SpanData`] and related types;
|
//! - the *span*, represented by [`SpanData`] and related types;
|
||||||
//! - source code as represented by a [`SourceMap`]; and
|
//! - source code as represented by a [`SourceMap`]; and
|
||||||
//! - interned strings, represented by [`Symbol`]s, with some common symbols available statically in the [`sym`] module.
|
//! - interned strings, represented by [`Symbol`]s, with some common symbols available statically
|
||||||
|
//! in the [`sym`] module.
|
||||||
//!
|
//!
|
||||||
//! Unlike most compilers, the span contains not only the position in the source code, but also various other metadata,
|
//! Unlike most compilers, the span contains not only the position in the source code, but also
|
||||||
//! such as the edition and macro hygiene. This metadata is stored in [`SyntaxContext`] and [`ExpnData`].
|
//! various other metadata, such as the edition and macro hygiene. This metadata is stored in
|
||||||
|
//! [`SyntaxContext`] and [`ExpnData`].
|
||||||
//!
|
//!
|
||||||
//! ## Note
|
//! ## Note
|
||||||
//!
|
//!
|
||||||
@ -117,7 +119,6 @@ impl SessionGlobals {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn create_session_globals_then<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
|
pub fn create_session_globals_then<R>(edition: Edition, f: impl FnOnce() -> R) -> R {
|
||||||
assert!(
|
assert!(
|
||||||
!SESSION_GLOBALS.is_set(),
|
!SESSION_GLOBALS.is_set(),
|
||||||
@ -128,7 +129,6 @@ pub fn create_session_globals_then<R>(edition: Edition, f: impl FnOnce() -> R) -
|
|||||||
SESSION_GLOBALS.set(&session_globals, f)
|
SESSION_GLOBALS.set(&session_globals, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnOnce() -> R) -> R {
|
pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnOnce() -> R) -> R {
|
||||||
assert!(
|
assert!(
|
||||||
!SESSION_GLOBALS.is_set(),
|
!SESSION_GLOBALS.is_set(),
|
||||||
@ -138,7 +138,6 @@ pub fn set_session_globals_then<R>(session_globals: &SessionGlobals, f: impl FnO
|
|||||||
SESSION_GLOBALS.set(session_globals, f)
|
SESSION_GLOBALS.set(session_globals, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn create_default_session_if_not_set_then<R, F>(f: F) -> R
|
pub fn create_default_session_if_not_set_then<R, F>(f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&SessionGlobals) -> R,
|
F: FnOnce(&SessionGlobals) -> R,
|
||||||
@ -146,7 +145,6 @@ where
|
|||||||
create_session_if_not_set_then(edition::DEFAULT_EDITION, f)
|
create_session_if_not_set_then(edition::DEFAULT_EDITION, f)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn create_session_if_not_set_then<R, F>(edition: Edition, f: F) -> R
|
pub fn create_session_if_not_set_then<R, F>(edition: Edition, f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&SessionGlobals) -> R,
|
F: FnOnce(&SessionGlobals) -> R,
|
||||||
@ -159,7 +157,6 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn with_session_globals<R, F>(f: F) -> R
|
pub fn with_session_globals<R, F>(f: F) -> R
|
||||||
where
|
where
|
||||||
F: FnOnce(&SessionGlobals) -> R,
|
F: FnOnce(&SessionGlobals) -> R,
|
||||||
@ -167,7 +164,6 @@ where
|
|||||||
SESSION_GLOBALS.with(f)
|
SESSION_GLOBALS.with(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn create_default_session_globals_then<R>(f: impl FnOnce() -> R) -> R {
|
pub fn create_default_session_globals_then<R>(f: impl FnOnce() -> R) -> R {
|
||||||
create_session_globals_then(edition::DEFAULT_EDITION, f)
|
create_session_globals_then(edition::DEFAULT_EDITION, f)
|
||||||
}
|
}
|
||||||
@ -179,8 +175,7 @@ scoped_tls::scoped_thread_local!(static SESSION_GLOBALS: SessionGlobals);
|
|||||||
|
|
||||||
// FIXME: We should use this enum or something like it to get rid of the
|
// FIXME: We should use this enum or something like it to get rid of the
|
||||||
// use of magic `/rust/1.x/...` paths across the board.
|
// use of magic `/rust/1.x/...` paths across the board.
|
||||||
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd)]
|
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Decodable)]
|
||||||
#[derive(Decodable)]
|
|
||||||
pub enum RealFileName {
|
pub enum RealFileName {
|
||||||
LocalPath(PathBuf),
|
LocalPath(PathBuf),
|
||||||
/// For remapped paths (namely paths into libstd that have been mapped
|
/// For remapped paths (namely paths into libstd that have been mapped
|
||||||
@ -217,8 +212,8 @@ impl<S: Encoder> Encodable<S> for RealFileName {
|
|||||||
|
|
||||||
RealFileName::Remapped { ref local_path, ref virtual_name } => encoder
|
RealFileName::Remapped { ref local_path, ref virtual_name } => encoder
|
||||||
.emit_enum_variant(1, |encoder| {
|
.emit_enum_variant(1, |encoder| {
|
||||||
// For privacy and build reproducibility, we must not embed host-dependant path in artifacts
|
// For privacy and build reproducibility, we must not embed host-dependant path
|
||||||
// if they have been remapped by --remap-path-prefix
|
// in artifacts if they have been remapped by --remap-path-prefix
|
||||||
assert!(local_path.is_none());
|
assert!(local_path.is_none());
|
||||||
local_path.encode(encoder);
|
local_path.encode(encoder);
|
||||||
virtual_name.encode(encoder);
|
virtual_name.encode(encoder);
|
||||||
@ -954,7 +949,7 @@ impl Span {
|
|||||||
/// Produces a span with the same location as `self` and context produced by a macro with the
|
/// Produces a span with the same location as `self` and context produced by a macro with the
|
||||||
/// given ID and transparency, assuming that macro was defined directly and not produced by
|
/// given ID and transparency, assuming that macro was defined directly and not produced by
|
||||||
/// some other macro (which is the case for built-in and procedural macros).
|
/// some other macro (which is the case for built-in and procedural macros).
|
||||||
pub fn with_ctxt_from_mark(self, expn_id: ExpnId, transparency: Transparency) -> Span {
|
fn with_ctxt_from_mark(self, expn_id: ExpnId, transparency: Transparency) -> Span {
|
||||||
self.with_ctxt(SyntaxContext::root().apply_mark(expn_id, transparency))
|
self.with_ctxt(SyntaxContext::root().apply_mark(expn_id, transparency))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1529,7 +1524,8 @@ impl SourceFile {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This converts the `lines` field to contain `SourceFileLines::Lines` if needed and freezes it.
|
/// This converts the `lines` field to contain `SourceFileLines::Lines` if needed and freezes
|
||||||
|
/// it.
|
||||||
fn convert_diffs_to_lines_frozen(&self) {
|
fn convert_diffs_to_lines_frozen(&self) {
|
||||||
let mut guard = if let Some(guard) = self.lines.try_write() { guard } else { return };
|
let mut guard = if let Some(guard) = self.lines.try_write() { guard } else { return };
|
||||||
|
|
||||||
@ -2247,6 +2243,9 @@ where
|
|||||||
|
|
||||||
/// Useful type to use with `Result<>` indicate that an error has already
|
/// Useful type to use with `Result<>` indicate that an error has already
|
||||||
/// been reported to the user, so no need to continue checking.
|
/// been reported to the user, so no need to continue checking.
|
||||||
|
///
|
||||||
|
/// The `()` field is necessary: it is non-`pub`, which means values of this
|
||||||
|
/// type cannot be constructed outside of this crate.
|
||||||
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
#[derive(HashStable_Generic)]
|
#[derive(HashStable_Generic)]
|
||||||
pub struct ErrorGuaranteed(());
|
pub struct ErrorGuaranteed(());
|
||||||
@ -2264,7 +2263,8 @@ impl<E: rustc_serialize::Encoder> Encodable<E> for ErrorGuaranteed {
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn encode(&self, _e: &mut E) {
|
fn encode(&self, _e: &mut E) {
|
||||||
panic!(
|
panic!(
|
||||||
"should never serialize an `ErrorGuaranteed`, as we do not write metadata or incremental caches in case errors occurred"
|
"should never serialize an `ErrorGuaranteed`, as we do not write metadata or \
|
||||||
|
incremental caches in case errors occurred"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,20 +9,15 @@
|
|||||||
//! within the `SourceMap`, which upon request can be converted to line and column
|
//! within the `SourceMap`, which upon request can be converted to line and column
|
||||||
//! information, source code snippets, etc.
|
//! information, source code snippets, etc.
|
||||||
|
|
||||||
pub use crate::hygiene::{ExpnData, ExpnKind};
|
use crate::*;
|
||||||
pub use crate::*;
|
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use rustc_data_structures::stable_hasher::{Hash128, Hash64, StableHasher};
|
use rustc_data_structures::stable_hasher::{Hash128, Hash64, StableHasher};
|
||||||
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock};
|
use rustc_data_structures::sync::{IntoDynSyncSend, Lrc, MappedReadGuard, ReadGuard, RwLock};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
use std::hash::Hash;
|
|
||||||
use std::path::{self, Path, PathBuf};
|
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::hash::Hash;
|
||||||
use std::io::BorrowedBuf;
|
use std::io::{self, BorrowedBuf, Read};
|
||||||
use std::io::Read;
|
use std::path::{self, Path, PathBuf};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
@ -41,7 +36,7 @@ pub fn original_sp(sp: Span, enclosing_sp: Span) -> Span {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod monotonic {
|
mod monotonic {
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
/// A `MonotonicVec` is a `Vec` which can only be grown.
|
/// A `MonotonicVec` is a `Vec` which can only be grown.
|
||||||
@ -51,18 +46,14 @@ pub mod monotonic {
|
|||||||
// field is inaccessible
|
// field is inaccessible
|
||||||
pub struct MonotonicVec<T>(Vec<T>);
|
pub struct MonotonicVec<T>(Vec<T>);
|
||||||
impl<T> MonotonicVec<T> {
|
impl<T> MonotonicVec<T> {
|
||||||
pub fn new(val: Vec<T>) -> MonotonicVec<T> {
|
pub(super) fn push(&mut self, val: T) {
|
||||||
MonotonicVec(val)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn push(&mut self, val: T) {
|
|
||||||
self.0.push(val);
|
self.0.push(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Default for MonotonicVec<T> {
|
impl<T> Default for MonotonicVec<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
MonotonicVec::new(vec![])
|
MonotonicVec(vec![])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +198,7 @@ impl StableSourceFileId {
|
|||||||
//
|
//
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(super) struct SourceMapFiles {
|
struct SourceMapFiles {
|
||||||
source_files: monotonic::MonotonicVec<Lrc<SourceFile>>,
|
source_files: monotonic::MonotonicVec<Lrc<SourceFile>>,
|
||||||
stable_id_to_source_file: FxHashMap<StableSourceFileId, Lrc<SourceFile>>,
|
stable_id_to_source_file: FxHashMap<StableSourceFileId, Lrc<SourceFile>>,
|
||||||
}
|
}
|
||||||
@ -466,33 +457,6 @@ impl SourceMap {
|
|||||||
self.span_to_string(sp, FileNameDisplayPreference::Remapped)
|
self.span_to_string(sp, FileNameDisplayPreference::Remapped)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Format the span location suitable for pretty printing annotations with relative line numbers
|
|
||||||
pub fn span_to_relative_line_string(&self, sp: Span, relative_to: Span) -> String {
|
|
||||||
if self.files.borrow().source_files.is_empty() || sp.is_dummy() || relative_to.is_dummy() {
|
|
||||||
return "no-location".to_string();
|
|
||||||
}
|
|
||||||
|
|
||||||
let lo = self.lookup_char_pos(sp.lo());
|
|
||||||
let hi = self.lookup_char_pos(sp.hi());
|
|
||||||
let offset = self.lookup_char_pos(relative_to.lo());
|
|
||||||
|
|
||||||
if lo.file.name != offset.file.name || !relative_to.contains(sp) {
|
|
||||||
return self.span_to_embeddable_string(sp);
|
|
||||||
}
|
|
||||||
|
|
||||||
let lo_line = lo.line.saturating_sub(offset.line);
|
|
||||||
let hi_line = hi.line.saturating_sub(offset.line);
|
|
||||||
|
|
||||||
format!(
|
|
||||||
"{}:+{}:{}: +{}:{}",
|
|
||||||
lo.file.name.display(FileNameDisplayPreference::Remapped),
|
|
||||||
lo_line,
|
|
||||||
lo.col.to_usize() + 1,
|
|
||||||
hi_line,
|
|
||||||
hi.col.to_usize() + 1,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Format the span location to be printed in diagnostics. Must not be emitted
|
/// Format the span location to be printed in diagnostics. Must not be emitted
|
||||||
/// to build artifacts as this may leak local file paths. Use span_to_embeddable_string
|
/// to build artifacts as this may leak local file paths. Use span_to_embeddable_string
|
||||||
/// for string suitable for embedding.
|
/// for string suitable for embedding.
|
||||||
|
@ -20,8 +20,8 @@ mod tests;
|
|||||||
|
|
||||||
// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
|
// The proc macro code for this is in `compiler/rustc_macros/src/symbols.rs`.
|
||||||
symbols! {
|
symbols! {
|
||||||
// After modifying this list adjust `is_special`, `is_used_keyword`/`is_unused_keyword`,
|
// If you modify this list, adjust `is_special` and `is_used_keyword`/`is_unused_keyword`.
|
||||||
// this should be rarely necessary though if the keywords are kept in alphabetic order.
|
// But this should rarely be necessary if the keywords are kept in alphabetic order.
|
||||||
Keywords {
|
Keywords {
|
||||||
// Special reserved identifiers used internally for elided lifetimes,
|
// Special reserved identifiers used internally for elided lifetimes,
|
||||||
// unnamed method parameters, crate root module, error recovery etc.
|
// unnamed method parameters, crate root module, error recovery etc.
|
||||||
@ -894,7 +894,7 @@ symbols! {
|
|||||||
inline_const_pat,
|
inline_const_pat,
|
||||||
inout,
|
inout,
|
||||||
instruction_set,
|
instruction_set,
|
||||||
integer_: "integer",
|
integer_: "integer", // underscore to avoid clashing with the function `sym::integer` below
|
||||||
integral,
|
integral,
|
||||||
into_future,
|
into_future,
|
||||||
into_iter,
|
into_iter,
|
||||||
|
@ -5,7 +5,7 @@ use crate::traits::{Normalized, ObligationCause, ObligationCtxt};
|
|||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
|
use rustc_middle::traits::query::{DropckConstraint, DropckOutlivesResult};
|
||||||
use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
|
use rustc_middle::ty::{self, EarlyBinder, ParamEnvAnd, Ty, TyCtxt};
|
||||||
use rustc_span::source_map::{Span, DUMMY_SP};
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
|
|
||||||
/// This returns true if the type `ty` is "trivial" for
|
/// This returns true if the type `ty` is "trivial" for
|
||||||
/// dropck-outlives -- that is, if it doesn't require any types to
|
/// dropck-outlives -- that is, if it doesn't require any types to
|
||||||
|
@ -6,8 +6,7 @@ use rustc_errors::ErrorGuaranteed;
|
|||||||
use rustc_infer::infer::region_constraints::RegionConstraintData;
|
use rustc_infer::infer::region_constraints::RegionConstraintData;
|
||||||
use rustc_middle::traits::query::NoSolution;
|
use rustc_middle::traits::query::NoSolution;
|
||||||
use rustc_middle::ty::{TyCtxt, TypeFoldable};
|
use rustc_middle::ty::{TyCtxt, TypeFoldable};
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::{Span, DUMMY_SP};
|
||||||
use rustc_span::Span;
|
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use rustc_middle::infer::canonical::CanonicalQueryResponse;
|
|||||||
use rustc_middle::traits::ObligationCause;
|
use rustc_middle::traits::ObligationCause;
|
||||||
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
|
use rustc_middle::ty::{self, ParamEnvAnd, Ty, TyCtxt, TypeVisitableExt};
|
||||||
use rustc_span::def_id::CRATE_DEF_ID;
|
use rustc_span::def_id::CRATE_DEF_ID;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
use smallvec::{smallvec, SmallVec};
|
use smallvec::{smallvec, SmallVec};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
|
#[derive(Copy, Clone, Debug, HashStable, TypeFoldable, TypeVisitable)]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use rustc_infer::infer::TyCtxtInferExt;
|
use rustc_infer::infer::TyCtxtInferExt;
|
||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
|
use rustc_middle::ty::{ParamEnvAnd, TyCtxt};
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
use rustc_trait_selection::traits::query::CanonicalPredicateGoal;
|
use rustc_trait_selection::traits::query::CanonicalPredicateGoal;
|
||||||
use rustc_trait_selection::traits::{
|
use rustc_trait_selection::traits::{
|
||||||
EvaluationResult, Obligation, ObligationCause, OverflowError, SelectionContext, TraitQueryMode,
|
EvaluationResult, Obligation, ObligationCause, OverflowError, SelectionContext, TraitQueryMode,
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use rustc_resolve::rustdoc::{unindent_doc_fragments, DocFragment, DocFragmentKind};
|
use rustc_resolve::rustdoc::{unindent_doc_fragments, DocFragment, DocFragmentKind};
|
||||||
use rustc_span::create_default_session_globals_then;
|
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
use rustc_span::{create_default_session_globals_then, DUMMY_SP};
|
||||||
|
|
||||||
fn create_doc_fragment(s: &str) -> Vec<DocFragment> {
|
fn create_doc_fragment(s: &str) -> Vec<DocFragment> {
|
||||||
vec![DocFragment {
|
vec![DocFragment {
|
||||||
|
@ -10,8 +10,7 @@ use rustc_hir::def_id::{DefIdMap, LOCAL_CRATE};
|
|||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map::FileName;
|
use rustc_span::{sym, FileName, Symbol};
|
||||||
use rustc_span::{sym, Symbol};
|
|
||||||
|
|
||||||
use super::print_item::{full_path, item_path, print_item};
|
use super::print_item::{full_path, item_path, print_item};
|
||||||
use super::search_index::build_index;
|
use super::search_index::build_index;
|
||||||
|
@ -13,8 +13,7 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||||||
use rustc_hir::def_id::LOCAL_CRATE;
|
use rustc_hir::def_id::LOCAL_CRATE;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::source_map::FileName;
|
use rustc_span::{sym, FileName};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
|
@ -4,7 +4,7 @@ use std::io::prelude::*;
|
|||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
use crate::config::{Options, RenderOptions};
|
use crate::config::{Options, RenderOptions};
|
||||||
use crate::doctest::{Collector, GlobalTestOptions};
|
use crate::doctest::{Collector, GlobalTestOptions};
|
||||||
|
@ -19,9 +19,8 @@ use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, Level,
|
|||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use rustc_span::{sym, DUMMY_SP};
|
use rustc_span::{sym, DUMMY_SP, Span};
|
||||||
use semver::Version;
|
use semver::Version;
|
||||||
|
|
||||||
static UNIX_SYSTEMS: &[&str] = &[
|
static UNIX_SYSTEMS: &[&str] = &[
|
||||||
|
@ -10,8 +10,7 @@ use rustc_hir::{BinOpKind, Body, Expr, ExprKind, FnDecl, UnOp};
|
|||||||
use rustc_lint::{LateContext, LateLintPass, Level};
|
use rustc_lint::{LateContext, LateLintPass, Level};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use cargo_metadata::Metadata;
|
use cargo_metadata::Metadata;
|
||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
use super::CARGO_COMMON_METADATA;
|
use super::CARGO_COMMON_METADATA;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use cargo_metadata::Metadata;
|
use cargo_metadata::Metadata;
|
||||||
use clippy_utils::diagnostics::span_lint_and_help;
|
use clippy_utils::diagnostics::span_lint_and_help;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
use super::{NEGATIVE_FEATURE_NAMES, REDUNDANT_FEATURE_NAMES};
|
use super::{NEGATIVE_FEATURE_NAMES, REDUNDANT_FEATURE_NAMES};
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use if_chain::if_chain;
|
|||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use rustc_hir::def_id::LOCAL_CRATE;
|
use rustc_hir::def_id::LOCAL_CRATE;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
use super::MULTIPLE_CRATE_VERSIONS;
|
use super::MULTIPLE_CRATE_VERSIONS;
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use cargo_metadata::Metadata;
|
|||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::DUMMY_SP;
|
use rustc_span::DUMMY_SP;
|
||||||
|
|
||||||
use super::WILDCARD_DEPENDENCIES;
|
use super::WILDCARD_DEPENDENCIES;
|
||||||
|
|
||||||
|
@ -12,8 +12,7 @@ use rustc_hir::{Body, Expr, ExprKind, FnDecl};
|
|||||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, BytePos, Span};
|
||||||
use rustc_span::{sym, BytePos};
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -17,8 +17,7 @@ use rustc_middle::ty::{
|
|||||||
};
|
};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -30,8 +30,8 @@ use rustc_resolve::rustdoc::{
|
|||||||
use rustc_session::parse::ParseSess;
|
use rustc_session::parse::ParseSess;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::edition::Edition;
|
use rustc_span::edition::Edition;
|
||||||
use rustc_span::source_map::{BytePos, FilePathMapping, SourceMap, Span};
|
use rustc_span::{sym, BytePos, FileName, Pos, Span};
|
||||||
use rustc_span::{sym, FileName, Pos};
|
use rustc_span::source_map::{FilePathMapping, SourceMap};
|
||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
use std::{io, thread};
|
use std::{io, thread};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -8,7 +8,7 @@ use rustc_middle::ty::layout::LayoutOf;
|
|||||||
use rustc_middle::ty::{self, TraitRef, Ty};
|
use rustc_middle::ty::{self, TraitRef, Ty};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::kw;
|
use rustc_span::symbol::kw;
|
||||||
use rustc_target::spec::abi::Abi;
|
use rustc_target::spec::abi::Abi;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use rustc_ast::ast::{BinOpKind, Block, Expr, ExprKind, StmtKind, UnOp};
|
|||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -10,7 +10,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
|||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_middle::ty::{Ty, TypeckResults};
|
use rustc_middle::ty::{Ty, TypeckResults};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
|
@ -7,7 +7,7 @@ use clippy_utils::str_utils::{camel_case_split, count_match_end, count_match_sta
|
|||||||
use rustc_hir::{EnumDef, FieldDef, Item, ItemKind, OwnerId, Variant, VariantData};
|
use rustc_hir::{EnumDef, FieldDef, Item, ItemKind, OwnerId, Variant, VariantData};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -9,7 +9,7 @@ use rustc_lint::{LateContext, LateLintPass};
|
|||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_middle::ty::{Adt, Ty};
|
use rustc_middle::ty::{Adt, Ty};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -15,7 +15,8 @@ use rustc_hir::{
|
|||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty::{self, AssocKind, FnSig, Ty};
|
use rustc_middle::ty::{self, AssocKind, FnSig, Ty};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::{Span, Spanned, Symbol};
|
use rustc_span::{Span, Symbol};
|
||||||
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -20,7 +20,7 @@ use rustc_middle::hir::nested_filter as middle_nested_filter;
|
|||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -10,7 +10,7 @@ use rustc_hir::def::Res;
|
|||||||
use rustc_hir::lang_items::LangItem;
|
use rustc_hir::lang_items::LangItem;
|
||||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind};
|
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
pub(super) fn check<'tcx>(
|
pub(super) fn check<'tcx>(
|
||||||
cx: &LateContext<'tcx>,
|
cx: &LateContext<'tcx>,
|
||||||
|
@ -9,7 +9,7 @@ use rustc_hir::def::{DefKind, Res};
|
|||||||
use rustc_hir::{Expr, Pat, PatKind};
|
use rustc_hir::{Expr, Pat, PatKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
/// Check for unnecessary `if let` usage in a for loop where only the `Some` or `Ok` variant of the
|
/// Check for unnecessary `if let` usage in a for loop where only the `Some` or `Ok` variant of the
|
||||||
/// iterator element is used.
|
/// iterator element is used.
|
||||||
|
@ -25,7 +25,7 @@ use clippy_utils::higher;
|
|||||||
use rustc_hir::{Expr, ExprKind, LoopSource, Pat};
|
use rustc_hir::{Expr, ExprKind, LoopSource, Pat};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use utils::{make_iterator_snippet, IncrementVisitor, InitializeVisitor};
|
use utils::{make_iterator_snippet, IncrementVisitor, InitializeVisitor};
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -9,7 +9,7 @@ use rustc_infer::infer::TyCtxtInferExt;
|
|||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::mir::FakeReadCause;
|
use rustc_middle::mir::FakeReadCause;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, body: &Expr<'_>) {
|
pub(super) fn check(cx: &LateContext<'_>, arg: &Expr<'_>, body: &Expr<'_>) {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
|
@ -8,8 +8,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -11,7 +11,7 @@ use rustc_hir::{Expr, ExprKind};
|
|||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
|
@ -6,7 +6,7 @@ use rustc_errors::Applicability;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
|
|||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::FILETYPE_IS_FILE;
|
use super::FILETYPE_IS_FILE;
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use rustc_hir::def::Res;
|
|||||||
use rustc_hir::{Closure, Expr, ExprKind, PatKind, PathSegment, QPath, UnOp};
|
use rustc_hir::{Closure, Expr, ExprKind, PatKind, PathSegment, QPath, UnOp};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::adjustment::Adjust;
|
use rustc_middle::ty::adjustment::Adjust;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::{sym, Ident, Symbol};
|
use rustc_span::symbol::{sym, Ident, Symbol};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ use clippy_utils::{is_expr_untyped_identity_function, is_trait_method};
|
|||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::FILTER_MAP_IDENTITY;
|
use super::FILTER_MAP_IDENTITY;
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ use clippy_utils::{is_expr_untyped_identity_function, is_trait_method};
|
|||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::FLAT_MAP_IDENTITY;
|
use super::FLAT_MAP_IDENTITY;
|
||||||
|
|
||||||
|
@ -4,8 +4,7 @@ use rustc_errors::Applicability;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::FLAT_MAP_OPTION;
|
use super::FLAT_MAP_OPTION;
|
||||||
use clippy_utils::ty::is_type_diagnostic_item;
|
use clippy_utils::ty::is_type_diagnostic_item;
|
||||||
|
@ -2,8 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
|
|||||||
use clippy_utils::is_trait_method;
|
use clippy_utils::is_trait_method;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::INSPECT_FOR_EACH;
|
use super::INSPECT_FOR_EACH;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ use rustc_errors::Applicability;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::{sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
|
|
||||||
use super::INTO_ITER_ON_REF;
|
use super::INTO_ITER_ON_REF;
|
||||||
|
@ -4,8 +4,7 @@ use clippy_utils::{is_expr_untyped_identity_function, is_trait_method};
|
|||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::MAP_IDENTITY;
|
use super::MAP_IDENTITY;
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ use clippy_utils::ty::is_type_diagnostic_item;
|
|||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_hir::{Expr, ExprKind};
|
use rustc_hir::{Expr, ExprKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::{Span, Spanned};
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::sym;
|
use rustc_span::{sym, Span};
|
||||||
|
|
||||||
use super::NONSENSICAL_OPEN_OPTIONS;
|
use super::NONSENSICAL_OPEN_OPTIONS;
|
||||||
|
|
||||||
|
@ -9,8 +9,7 @@ use rustc_hir::intravisit::{walk_path, Visitor};
|
|||||||
use rustc_hir::{self, ExprKind, HirId, Node, PatKind, Path, QPath};
|
use rustc_hir::{self, ExprKind, HirId, Node, PatKind, Path, QPath};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::hir::nested_filter;
|
use rustc_middle::hir::nested_filter;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::MAP_UNWRAP_OR;
|
use super::MAP_UNWRAP_OR;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ use if_chain::if_chain;
|
|||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::{self, sym, Symbol};
|
use rustc_span::symbol::{self, sym, Symbol};
|
||||||
use {rustc_ast as ast, rustc_hir as hir};
|
use {rustc_ast as ast, rustc_hir as hir};
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ use rustc_errors::Applicability;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_hir::PatKind;
|
use rustc_hir::PatKind;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
use super::SEARCH_IS_SOME;
|
use super::SEARCH_IS_SOME;
|
||||||
|
@ -8,8 +8,7 @@ use rustc_hir as hir;
|
|||||||
use rustc_hir::PatKind;
|
use rustc_hir::PatKind;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty;
|
use rustc_middle::ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
use super::UNNECESSARY_FOLD;
|
use super::UNNECESSARY_FOLD;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
|
|||||||
use clippy_utils::ty::is_copy;
|
use clippy_utils::ty::is_copy;
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use super::WRONG_SELF_CONVENTION;
|
use super::WRONG_SELF_CONVENTION;
|
||||||
|
@ -16,7 +16,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
|
|||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use crate::ref_patterns::REF_PATTERNS;
|
use crate::ref_patterns::REF_PATTERNS;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ use rustc_data_structures::fx::FxHashMap;
|
|||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
|||||||
use rustc_ast::ast::{Pat, PatKind};
|
use rustc_ast::ast::{Pat, PatKind};
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_lint::EarlyContext;
|
use rustc_lint::EarlyContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use super::UNNEEDED_WILDCARD_PATTERN;
|
use super::UNNEEDED_WILDCARD_PATTERN;
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ use rustc_lint::{LateContext, LateLintPass, LintContext};
|
|||||||
use rustc_middle::ty::Visibility;
|
use rustc_middle::ty::Visibility;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::def_id::CRATE_DEF_ID;
|
use rustc_span::def_id::CRATE_DEF_ID;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -3,8 +3,7 @@ use rustc_ast::ast;
|
|||||||
use rustc_hir as hir;
|
use rustc_hir as hir;
|
||||||
use rustc_lint::{self, LateContext, LateLintPass, LintContext};
|
use rustc_lint::{self, LateContext, LateLintPass, LintContext};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -8,7 +8,7 @@ use rustc_middle::query::Key;
|
|||||||
use rustc_middle::ty::{Adt, Ty};
|
use rustc_middle::ty::{Adt, Ty};
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::def_id::LocalDefId;
|
use rustc_span::def_id::LocalDefId;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
|
@ -3,8 +3,7 @@ use rustc_hir::intravisit::{walk_expr, Visitor};
|
|||||||
use rustc_hir::{Closure, Expr, ExprKind, Stmt, StmtKind};
|
use rustc_hir::{Closure, Expr, ExprKind, Stmt, StmtKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span, Symbol};
|
||||||
use rustc_span::{sym, Symbol};
|
|
||||||
|
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ use rustc_errors::Applicability;
|
|||||||
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
|
use rustc_hir::{BinOpKind, Expr, ExprKind, UnOp};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
use rustc_session::{declare_lint_pass, declare_tool_lint};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
declare_clippy_lint! {
|
declare_clippy_lint! {
|
||||||
/// ### What it does
|
/// ### What it does
|
||||||
|
@ -6,8 +6,7 @@ use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor};
|
|||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||||
use rustc_middle::lint::in_external_macro;
|
use rustc_middle::lint::in_external_macro;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::{sym, Span};
|
||||||
use rustc_span::sym;
|
|
||||||
use rustc_span::symbol::{Ident, Symbol};
|
use rustc_span::symbol::{Ident, Symbol};
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
|||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass};
|
||||||
use rustc_middle::ty::Ty;
|
use rustc_middle::ty::Ty;
|
||||||
use rustc_session::impl_lint_pass;
|
use rustc_session::impl_lint_pass;
|
||||||
use rustc_span::source_map::{Span, Spanned};
|
use rustc_span::{Span, Symbol};
|
||||||
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::Symbol;
|
|
||||||
use {rustc_ast as ast, rustc_hir as hir};
|
use {rustc_ast as ast, rustc_hir as hir};
|
||||||
|
|
||||||
const HARD_CODED_ALLOWED_BINARY: &[[&str; 2]] = &[["f32", "f32"], ["f64", "f64"], ["std::string::String", "str"]];
|
const HARD_CODED_ALLOWED_BINARY: &[[&str; 2]] = &[["f32", "f32"], ["f64", "f64"], ["std::string::String", "str"]];
|
||||||
|
@ -2,7 +2,7 @@ use clippy_utils::consts::{constant, Constant};
|
|||||||
use clippy_utils::diagnostics::span_lint;
|
use clippy_utils::diagnostics::span_lint;
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_span::source_map::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
use super::{BAD_BIT_MASK, INEFFECTIVE_BIT_MASK};
|
use super::{BAD_BIT_MASK, INEFFECTIVE_BIT_MASK};
|
||||||
|
|
||||||
|
@ -8,7 +8,8 @@ use rustc_hir::{BinOpKind, Expr, ExprKind};
|
|||||||
use rustc_lint::LateContext;
|
use rustc_lint::LateContext;
|
||||||
use rustc_middle::ty::layout::HasTyCtxt;
|
use rustc_middle::ty::layout::HasTyCtxt;
|
||||||
use rustc_middle::ty::{Ty, TypeckResults};
|
use rustc_middle::ty::{Ty, TypeckResults};
|
||||||
use rustc_span::source_map::{Span, Spanned};
|
use rustc_span::Span;
|
||||||
|
use rustc_span::source_map::Spanned;
|
||||||
|
|
||||||
use clippy_utils::diagnostics::span_lint_and_note;
|
use clippy_utils::diagnostics::span_lint_and_note;
|
||||||
use clippy_utils::source::snippet;
|
use clippy_utils::source::snippet;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user