_: NodeId)
{
debug!("(resolving function) entering function");
- let (rib_kind, asyncness) = match function_kind {
- FnKind::ItemFn(_, ref header, ..) =>
- (FnItemRibKind, &header.asyncness.node),
- FnKind::Method(_, ref sig, _, _) =>
- (AssocItemRibKind, &sig.header.asyncness.node),
- FnKind::Closure(_) =>
- // Async closures aren't resolved through `visit_fn`-- they're
- // processed separately
- (NormalRibKind, &IsAsync::NotAsync),
+ let rib_kind = match function_kind {
+ FnKind::ItemFn(..) => FnItemRibKind,
+ FnKind::Method(..) => AssocItemRibKind,
+ FnKind::Closure(_) => NormalRibKind,
};
// Create a value rib for the function.
// Add each argument to the rib.
let mut bindings_list = FxHashMap::default();
- let mut add_argument = |argument: &ast::Arg| {
+ for argument in &declaration.inputs {
self.resolve_pattern(&argument.pat, PatternSource::FnParam, &mut bindings_list);
+
self.visit_ty(&argument.ty);
- debug!("(resolving function) recorded argument");
- };
- // Walk the generated async arguments if this is an `async fn`, otherwise walk the
- // normal arguments.
- if let IsAsync::Async { ref arguments, .. } = asyncness {
- for (i, a) in arguments.iter().enumerate() {
- if let Some(arg) = &a.arg {
- add_argument(&arg);
- } else {
- add_argument(&declaration.inputs[i]);
- }
- }
- } else {
- for a in &declaration.inputs { add_argument(a); }
+ debug!("(resolving function) recorded argument");
}
-
visit::walk_fn_ret_ty(self, &declaration.output);
// Resolve the function body, potentially inside the body of an async closure
match function_kind {
- FnKind::ItemFn(.., body) | FnKind::Method(.., body) => {
- if let IsAsync::Async { ref arguments, .. } = asyncness {
- let mut body = body.clone();
- // Insert the generated statements into the body before attempting to
- // resolve names.
- for a in arguments.iter().rev() {
- if let Some(pat_stmt) = a.pat_stmt.clone() {
- body.stmts.insert(0, pat_stmt);
- }
- body.stmts.insert(0, a.move_stmt.clone());
- }
- self.visit_block(&body);
- } else {
- self.visit_block(body);
- }
+ FnKind::ItemFn(.., body) |
+ FnKind::Method(.., body) => {
+ self.visit_block(body);
}
FnKind::Closure(body) => {
self.visit_expr(body);
let orig_current_module = self.current_module;
match module {
ModuleOrUniformRoot::Module(module) => {
- ident.span = ident.span.modern();
- if let Some(def) = ident.span.adjust(module.expansion) {
+ if let Some(def) = ident.span.modernize_and_adjust(module.expansion) {
self.current_module = self.macro_def_scope(def);
}
}
ModuleOrUniformRoot::ExternPrelude => {
- ident.span = ident.span.modern();
- ident.span.adjust(Mark::root());
+ ident.span.modernize_and_adjust(Mark::root());
}
ModuleOrUniformRoot::CrateRootAndExternPrelude |
ModuleOrUniformRoot::CurrentScope => {
let add_module_candidates = |module: Module<'_>, names: &mut Vec<TypoSuggestion>| {
for (&(ident, _), resolution) in module.resolutions.borrow().iter() {
if let Some(binding) = resolution.borrow().binding {
- if !ident.is_gensymed() && filter_fn(binding.res()) {
+ if filter_fn(binding.res()) {
names.push(TypoSuggestion {
candidate: ident.name,
article: binding.res().article(),
for rib in self.ribs[ns].iter().rev() {
// Locals and type parameters
for (ident, &res) in &rib.bindings {
- if !ident.is_gensymed() && filter_fn(res) {
+ if filter_fn(res) {
names.push(TypoSuggestion {
candidate: ident.name,
article: res.article(),
},
);
- if !ident.is_gensymed() && filter_fn(crate_mod) {
+ if filter_fn(crate_mod) {
Some(TypoSuggestion {
candidate: ident.name,
article: "a",
// Add primitive types to the mix
if filter_fn(Res::PrimTy(Bool)) {
names.extend(
- self.primitive_type_table.primitive_types
- .iter()
- .map(|(name, _)| {
- TypoSuggestion {
- candidate: *name,
- article: "a",
- kind: "primitive type",
- }
- })
+ self.primitive_type_table.primitive_types.iter().map(|(name, _)| {
+ TypoSuggestion {
+ candidate: *name,
+ article: "a",
+ kind: "primitive type",
+ }
+ })
)
}
} else {
let mut ident = ident;
if ident.span.glob_adjust(
module.expansion,
- binding.span.ctxt().modern(),
+ binding.span,
).is_none() {
continue
}