Skip to content

Commit 73f83ff

Browse files
committed
Auto merge of #2790 - RalfJung:rustup, r=RalfJung
Rustup
2 parents 52af045 + 044aa87 commit 73f83ff

File tree

274 files changed

+2120
-7324
lines changed

Some content is hidden

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

274 files changed

+2120
-7324
lines changed

Cargo.lock

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,25 +3495,6 @@ dependencies = [
34953495
"serde_json",
34963496
]
34973497

3498-
[[package]]
3499-
name = "rls-data"
3500-
version = "0.19.1"
3501-
source = "registry+https://github.com/rust-lang/crates.io-index"
3502-
checksum = "a58135eb039f3a3279a33779192f0ee78b56f57ae636e25cec83530e41debb99"
3503-
dependencies = [
3504-
"rls-span",
3505-
"serde",
3506-
]
3507-
3508-
[[package]]
3509-
name = "rls-span"
3510-
version = "0.5.3"
3511-
source = "registry+https://github.com/rust-lang/crates.io-index"
3512-
checksum = "f0eea58478fc06e15f71b03236612173a1b81e9770314edecfa664375e3e4c86"
3513-
dependencies = [
3514-
"serde",
3515-
]
3516-
35173498
[[package]]
35183499
name = "rust-demangler"
35193500
version = "0.0.1"
@@ -3965,7 +3946,6 @@ dependencies = [
39653946
"rustc_middle",
39663947
"rustc_parse",
39673948
"rustc_plugin_impl",
3968-
"rustc_save_analysis",
39693949
"rustc_session",
39703950
"rustc_span",
39713951
"rustc_target",
@@ -4625,27 +4605,6 @@ dependencies = [
46254605
"tracing",
46264606
]
46274607

4628-
[[package]]
4629-
name = "rustc_save_analysis"
4630-
version = "0.0.0"
4631-
dependencies = [
4632-
"rls-data",
4633-
"rls-span",
4634-
"rustc_ast",
4635-
"rustc_ast_pretty",
4636-
"rustc_data_structures",
4637-
"rustc_errors",
4638-
"rustc_hir",
4639-
"rustc_hir_pretty",
4640-
"rustc_lexer",
4641-
"rustc_macros",
4642-
"rustc_middle",
4643-
"rustc_session",
4644-
"rustc_span",
4645-
"serde_json",
4646-
"tracing",
4647-
]
4648-
46494608
[[package]]
46504609
name = "rustc_serialize"
46514610
version = "0.0.0"

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
139139
ExprKind::Cast(expr, ty) => {
140140
let expr = self.lower_expr(expr);
141141
let ty =
142-
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
142+
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Cast));
143143
hir::ExprKind::Cast(expr, ty)
144144
}
145145
ExprKind::Type(expr, ty) => {
146146
let expr = self.lower_expr(expr);
147147
let ty =
148-
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
148+
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Cast));
149149
hir::ExprKind::Type(expr, ty)
150150
}
151151
ExprKind::AddrOf(k, m, ohs) => {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
378378
)
379379
});
380380

381-
let lowered_ty = this
382-
.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
381+
let lowered_ty = this.lower_ty(
382+
ty,
383+
&ImplTraitContext::Disallowed(ImplTraitPosition::ImplSelf),
384+
);
383385

384386
(trait_ref, lowered_ty)
385387
});
@@ -458,7 +460,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
458460
span: Span,
459461
body: Option<&Expr>,
460462
) -> (&'hir hir::Ty<'hir>, hir::BodyId) {
461-
let ty = self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
463+
let ty = self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy));
462464
(ty, self.lower_const_body(span, body))
463465
}
464466

@@ -608,8 +610,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
608610
hir::ForeignItemKind::Fn(fn_dec, fn_args, generics)
609611
}
610612
ForeignItemKind::Static(t, m, _) => {
611-
let ty =
612-
self.lower_ty(t, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
613+
let ty = self
614+
.lower_ty(t, &ImplTraitContext::Disallowed(ImplTraitPosition::StaticTy));
613615
hir::ForeignItemKind::Static(ty, *m)
614616
}
615617
ForeignItemKind::TyAlias(..) => hir::ForeignItemKind::Type,
@@ -679,11 +681,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
679681
qself,
680682
path,
681683
ParamMode::ExplicitNamed, // no `'_` in declarations (Issue #61124)
682-
&ImplTraitContext::Disallowed(ImplTraitPosition::Path),
684+
&ImplTraitContext::Disallowed(ImplTraitPosition::FieldTy),
683685
);
684686
self.arena.alloc(t)
685687
} else {
686-
self.lower_ty(&f.ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type))
688+
self.lower_ty(&f.ty, &ImplTraitContext::Disallowed(ImplTraitPosition::FieldTy))
687689
};
688690
let hir_id = self.lower_node_id(f.id);
689691
self.lower_attrs(hir_id, &f.attrs);
@@ -708,7 +710,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
708710

709711
let (generics, kind, has_default) = match &i.kind {
710712
AssocItemKind::Const(_, ty, default) => {
711-
let ty = self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
713+
let ty =
714+
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy));
712715
let body = default.as_ref().map(|x| self.lower_const_body(i.span, Some(x)));
713716
(hir::Generics::empty(), hir::TraitItemKind::Const(ty, body), body.is_some())
714717
}
@@ -746,7 +749,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
746749
&ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
747750
|this| {
748751
let ty = ty.as_ref().map(|x| {
749-
this.lower_ty(x, &ImplTraitContext::Disallowed(ImplTraitPosition::Type))
752+
this.lower_ty(
753+
x,
754+
&ImplTraitContext::Disallowed(ImplTraitPosition::AssocTy),
755+
)
750756
});
751757
hir::TraitItemKind::Type(
752758
this.lower_param_bounds(
@@ -805,7 +811,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
805811

806812
let (generics, kind) = match &i.kind {
807813
AssocItemKind::Const(_, ty, expr) => {
808-
let ty = self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
814+
let ty =
815+
self.lower_ty(ty, &ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy));
809816
(
810817
hir::Generics::empty(),
811818
hir::ImplItemKind::Const(ty, self.lower_const_body(i.span, expr.as_deref())),
@@ -1441,7 +1448,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14411448
hir_id: self.next_id(),
14421449
bound_generic_params: self.lower_generic_params(bound_generic_params),
14431450
bounded_ty: self
1444-
.lower_ty(bounded_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
1451+
.lower_ty(bounded_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Bound)),
14451452
bounds: self.arena.alloc_from_iter(bounds.iter().map(|bound| {
14461453
self.lower_param_bound(
14471454
bound,
@@ -1465,9 +1472,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
14651472
WherePredicate::EqPredicate(WhereEqPredicate { lhs_ty, rhs_ty, span }) => {
14661473
hir::WherePredicate::EqPredicate(hir::WhereEqPredicate {
14671474
lhs_ty: self
1468-
.lower_ty(lhs_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
1475+
.lower_ty(lhs_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Bound)),
14691476
rhs_ty: self
1470-
.lower_ty(rhs_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type)),
1477+
.lower_ty(rhs_ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Bound)),
14711478
span: self.lower_span(*span),
14721479
})
14731480
}

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ enum ImplTraitContext {
253253
enum ImplTraitPosition {
254254
Path,
255255
Variable,
256-
Type,
257256
Trait,
258257
AsyncBlock,
259258
Bound,
@@ -270,14 +269,20 @@ enum ImplTraitPosition {
270269
FnTraitReturn,
271270
TraitReturn,
272271
ImplReturn,
272+
GenericDefault,
273+
ConstTy,
274+
StaticTy,
275+
AssocTy,
276+
FieldTy,
277+
Cast,
278+
ImplSelf,
273279
}
274280

275281
impl std::fmt::Display for ImplTraitPosition {
276282
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
277283
let name = match self {
278284
ImplTraitPosition::Path => "path",
279285
ImplTraitPosition::Variable => "variable binding",
280-
ImplTraitPosition::Type => "type",
281286
ImplTraitPosition::Trait => "trait",
282287
ImplTraitPosition::AsyncBlock => "async block",
283288
ImplTraitPosition::Bound => "bound",
@@ -294,6 +299,13 @@ impl std::fmt::Display for ImplTraitPosition {
294299
ImplTraitPosition::FnTraitReturn => "`Fn` trait return",
295300
ImplTraitPosition::TraitReturn => "trait method return",
296301
ImplTraitPosition::ImplReturn => "`impl` method return",
302+
ImplTraitPosition::GenericDefault => "generic parameter default",
303+
ImplTraitPosition::ConstTy => "const type",
304+
ImplTraitPosition::StaticTy => "static type",
305+
ImplTraitPosition::AssocTy => "associated type",
306+
ImplTraitPosition::FieldTy => "field type",
307+
ImplTraitPosition::Cast => "cast type",
308+
ImplTraitPosition::ImplSelf => "impl header",
297309
};
298310

299311
write!(f, "{name}")
@@ -2166,15 +2178,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
21662178
GenericParamKind::Type { default, .. } => {
21672179
let kind = hir::GenericParamKind::Type {
21682180
default: default.as_ref().map(|x| {
2169-
self.lower_ty(x, &ImplTraitContext::Disallowed(ImplTraitPosition::Type))
2181+
self.lower_ty(
2182+
x,
2183+
&ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2184+
)
21702185
}),
21712186
synthetic: false,
21722187
};
21732188

21742189
(hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
21752190
}
21762191
GenericParamKind::Const { ty, kw_span: _, default } => {
2177-
let ty = self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::Type));
2192+
let ty = self.lower_ty(
2193+
&ty,
2194+
&ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault),
2195+
);
21782196
let default = default.as_ref().map(|def| self.lower_anon_const(def));
21792197
(
21802198
hir::ParamName::Plain(self.lower_ident(param.ident)),

compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11441144
LateBoundRegionConversionTime::FnCall,
11451145
tcx.fn_sig(method_did).subst(tcx, method_substs).input(0),
11461146
)
1147-
&& infcx.can_eq(self.param_env, ty, self_ty).is_ok()
1147+
&& infcx.can_eq(self.param_env, ty, self_ty)
11481148
{
11491149
err.span_suggestion_verbose(
11501150
fn_call_span.shrink_to_lo(),
@@ -1182,13 +1182,13 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
11821182
);
11831183
}
11841184
let parent_did = tcx.parent(method_did);
1185-
let parent_self_ty = (tcx.def_kind(parent_did)
1186-
== rustc_hir::def::DefKind::Impl)
1187-
.then_some(parent_did)
1188-
.and_then(|did| match tcx.type_of(did).kind() {
1189-
ty::Adt(def, ..) => Some(def.did()),
1190-
_ => None,
1191-
});
1185+
let parent_self_ty =
1186+
matches!(tcx.def_kind(parent_did), rustc_hir::def::DefKind::Impl { .. })
1187+
.then_some(parent_did)
1188+
.and_then(|did| match tcx.type_of(did).kind() {
1189+
ty::Adt(def, ..) => Some(def.did()),
1190+
_ => None,
1191+
});
11921192
let is_option_or_result = parent_self_ty.map_or(false, |def_id| {
11931193
matches!(tcx.get_diagnostic_name(def_id), Some(sym::Option | sym::Result))
11941194
});

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -852,9 +852,9 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
852852

853853
let tcx = self.infcx.tcx;
854854
let region_parent = tcx.parent(region.def_id);
855-
if tcx.def_kind(region_parent) != DefKind::Impl {
855+
let DefKind::Impl { .. } = tcx.def_kind(region_parent) else {
856856
return None;
857-
}
857+
};
858858

859859
let found = tcx
860860
.any_free_region_meets(&tcx.type_of(region_parent), |r| *r == ty::ReEarlyBound(region));

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
640640
sym::assert_inhabited | sym::assert_zero_valid | sym::assert_mem_uninitialized_valid => {
641641
intrinsic_args!(fx, args => (); intrinsic);
642642

643-
let layout = fx.layout_of(substs.type_at(0));
643+
let ty = substs.type_at(0);
644+
let layout = fx.layout_of(ty);
644645
if layout.abi.is_uninhabited() {
645646
with_no_trimmed_paths!({
646647
crate::base::codegen_panic_nounwind(
@@ -653,7 +654,10 @@ fn codegen_regular_intrinsic_call<'tcx>(
653654
}
654655

655656
if intrinsic == sym::assert_zero_valid
656-
&& !fx.tcx.permits_zero_init(fx.param_env().and(layout))
657+
&& !fx
658+
.tcx
659+
.permits_zero_init(fx.param_env().and(ty))
660+
.expect("expected to have layout during codegen")
657661
{
658662
with_no_trimmed_paths!({
659663
crate::base::codegen_panic_nounwind(
@@ -669,7 +673,10 @@ fn codegen_regular_intrinsic_call<'tcx>(
669673
}
670674

671675
if intrinsic == sym::assert_mem_uninitialized_valid
672-
&& !fx.tcx.permits_uninit_init(fx.param_env().and(layout))
676+
&& !fx
677+
.tcx
678+
.permits_uninit_init(fx.param_env().and(ty))
679+
.expect("expected to have layout during codegen")
673680
{
674681
with_no_trimmed_paths!({
675682
crate::base::codegen_panic_nounwind(

0 commit comments

Comments
 (0)