Reformat using the new identifier sorting from rustfmt
This commit is contained in:
parent
1173204b36
commit
c682aa162b
1455 changed files with 7152 additions and 8384 deletions
|
@ -17,24 +17,25 @@ use rustc_data_structures::sync::Lrc;
|
|||
use rustc_expand::base::ResolverExpand;
|
||||
use rustc_expand::expand::AstFragment;
|
||||
use rustc_hir::def::{self, *};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
|
||||
use rustc_metadata::creader::LoadedMacro;
|
||||
use rustc_middle::metadata::ModChild;
|
||||
use rustc_middle::ty::Feed;
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::Namespace::{MacroNS, TypeNS, ValueNS};
|
||||
use crate::def_collector::collect_definitions;
|
||||
use crate::imports::{ImportData, ImportKind};
|
||||
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
|
||||
use crate::Namespace::{MacroNS, TypeNS, ValueNS};
|
||||
use crate::{
|
||||
errors, BindingKey, Determinacy, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind,
|
||||
BindingKey, Determinacy, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind,
|
||||
ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult,
|
||||
ResolutionError, Resolver, ResolverArenas, Segment, ToNameBinding, Used, VisResolutionError,
|
||||
errors,
|
||||
};
|
||||
|
||||
type Res = def::Res<NodeId>;
|
||||
|
@ -565,13 +566,10 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
|
|||
Some(rename) => source.ident.span.to(rename.span),
|
||||
None => source.ident.span,
|
||||
};
|
||||
self.r.report_error(
|
||||
span,
|
||||
ResolutionError::SelfImportsOnlyAllowedWithin {
|
||||
root: parent.is_none(),
|
||||
span_with_rename,
|
||||
},
|
||||
);
|
||||
self.r.report_error(span, ResolutionError::SelfImportsOnlyAllowedWithin {
|
||||
root: parent.is_none(),
|
||||
span_with_rename,
|
||||
});
|
||||
|
||||
// Error recovery: replace `use foo::self;` with `use foo;`
|
||||
if let Some(parent) = module_path.pop() {
|
||||
|
|
|
@ -29,15 +29,15 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
|
|||
use rustc_data_structures::unord::UnordSet;
|
||||
use rustc_errors::MultiSpan;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::lint::builtin::{
|
||||
MACRO_USE_EXTERN_CRATE, UNUSED_EXTERN_CRATES, UNUSED_IMPORTS, UNUSED_QUALIFICATIONS,
|
||||
};
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::{Ident, kw};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
|
||||
use crate::imports::{Import, ImportKind};
|
||||
use crate::{module_to_string, LexicalScopeBinding, NameBindingKind, Resolver};
|
||||
use crate::{LexicalScopeBinding, NameBindingKind, Resolver, module_to_string};
|
||||
|
||||
struct UnusedImport {
|
||||
use_tree: ast::UseTree,
|
||||
|
|
|
@ -7,9 +7,9 @@ use rustc_expand::expand::AstFragment;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
|
||||
use rustc_hir::def_id::LocalDefId;
|
||||
use rustc_span::hygiene::LocalExpnId;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::hygiene::LocalExpnId;
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::{ImplTraitContext, InvocationParent, PendingAnonConstInfo, Resolver};
|
||||
|
@ -127,15 +127,12 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
|
|||
fn visit_macro_invoc(&mut self, id: NodeId) {
|
||||
let id = id.placeholder_to_expn_id();
|
||||
let pending_anon_const_info = self.pending_anon_const_info.take();
|
||||
let old_parent = self.resolver.invocation_parents.insert(
|
||||
id,
|
||||
InvocationParent {
|
||||
parent_def: self.parent_def,
|
||||
pending_anon_const_info,
|
||||
impl_trait_context: self.impl_trait_context,
|
||||
in_attr: self.in_attr,
|
||||
},
|
||||
);
|
||||
let old_parent = self.resolver.invocation_parents.insert(id, InvocationParent {
|
||||
parent_def: self.parent_def,
|
||||
pending_anon_const_info,
|
||||
impl_trait_context: self.impl_trait_context,
|
||||
in_attr: self.in_attr,
|
||||
});
|
||||
assert!(old_parent.is_none(), "parent `LocalDefId` is reset for an invocation");
|
||||
}
|
||||
|
||||
|
|
|
@ -2,36 +2,36 @@ use rustc_ast::expand::StrippedCfgItem;
|
|||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{self, Visitor};
|
||||
use rustc_ast::{
|
||||
self as ast, Crate, ItemKind, MetaItemKind, ModKind, NestedMetaItem, NodeId, Path,
|
||||
CRATE_NODE_ID,
|
||||
self as ast, CRATE_NODE_ID, Crate, ItemKind, MetaItemKind, ModKind, NestedMetaItem, NodeId,
|
||||
Path,
|
||||
};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
report_ambiguity_error, struct_span_code_err, Applicability, Diag, DiagCtxtHandle,
|
||||
ErrorGuaranteed, MultiSpan, SuggestionStyle,
|
||||
Applicability, Diag, DiagCtxtHandle, ErrorGuaranteed, MultiSpan, SuggestionStyle,
|
||||
report_ambiguity_error, struct_span_code_err,
|
||||
};
|
||||
use rustc_feature::BUILTIN_ATTRIBUTES;
|
||||
use rustc_hir::PrimTy;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind, PerNS};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||
use rustc_hir::PrimTy;
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::builtin::{
|
||||
ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE, AMBIGUOUS_GLOB_IMPORTS,
|
||||
MACRO_EXPANDED_MACRO_EXPORTS_ACCESSED_BY_ABSOLUTE_PATHS,
|
||||
};
|
||||
use rustc_session::lint::{AmbiguityErrorDiag, BuiltinLintDiag};
|
||||
use rustc_session::Session;
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::source_map::SourceMap;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{BytePos, Span, SyntaxContext};
|
||||
use thin_vec::{thin_vec, ThinVec};
|
||||
use thin_vec::{ThinVec, thin_vec};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::errors::{
|
||||
|
@ -41,11 +41,11 @@ use crate::errors::{
|
|||
use crate::imports::{Import, ImportKind};
|
||||
use crate::late::{PatternSource, Rib};
|
||||
use crate::{
|
||||
errors as errs, path_names_to_string, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind,
|
||||
BindingError, BindingKey, Finalize, HasGenericParams, LexicalScopeBinding, MacroRulesScope,
|
||||
Module, ModuleKind, ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult,
|
||||
PrivacyError, ResolutionError, Resolver, Scope, ScopeSet, Segment, UseError, Used,
|
||||
VisResolutionError,
|
||||
AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingError, BindingKey, Finalize,
|
||||
HasGenericParams, LexicalScopeBinding, MacroRulesScope, Module, ModuleKind,
|
||||
ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult, PrivacyError,
|
||||
ResolutionError, Resolver, Scope, ScopeSet, Segment, UseError, Used, VisResolutionError,
|
||||
errors as errs, path_names_to_string,
|
||||
};
|
||||
|
||||
type Res = def::Res<ast::NodeId>;
|
||||
|
@ -1002,10 +1002,14 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
VisResolutionError::AncestorOnly(span) => {
|
||||
self.dcx().create_err(errs::AncestorOnly(span))
|
||||
}
|
||||
VisResolutionError::FailedToResolve(span, label, suggestion) => self.into_struct_error(
|
||||
span,
|
||||
ResolutionError::FailedToResolve { segment: None, label, suggestion, module: None },
|
||||
),
|
||||
VisResolutionError::FailedToResolve(span, label, suggestion) => {
|
||||
self.into_struct_error(span, ResolutionError::FailedToResolve {
|
||||
segment: None,
|
||||
label,
|
||||
suggestion,
|
||||
module: None,
|
||||
})
|
||||
}
|
||||
VisResolutionError::ExpectedFound(span, path_str, res) => {
|
||||
self.dcx().create_err(errs::ExpectedModuleFound { span, res, path_str })
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use std::mem;
|
||||
|
||||
use rustc_ast::visit::Visitor;
|
||||
use rustc_ast::{ast, visit, Crate, EnumDef};
|
||||
use rustc_ast::{Crate, EnumDef, ast, visit};
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, LocalDefId};
|
||||
use rustc_middle::middle::privacy::{EffectiveVisibilities, EffectiveVisibility, Level};
|
||||
use rustc_middle::ty::Visibility;
|
||||
use tracing::info;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{Applicability, ElidedLifetimeInPathSubdiag, MultiSpan};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::{Ident, Symbol};
|
||||
|
||||
use crate::late::PatternSource;
|
||||
use crate::Res;
|
||||
use crate::late::PatternSource;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(resolve_generic_params_from_outer_item, code = E0401)]
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
use Determinacy::*;
|
||||
use Namespace::*;
|
||||
use rustc_ast::{self as ast, NodeId};
|
||||
use rustc_errors::ErrorGuaranteed;
|
||||
use rustc_hir::def::{DefKind, Namespace, NonMacroAttrKind, PartialRes, PerNS};
|
||||
use rustc_middle::{bug, ty};
|
||||
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::lint::builtin::PROC_MACRO_DERIVE_RESOLUTION_FALLBACK;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::hygiene::{ExpnId, ExpnKind, LocalExpnId, MacroKind, SyntaxContext};
|
||||
use rustc_span::symbol::{kw, Ident};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_span::symbol::{Ident, kw};
|
||||
use rustc_span::{Span, sym};
|
||||
use tracing::{debug, instrument};
|
||||
use Determinacy::*;
|
||||
use Namespace::*;
|
||||
|
||||
use crate::errors::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst};
|
||||
use crate::imports::Import;
|
||||
use crate::late::{ConstantHasGenerics, NoConstantGenericsReason, PathSource, Rib, RibKind};
|
||||
use crate::macros::{sub_namespace_match, MacroRulesScope};
|
||||
use crate::macros::{MacroRulesScope, sub_namespace_match};
|
||||
use crate::{
|
||||
errors, AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingKey, Determinacy, Finalize,
|
||||
AmbiguityError, AmbiguityErrorMisc, AmbiguityKind, BindingKey, Determinacy, Finalize,
|
||||
ImportKind, LexicalScopeBinding, Module, ModuleKind, ModuleOrUniformRoot, NameBinding,
|
||||
NameBindingKind, ParentScope, PathResult, PrivacyError, Res, ResolutionError, Resolver, Scope,
|
||||
ScopeSet, Segment, ToNameBinding, Used, Weak,
|
||||
ScopeSet, Segment, ToNameBinding, Used, Weak, errors,
|
||||
};
|
||||
|
||||
type Visibility = ty::Visibility<LocalDefId>;
|
||||
|
@ -1218,25 +1218,21 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
Some(_) => None,
|
||||
};
|
||||
(
|
||||
rib_ident.span,
|
||||
AttemptToUseNonConstantValueInConstant {
|
||||
ident: original_rib_ident_def,
|
||||
suggestion: "const",
|
||||
current: "let",
|
||||
type_span,
|
||||
},
|
||||
)
|
||||
(rib_ident.span, AttemptToUseNonConstantValueInConstant {
|
||||
ident: original_rib_ident_def,
|
||||
suggestion: "const",
|
||||
current: "let",
|
||||
type_span,
|
||||
})
|
||||
}
|
||||
Some((ident, kind)) => (
|
||||
span,
|
||||
AttemptToUseNonConstantValueInConstant {
|
||||
Some((ident, kind)) => {
|
||||
(span, AttemptToUseNonConstantValueInConstant {
|
||||
ident,
|
||||
suggestion: "let",
|
||||
current: kind.as_str(),
|
||||
type_span: None,
|
||||
},
|
||||
),
|
||||
})
|
||||
}
|
||||
};
|
||||
self.report_error(span, resolution_error);
|
||||
}
|
||||
|
@ -1244,13 +1240,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
RibKind::ConstParamTy => {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
param_kind: None,
|
||||
},
|
||||
);
|
||||
self.report_error(span, ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
param_kind: None,
|
||||
});
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
|
@ -1331,13 +1324,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
RibKind::ConstParamTy => {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
param_kind: Some(errors::ParamKindInTyOfConstParam::Type),
|
||||
},
|
||||
);
|
||||
self.report_error(span, ResolutionError::ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
param_kind: Some(errors::ParamKindInTyOfConstParam::Type),
|
||||
});
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
|
@ -1400,13 +1390,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
}
|
||||
RibKind::ConstParamTy => {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
param_kind: Some(errors::ParamKindInTyOfConstParam::Const),
|
||||
},
|
||||
);
|
||||
self.report_error(span, ResolutionError::ParamInTyOfConstParam {
|
||||
name: rib_ident.name,
|
||||
param_kind: Some(errors::ParamKindInTyOfConstParam::Const),
|
||||
});
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
|
|
|
@ -7,36 +7,36 @@ use rustc_ast::NodeId;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{pluralize, struct_span_code_err, Applicability, MultiSpan};
|
||||
use rustc_errors::{Applicability, MultiSpan, pluralize, struct_span_code_err};
|
||||
use rustc_hir::def::{self, DefKind, PartialRes};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::metadata::{ModChild, Reexport};
|
||||
use rustc_middle::{span_bug, ty};
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::lint::builtin::{
|
||||
AMBIGUOUS_GLOB_REEXPORTS, HIDDEN_GLOB_REEXPORTS, PUB_USE_OF_PRIVATE_EXTERN_CRATE,
|
||||
REDUNDANT_IMPORTS, UNUSED_IMPORTS,
|
||||
};
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_span::Span;
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::hygiene::LocalExpnId;
|
||||
use rustc_span::symbol::{kw, Ident, Symbol};
|
||||
use rustc_span::Span;
|
||||
use rustc_span::symbol::{Ident, Symbol, kw};
|
||||
use smallvec::SmallVec;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::diagnostics::{import_candidates, DiagMode, Suggestion};
|
||||
use crate::Determinacy::{self, *};
|
||||
use crate::Namespace::*;
|
||||
use crate::diagnostics::{DiagMode, Suggestion, import_candidates};
|
||||
use crate::errors::{
|
||||
CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS, CannotBeReexportedPrivate,
|
||||
CannotBeReexportedPrivateNS, CannotDetermineImportResolution, CannotGlobImportAllCrates,
|
||||
ConsiderAddingMacroExport, ConsiderMarkingAsPub, IsNotDirectlyImportable,
|
||||
ItemsInTraitsAreNotImportable,
|
||||
};
|
||||
use crate::Determinacy::{self, *};
|
||||
use crate::Namespace::*;
|
||||
use crate::{
|
||||
module_to_string, names_to_string, AmbiguityError, AmbiguityKind, BindingKey, Finalize,
|
||||
ImportSuggestion, Module, ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind,
|
||||
ParentScope, PathResult, PerNS, ResolutionError, Resolver, ScopeSet, Segment, Used,
|
||||
AmbiguityError, AmbiguityKind, BindingKey, Finalize, ImportSuggestion, Module,
|
||||
ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult,
|
||||
PerNS, ResolutionError, Resolver, ScopeSet, Segment, Used, module_to_string, names_to_string,
|
||||
};
|
||||
|
||||
type Res = def::Res<NodeId>;
|
||||
|
@ -901,15 +901,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
} => {
|
||||
if no_ambiguity {
|
||||
assert!(import.imported_module.get().is_none());
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::FailedToResolve {
|
||||
segment: Some(segment_name),
|
||||
label,
|
||||
suggestion,
|
||||
module,
|
||||
},
|
||||
);
|
||||
self.report_error(span, ResolutionError::FailedToResolve {
|
||||
segment: Some(segment_name),
|
||||
label,
|
||||
suggestion,
|
||||
module,
|
||||
});
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@
|
|||
|
||||
use std::assert_matches::debug_assert_matches;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::collections::BTreeSet;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::mem::{replace, swap, take};
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{visit_opt, walk_list, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
|
||||
use rustc_ast::visit::{AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor, visit_opt, walk_list};
|
||||
use rustc_ast::*;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{Applicability, DiagArgValue, IntoDiagArg, StashKey, Suggestions};
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, DefKind, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS};
|
||||
use rustc_hir::def_id::{DefId, LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LOCAL_CRATE, LocalDefId};
|
||||
use rustc_hir::{MissingLifetimeKind, PrimTy, TraitCandidate};
|
||||
use rustc_middle::middle::resolve_bound_vars::Set1;
|
||||
use rustc_middle::ty::DelegationFnSig;
|
||||
|
@ -28,16 +28,16 @@ use rustc_middle::{bug, span_bug};
|
|||
use rustc_session::config::{CrateType, ResolveDocLinks};
|
||||
use rustc_session::lint::{self, BuiltinLintDiag};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::source_map::{respan, Spanned};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::source_map::{Spanned, respan};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{BytePos, Span, SyntaxContext};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use tracing::{debug, instrument, trace};
|
||||
|
||||
use crate::{
|
||||
errors, path_names_to_string, rustdoc, BindingError, BindingKey, Finalize, LexicalScopeBinding,
|
||||
Module, ModuleOrUniformRoot, NameBinding, ParentScope, PathResult, ResolutionError, Resolver,
|
||||
Segment, TyCtxt, UseError, Used,
|
||||
BindingError, BindingKey, Finalize, LexicalScopeBinding, Module, ModuleOrUniformRoot,
|
||||
NameBinding, ParentScope, PathResult, ResolutionError, Resolver, Segment, TyCtxt, UseError,
|
||||
Used, errors, path_names_to_string, rustdoc,
|
||||
};
|
||||
|
||||
mod diagnostics;
|
||||
|
@ -1801,11 +1801,9 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
&& Some(true) == self.diag_metadata.in_non_gat_assoc_type
|
||||
&& let crate::ModuleKind::Def(DefKind::Trait, trait_id, _) = module.kind
|
||||
{
|
||||
if def_id_matches_path(
|
||||
self.r.tcx,
|
||||
trait_id,
|
||||
&["core", "iter", "traits", "iterator", "Iterator"],
|
||||
) {
|
||||
if def_id_matches_path(self.r.tcx, trait_id, &[
|
||||
"core", "iter", "traits", "iterator", "Iterator",
|
||||
]) {
|
||||
self.r.dcx().emit_err(errors::LendingIteratorReportError {
|
||||
lifetime: lifetime.ident.span,
|
||||
ty: ty.span,
|
||||
|
@ -3412,14 +3410,11 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
|
||||
match seen_trait_items.entry(id_in_trait) {
|
||||
Entry::Occupied(entry) => {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::TraitImplDuplicate {
|
||||
name: ident.name,
|
||||
old_span: *entry.get(),
|
||||
trait_item_span: binding.span,
|
||||
},
|
||||
);
|
||||
self.report_error(span, ResolutionError::TraitImplDuplicate {
|
||||
name: ident.name,
|
||||
old_span: *entry.get(),
|
||||
trait_item_span: binding.span,
|
||||
});
|
||||
return;
|
||||
}
|
||||
Entry::Vacant(entry) => {
|
||||
|
@ -3450,16 +3445,13 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
}
|
||||
};
|
||||
let trait_path = path_names_to_string(path);
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::TraitImplMismatch {
|
||||
name: ident.name,
|
||||
kind,
|
||||
code,
|
||||
trait_path,
|
||||
trait_item_span: binding.span,
|
||||
},
|
||||
);
|
||||
self.report_error(span, ResolutionError::TraitImplMismatch {
|
||||
name: ident.name,
|
||||
kind,
|
||||
code,
|
||||
trait_path,
|
||||
trait_item_span: binding.span,
|
||||
});
|
||||
}
|
||||
|
||||
fn resolve_const_body(&mut self, expr: &'ast Expr, item: Option<(Ident, ConstantItemKind)>) {
|
||||
|
@ -4447,15 +4439,12 @@ impl<'a, 'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {
|
|||
module,
|
||||
segment_name,
|
||||
} => {
|
||||
return Err(respan(
|
||||
span,
|
||||
ResolutionError::FailedToResolve {
|
||||
segment: Some(segment_name),
|
||||
label,
|
||||
suggestion,
|
||||
module,
|
||||
},
|
||||
));
|
||||
return Err(respan(span, ResolutionError::FailedToResolve {
|
||||
segment: Some(segment_name),
|
||||
label,
|
||||
suggestion,
|
||||
module,
|
||||
}));
|
||||
}
|
||||
PathResult::Module(..) | PathResult::Failed { .. } => return Ok(None),
|
||||
PathResult::Indeterminate => bug!("indeterminate path result in resolve_qpath"),
|
||||
|
|
|
@ -5,30 +5,30 @@ use std::iter;
|
|||
use std::ops::Deref;
|
||||
|
||||
use rustc_ast::ptr::P;
|
||||
use rustc_ast::visit::{walk_ty, FnCtxt, FnKind, LifetimeCtxt, Visitor};
|
||||
use rustc_ast::visit::{FnCtxt, FnKind, LifetimeCtxt, Visitor, walk_ty};
|
||||
use rustc_ast::{
|
||||
self as ast, AssocItemKind, Expr, ExprKind, GenericParam, GenericParamKind, Item, ItemKind,
|
||||
MethodCall, NodeId, Path, Ty, TyKind, DUMMY_NODE_ID,
|
||||
self as ast, AssocItemKind, DUMMY_NODE_ID, Expr, ExprKind, GenericParam, GenericParamKind,
|
||||
Item, ItemKind, MethodCall, NodeId, Path, Ty, TyKind,
|
||||
};
|
||||
use rustc_ast_pretty::pprust::where_bound_predicate_to_string;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexSet};
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
pluralize, struct_span_code_err, Applicability, Diag, ErrorGuaranteed, MultiSpan,
|
||||
SuggestionStyle,
|
||||
Applicability, Diag, ErrorGuaranteed, MultiSpan, SuggestionStyle, pluralize,
|
||||
struct_span_code_err,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::Namespace::{self, *};
|
||||
use rustc_hir::def::{self, CtorKind, CtorOf, DefKind};
|
||||
use rustc_hir::def_id::{DefId, CRATE_DEF_ID};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, DefId};
|
||||
use rustc_hir::{MissingLifetimeKind, PrimTy};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::{lint, Session};
|
||||
use rustc_session::{Session, lint};
|
||||
use rustc_span::edit_distance::find_best_match_for_name;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use thin_vec::ThinVec;
|
||||
use tracing::debug;
|
||||
|
||||
|
@ -40,8 +40,8 @@ use crate::late::{
|
|||
};
|
||||
use crate::ty::fast_reject::SimplifiedType;
|
||||
use crate::{
|
||||
errors, path_names_to_string, Module, ModuleKind, ModuleOrUniformRoot, PathResult, PathSource,
|
||||
Segment,
|
||||
Module, ModuleKind, ModuleOrUniformRoot, PathResult, PathSource, Segment, errors,
|
||||
path_names_to_string,
|
||||
};
|
||||
|
||||
type Res = def::Res<ast::NodeId>;
|
||||
|
@ -1017,15 +1017,12 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
|||
|
||||
debug!("smart_resolve_path_fragment: E0424, source={:?}", source);
|
||||
err.code(E0424);
|
||||
err.span_label(
|
||||
span,
|
||||
match source {
|
||||
PathSource::Pat => {
|
||||
"`self` value is a keyword and may not be bound to variables or shadowed"
|
||||
}
|
||||
_ => "`self` value is a keyword only available in methods with a `self` parameter",
|
||||
},
|
||||
);
|
||||
err.span_label(span, match source {
|
||||
PathSource::Pat => {
|
||||
"`self` value is a keyword and may not be bound to variables or shadowed"
|
||||
}
|
||||
_ => "`self` value is a keyword only available in methods with a `self` parameter",
|
||||
});
|
||||
let is_assoc_fn = self.self_type_is_available();
|
||||
let self_from_macro = "a `self` parameter, but a macro invocation can only \
|
||||
access identifiers it receives from parameters";
|
||||
|
@ -2309,18 +2306,15 @@ impl<'ast, 'ra: 'ast, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
|
|||
if module_def_id == def_id {
|
||||
let path =
|
||||
Path { span: name_binding.span, segments: path_segments, tokens: None };
|
||||
result = Some((
|
||||
module,
|
||||
ImportSuggestion {
|
||||
did: Some(def_id),
|
||||
descr: "module",
|
||||
path,
|
||||
accessible: true,
|
||||
doc_visible,
|
||||
note: None,
|
||||
via_import: false,
|
||||
},
|
||||
));
|
||||
result = Some((module, ImportSuggestion {
|
||||
did: Some(def_id),
|
||||
descr: "module",
|
||||
path,
|
||||
accessible: true,
|
||||
doc_visible,
|
||||
note: None,
|
||||
via_import: false,
|
||||
}));
|
||||
} else {
|
||||
// add the module to the lookup
|
||||
if seen_modules.insert(module_def_id) {
|
||||
|
|
|
@ -40,8 +40,8 @@ use rustc_arena::{DroplessArena, TypedArena};
|
|||
use rustc_ast::expand::StrippedCfgItem;
|
||||
use rustc_ast::node_id::NodeMap;
|
||||
use rustc_ast::{
|
||||
self as ast, attr, AngleBracketedArg, Crate, Expr, ExprKind, GenericArg, GenericArgs, LitKind,
|
||||
NodeId, Path, CRATE_NODE_ID,
|
||||
self as ast, AngleBracketedArg, CRATE_NODE_ID, Crate, Expr, ExprKind, GenericArg, GenericArgs,
|
||||
LitKind, NodeId, Path, attr,
|
||||
};
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_data_structures::intern::Interned;
|
||||
|
@ -54,7 +54,7 @@ use rustc_hir::def::Namespace::{self, *};
|
|||
use rustc_hir::def::{
|
||||
self, CtorOf, DefKind, DocLinkResMap, LifetimeRes, NonMacroAttrKind, PartialRes, PerNS,
|
||||
};
|
||||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_ID, LOCAL_CRATE};
|
||||
use rustc_hir::def_id::{CRATE_DEF_ID, CrateNum, DefId, LOCAL_CRATE, LocalDefId, LocalDefIdMap};
|
||||
use rustc_hir::{PrimTy, TraitCandidate};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_metadata::creader::{CStore, CrateLoader};
|
||||
|
@ -70,9 +70,9 @@ use rustc_query_system::ich::StableHashingContext;
|
|||
use rustc_session::lint::builtin::PRIVATE_MACRO_USE;
|
||||
use rustc_session::lint::{BuiltinLintDiag, LintBuffer};
|
||||
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind, SyntaxContext, Transparency};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use tracing::debug;
|
||||
|
||||
type Res = def::Res<NodeId>;
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::cell::Cell;
|
|||
use std::mem;
|
||||
|
||||
use rustc_ast::expand::StrippedCfgItem;
|
||||
use rustc_ast::{self as ast, attr, Crate, Inline, ItemKind, ModKind, NodeId};
|
||||
use rustc_ast::{self as ast, Crate, Inline, ItemKind, ModKind, NodeId, attr};
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_attr::StabilityLevel;
|
||||
use rustc_data_structures::intern::Interned;
|
||||
|
@ -23,24 +23,24 @@ use rustc_hir::def::{self, DefKind, Namespace, NonMacroAttrKind};
|
|||
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId};
|
||||
use rustc_middle::middle::stability;
|
||||
use rustc_middle::ty::{RegisteredTools, TyCtxt, Visibility};
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::lint::builtin::{
|
||||
LEGACY_DERIVE_HELPERS, OUT_OF_SCOPE_MACRO_CALLS, SOFT_UNSTABLE,
|
||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACROS, UNUSED_MACRO_RULES,
|
||||
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_MACRO_RULES, UNUSED_MACROS,
|
||||
};
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_span::edit_distance::edit_distance;
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::hygiene::{self, AstPass, ExpnData, ExpnKind, LocalExpnId, MacroKind};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::{Ident, Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, Span};
|
||||
|
||||
use crate::Namespace::*;
|
||||
use crate::errors::{
|
||||
self, AddAsNonDerive, CannotDetermineMacroResolution, CannotFindIdentInThisScope,
|
||||
MacroExpectedFound, RemoveSurroundingDerive,
|
||||
};
|
||||
use crate::imports::Import;
|
||||
use crate::Namespace::*;
|
||||
use crate::{
|
||||
BindingKey, BuiltinMacroState, DeriveData, Determinacy, Finalize, InvocationParent, MacroData,
|
||||
ModuleKind, ModuleOrUniformRoot, NameBinding, NameBindingKind, ParentScope, PathResult,
|
||||
|
@ -914,15 +914,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
|
|||
None,
|
||||
)
|
||||
};
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::FailedToResolve {
|
||||
segment: path.last().map(|segment| segment.ident.name),
|
||||
label,
|
||||
suggestion,
|
||||
module,
|
||||
},
|
||||
);
|
||||
self.report_error(span, ResolutionError::FailedToResolve {
|
||||
segment: path.last().map(|segment| segment.ident.name),
|
||||
label,
|
||||
suggestion,
|
||||
module,
|
||||
});
|
||||
}
|
||||
PathResult::Module(..) | PathResult::Indeterminate => unreachable!(),
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ use rustc_ast::util::comments::beautify_doc_string;
|
|||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_span::def_id::DefId;
|
||||
use rustc_span::symbol::{kw, sym, Symbol};
|
||||
use rustc_span::{InnerSpan, Span, DUMMY_SP};
|
||||
use rustc_span::symbol::{Symbol, kw, sym};
|
||||
use rustc_span::{DUMMY_SP, InnerSpan, Span};
|
||||
use tracing::{debug, trace};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue