Skip to content

Commit 6212cc6

Browse files
committed
Auto merge of #3147 - rust-lang:rustup-2023-10-28, r=saethlin
Automatic Rustup
2 parents 5f3d81a + 293501b commit 6212cc6

File tree

573 files changed

+9701
-4600
lines changed

Some content is hidden

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

573 files changed

+9701
-4600
lines changed

Cargo.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4557,9 +4557,7 @@ dependencies = [
45574557
"rustc-demangle",
45584558
"rustc_data_structures",
45594559
"rustc_errors",
4560-
"rustc_fluent_macro",
45614560
"rustc_hir",
4562-
"rustc_macros",
45634561
"rustc_middle",
45644562
"rustc_session",
45654563
"rustc_span",
@@ -4694,6 +4692,7 @@ dependencies = [
46944692
"arrayvec",
46954693
"askama",
46964694
"expect-test",
4695+
"indexmap 2.0.0",
46974696
"itertools",
46984697
"minifier",
46994698
"once_cell",

compiler/rustc_arena/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#![feature(new_uninit)]
1919
#![feature(maybe_uninit_slice)]
2020
#![feature(decl_macro)]
21-
#![feature(pointer_byte_offsets)]
2221
#![feature(rustc_attrs)]
2322
#![cfg_attr(test, feature(test))]
2423
#![feature(strict_provenance)]

compiler/rustc_ast/src/ast.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,8 @@ pub enum RangeSyntax {
734734
}
735735

736736
/// All the different flavors of pattern that Rust recognizes.
737+
//
738+
// Adding a new variant? Please update `test_pat` in `tests/ui/macros/stringify.rs`.
737739
#[derive(Clone, Encodable, Decodable, Debug)]
738740
pub enum PatKind {
739741
/// Represents a wildcard pattern (`_`).
@@ -967,6 +969,7 @@ impl Stmt {
967969
}
968970
}
969971

972+
// Adding a new variant? Please update `test_stmt` in `tests/ui/macros/stringify.rs`.
970973
#[derive(Clone, Encodable, Decodable, Debug)]
971974
pub enum StmtKind {
972975
/// A local (let) binding.
@@ -1345,6 +1348,7 @@ pub struct StructExpr {
13451348
pub rest: StructRest,
13461349
}
13471350

1351+
// Adding a new variant? Please update `test_expr` in `tests/ui/macros/stringify.rs`.
13481352
#[derive(Clone, Encodable, Decodable, Debug)]
13491353
pub enum ExprKind {
13501354
/// An array (`[a, b, c, d]`)
@@ -2015,6 +2019,8 @@ pub struct BareFnTy {
20152019
}
20162020

20172021
/// The various kinds of type recognized by the compiler.
2022+
//
2023+
// Adding a new variant? Please update `test_ty` in `tests/ui/macros/stringify.rs`.
20182024
#[derive(Clone, Encodable, Decodable, Debug)]
20192025
pub enum TyKind {
20202026
/// A variable-length slice (`[T]`).
@@ -2880,6 +2886,7 @@ pub struct ConstItem {
28802886
pub expr: Option<P<Expr>>,
28812887
}
28822888

2889+
// Adding a new variant? Please update `test_item` in `tests/ui/macros/stringify.rs`.
28832890
#[derive(Clone, Encodable, Decodable, Debug)]
28842891
pub enum ItemKind {
28852892
/// An `extern crate` item, with the optional *original* crate name if the crate was renamed.

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
188188
e.id,
189189
None,
190190
e.span,
191-
hir::AsyncCoroutineKind::Block,
191+
hir::CoroutineSource::Block,
192192
|this| this.with_new_scopes(|this| this.lower_block_expr(block)),
193193
),
194194
ExprKind::Await(expr, await_kw_span) => self.lower_expr_await(*await_kw_span, expr),
@@ -598,7 +598,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
598598
closure_node_id: NodeId,
599599
ret_ty: Option<hir::FnRetTy<'hir>>,
600600
span: Span,
601-
async_gen_kind: hir::AsyncCoroutineKind,
601+
async_gen_kind: hir::CoroutineSource,
602602
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
603603
) -> hir::ExprKind<'hir> {
604604
let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
@@ -1005,7 +1005,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10051005
inner_closure_id,
10061006
async_ret_ty,
10071007
body.span,
1008-
hir::AsyncCoroutineKind::Closure,
1008+
hir::CoroutineSource::Closure,
10091009
|this| this.with_new_scopes(|this| this.lower_expr_mut(body)),
10101010
);
10111011
let hir_id = this.lower_node_id(inner_closure_id);

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12061206
closure_id,
12071207
None,
12081208
body.span,
1209-
hir::AsyncCoroutineKind::Fn,
1209+
hir::CoroutineSource::Fn,
12101210
|this| {
12111211
// Create a block from the user's function body:
12121212
let user_body = this.lower_block_expr(body);

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12171217
hir_id: this.lower_node_id(node_id),
12181218
body: this.lower_const_body(path_expr.span, Some(&path_expr)),
12191219
});
1220-
return GenericArg::Const(ConstArg { value: ct, span });
1220+
return GenericArg::Const(ConstArg {
1221+
value: ct,
1222+
span,
1223+
is_desugared_from_effects: false,
1224+
});
12211225
}
12221226
}
12231227
}
@@ -1228,6 +1232,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
12281232
ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg {
12291233
value: self.lower_anon_const(&ct),
12301234
span: self.lower_span(ct.value.span),
1235+
is_desugared_from_effects: false,
12311236
}),
12321237
}
12331238
}
@@ -2525,6 +2530,7 @@ impl<'hir> GenericArgsCtor<'hir> {
25252530
self.args.push(hir::GenericArg::Const(hir::ConstArg {
25262531
value: hir::AnonConst { def_id, hir_id, body },
25272532
span,
2533+
is_desugared_from_effects: true,
25282534
}))
25292535
}
25302536

compiler/rustc_attr/src/builtin.rs

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_session::parse::{feature_err, ParseSess};
1313
use rustc_session::Session;
1414
use rustc_span::hygiene::Transparency;
1515
use rustc_span::{symbol::sym, symbol::Symbol, Span};
16+
use std::fmt::{self, Display};
1617
use std::num::NonZeroU32;
1718

1819
use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
@@ -23,10 +24,7 @@ use crate::session_diagnostics::{self, IncorrectReprFormatGenericCause};
2324
/// For more, see [this pull request](https://github.com/rust-lang/rust/pull/100591).
2425
pub const VERSION_PLACEHOLDER: &str = "CURRENT_RUSTC_VERSION";
2526

26-
pub fn rust_version_symbol() -> Symbol {
27-
let version = option_env!("CFG_RELEASE").unwrap_or("<current>");
28-
Symbol::intern(&version)
29-
}
27+
pub const CURRENT_RUSTC_VERSION: &str = env!("CFG_RELEASE");
3028

3129
pub fn is_builtin_attr(attr: &Attribute) -> bool {
3230
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
@@ -144,13 +142,24 @@ pub enum StabilityLevel {
144142
/// `#[stable]`
145143
Stable {
146144
/// Rust release which stabilized this feature.
147-
since: Symbol,
145+
since: Since,
148146
/// Is this item allowed to be referred to on stable, despite being contained in unstable
149147
/// modules?
150148
allowed_through_unstable_modules: bool,
151149
},
152150
}
153151

152+
/// Rust release in which a feature is stabilized.
153+
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
154+
#[derive(HashStable_Generic)]
155+
pub enum Since {
156+
Version(Version),
157+
/// Stabilized in the upcoming version, whatever number that is.
158+
Current,
159+
/// Failed to parse a stabilization version.
160+
Err,
161+
}
162+
154163
impl StabilityLevel {
155164
pub fn is_unstable(&self) -> bool {
156165
matches!(self, StabilityLevel::Unstable { .. })
@@ -372,22 +381,24 @@ fn parse_stability(sess: &Session, attr: &Attribute) -> Option<(Symbol, Stabilit
372381

373382
let since = if let Some(since) = since {
374383
if since.as_str() == VERSION_PLACEHOLDER {
375-
Ok(rust_version_symbol())
376-
} else if parse_version(since.as_str(), false).is_some() {
377-
Ok(since)
384+
Since::Current
385+
} else if let Some(version) = parse_version(since.as_str(), false) {
386+
Since::Version(version)
378387
} else {
379-
Err(sess.emit_err(session_diagnostics::InvalidSince { span: attr.span }))
388+
sess.emit_err(session_diagnostics::InvalidSince { span: attr.span });
389+
Since::Err
380390
}
381391
} else {
382-
Err(sess.emit_err(session_diagnostics::MissingSince { span: attr.span }))
392+
sess.emit_err(session_diagnostics::MissingSince { span: attr.span });
393+
Since::Err
383394
};
384395

385-
match (feature, since) {
386-
(Ok(feature), Ok(since)) => {
396+
match feature {
397+
Ok(feature) => {
387398
let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false };
388399
Some((feature, level))
389400
}
390-
(Err(ErrorGuaranteed { .. }), _) | (_, Err(ErrorGuaranteed { .. })) => None,
401+
Err(ErrorGuaranteed { .. }) => None,
391402
}
392403
}
393404

@@ -556,11 +567,12 @@ fn gate_cfg(gated_cfg: &GatedCfg, cfg_span: Span, sess: &ParseSess, features: &F
556567
}
557568
}
558569

559-
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
560-
struct Version {
561-
major: u16,
562-
minor: u16,
563-
patch: u16,
570+
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
571+
#[derive(HashStable_Generic)]
572+
pub struct Version {
573+
pub major: u16,
574+
pub minor: u16,
575+
pub patch: u16,
564576
}
565577

566578
fn parse_version(s: &str, allow_appendix: bool) -> Option<Version> {
@@ -576,6 +588,12 @@ fn parse_version(s: &str, allow_appendix: bool) -> Option<Version> {
576588
Some(Version { major, minor, patch })
577589
}
578590

591+
impl Display for Version {
592+
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
593+
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
594+
}
595+
}
596+
579597
/// Evaluate a cfg-like condition (with `any` and `all`), using `eval` to
580598
/// evaluate individual items.
581599
pub fn eval_condition(
@@ -609,7 +627,7 @@ pub fn eval_condition(
609627
sess.emit_warning(session_diagnostics::UnknownVersionLiteral { span: *span });
610628
return false;
611629
};
612-
let rustc_version = parse_version(env!("CFG_RELEASE"), true).unwrap();
630+
let rustc_version = parse_version(CURRENT_RUSTC_VERSION, true).unwrap();
613631

614632
// See https://github.com/rust-lang/rust/issues/64796#issuecomment-640851454 for details
615633
if sess.assume_incomplete_release {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_errors::{
88
use rustc_hir as hir;
99
use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
11-
use rustc_hir::{AsyncCoroutineKind, CoroutineKind, LangItem};
11+
use rustc_hir::{CoroutineKind, CoroutineSource, LangItem};
1212
use rustc_infer::traits::ObligationCause;
1313
use rustc_middle::hir::nested_filter::OnlyBodies;
1414
use rustc_middle::mir::tcx::PlaceTy;
@@ -2506,8 +2506,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
25062506
let kind = match use_span.coroutine_kind() {
25072507
Some(coroutine_kind) => match coroutine_kind {
25082508
CoroutineKind::Async(async_kind) => match async_kind {
2509-
AsyncCoroutineKind::Block => "async block",
2510-
AsyncCoroutineKind::Closure => "async closure",
2509+
CoroutineSource::Block => "async block",
2510+
CoroutineSource::Closure => "async closure",
25112511
_ => bug!("async block/closure expected, but async function found."),
25122512
},
25132513
CoroutineKind::Coroutine => "coroutine",

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,9 +682,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
682682
};
683683
let mir_description = match hir.body(body).coroutine_kind {
684684
Some(hir::CoroutineKind::Async(gen)) => match gen {
685-
hir::AsyncCoroutineKind::Block => " of async block",
686-
hir::AsyncCoroutineKind::Closure => " of async closure",
687-
hir::AsyncCoroutineKind::Fn => {
685+
hir::CoroutineSource::Block => " of async block",
686+
hir::CoroutineSource::Closure => " of async closure",
687+
hir::CoroutineSource::Fn => {
688688
let parent_item =
689689
hir.get_by_def_id(hir.get_parent_item(mir_hir_id).def_id);
690690
let output = &parent_item

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
88
use rustc_middle::mir::ConstraintCategory;
99
use rustc_middle::traits::query::OutlivesBound;
1010
use rustc_middle::ty::{self, RegionVid, Ty};
11-
use rustc_span::{Span, DUMMY_SP};
11+
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
1212
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
1313
use std::rc::Rc;
1414
use type_op::TypeOpOutput;
@@ -318,7 +318,8 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
318318
.param_env
319319
.and(type_op::implied_outlives_bounds::ImpliedOutlivesBounds { ty })
320320
.fully_perform(self.infcx, DUMMY_SP)
321-
.unwrap_or_else(|_| bug!("failed to compute implied bounds {:?}", ty));
321+
.map_err(|_: ErrorGuaranteed| debug!("failed to compute implied bounds {:?}", ty))
322+
.ok()?;
322323
debug!(?bounds, ?constraints);
323324
self.add_outlives_bounds(bounds);
324325
constraints

0 commit comments

Comments
 (0)