Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 0398759

Browse files
committed
Auto merge of rust-lang#3061 - rust-lang:rustup-2023-09-15, r=saethlin
Automatic sync from rustc
2 parents 8cd31ea + faa57a7 commit 0398759

File tree

507 files changed

+10980
-5695
lines changed

Some content is hidden

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

507 files changed

+10980
-5695
lines changed

Cargo.lock

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ dependencies = [
531531
"tester",
532532
"tokio",
533533
"toml 0.7.5",
534-
"ui_test 0.18.1",
534+
"ui_test 0.20.0",
535535
"walkdir",
536536
]
537537

@@ -662,6 +662,7 @@ dependencies = [
662662
"diff",
663663
"getopts",
664664
"glob",
665+
"home",
665666
"lazycell",
666667
"libc",
667668
"miow",
@@ -1597,6 +1598,15 @@ version = "0.4.3"
15971598
source = "registry+https://github.com/rust-lang/crates.io-index"
15981599
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
15991600

1601+
[[package]]
1602+
name = "home"
1603+
version = "0.5.5"
1604+
source = "registry+https://github.com/rust-lang/crates.io-index"
1605+
checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"
1606+
dependencies = [
1607+
"windows-sys 0.48.0",
1608+
]
1609+
16001610
[[package]]
16011611
name = "html-checker"
16021612
version = "0.1.0"
@@ -5596,9 +5606,9 @@ dependencies = [
55965606

55975607
[[package]]
55985608
name = "ui_test"
5599-
version = "0.18.1"
5609+
version = "0.20.0"
56005610
source = "registry+https://github.com/rust-lang/crates.io-index"
5601-
checksum = "640159421816683e558867ffc0e60ed3a3ed97ec6ccb22c03adb41bf87c5cfa4"
5611+
checksum = "bfd8fb9b15c8332cf51bfc2dc4830063b2446a9c9d732421b56f2478024a3971"
56025612
dependencies = [
56035613
"annotate-snippets",
56045614
"anyhow",

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use rustc_macros::HashStable_Generic;
3333
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
3434
use rustc_span::source_map::{respan, Spanned};
3535
use rustc_span::symbol::{kw, sym, Ident, Symbol};
36-
use rustc_span::{Span, DUMMY_SP};
36+
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
3737
use std::fmt;
3838
use std::mem;
3939
use thin_vec::{thin_vec, ThinVec};
@@ -1426,7 +1426,7 @@ pub enum ExprKind {
14261426
/// of `if` / `while` expressions. (e.g., `if let 0 = x { .. }`).
14271427
///
14281428
/// `Span` represents the whole `let pat = expr` statement.
1429-
Let(P<Pat>, P<Expr>, Span),
1429+
Let(P<Pat>, P<Expr>, Span, Option<ErrorGuaranteed>),
14301430
/// An `if` block, with an optional `else` block.
14311431
///
14321432
/// `if expr { block } else { expr }`

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
13661366
vis.visit_ty(ty);
13671367
}
13681368
ExprKind::AddrOf(_, _, ohs) => vis.visit_expr(ohs),
1369-
ExprKind::Let(pat, scrutinee, _) => {
1369+
ExprKind::Let(pat, scrutinee, _, _) => {
13701370
vis.visit_pat(pat);
13711371
vis.visit_expr(scrutinee);
13721372
}

compiler/rustc_ast/src/util/classify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
3636
| AssignOp(_, _, e)
3737
| Binary(_, _, e)
3838
| Break(_, Some(e))
39-
| Let(_, e, _)
39+
| Let(_, e, _, _)
4040
| Range(_, Some(e), _)
4141
| Ret(Some(e))
4242
| Unary(_, e)

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
827827
visitor.visit_expr(subexpression);
828828
visitor.visit_ty(typ)
829829
}
830-
ExprKind::Let(pat, expr, _) => {
830+
ExprKind::Let(pat, expr, _, _) => {
831831
visitor.visit_pat(pat);
832832
visitor.visit_expr(expr);
833833
}

compiler/rustc_ast_lowering/messages.ftl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ ast_lowering_bad_return_type_notation_inputs =
2929
argument types not allowed with return type notation
3030
.suggestion = remove the input types
3131
32-
ast_lowering_bad_return_type_notation_needs_dots =
33-
return type notation arguments must be elided with `..`
34-
.suggestion = add `..`
35-
3632
ast_lowering_bad_return_type_notation_output =
3733
return type not allowed with return type notation
3834
.suggestion = remove the return type

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
152152
let ohs = self.lower_expr(ohs);
153153
hir::ExprKind::AddrOf(*k, *m, ohs)
154154
}
155-
ExprKind::Let(pat, scrutinee, span) => {
155+
ExprKind::Let(pat, scrutinee, span, is_recovered) => {
156156
hir::ExprKind::Let(self.arena.alloc(hir::Let {
157157
hir_id: self.next_id(),
158158
span: self.lower_span(*span),
159159
pat: self.lower_pat(pat),
160160
ty: None,
161161
init: self.lower_expr(scrutinee),
162+
is_recovered: *is_recovered,
162163
}))
163164
}
164165
ExprKind::If(cond, then, else_opt) => {
@@ -558,13 +559,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
558559
fn lower_arm(&mut self, arm: &Arm) -> hir::Arm<'hir> {
559560
let pat = self.lower_pat(&arm.pat);
560561
let guard = arm.guard.as_ref().map(|cond| {
561-
if let ExprKind::Let(pat, scrutinee, span) = &cond.kind {
562+
if let ExprKind::Let(pat, scrutinee, span, is_recovered) = &cond.kind {
562563
hir::Guard::IfLet(self.arena.alloc(hir::Let {
563564
hir_id: self.next_id(),
564565
span: self.lower_span(*span),
565566
pat: self.lower_pat(pat),
566567
ty: None,
567568
init: self.lower_expr(scrutinee),
569+
is_recovered: *is_recovered,
568570
}))
569571
} else {
570572
hir::Guard::If(self.lower_expr(cond))

compiler/rustc_ast_passes/messages.ftl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ ast_passes_forbidden_default =
117117
`default` is only allowed on items in trait impls
118118
.label = `default` because of this
119119
120-
ast_passes_forbidden_let =
121-
`let` expressions are not supported here
122-
.note = only supported directly in conditions of `if` and `while` expressions
123-
.not_supported_or = `||` operators are not supported in let chain expressions
124-
.not_supported_parentheses = `let`s wrapped in parentheses are not supported in a context with let chains
125-
126-
ast_passes_forbidden_let_stable =
127-
expected expression, found statement (`let`)
128-
.note = variable declaration using `let` is a statement
129-
130120
ast_passes_forbidden_lifetime_bound =
131121
lifetime bounds cannot be used in this context
132122

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ use rustc_ast::{walk_list, StaticItem};
1414
use rustc_ast_pretty::pprust::{self, State};
1515
use rustc_data_structures::fx::FxIndexMap;
1616
use rustc_feature::Features;
17-
use rustc_macros::Subdiagnostic;
1817
use rustc_parse::validate_attr;
1918
use rustc_session::lint::builtin::{
2019
DEPRECATED_WHERE_CLAUSE_LOCATION, MISSING_ABI, PATTERNS_IN_FNS_WITHOUT_BODY,
2120
};
2221
use rustc_session::lint::{BuiltinLintDiagnostics, LintBuffer};
2322
use rustc_session::Session;
24-
use rustc_span::source_map::Spanned;
2523
use rustc_span::symbol::{kw, sym, Ident};
2624
use rustc_span::Span;
2725
use rustc_target::spec::abi;
@@ -69,9 +67,6 @@ struct AstValidator<'a> {
6967
/// or `Foo::Bar<impl Trait>`
7068
is_impl_trait_banned: bool,
7169

72-
/// See [ForbiddenLetReason]
73-
forbidden_let_reason: Option<ForbiddenLetReason>,
74-
7570
lint_buffer: &'a mut LintBuffer,
7671
}
7772

@@ -118,26 +113,6 @@ impl<'a> AstValidator<'a> {
118113
self.with_tilde_const(Some(ctx), f)
119114
}
120115

121-
fn with_let_management(
122-
&mut self,
123-
forbidden_let_reason: Option<ForbiddenLetReason>,
124-
f: impl FnOnce(&mut Self, Option<ForbiddenLetReason>),
125-
) {
126-
let old = mem::replace(&mut self.forbidden_let_reason, forbidden_let_reason);
127-
f(self, old);
128-
self.forbidden_let_reason = old;
129-
}
130-
131-
/// Emits an error banning the `let` expression provided in the given location.
132-
fn ban_let_expr(&self, expr: &'a Expr, forbidden_let_reason: ForbiddenLetReason) {
133-
let sess = &self.session;
134-
if sess.opts.unstable_features.is_nightly_build() {
135-
sess.emit_err(errors::ForbiddenLet { span: expr.span, reason: forbidden_let_reason });
136-
} else {
137-
sess.emit_err(errors::ForbiddenLetStable { span: expr.span });
138-
}
139-
}
140-
141116
fn check_type_alias_where_clause_location(
142117
&mut self,
143118
ty_alias: &TyAlias,
@@ -779,67 +754,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
779754
validate_attr::check_attr(&self.session.parse_sess, attr);
780755
}
781756

782-
fn visit_expr(&mut self, expr: &'a Expr) {
783-
self.with_let_management(Some(ForbiddenLetReason::GenericForbidden), |this, forbidden_let_reason| {
784-
match &expr.kind {
785-
ExprKind::Binary(Spanned { node: BinOpKind::Or, span }, lhs, rhs) => {
786-
let local_reason = Some(ForbiddenLetReason::NotSupportedOr(*span));
787-
this.with_let_management(local_reason, |this, _| this.visit_expr(lhs));
788-
this.with_let_management(local_reason, |this, _| this.visit_expr(rhs));
789-
}
790-
ExprKind::If(cond, then, opt_else) => {
791-
this.visit_block(then);
792-
walk_list!(this, visit_expr, opt_else);
793-
this.with_let_management(None, |this, _| this.visit_expr(cond));
794-
return;
795-
}
796-
ExprKind::Let(..) if let Some(elem) = forbidden_let_reason => {
797-
this.ban_let_expr(expr, elem);
798-
},
799-
ExprKind::Match(scrutinee, arms) => {
800-
this.visit_expr(scrutinee);
801-
for arm in arms {
802-
this.visit_expr(&arm.body);
803-
this.visit_pat(&arm.pat);
804-
walk_list!(this, visit_attribute, &arm.attrs);
805-
if let Some(guard) = &arm.guard {
806-
this.with_let_management(None, |this, _| {
807-
this.visit_expr(guard)
808-
});
809-
}
810-
}
811-
}
812-
ExprKind::Paren(local_expr) => {
813-
fn has_let_expr(expr: &Expr) -> bool {
814-
match &expr.kind {
815-
ExprKind::Binary(_, lhs, rhs) => has_let_expr(lhs) || has_let_expr(rhs),
816-
ExprKind::Let(..) => true,
817-
_ => false,
818-
}
819-
}
820-
let local_reason = if has_let_expr(local_expr) {
821-
Some(ForbiddenLetReason::NotSupportedParentheses(local_expr.span))
822-
}
823-
else {
824-
forbidden_let_reason
825-
};
826-
this.with_let_management(local_reason, |this, _| this.visit_expr(local_expr));
827-
}
828-
ExprKind::Binary(Spanned { node: BinOpKind::And, .. }, ..) => {
829-
this.with_let_management(forbidden_let_reason, |this, _| visit::walk_expr(this, expr));
830-
return;
831-
}
832-
ExprKind::While(cond, then, opt_label) => {
833-
walk_list!(this, visit_label, opt_label);
834-
this.visit_block(then);
835-
this.with_let_management(None, |this, _| this.visit_expr(cond));
836-
return;
837-
}
838-
_ => visit::walk_expr(this, expr),
839-
}
840-
});
841-
}
842-
843757
fn visit_ty(&mut self, ty: &'a Ty) {
844758
self.visit_ty_common(ty);
845759
self.deny_anon_struct_or_union(ty);
@@ -1601,26 +1515,9 @@ pub fn check_crate(
16011515
outer_impl_trait: None,
16021516
disallow_tilde_const: None,
16031517
is_impl_trait_banned: false,
1604-
forbidden_let_reason: Some(ForbiddenLetReason::GenericForbidden),
16051518
lint_buffer: lints,
16061519
};
16071520
visit::walk_crate(&mut validator, krate);
16081521

16091522
validator.has_proc_macro_decls
16101523
}
1611-
1612-
/// Used to forbid `let` expressions in certain syntactic locations.
1613-
#[derive(Clone, Copy, Subdiagnostic)]
1614-
pub(crate) enum ForbiddenLetReason {
1615-
/// `let` is not valid and the source environment is not important
1616-
GenericForbidden,
1617-
/// A let chain with the `||` operator
1618-
#[note(ast_passes_not_supported_or)]
1619-
NotSupportedOr(#[primary_span] Span),
1620-
/// A let chain with invalid parentheses
1621-
///
1622-
/// For example, `let 1 = 1 && (expr && expr)` is allowed
1623-
/// but `(let 1 = 1 && (let 1 = 1 && (let 1 = 1))) && let a = 1` is not
1624-
#[note(ast_passes_not_supported_parentheses)]
1625-
NotSupportedParentheses(#[primary_span] Span),
1626-
}

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,8 @@ use rustc_errors::AddToDiagnostic;
55
use rustc_macros::{Diagnostic, Subdiagnostic};
66
use rustc_span::{symbol::Ident, Span, Symbol};
77

8-
use crate::ast_validation::ForbiddenLetReason;
98
use crate::fluent_generated as fluent;
109

11-
#[derive(Diagnostic)]
12-
#[diag(ast_passes_forbidden_let)]
13-
#[note]
14-
pub struct ForbiddenLet {
15-
#[primary_span]
16-
pub span: Span,
17-
#[subdiagnostic]
18-
pub(crate) reason: ForbiddenLetReason,
19-
}
20-
21-
#[derive(Diagnostic)]
22-
#[diag(ast_passes_forbidden_let_stable)]
23-
#[note]
24-
pub struct ForbiddenLetStable {
25-
#[primary_span]
26-
pub span: Span,
27-
}
28-
2910
#[derive(Diagnostic)]
3011
#[diag(ast_passes_keyword_lifetime)]
3112
pub struct KeywordLifetime {

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl<'a> State<'a> {
352352
self.end();
353353
self.word(")");
354354
}
355-
ast::ExprKind::Let(pat, scrutinee, _) => {
355+
ast::ExprKind::Let(pat, scrutinee, _, _) => {
356356
self.print_let(pat, scrutinee);
357357
}
358358
ast::ExprKind::If(test, blk, elseopt) => self.print_if(test, blk, elseopt.as_deref()),

compiler/rustc_borrowck/messages.ftl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,6 @@ borrowck_higher_ranked_subtype_error =
7474
borrowck_lifetime_constraints_error =
7575
lifetime may not live long enough
7676
77-
borrowck_move_borrowed =
78-
cannot move out of `{$desc}` because it is borrowed
79-
8077
borrowck_move_out_place_here =
8178
{$place} is moved here
8279
@@ -250,12 +247,6 @@ borrowck_var_move_by_use_in_closure =
250247
borrowck_var_move_by_use_in_generator =
251248
move occurs due to use in generator
252249
253-
borrowck_var_move_by_use_place_in_closure =
254-
move occurs due to use of {$place} in closure
255-
256-
borrowck_var_move_by_use_place_in_generator =
257-
move occurs due to use of {$place} in generator
258-
259250
borrowck_var_mutable_borrow_by_use_place_in_closure =
260251
mutable borrow occurs due to use of {$place} in closure
261252

compiler/rustc_builtin_macros/src/assert/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'cx, 'a> Context<'cx, 'a> {
241241
self.manage_cond_expr(prefix);
242242
self.manage_cond_expr(suffix);
243243
}
244-
ExprKind::Let(_, local_expr, _) => {
244+
ExprKind::Let(_, local_expr, _, _) => {
245245
self.manage_cond_expr(local_expr);
246246
}
247247
ExprKind::Match(local_expr, _) => {

compiler/rustc_builtin_macros/src/deriving/cmp/eq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn expand_deriving_eq(
3434
attributes: thin_vec![
3535
cx.attr_word(sym::inline, span),
3636
cx.attr_nested_word(sym::doc, sym::hidden, span),
37-
cx.attr_word(sym::no_coverage, span)
37+
cx.attr_nested_word(sym::coverage, sym::off, span)
3838
],
3939
fieldless_variants_strategy: FieldlessVariantsStrategy::Unify,
4040
combine_substructure: combine_substructure(Box::new(|a, b, c| {

0 commit comments

Comments
 (0)