Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit be493fe

Browse files
committedFeb 13, 2020
Auto merge of #69023 - Centril:parse_fn, r=petrochenkov
parse: unify function front matter parsing Part of #68728. - `const extern fn` feature gating is now done post-expansion such that we do not have conditional compatibilities of function qualifiers *in parsing*. - The `FnFrontMatter` grammar becomes: ```rust Extern = "extern" StringLit ; FnQual = "const"? "async"? "unsafe"? Extern? ; FnFrontMatter = FnQual "fn" ; ``` That is, all item contexts now *syntactically* allow `const async unsafe extern "C" fn` and use semantic restrictions to rule out combinations previously prevented syntactically. The semantic restrictions include in particular: - `fn`s in `extern { ... }` can have no qualifiers. - `const` and `async` cannot be combined. - We change `ast::{Unsafety, Spanned<Constness>}>` into `enum ast::{Unsafe, Const} { Yes(Span), No }` respectively. This change in formulation allow us to exclude `Span` in the case of `No`, which facilitates parsing. Moreover, we also add a `Span` to `IsAsync` which is renamed to `Async`. The new `Span`s in `Unsafety` and `Async` are then taken advantage of for better diagnostics. A reason this change was made is to have a more uniform and clear naming scheme. The HIR keeps the structures in AST (with those definitions moved into HIR) for now to avoid regressing perf. r? @petrochenkov
2 parents 2e6eace + 9828559 commit be493fe

File tree

94 files changed

+737
-694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+737
-694
lines changed
 

‎src/librustc/traits/auto_trait.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use crate::ty::fold::TypeFolder;
99
use crate::ty::{Region, RegionVid};
1010

1111
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
12-
use syntax::ast;
1312

1413
use std::collections::hash_map::Entry;
1514
use std::collections::VecDeque;
@@ -350,7 +349,7 @@ impl AutoTraitFinder<'tcx> {
350349
already_visited.remove(&pred);
351350
self.add_user_pred(
352351
&mut user_computed_preds,
353-
ty::Predicate::Trait(pred, ast::Constness::NotConst),
352+
ty::Predicate::Trait(pred, hir::Constness::NotConst),
354353
);
355354
predicates.push_back(pred);
356355
} else {

‎src/librustc/traits/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
695695
let unit_obligation = Obligation {
696696
predicate: ty::Predicate::Trait(
697697
predicate,
698-
ast::Constness::NotConst,
698+
hir::Constness::NotConst,
699699
),
700700
..obligation.clone()
701701
};

0 commit comments

Comments
 (0)
Please sign in to comment.