Implement resolution, parse use<Self>
This commit is contained in:
parent
fc9e344874
commit
c897092654
2 changed files with 29 additions and 3 deletions
|
@ -694,7 +694,13 @@ impl<'a> Parser<'a> {
|
||||||
&TokenKind::Gt,
|
&TokenKind::Gt,
|
||||||
SeqSep::trailing_allowed(token::Comma),
|
SeqSep::trailing_allowed(token::Comma),
|
||||||
|self_| {
|
|self_| {
|
||||||
if self_.check_ident() {
|
if self_.check_keyword(kw::SelfUpper) {
|
||||||
|
self_.bump();
|
||||||
|
Ok(PreciseCapturingArg::Arg(
|
||||||
|
self_.prev_token.ident().unwrap().0,
|
||||||
|
DUMMY_NODE_ID,
|
||||||
|
))
|
||||||
|
} else if self_.check_ident() {
|
||||||
Ok(PreciseCapturingArg::Arg(self_.parse_ident().unwrap(), DUMMY_NODE_ID))
|
Ok(PreciseCapturingArg::Arg(self_.parse_ident().unwrap(), DUMMY_NODE_ID))
|
||||||
} else if self_.check_lifetime() {
|
} else if self_.check_lifetime() {
|
||||||
Ok(PreciseCapturingArg::Lifetime(self_.expect_lifetime()))
|
Ok(PreciseCapturingArg::Lifetime(self_.expect_lifetime()))
|
||||||
|
|
|
@ -1055,8 +1055,28 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
|
||||||
fn visit_precise_capturing_arg(&mut self, arg: &'ast PreciseCapturingArg) {
|
fn visit_precise_capturing_arg(&mut self, arg: &'ast PreciseCapturingArg) {
|
||||||
match arg {
|
match arg {
|
||||||
PreciseCapturingArg::Lifetime(_) => visit::walk_precise_capturing_arg(self, arg),
|
PreciseCapturingArg::Lifetime(_) => visit::walk_precise_capturing_arg(self, arg),
|
||||||
PreciseCapturingArg::Arg(ident, _) => {
|
PreciseCapturingArg::Arg(ident, node_id) => {
|
||||||
todo!("cannot resolve args yet: {ident}");
|
let ident = ident.normalize_to_macros_2_0();
|
||||||
|
'found: {
|
||||||
|
for (rib_t, rib_v) in
|
||||||
|
std::iter::zip(&self.ribs.type_ns, &self.ribs.value_ns).rev()
|
||||||
|
{
|
||||||
|
if let Some(res) = rib_t.bindings.get(&ident).or(rib_v.bindings.get(&ident))
|
||||||
|
{
|
||||||
|
self.r.record_partial_res(*node_id, PartialRes::new(*res));
|
||||||
|
break 'found;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.report_error(
|
||||||
|
ident.span,
|
||||||
|
ResolutionError::FailedToResolve {
|
||||||
|
segment: Some(ident.name),
|
||||||
|
label: "could not find type or const parameter".to_string(),
|
||||||
|
suggestion: None,
|
||||||
|
module: None,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue