Skip to content

Commit 01e137c

Browse files
committed
Revert to 57a71ac
1 parent 7907345 commit 01e137c

File tree

391 files changed

+6451
-8988
lines changed

Some content is hidden

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

391 files changed

+6451
-8988
lines changed

.github/ISSUE_TEMPLATE/tracking_issue.md

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ title: Tracking Issue for XXX
55
labels: C-tracking-issue
66
---
77
<!--
8-
NOTE: For library features, please use the "Library Tracking Issue" template instead.
9-
108
Thank you for creating a tracking issue! 📜 Tracking issues are for tracking a
119
feature from implementation to stabilisation. Make sure to include the relevant
1210
RFC for the feature if it has one. Otherwise provide a short summary of the

Cargo.lock

+2-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ dependencies = [
427427
"remove_dir_all",
428428
"serde_json",
429429
"tar",
430-
"toml",
431430
"url 2.1.1",
432431
]
433432

@@ -3551,6 +3550,7 @@ version = "0.0.0"
35513550
dependencies = [
35523551
"rustc_ast",
35533552
"rustc_span",
3553+
"rustc_target",
35543554
"tracing",
35553555
]
35563556

@@ -3568,6 +3568,7 @@ dependencies = [
35683568
"rustc_serialize",
35693569
"rustc_session",
35703570
"rustc_span",
3571+
"version_check",
35713572
]
35723573

35733574
[[package]]

compiler/rustc_ast/src/tokenstream.rs

+11
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,14 @@ where
127127
}
128128

129129
pub trait CreateTokenStream: sync::Send + sync::Sync {
130+
fn add_trailing_semi(&self) -> Box<dyn CreateTokenStream>;
130131
fn create_token_stream(&self) -> TokenStream;
131132
}
132133

133134
impl CreateTokenStream for TokenStream {
135+
fn add_trailing_semi(&self) -> Box<dyn CreateTokenStream> {
136+
panic!("Cannot call `add_trailing_semi` on a `TokenStream`!");
137+
}
134138
fn create_token_stream(&self) -> TokenStream {
135139
self.clone()
136140
}
@@ -147,6 +151,13 @@ impl LazyTokenStream {
147151
LazyTokenStream(Lrc::new(Box::new(inner)))
148152
}
149153

154+
/// Extends the captured stream by one token,
155+
/// which must be a trailing semicolon. This
156+
/// affects the `TokenStream` created by `make_tokenstream`.
157+
pub fn add_trailing_semi(&self) -> LazyTokenStream {
158+
LazyTokenStream(Lrc::new(self.0.add_trailing_semi()))
159+
}
160+
150161
pub fn create_token_stream(&self) -> TokenStream {
151162
self.0.create_token_stream()
152163
}

compiler/rustc_ast_lowering/src/expr.rs

+17-33
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_errors::struct_span_err;
1010
use rustc_hir as hir;
1111
use rustc_hir::def::Res;
1212
use rustc_session::parse::feature_err;
13+
use rustc_span::hygiene::ForLoopLoc;
1314
use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
1415
use rustc_span::symbol::{sym, Ident, Symbol};
15-
use rustc_span::{hygiene::ForLoopLoc, DUMMY_SP};
1616
use rustc_target::asm;
1717
use std::collections::hash_map::Entry;
1818
use std::fmt::Write;
@@ -102,7 +102,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
102102
this.lower_block(body, false),
103103
opt_label,
104104
hir::LoopSource::Loop,
105-
DUMMY_SP,
106105
)
107106
}),
108107
ExprKind::TryBlock(ref body) => self.lower_expr_try_block(body),
@@ -454,12 +453,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
454453
self.expr_match(span, scrutinee, arena_vec![self; then_arm, else_arm], desugar);
455454

456455
// `[opt_ident]: loop { ... }`
457-
hir::ExprKind::Loop(
458-
self.block_expr(self.arena.alloc(match_expr)),
459-
opt_label,
460-
source,
461-
span.with_hi(cond.span.hi()),
462-
)
456+
hir::ExprKind::Loop(self.block_expr(self.arena.alloc(match_expr)), opt_label, source)
463457
}
464458

465459
/// Desugar `try { <stmts>; <expr> }` into `{ <stmts>; ::std::ops::Try::from_ok(<expr>) }`,
@@ -754,7 +748,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
754748
// loop { .. }
755749
let loop_expr = self.arena.alloc(hir::Expr {
756750
hir_id: loop_hir_id,
757-
kind: hir::ExprKind::Loop(loop_block, None, hir::LoopSource::Loop, span),
751+
kind: hir::ExprKind::Loop(loop_block, None, hir::LoopSource::Loop),
758752
span,
759753
attrs: ThinVec::new(),
760754
});
@@ -776,7 +770,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
776770
body: &Expr,
777771
fn_decl_span: Span,
778772
) -> hir::ExprKind<'hir> {
779-
let (body_id, generator_option) = self.with_new_scopes(move |this| {
773+
// Lower outside new scope to preserve `is_in_loop_condition`.
774+
let fn_decl = self.lower_fn_decl(decl, None, false, None);
775+
776+
self.with_new_scopes(move |this| {
780777
let prev = this.current_item;
781778
this.current_item = Some(fn_decl_span);
782779
let mut generator_kind = None;
@@ -788,13 +785,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
788785
let generator_option =
789786
this.generator_movability_for_fn(&decl, fn_decl_span, generator_kind, movability);
790787
this.current_item = prev;
791-
(body_id, generator_option)
792-
});
793-
794-
// Lower outside new scope to preserve `is_in_loop_condition`.
795-
let fn_decl = self.lower_fn_decl(decl, None, false, None);
796-
797-
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
788+
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
789+
})
798790
}
799791

800792
fn generator_movability_for_fn(
@@ -840,8 +832,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
840832
) -> hir::ExprKind<'hir> {
841833
let outer_decl =
842834
FnDecl { inputs: decl.inputs.clone(), output: FnRetTy::Default(fn_decl_span) };
835+
// We need to lower the declaration outside the new scope, because we
836+
// have to conserve the state of being inside a loop condition for the
837+
// closure argument types.
838+
let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None);
843839

844-
let body_id = self.with_new_scopes(|this| {
840+
self.with_new_scopes(move |this| {
845841
// FIXME(cramertj): allow `async` non-`move` closures with arguments.
846842
if capture_clause == CaptureBy::Ref && !decl.inputs.is_empty() {
847843
struct_span_err!(
@@ -872,15 +868,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
872868
);
873869
this.expr(fn_decl_span, async_body, ThinVec::new())
874870
});
875-
body_id
876-
});
877-
878-
// We need to lower the declaration outside the new scope, because we
879-
// have to conserve the state of being inside a loop condition for the
880-
// closure argument types.
881-
let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None);
882-
883-
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
871+
hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
872+
})
884873
}
885874

886875
/// Destructure the LHS of complex assignments.
@@ -1720,12 +1709,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
17201709
);
17211710

17221711
// `[opt_ident]: loop { ... }`
1723-
let kind = hir::ExprKind::Loop(
1724-
loop_block,
1725-
opt_label,
1726-
hir::LoopSource::ForLoop,
1727-
e.span.with_hi(orig_head_span.hi()),
1728-
);
1712+
let kind = hir::ExprKind::Loop(loop_block, opt_label, hir::LoopSource::ForLoop);
17291713
let loop_expr = self.arena.alloc(hir::Expr {
17301714
hir_id: self.lower_node_id(e.id),
17311715
kind,

compiler/rustc_ast_pretty/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ doctest = false
1111
tracing = "0.1"
1212
rustc_span = { path = "../rustc_span" }
1313
rustc_ast = { path = "../rustc_ast" }
14+
rustc_target = { path = "../rustc_target" }

compiler/rustc_attr/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ rustc_lexer = { path = "../rustc_lexer" }
1818
rustc_macros = { path = "../rustc_macros" }
1919
rustc_session = { path = "../rustc_session" }
2020
rustc_ast = { path = "../rustc_ast" }
21+
version_check = "0.9"

compiler/rustc_attr/src/builtin.rs

+7-31
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use rustc_session::Session;
1010
use rustc_span::hygiene::Transparency;
1111
use rustc_span::{symbol::sym, symbol::Symbol, Span};
1212
use std::num::NonZeroU32;
13+
use version_check::Version;
1314

1415
pub fn is_builtin_attr(attr: &Attribute) -> bool {
1516
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
@@ -66,21 +67,21 @@ fn handle_errors(sess: &ParseSess, span: Span, error: AttrError) {
6667
}
6768
}
6869

69-
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug)]
70+
#[derive(Copy, Clone, PartialEq, Encodable, Decodable)]
7071
pub enum InlineAttr {
7172
None,
7273
Hint,
7374
Always,
7475
Never,
7576
}
7677

77-
#[derive(Clone, Encodable, Decodable, Debug)]
78+
#[derive(Clone, Encodable, Decodable)]
7879
pub enum InstructionSetAttr {
7980
ArmA32,
8081
ArmT32,
8182
}
8283

83-
#[derive(Clone, Encodable, Decodable, Debug)]
84+
#[derive(Clone, Encodable, Decodable)]
8485
pub enum OptimizeAttr {
8586
None,
8687
Speed,
@@ -525,26 +526,6 @@ fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &F
525526
}
526527
}
527528

528-
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
529-
struct Version {
530-
major: u16,
531-
minor: u16,
532-
patch: u16,
533-
}
534-
535-
fn parse_version(s: &str, allow_appendix: bool) -> Option<Version> {
536-
let mut components = s.split('-');
537-
let d = components.next()?;
538-
if !allow_appendix && components.next().is_some() {
539-
return None;
540-
}
541-
let mut digits = d.splitn(3, '.');
542-
let major = digits.next()?.parse().ok()?;
543-
let minor = digits.next()?.parse().ok()?;
544-
let patch = digits.next().unwrap_or("0").parse().ok()?;
545-
Some(Version { major, minor, patch })
546-
}
547-
548529
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
549530
/// evaluate individual items.
550531
pub fn eval_condition(
@@ -574,21 +555,16 @@ pub fn eval_condition(
574555
return false;
575556
}
576557
};
577-
let min_version = match parse_version(&min_version.as_str(), false) {
558+
let min_version = match Version::parse(&min_version.as_str()) {
578559
Some(ver) => ver,
579560
None => {
580-
sess.span_diagnostic
581-
.struct_span_warn(
582-
*span,
583-
"unknown version literal format, assuming it refers to a future version",
584-
)
585-
.emit();
561+
sess.span_diagnostic.struct_span_err(*span, "invalid version literal").emit();
586562
return false;
587563
}
588564
};
589565
let channel = env!("CFG_RELEASE_CHANNEL");
590566
let nightly = channel == "nightly" || channel == "dev";
591-
let rustc_version = parse_version(env!("CFG_RELEASE"), true).unwrap();
567+
let rustc_version = Version::parse(env!("CFG_RELEASE")).unwrap();
592568

593569
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-625474439 for details
594570
if nightly { rustc_version > min_version } else { rustc_version >= min_version }

compiler/rustc_builtin_macros/src/assert.rs

+5-21
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,27 @@ use rustc_span::{Span, DUMMY_SP};
1212

1313
pub fn expand_assert<'cx>(
1414
cx: &'cx mut ExtCtxt<'_>,
15-
span: Span,
15+
sp: Span,
1616
tts: TokenStream,
1717
) -> Box<dyn MacResult + 'cx> {
18-
let Assert { cond_expr, custom_message } = match parse_assert(cx, span, tts) {
18+
let Assert { cond_expr, custom_message } = match parse_assert(cx, sp, tts) {
1919
Ok(assert) => assert,
2020
Err(mut err) => {
2121
err.emit();
22-
return DummyResult::any(span);
22+
return DummyResult::any(sp);
2323
}
2424
};
2525

2626
// `core::panic` and `std::panic` are different macros, so we use call-site
2727
// context to pick up whichever is currently in scope.
28-
let sp = cx.with_call_site_ctxt(span);
28+
let sp = cx.with_call_site_ctxt(sp);
2929

3030
let panic_call = if let Some(tokens) = custom_message {
31-
let path = if span.rust_2021() {
32-
// On edition 2021, we always call `$crate::panic!()`.
33-
Path {
34-
span: sp,
35-
segments: cx
36-
.std_path(&[sym::panic])
37-
.into_iter()
38-
.map(|ident| PathSegment::from_ident(ident))
39-
.collect(),
40-
tokens: None,
41-
}
42-
} else {
43-
// Before edition 2021, we call `panic!()` unqualified,
44-
// such that it calls either `std::panic!()` or `core::panic!()`.
45-
Path::from_ident(Ident::new(sym::panic, sp))
46-
};
4731
// Pass the custom message to panic!().
4832
cx.expr(
4933
sp,
5034
ExprKind::MacCall(MacCall {
51-
path,
35+
path: Path::from_ident(Ident::new(sym::panic, sp)),
5236
args: P(MacArgs::Delimited(
5337
DelimSpan::from_single(sp),
5438
MacDelimiter::Parenthesis,

compiler/rustc_builtin_macros/src/source_util.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ use rustc_ast::tokenstream::TokenStream;
55
use rustc_ast_pretty::pprust;
66
use rustc_expand::base::{self, *};
77
use rustc_expand::module::DirectoryOwnership;
8-
use rustc_parse::parser::{ForceCollect, Parser};
9-
use rustc_parse::{self, new_parser_from_file};
8+
use rustc_parse::{self, new_parser_from_file, parser::Parser};
109
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
1110
use rustc_span::symbol::Symbol;
1211
use rustc_span::{self, Pos, Span};
@@ -140,7 +139,7 @@ pub fn expand_include<'cx>(
140139
fn make_items(mut self: Box<ExpandResult<'a>>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
141140
let mut ret = SmallVec::new();
142141
while self.p.token != token::Eof {
143-
match self.p.parse_item(ForceCollect::No) {
142+
match self.p.parse_item() {
144143
Err(mut err) => {
145144
err.emit();
146145
break;

0 commit comments

Comments
 (0)