Skip to content

Commit 846cc63

Browse files
Make it clearer that edition functions are >=, not ==
1 parent 77e24f9 commit 846cc63

File tree

16 files changed

+46
-42
lines changed

16 files changed

+46
-42
lines changed

compiler/rustc_expand/src/mbe/macro_rules.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,7 @@ fn check_matcher_core<'tt>(
12001200
err.span_label(sp, format!("not allowed after `{}` fragments", kind));
12011201

12021202
if kind == NonterminalKind::PatWithOr
1203-
&& sess.edition.rust_2021()
1203+
&& sess.edition.at_least_rust_2021()
12041204
&& next_token.is_token(&BinOp(token::BinOpToken::Or))
12051205
{
12061206
let suggestion = quoted_tt_to_string(&TokenTree::MetaVarDecl(

compiler/rustc_hir_analysis/src/astconv/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
8686
));
8787
}
8888

89-
if self_ty.span.edition().rust_2021() {
89+
if self_ty.span.edition().at_least_rust_2021() {
9090
let msg = "trait objects must include the `dyn` keyword";
9191
let label = "add `dyn` keyword before this trait";
9292
let mut diag =

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
860860
.resolve_fully_qualified_call(span, item_name, ty.normalized, qself.span, hir_id)
861861
.and_then(|r| {
862862
// lint bare trait if the method is found in the trait
863-
if span.edition().rust_2021() && let Some(mut diag) = self.tcx.sess.diagnostic().steal_diagnostic(qself.span, StashKey::TraitMissingMethod) {
863+
if span.edition().at_least_rust_2021() && let Some(mut diag) = self.tcx.sess.diagnostic().steal_diagnostic(qself.span, StashKey::TraitMissingMethod) {
864864
diag.emit();
865865
}
866866
Ok(r)
@@ -890,7 +890,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
890890
}
891891

892892
// emit or cancel the diagnostic for bare traits
893-
if span.edition().rust_2021() && let Some(mut diag) = self.tcx.sess.diagnostic().steal_diagnostic(qself.span, StashKey::TraitMissingMethod) {
893+
if span.edition().at_least_rust_2021() && let Some(mut diag) = self.tcx.sess.diagnostic().steal_diagnostic(qself.span, StashKey::TraitMissingMethod) {
894894
if trait_missing_method {
895895
// cancel the diag for bare traits when meeting `MyTrait::missing_method`
896896
diag.cancel();
@@ -908,7 +908,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
908908
error,
909909
None,
910910
Expectation::NoExpectation,
911-
trait_missing_method && span.edition().rust_2021(), // emits missing method for trait only after edition 2021
911+
trait_missing_method && span.edition().at_least_rust_2021(), // emits missing method for trait only after edition 2021
912912
) {
913913
e.emit();
914914
}

compiler/rustc_hir_typeck/src/method/prelude2021.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3232
);
3333

3434
// Rust 2021 and later is already using the new prelude
35-
if span.rust_2021() {
35+
if span.at_least_rust_2021() {
3636
return;
3737
}
3838

@@ -203,7 +203,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
203203
pick: &Pick<'tcx>,
204204
) {
205205
// Rust 2021 and later is already using the new prelude
206-
if span.rust_2021() {
206+
if span.at_least_rust_2021() {
207207
return;
208208
}
209209

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
437437
// this case used to be allowed by the compiler,
438438
// so we do a future-compat lint here for the 2015 edition
439439
// (see https://github.com/rust-lang/rust/issues/46906)
440-
if self.tcx.sess.rust_2018() {
440+
if self.tcx.sess.at_least_rust_2018() {
441441
self.tcx.sess.emit_err(MethodCallOnUnknownRawPointee { span });
442442
} else {
443443
self.tcx.struct_span_lint_hir(
@@ -1592,7 +1592,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
15921592
if let Some(method_name) = self.method_name {
15931593
// Some trait methods are excluded for arrays before 2021.
15941594
// (`array.into_iter()` wants a slice iterator for compatibility.)
1595-
if self_ty.is_array() && !method_name.span.rust_2021() {
1595+
if self_ty.is_array() && !method_name.span.at_least_rust_2021() {
15961596
let trait_def = self.tcx.trait_def(trait_ref.def_id);
15971597
if trait_def.skip_array_during_method_dispatch {
15981598
return ProbeResult::NoMatch;

compiler/rustc_hir_typeck/src/upvar.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,7 +2001,7 @@ fn should_do_rust_2021_incompatible_closure_captures_analysis(
20012001
tcx: TyCtxt<'_>,
20022002
closure_id: hir::HirId,
20032003
) -> bool {
2004-
if tcx.sess.rust_2021() {
2004+
if tcx.sess.at_least_rust_2021() {
20052005
return false;
20062006
}
20072007

@@ -2247,5 +2247,5 @@ fn truncate_capture_for_optimization(
22472247
fn enable_precise_capture(span: Span) -> bool {
22482248
// We use span here to ensure that if the closure was generated by a macro with a different
22492249
// edition.
2250-
span.rust_2021()
2250+
span.at_least_rust_2021()
22512251
}

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1932,7 +1932,7 @@ impl<'tcx> Printer<'tcx> for FmtPrinter<'_, 'tcx> {
19321932
fn path_crate(mut self, cnum: CrateNum) -> Result<Self::Path, Self::Error> {
19331933
self.empty_path = true;
19341934
if cnum == LOCAL_CRATE {
1935-
if self.tcx.sess.rust_2018() {
1935+
if self.tcx.sess.at_least_rust_2018() {
19361936
// We add the `crate::` keyword on Rust 2018, only when desired.
19371937
if SHOULD_PREFIX_WITH_CRATE.with(|flag| flag.get()) {
19381938
write!(self, "{}", kw::Crate)?;

compiler/rustc_mir_build/src/build/expr/as_place.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,5 +730,5 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
730730

731731
/// Precise capture is enabled if user is using Rust Edition 2021 or higher.
732732
fn enable_precise_capture(closure_span: Span) -> bool {
733-
closure_span.rust_2021()
733+
closure_span.at_least_rust_2021()
734734
}

compiler/rustc_parse/src/parser/expr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ impl<'a> Parser<'a> {
13091309

13101310
/// Assuming we have just parsed `.`, continue parsing into an expression.
13111311
fn parse_dot_suffix(&mut self, self_arg: P<Expr>, lo: Span) -> PResult<'a, P<Expr>> {
1312-
if self.token.uninterpolated_span().rust_2018() && self.eat_keyword(kw::Await) {
1312+
if self.token.uninterpolated_span().at_least_rust_2018() && self.eat_keyword(kw::Await) {
13131313
return Ok(self.mk_await_expr(self_arg, lo));
13141314
}
13151315

@@ -1442,8 +1442,8 @@ impl<'a> Parser<'a> {
14421442
self.parse_expr_let()
14431443
} else if self.eat_keyword(kw::Underscore) {
14441444
Ok(self.mk_expr(self.prev_token.span, ExprKind::Underscore))
1445-
} else if self.token.uninterpolated_span().rust_2018() {
1446-
// `Span::rust_2018()` is somewhat expensive; don't get it repeatedly.
1445+
} else if self.token.uninterpolated_span().at_least_rust_2018() {
1446+
// `Span:.at_least_rust_2018()` is somewhat expensive; don't get it repeatedly.
14471447
if self.check_keyword(kw::Async) {
14481448
if self.is_async_block() {
14491449
// Check for `async {` and `async move {`.
@@ -2230,7 +2230,7 @@ impl<'a> Parser<'a> {
22302230
let movability =
22312231
if self.eat_keyword(kw::Static) { Movability::Static } else { Movability::Movable };
22322232

2233-
let asyncness = if self.token.uninterpolated_span().rust_2018() {
2233+
let asyncness = if self.token.uninterpolated_span().at_least_rust_2018() {
22342234
self.parse_asyncness(Case::Sensitive)
22352235
} else {
22362236
Async::No
@@ -3014,7 +3014,7 @@ impl<'a> Parser<'a> {
30143014
fn is_try_block(&self) -> bool {
30153015
self.token.is_keyword(kw::Try)
30163016
&& self.look_ahead(1, |t| *t == token::OpenDelim(Delimiter::Brace))
3017-
&& self.token.uninterpolated_span().rust_2018()
3017+
&& self.token.uninterpolated_span().at_least_rust_2018()
30183018
}
30193019

30203020
/// Parses an `async move? {...}` expression.

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ impl<'a> Parser<'a> {
608608
/// Is a `dyn B0 + ... + Bn` type allowed here?
609609
fn is_explicit_dyn_type(&mut self) -> bool {
610610
self.check_keyword(kw::Dyn)
611-
&& (self.token.uninterpolated_span().rust_2018()
611+
&& (self.token.uninterpolated_span().at_least_rust_2018()
612612
|| self.look_ahead(1, |t| {
613613
(t.can_begin_bound() || t.kind == TokenKind::BinOp(token::Star))
614614
&& !can_continue_type_after_non_fn_ident(t)

0 commit comments

Comments
 (0)