Permit asm_const and asm_sym to reference outer generic params
This commit is contained in:
parent
d93b03793d
commit
b1c6c0648e
6 changed files with 60 additions and 47 deletions
|
@ -1171,6 +1171,7 @@ impl<'a> Resolver<'a> {
|
|||
| AssocItemRibKind
|
||||
| ModuleRibKind(..)
|
||||
| MacroDefinition(..)
|
||||
| InlineAsmSymRibKind
|
||||
| ForwardGenericParamBanRibKind => {
|
||||
// Nothing to do. Continue.
|
||||
continue;
|
||||
|
@ -1216,22 +1217,6 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
return Res::Err;
|
||||
}
|
||||
InlineAsmSymRibKind => {
|
||||
let features = self.session.features_untracked();
|
||||
if !features.generic_const_exprs {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInNonTrivialAnonConst {
|
||||
name: rib_ident.name,
|
||||
is_type: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(span) = finalize {
|
||||
|
@ -1262,6 +1247,7 @@ impl<'a> Resolver<'a> {
|
|||
| AssocItemRibKind
|
||||
| ModuleRibKind(..)
|
||||
| MacroDefinition(..)
|
||||
| InlineAsmSymRibKind
|
||||
| ForwardGenericParamBanRibKind => continue,
|
||||
|
||||
ConstantItemRibKind(trivial, _) => {
|
||||
|
@ -1296,22 +1282,6 @@ impl<'a> Resolver<'a> {
|
|||
}
|
||||
return Res::Err;
|
||||
}
|
||||
InlineAsmSymRibKind => {
|
||||
let features = self.session.features_untracked();
|
||||
if !features.generic_const_exprs {
|
||||
if let Some(span) = finalize {
|
||||
self.report_error(
|
||||
span,
|
||||
ResolutionError::ParamInNonTrivialAnonConst {
|
||||
name: rib_ident.name,
|
||||
is_type: false,
|
||||
},
|
||||
);
|
||||
}
|
||||
return Res::Err;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
// This was an attempt to use a const parameter outside its scope.
|
||||
|
|
|
@ -918,6 +918,29 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> {
|
|||
self.diagnostic_metadata.current_where_predicate = previous_value;
|
||||
}
|
||||
|
||||
fn visit_inline_asm(&mut self, asm: &'ast InlineAsm) {
|
||||
for (op, _) in &asm.operands {
|
||||
match op {
|
||||
InlineAsmOperand::In { expr, .. }
|
||||
| InlineAsmOperand::Out { expr: Some(expr), .. }
|
||||
| InlineAsmOperand::InOut { expr, .. } => self.visit_expr(expr),
|
||||
InlineAsmOperand::Out { expr: None, .. } => {}
|
||||
InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
|
||||
self.visit_expr(in_expr);
|
||||
if let Some(out_expr) = out_expr {
|
||||
self.visit_expr(out_expr);
|
||||
}
|
||||
}
|
||||
InlineAsmOperand::Const { anon_const, .. } => {
|
||||
// Although this is `DefKind::AnonConst`, it is allowed to reference outer
|
||||
// generic parameters like an inline const.
|
||||
self.resolve_inline_const(anon_const);
|
||||
}
|
||||
InlineAsmOperand::Sym { sym } => self.visit_inline_asm_sym(sym),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_inline_asm_sym(&mut self, sym: &'ast InlineAsmSym) {
|
||||
// This is similar to the code for AnonConst.
|
||||
self.with_rib(ValueNS, InlineAsmSymRibKind, |this| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue