Express contracts as part of function header and lower it to the contract lang items
includes post-developed commit: do not suggest internal-only keywords as corrections to parse failures. includes post-developed commit: removed tabs that creeped in into rustfmt tool source code. includes post-developed commit, placating rustfmt self dogfooding. includes post-developed commit: add backquotes to prevent markdown checking from trying to treat an attr as a markdown hyperlink/ includes post-developed commit: fix lowering to keep contracts from being erroneously inherited by nested bodies (like closures). Rebase Conflicts: - compiler/rustc_parse/src/parser/diagnostics.rs - compiler/rustc_parse/src/parser/item.rs - compiler/rustc_span/src/hygiene.rs Remove contracts keywords from diagnostic messages
This commit is contained in:
parent
777def87d5
commit
38eff16d0a
27 changed files with 405 additions and 17 deletions
|
@ -174,10 +174,13 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
|
|||
_ctxt,
|
||||
_ident,
|
||||
_vis,
|
||||
Fn { sig: FnSig { header, decl, span: _ }, generics, body, .. },
|
||||
Fn { sig: FnSig { header, decl, span: _ }, generics, contract, body, .. },
|
||||
) if let Some(coroutine_kind) = header.coroutine_kind => {
|
||||
self.visit_fn_header(header);
|
||||
self.visit_generics(generics);
|
||||
if let Some(contract) = contract {
|
||||
self.visit_contract(contract);
|
||||
}
|
||||
|
||||
// For async functions, we need to create their inner defs inside of a
|
||||
// closure to match their desugared representation. Besides that,
|
||||
|
|
|
@ -1019,7 +1019,7 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
|
|||
// Create a label rib for the function.
|
||||
this.with_label_rib(RibKind::FnOrCoroutine, |this| {
|
||||
match fn_kind {
|
||||
FnKind::Fn(_, _, _, Fn { sig, generics, body, .. }) => {
|
||||
FnKind::Fn(_, _, _, Fn { sig, generics, contract, body, .. }) => {
|
||||
this.visit_generics(generics);
|
||||
|
||||
let declaration = &sig.decl;
|
||||
|
@ -1046,6 +1046,10 @@ impl<'ra: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'_, 'ast, 'r
|
|||
},
|
||||
);
|
||||
|
||||
if let Some(contract) = contract {
|
||||
this.visit_contract(contract);
|
||||
}
|
||||
|
||||
if let Some(body) = body {
|
||||
// Ignore errors in function bodies if this is rustdoc
|
||||
// Be sure not to set this until the function signature has been resolved.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue