Skip to content

Commit 7a9e1e3

Browse files
author
The Miri Cronjob Bot
committed
Merge from rustc
2 parents 4b69da9 + c895985 commit 7a9e1e3

File tree

225 files changed

+4928
-2927
lines changed

Some content is hidden

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

225 files changed

+4928
-2927
lines changed

Cargo.lock

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4168,8 +4168,10 @@ dependencies = [
41684168
"rustc_index",
41694169
"rustc_macros",
41704170
"rustc_middle",
4171+
"rustc_next_trait_solver",
41714172
"rustc_span",
41724173
"rustc_target",
4174+
"rustc_type_ir",
41734175
"smallvec",
41744176
"tracing",
41754177
]
@@ -6356,9 +6358,9 @@ dependencies = [
63566358

63576359
[[package]]
63586360
name = "windows-bindgen"
6359-
version = "0.57.0"
6361+
version = "0.58.0"
63606362
source = "registry+https://github.com/rust-lang/crates.io-index"
6361-
checksum = "1ccb96113d6277ba543c0f77e1c5494af8094bf9daf9b85acdc3f1b620e7c7b4"
6363+
checksum = "91cd28d93c692351f3a6e5615567c56756e330bee1c99c6bdd57bfc5ab15f589"
63626364
dependencies = [
63636365
"proc-macro2",
63646366
"rayon",
@@ -6379,9 +6381,9 @@ dependencies = [
63796381

63806382
[[package]]
63816383
name = "windows-metadata"
6382-
version = "0.57.0"
6384+
version = "0.58.0"
63836385
source = "registry+https://github.com/rust-lang/crates.io-index"
6384-
checksum = "8308d076825b9d9e5abc64f8113e96d02b2aeeba869b20fdd65c7e70cda13dfc"
6386+
checksum = "2e837f3c3012cfe9e7086302a93f441a7999439be1ad4c530d55d2f6d2921809"
63856387

63866388
[[package]]
63876389
name = "windows-sys"

compiler/rustc_ast/src/ast.rs

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub enum GenericArgs {
176176
AngleBracketed(AngleBracketedArgs),
177177
/// The `(A, B)` and `C` in `Foo(A, B) -> C`.
178178
Parenthesized(ParenthesizedArgs),
179-
/// `(..)` in return type notation
179+
/// `(..)` in return type notation.
180180
ParenthesizedElided(Span),
181181
}
182182

@@ -197,11 +197,11 @@ impl GenericArgs {
197197
/// Concrete argument in the sequence of generic args.
198198
#[derive(Clone, Encodable, Decodable, Debug)]
199199
pub enum GenericArg {
200-
/// `'a` in `Foo<'a>`
200+
/// `'a` in `Foo<'a>`.
201201
Lifetime(Lifetime),
202-
/// `Bar` in `Foo<Bar>`
202+
/// `Bar` in `Foo<Bar>`.
203203
Type(P<Ty>),
204-
/// `1` in `Foo<1>`
204+
/// `1` in `Foo<1>`.
205205
Const(AnonConst),
206206
}
207207

@@ -355,7 +355,7 @@ pub enum GenericParamKind {
355355
ty: P<Ty>,
356356
/// Span of the `const` keyword.
357357
kw_span: Span,
358-
/// Optional default value for the const generic param
358+
/// Optional default value for the const generic param.
359359
default: Option<AnonConst>,
360360
},
361361
}
@@ -714,6 +714,7 @@ pub enum ByRef {
714714
}
715715

716716
impl ByRef {
717+
#[must_use]
717718
pub fn cap_ref_mutability(mut self, mutbl: Mutability) -> Self {
718719
if let ByRef::Yes(old_mutbl) = &mut self {
719720
*old_mutbl = cmp::min(*old_mutbl, mutbl);
@@ -832,7 +833,7 @@ pub enum PatKind {
832833
/// only one rest pattern may occur in the pattern sequences.
833834
Rest,
834835

835-
// A never pattern `!`
836+
// A never pattern `!`.
836837
Never,
837838

838839
/// Parentheses in patterns used for grouping (i.e., `(PAT)`).
@@ -1121,9 +1122,9 @@ impl LocalKind {
11211122
#[derive(Clone, Encodable, Decodable, Debug)]
11221123
pub struct Arm {
11231124
pub attrs: AttrVec,
1124-
/// Match arm pattern, e.g. `10` in `match foo { 10 => {}, _ => {} }`
1125+
/// Match arm pattern, e.g. `10` in `match foo { 10 => {}, _ => {} }`.
11251126
pub pat: P<Pat>,
1126-
/// Match arm guard, e.g. `n > 10` in `match foo { n if n > 10 => {}, _ => {} }`
1127+
/// Match arm guard, e.g. `n > 10` in `match foo { n if n > 10 => {}, _ => {} }`.
11271128
pub guard: Option<P<Expr>>,
11281129
/// Match arm body. Omitted if the pattern is a never pattern.
11291130
pub body: Option<P<Expr>>,
@@ -1354,12 +1355,12 @@ pub struct Closure {
13541355
pub fn_arg_span: Span,
13551356
}
13561357

1357-
/// Limit types of a range (inclusive or exclusive)
1358+
/// Limit types of a range (inclusive or exclusive).
13581359
#[derive(Copy, Clone, PartialEq, Encodable, Decodable, Debug)]
13591360
pub enum RangeLimits {
1360-
/// Inclusive at the beginning, exclusive at the end
1361+
/// Inclusive at the beginning, exclusive at the end.
13611362
HalfOpen,
1362-
/// Inclusive at the beginning and end
1363+
/// Inclusive at the beginning and end.
13631364
Closed,
13641365
}
13651366

@@ -1400,9 +1401,9 @@ pub struct StructExpr {
14001401
pub enum ExprKind {
14011402
/// An array (e.g, `[a, b, c, d]`).
14021403
Array(ThinVec<P<Expr>>),
1403-
/// Allow anonymous constants from an inline `const` block
1404+
/// Allow anonymous constants from an inline `const` block.
14041405
ConstBlock(AnonConst),
1405-
/// A function call
1406+
/// A function call.
14061407
///
14071408
/// The first field resolves to the function itself,
14081409
/// and the second field is the list of arguments.
@@ -1456,7 +1457,7 @@ pub enum ExprKind {
14561457
/// A block (`'label: { ... }`).
14571458
Block(P<Block>, Option<Label>),
14581459
/// An `async` block (`async move { ... }`),
1459-
/// or a `gen` block (`gen move { ... }`)
1460+
/// or a `gen` block (`gen move { ... }`).
14601461
///
14611462
/// The span is the "decl", which is the header before the body `{ }`
14621463
/// including the `asyng`/`gen` keywords and possibly `move`.
@@ -2156,9 +2157,9 @@ pub enum TyKind {
21562157
Never,
21572158
/// A tuple (`(A, B, C, D,...)`).
21582159
Tup(ThinVec<P<Ty>>),
2159-
/// An anonymous struct type i.e. `struct { foo: Type }`
2160+
/// An anonymous struct type i.e. `struct { foo: Type }`.
21602161
AnonStruct(NodeId, ThinVec<FieldDef>),
2161-
/// An anonymous union type i.e. `union { bar: Type }`
2162+
/// An anonymous union type i.e. `union { bar: Type }`.
21622163
AnonUnion(NodeId, ThinVec<FieldDef>),
21632164
/// A path (`module::module::...::Type`), optionally
21642165
/// "qualified", e.g., `<Vec<T> as SomeTrait>::SomeType`.
@@ -2232,9 +2233,9 @@ pub enum TraitObjectSyntax {
22322233

22332234
#[derive(Clone, Encodable, Decodable, Debug)]
22342235
pub enum PreciseCapturingArg {
2235-
/// Lifetime parameter
2236+
/// Lifetime parameter.
22362237
Lifetime(Lifetime),
2237-
/// Type or const parameter
2238+
/// Type or const parameter.
22382239
Arg(Path, NodeId),
22392240
}
22402241

@@ -2528,11 +2529,11 @@ pub enum Safety {
25282529
/// Iterator`.
25292530
#[derive(Copy, Clone, Encodable, Decodable, Debug)]
25302531
pub enum CoroutineKind {
2531-
/// `async`, which returns an `impl Future`
2532+
/// `async`, which returns an `impl Future`.
25322533
Async { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
2533-
/// `gen`, which returns an `impl Iterator`
2534+
/// `gen`, which returns an `impl Iterator`.
25342535
Gen { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
2535-
/// `async gen`, which returns an `impl AsyncIterator`
2536+
/// `async gen`, which returns an `impl AsyncIterator`.
25362537
AsyncGen { span: Span, closure_id: NodeId, return_impl_trait_id: NodeId },
25372538
}
25382539

@@ -2749,7 +2750,7 @@ pub struct Variant {
27492750
pub data: VariantData,
27502751
/// Explicit discriminant, e.g., `Foo = 1`.
27512752
pub disr_expr: Option<AnonConst>,
2752-
/// Is a macro placeholder
2753+
/// Is a macro placeholder.
27532754
pub is_placeholder: bool,
27542755
}
27552756

@@ -3023,19 +3024,19 @@ impl Item {
30233024
/// `extern` qualifier on a function item or function type.
30243025
#[derive(Clone, Copy, Encodable, Decodable, Debug)]
30253026
pub enum Extern {
3026-
/// No explicit extern keyword was used
3027+
/// No explicit extern keyword was used.
30273028
///
3028-
/// E.g. `fn foo() {}`
3029+
/// E.g. `fn foo() {}`.
30293030
None,
3030-
/// An explicit extern keyword was used, but with implicit ABI
3031+
/// An explicit extern keyword was used, but with implicit ABI.
30313032
///
3032-
/// E.g. `extern fn foo() {}`
3033+
/// E.g. `extern fn foo() {}`.
30333034
///
3034-
/// This is just `extern "C"` (see `rustc_target::spec::abi::Abi::FALLBACK`)
3035+
/// This is just `extern "C"` (see `rustc_target::spec::abi::Abi::FALLBACK`).
30353036
Implicit(Span),
3036-
/// An explicit extern keyword was used with an explicit ABI
3037+
/// An explicit extern keyword was used with an explicit ABI.
30373038
///
3038-
/// E.g. `extern "C" fn foo() {}`
3039+
/// E.g. `extern "C" fn foo() {}`.
30393040
Explicit(StrLit, Span),
30403041
}
30413042

@@ -3054,13 +3055,13 @@ impl Extern {
30543055
/// included in this struct (e.g., `async unsafe fn` or `const extern "C" fn`).
30553056
#[derive(Clone, Copy, Encodable, Decodable, Debug)]
30563057
pub struct FnHeader {
3057-
/// Whether this is `unsafe`, or has a default safety
3058+
/// Whether this is `unsafe`, or has a default safety.
30583059
pub safety: Safety,
30593060
/// Whether this is `async`, `gen`, or nothing.
30603061
pub coroutine_kind: Option<CoroutineKind>,
30613062
/// The `const` keyword, if any
30623063
pub constness: Const,
3063-
/// The `extern` keyword and corresponding ABI string, if any
3064+
/// The `extern` keyword and corresponding ABI string, if any.
30643065
pub ext: Extern,
30653066
}
30663067

@@ -3254,7 +3255,7 @@ pub enum ItemKind {
32543255
///
32553256
/// E.g., `trait Foo { .. }`, `trait Foo<T> { .. }` or `auto trait Foo {}`.
32563257
Trait(Box<Trait>),
3257-
/// Trait alias
3258+
/// Trait alias.
32583259
///
32593260
/// E.g., `trait Foo = Bar + Quux;`.
32603261
TraitAlias(Generics, GenericBounds),

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
3939
use rustc_trait_selection::traits::error_reporting::FindExprBySpan;
4040
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
4141
use std::iter;
42+
use std::ops::ControlFlow;
4243

4344
use crate::borrow_set::TwoPhaseActivation;
4445
use crate::borrowck_errors;
@@ -784,20 +785,20 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
784785
/// binding declaration within every scope we inspect.
785786
struct Finder {
786787
hir_id: hir::HirId,
787-
found: bool,
788788
}
789789
impl<'hir> Visitor<'hir> for Finder {
790-
fn visit_pat(&mut self, pat: &'hir hir::Pat<'hir>) {
790+
type Result = ControlFlow<()>;
791+
fn visit_pat(&mut self, pat: &'hir hir::Pat<'hir>) -> Self::Result {
791792
if pat.hir_id == self.hir_id {
792-
self.found = true;
793+
return ControlFlow::Break(());
793794
}
794-
hir::intravisit::walk_pat(self, pat);
795+
hir::intravisit::walk_pat(self, pat)
795796
}
796-
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) {
797+
fn visit_expr(&mut self, ex: &'hir hir::Expr<'hir>) -> Self::Result {
797798
if ex.hir_id == self.hir_id {
798-
self.found = true;
799+
return ControlFlow::Break(());
799800
}
800-
hir::intravisit::walk_expr(self, ex);
801+
hir::intravisit::walk_expr(self, ex)
801802
}
802803
}
803804
// The immediate HIR parent of the moved expression. We'll look for it to be a call.
@@ -822,9 +823,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
822823
_ => continue,
823824
};
824825
if let Some(&hir_id) = local_hir_id {
825-
let mut finder = Finder { hir_id, found: false };
826-
finder.visit_expr(e);
827-
if finder.found {
826+
if (Finder { hir_id }).visit_expr(e).is_break() {
828827
// The current scope includes the declaration of the binding we're accessing, we
829828
// can't look up any further for loops.
830829
break;
@@ -839,9 +838,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
839838
hir::Node::Expr(hir::Expr {
840839
kind: hir::ExprKind::If(cond, ..), ..
841840
}) => {
842-
let mut finder = Finder { hir_id: expr.hir_id, found: false };
843-
finder.visit_expr(cond);
844-
if finder.found {
841+
if (Finder { hir_id: expr.hir_id }).visit_expr(cond).is_break() {
845842
// The expression where the move error happened is in a `while let`
846843
// condition Don't suggest clone as it will likely end in an
847844
// infinite loop.
@@ -1837,15 +1834,14 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
18371834

18381835
pub struct Holds<'tcx> {
18391836
ty: Ty<'tcx>,
1840-
holds: bool,
18411837
}
18421838

18431839
impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for Holds<'tcx> {
18441840
type Result = std::ops::ControlFlow<()>;
18451841

18461842
fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
18471843
if t == self.ty {
1848-
self.holds = true;
1844+
return ControlFlow::Break(());
18491845
}
18501846
t.super_visit_with(self)
18511847
}
@@ -1863,9 +1859,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
18631859
&& rcvr_ty == ty
18641860
&& let ty::Ref(_, inner, _) = rcvr_ty.kind()
18651861
&& let inner = inner.peel_refs()
1866-
&& let mut v = (Holds { ty: inner, holds: false })
1867-
&& let _ = v.visit_ty(local_ty)
1868-
&& v.holds
1862+
&& (Holds { ty: inner }).visit_ty(local_ty).is_break()
18691863
&& let None = self.infcx.type_implements_trait_shallow(clone, inner, self.param_env)
18701864
{
18711865
err.span_label(
@@ -4325,15 +4319,14 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
43254319
}
43264320

43274321
/// Detect whether one of the provided spans is a statement nested within the top-most visited expr
4328-
struct ReferencedStatementsVisitor<'a>(&'a [Span], bool);
4322+
struct ReferencedStatementsVisitor<'a>(&'a [Span]);
43294323

4330-
impl<'a, 'v> Visitor<'v> for ReferencedStatementsVisitor<'a> {
4331-
fn visit_stmt(&mut self, s: &'v hir::Stmt<'v>) {
4324+
impl<'v> Visitor<'v> for ReferencedStatementsVisitor<'_> {
4325+
type Result = ControlFlow<()>;
4326+
fn visit_stmt(&mut self, s: &'v hir::Stmt<'v>) -> Self::Result {
43324327
match s.kind {
4333-
hir::StmtKind::Semi(expr) if self.0.contains(&expr.span) => {
4334-
self.1 = true;
4335-
}
4336-
_ => {}
4328+
hir::StmtKind::Semi(expr) if self.0.contains(&expr.span) => ControlFlow::Break(()),
4329+
_ => ControlFlow::Continue(()),
43374330
}
43384331
}
43394332
}
@@ -4375,9 +4368,7 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
43754368
hir::ExprKind::If(cond, body, None) => {
43764369
// `if` expressions with no `else` that initialize the binding might be missing an
43774370
// `else` arm.
4378-
let mut v = ReferencedStatementsVisitor(self.spans, false);
4379-
v.visit_expr(body);
4380-
if v.1 {
4371+
if ReferencedStatementsVisitor(self.spans).visit_expr(body).is_break() {
43814372
self.errors.push((
43824373
cond.span,
43834374
format!(
@@ -4394,11 +4385,9 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
43944385
hir::ExprKind::If(cond, body, Some(other)) => {
43954386
// `if` expressions where the binding is only initialized in one of the two arms
43964387
// might be missing a binding initialization.
4397-
let mut a = ReferencedStatementsVisitor(self.spans, false);
4398-
a.visit_expr(body);
4399-
let mut b = ReferencedStatementsVisitor(self.spans, false);
4400-
b.visit_expr(other);
4401-
match (a.1, b.1) {
4388+
let a = ReferencedStatementsVisitor(self.spans).visit_expr(body).is_break();
4389+
let b = ReferencedStatementsVisitor(self.spans).visit_expr(other).is_break();
4390+
match (a, b) {
44024391
(true, true) | (false, false) => {}
44034392
(true, false) => {
44044393
if other.span.is_desugaring(DesugaringKind::WhileLoop) {
@@ -4437,11 +4426,7 @@ impl<'b, 'v, 'tcx> Visitor<'v> for ConditionVisitor<'b, 'tcx> {
44374426
// arms might be missing an initialization.
44384427
let results: Vec<bool> = arms
44394428
.iter()
4440-
.map(|arm| {
4441-
let mut v = ReferencedStatementsVisitor(self.spans, false);
4442-
v.visit_arm(arm);
4443-
v.1
4444-
})
4429+
.map(|arm| ReferencedStatementsVisitor(self.spans).visit_arm(arm).is_break())
44454430
.collect();
44464431
if results.iter().any(|x| *x) && !results.iter().all(|x| *x) {
44474432
for (arm, seen) in arms.iter().zip(results) {

0 commit comments

Comments
 (0)