@@ -86,6 +86,10 @@ mod check_unused;
86
86
mod build_reduced_graph;
87
87
mod resolve_imports;
88
88
89
+ fn is_known_tool ( name : Name ) -> bool {
90
+ [ "clippy" , "rustfmt" ] . contains ( & & * name. as_str ( ) )
91
+ }
92
+
89
93
/// A free importable items suggested in case of resolution failure.
90
94
struct ImportSuggestion {
91
95
path : Path ,
@@ -200,15 +204,10 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver,
200
204
err. span_label ( typaram_span, "type variable from outer function" ) ;
201
205
}
202
206
} ,
203
- Def :: Mod ( ..) | Def :: Struct ( ..) | Def :: Union ( ..) | Def :: Enum ( ..) | Def :: Variant ( ..) |
204
- Def :: Trait ( ..) | Def :: TyAlias ( ..) | Def :: TyForeign ( ..) | Def :: TraitAlias ( ..) |
205
- Def :: AssociatedTy ( ..) | Def :: PrimTy ( ..) | Def :: Fn ( ..) | Def :: Const ( ..) |
206
- Def :: Static ( ..) | Def :: StructCtor ( ..) | Def :: VariantCtor ( ..) | Def :: Method ( ..) |
207
- Def :: AssociatedConst ( ..) | Def :: Local ( ..) | Def :: Upvar ( ..) | Def :: Label ( ..) |
208
- Def :: Existential ( ..) | Def :: AssociatedExistential ( ..) |
209
- Def :: Macro ( ..) | Def :: GlobalAsm ( ..) | Def :: Err =>
207
+ _ => {
210
208
bug ! ( "TypeParametersFromOuterFunction should only be used with Def::SelfTy or \
211
209
Def::TyParam")
210
+ }
212
211
}
213
212
214
213
// Try to retrieve the span of the function signature and generate a new message with
@@ -1711,9 +1710,7 @@ impl<'a> Resolver<'a> {
1711
1710
vis : ty:: Visibility :: Public ,
1712
1711
} ) ,
1713
1712
1714
- // The `proc_macro` and `decl_macro` features imply `use_extern_macros`
1715
- use_extern_macros :
1716
- features. use_extern_macros || features. decl_macro ,
1713
+ use_extern_macros : features. use_extern_macros ( ) ,
1717
1714
1718
1715
crate_loader,
1719
1716
macro_names : FxHashSet ( ) ,
@@ -1846,6 +1843,7 @@ impl<'a> Resolver<'a> {
1846
1843
path_span : Span )
1847
1844
-> Option < LexicalScopeBinding < ' a > > {
1848
1845
let record_used = record_used_id. is_some ( ) ;
1846
+ assert ! ( ns == TypeNS || ns == ValueNS ) ;
1849
1847
if ns == TypeNS {
1850
1848
ident. span = if ident. name == keywords:: SelfType . name ( ) {
1851
1849
// FIXME(jseyfried) improve `Self` hygiene
@@ -1922,8 +1920,9 @@ impl<'a> Resolver<'a> {
1922
1920
return Some ( LexicalScopeBinding :: Item ( binding) )
1923
1921
}
1924
1922
_ if poisoned. is_some ( ) => break ,
1925
- Err ( Undetermined ) => return None ,
1926
- Err ( Determined ) => { }
1923
+ Err ( Determined ) => continue ,
1924
+ Err ( Undetermined ) =>
1925
+ span_bug ! ( ident. span, "undetermined resolution during main resolution pass" ) ,
1927
1926
}
1928
1927
}
1929
1928
@@ -1945,6 +1944,11 @@ impl<'a> Resolver<'a> {
1945
1944
ident. span , Mark :: root ( ) ) . to_name_binding ( self . arenas ) ;
1946
1945
return Some ( LexicalScopeBinding :: Item ( binding) ) ;
1947
1946
}
1947
+ if ns == TypeNS && is_known_tool ( ident. name ) {
1948
+ let binding = ( Def :: ToolMod , ty:: Visibility :: Public ,
1949
+ ident. span , Mark :: root ( ) ) . to_name_binding ( self . arenas ) ;
1950
+ return Some ( LexicalScopeBinding :: Item ( binding) ) ;
1951
+ }
1948
1952
if let Some ( prelude) = self . prelude {
1949
1953
if let Ok ( binding) = self . resolve_ident_in_module_unadjusted ( prelude, ident, ns,
1950
1954
false , false , path_span) {
@@ -3505,6 +3509,8 @@ impl<'a> Resolver<'a> {
3505
3509
let maybe_assoc = opt_ns != Some ( MacroNS ) && PathSource :: Type . is_expected ( def) ;
3506
3510
if let Some ( next_module) = binding. module ( ) {
3507
3511
module = Some ( next_module) ;
3512
+ } else if def == Def :: ToolMod && i + 1 != path. len ( ) {
3513
+ return PathResult :: NonModule ( PathResolution :: new ( Def :: NonMacroAttr ) )
3508
3514
} else if def == Def :: Err {
3509
3515
return PathResult :: NonModule ( err_path_resolution ( ) ) ;
3510
3516
} else if opt_ns. is_some ( ) && ( is_last || maybe_assoc) {
0 commit comments