Skip to content

Commit f5fd967

Browse files
committed
Merge from rustc
2 parents 09ef8ec + 2d0ea79 commit f5fd967

File tree

227 files changed

+3526
-1534
lines changed

Some content is hidden

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

227 files changed

+3526
-1534
lines changed

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ pub trait MutVisitor: Sized {
330330
fn visit_capture_by(&mut self, capture_by: &mut CaptureBy) {
331331
walk_capture_by(self, capture_by)
332332
}
333+
334+
fn visit_fn_ret_ty(&mut self, fn_ret_ty: &mut FnRetTy) {
335+
walk_fn_ret_ty(self, fn_ret_ty)
336+
}
333337
}
334338

335339
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
@@ -609,7 +613,7 @@ fn walk_angle_bracketed_parameter_data<T: MutVisitor>(vis: &mut T, data: &mut An
609613
fn walk_parenthesized_parameter_data<T: MutVisitor>(vis: &mut T, args: &mut ParenthesizedArgs) {
610614
let ParenthesizedArgs { inputs, output, span, inputs_span } = args;
611615
visit_thin_vec(inputs, |input| vis.visit_ty(input));
612-
walk_fn_ret_ty(vis, output);
616+
vis.visit_fn_ret_ty(output);
613617
vis.visit_span(span);
614618
vis.visit_span(inputs_span);
615619
}
@@ -911,7 +915,7 @@ fn walk_fn<T: MutVisitor>(vis: &mut T, kind: FnKind<'_>) {
911915
fn walk_fn_decl<T: MutVisitor>(vis: &mut T, decl: &mut P<FnDecl>) {
912916
let FnDecl { inputs, output } = decl.deref_mut();
913917
inputs.flat_map_in_place(|param| vis.flat_map_param(param));
914-
walk_fn_ret_ty(vis, output);
918+
vis.visit_fn_ret_ty(output);
915919
}
916920

917921
fn walk_fn_ret_ty<T: MutVisitor>(vis: &mut T, fn_ret_ty: &mut FnRetTy) {

compiler/rustc_ast/src/visit.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ pub trait Visitor<'ast>: Sized {
299299
fn visit_coroutine_kind(&mut self, _coroutine_kind: &'ast CoroutineKind) -> Self::Result {
300300
Self::Result::output()
301301
}
302+
fn visit_fn_decl(&mut self, fn_decl: &'ast FnDecl) -> Self::Result {
303+
walk_fn_decl(self, fn_decl)
304+
}
305+
fn visit_qself(&mut self, qs: &'ast Option<P<QSelf>>) -> Self::Result {
306+
walk_qself(self, qs)
307+
}
302308
}
303309

304310
pub fn walk_crate<'a, V: Visitor<'a>>(visitor: &mut V, krate: &'a Crate) -> V::Result {
@@ -434,13 +440,13 @@ impl WalkItemKind for ItemKind {
434440
body,
435441
from_glob: _,
436442
}) => {
437-
try_visit!(walk_qself(visitor, qself));
443+
try_visit!(visitor.visit_qself(qself));
438444
try_visit!(visitor.visit_path(path, *id));
439445
visit_opt!(visitor, visit_ident, rename);
440446
visit_opt!(visitor, visit_block, body);
441447
}
442448
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
443-
try_visit!(walk_qself(visitor, qself));
449+
try_visit!(visitor.visit_qself(qself));
444450
try_visit!(visitor.visit_path(prefix, id));
445451
if let Some(suffixes) = suffixes {
446452
for (ident, rename) in suffixes {
@@ -518,10 +524,10 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) -> V::Result {
518524
let BareFnTy { safety: _, ext: _, generic_params, decl, decl_span: _ } =
519525
&**function_declaration;
520526
walk_list!(visitor, visit_generic_param, generic_params);
521-
try_visit!(walk_fn_decl(visitor, decl));
527+
try_visit!(visitor.visit_fn_decl(decl));
522528
}
523529
TyKind::Path(maybe_qself, path) => {
524-
try_visit!(walk_qself(visitor, maybe_qself));
530+
try_visit!(visitor.visit_qself(maybe_qself));
525531
try_visit!(visitor.visit_path(path, *id));
526532
}
527533
TyKind::Pat(ty, pat) => {
@@ -652,16 +658,16 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
652658
let Pat { id, kind, span: _, tokens: _ } = pattern;
653659
match kind {
654660
PatKind::TupleStruct(opt_qself, path, elems) => {
655-
try_visit!(walk_qself(visitor, opt_qself));
661+
try_visit!(visitor.visit_qself(opt_qself));
656662
try_visit!(visitor.visit_path(path, *id));
657663
walk_list!(visitor, visit_pat, elems);
658664
}
659665
PatKind::Path(opt_qself, path) => {
660-
try_visit!(walk_qself(visitor, opt_qself));
666+
try_visit!(visitor.visit_qself(opt_qself));
661667
try_visit!(visitor.visit_path(path, *id))
662668
}
663669
PatKind::Struct(opt_qself, path, fields, _rest) => {
664-
try_visit!(walk_qself(visitor, opt_qself));
670+
try_visit!(visitor.visit_qself(opt_qself));
665671
try_visit!(visitor.visit_path(path, *id));
666672
walk_list!(visitor, visit_pat_field, fields);
667673
}
@@ -846,13 +852,13 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Resu
846852
// Identifier and visibility are visited as a part of the item.
847853
try_visit!(visitor.visit_fn_header(header));
848854
try_visit!(visitor.visit_generics(generics));
849-
try_visit!(walk_fn_decl(visitor, decl));
855+
try_visit!(visitor.visit_fn_decl(decl));
850856
visit_opt!(visitor, visit_block, body);
851857
}
852858
FnKind::Closure(binder, coroutine_kind, decl, body) => {
853859
try_visit!(visitor.visit_closure_binder(binder));
854860
visit_opt!(visitor, visit_coroutine_kind, coroutine_kind.as_ref());
855-
try_visit!(walk_fn_decl(visitor, decl));
861+
try_visit!(visitor.visit_fn_decl(decl));
856862
try_visit!(visitor.visit_expr(body));
857863
}
858864
}
@@ -902,13 +908,13 @@ impl WalkItemKind for AssocItemKind {
902908
body,
903909
from_glob: _,
904910
}) => {
905-
try_visit!(walk_qself(visitor, qself));
911+
try_visit!(visitor.visit_qself(qself));
906912
try_visit!(visitor.visit_path(path, *id));
907913
visit_opt!(visitor, visit_ident, rename);
908914
visit_opt!(visitor, visit_block, body);
909915
}
910916
AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
911-
try_visit!(walk_qself(visitor, qself));
917+
try_visit!(visitor.visit_qself(qself));
912918
try_visit!(visitor.visit_path(prefix, id));
913919
if let Some(suffixes) = suffixes {
914920
for (ident, rename) in suffixes {
@@ -1023,7 +1029,7 @@ pub fn walk_inline_asm_sym<'a, V: Visitor<'a>>(
10231029
visitor: &mut V,
10241030
InlineAsmSym { id, qself, path }: &'a InlineAsmSym,
10251031
) -> V::Result {
1026-
try_visit!(walk_qself(visitor, qself));
1032+
try_visit!(visitor.visit_qself(qself));
10271033
visitor.visit_path(path, *id)
10281034
}
10291035

@@ -1055,7 +1061,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
10551061
}
10561062
ExprKind::Struct(se) => {
10571063
let StructExpr { qself, path, fields, rest } = &**se;
1058-
try_visit!(walk_qself(visitor, qself));
1064+
try_visit!(visitor.visit_qself(qself));
10591065
try_visit!(visitor.visit_path(path, *id));
10601066
walk_list!(visitor, visit_expr_field, fields);
10611067
match rest {
@@ -1164,7 +1170,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) -> V
11641170
}
11651171
ExprKind::Underscore => {}
11661172
ExprKind::Path(maybe_qself, path) => {
1167-
try_visit!(walk_qself(visitor, maybe_qself));
1173+
try_visit!(visitor.visit_qself(maybe_qself));
11681174
try_visit!(visitor.visit_path(path, *id));
11691175
}
11701176
ExprKind::Break(opt_label, opt_expr) => {

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ impl<'tcx> rustc_mir_dataflow::Analysis<'tcx> for Borrows<'_, 'tcx> {
641641
| mir::StatementKind::Coverage(..)
642642
| mir::StatementKind::Intrinsic(..)
643643
| mir::StatementKind::ConstEvalCounter
644+
| mir::StatementKind::BackwardIncompatibleDropHint { .. }
644645
| mir::StatementKind::Nop => {}
645646
}
646647
}

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,8 @@ impl<'a, 'tcx> ResultsVisitor<'a, 'tcx, Borrowck<'a, 'tcx>> for MirBorrowckCtxt<
652652
| StatementKind::Coverage(..)
653653
// These do not actually affect borrowck
654654
| StatementKind::ConstEvalCounter
655+
// This do not affect borrowck
656+
| StatementKind::BackwardIncompatibleDropHint { .. }
655657
| StatementKind::StorageLive(..) => {}
656658
StatementKind::StorageDead(local) => {
657659
self.access_place(

compiler/rustc_borrowck/src/polonius/loan_invalidations.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LoanInvalidationsGenerator<'a, 'tcx> {
8888
| StatementKind::Nop
8989
| StatementKind::Retag { .. }
9090
| StatementKind::Deinit(..)
91+
| StatementKind::BackwardIncompatibleDropHint { .. }
9192
| StatementKind::SetDiscriminant { .. } => {
9293
bug!("Statement not allowed in this MIR phase")
9394
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12521252
| StatementKind::Coverage(..)
12531253
| StatementKind::ConstEvalCounter
12541254
| StatementKind::PlaceMention(..)
1255+
| StatementKind::BackwardIncompatibleDropHint { .. }
12551256
| StatementKind::Nop => {}
12561257
StatementKind::Deinit(..) | StatementKind::SetDiscriminant { .. } => {
12571258
bug!("Statement not allowed in this MIR phase")
@@ -1727,7 +1728,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
17271728
// `Sized` bound in no way depends on precise regions, so this
17281729
// shouldn't affect `is_sized`.
17291730
let erased_ty = tcx.erase_regions(ty);
1730-
if !erased_ty.is_sized(tcx, self.infcx.param_env) {
1731+
// FIXME(#132279): Using `Ty::is_sized` causes us to incorrectly handle opaques here.
1732+
if !erased_ty.is_sized(tcx, self.infcx.typing_env(self.infcx.param_env)) {
17311733
// in current MIR construction, all non-control-flow rvalue
17321734
// expressions evaluate through `as_temp` or `into` a return
17331735
// slot or local, so to find all unsized rvalues it is enough

compiler/rustc_codegen_cranelift/scripts/setup_rust_fork.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ local-rebuild = true
3838
codegen-backends = ["cranelift"]
3939
deny-warnings = false
4040
verbose-tests = false
41+
# The cg_clif sysroot doesn't contain llvm tools and unless llvm_tools is
42+
# disabled bootstrap will crash trying to copy llvm tools for the bootstrap
43+
# compiler.
44+
llvm_tools = false
45+
4146
EOF
4247
popd
4348

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1111
use rustc_middle::mir::InlineAsmMacro;
1212
use rustc_middle::ty::TypeVisitableExt;
1313
use rustc_middle::ty::adjustment::PointerCoercion;
14-
use rustc_middle::ty::layout::FnAbiOf;
14+
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv};
1515
use rustc_middle::ty::print::with_no_trimmed_paths;
1616

1717
use crate::constant::ConstantCx;
@@ -841,7 +841,7 @@ fn codegen_stmt<'tcx>(
841841
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
842842
}
843843
Rvalue::NullaryOp(ref null_op, ty) => {
844-
assert!(lval.layout().ty.is_sized(fx.tcx, ty::ParamEnv::reveal_all()));
844+
assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env()));
845845
let layout = fx.layout_of(fx.monomorphize(ty));
846846
let val = match null_op {
847847
NullOp::SizeOf => layout.size.bytes(),
@@ -924,6 +924,7 @@ fn codegen_stmt<'tcx>(
924924
| StatementKind::FakeRead(..)
925925
| StatementKind::Retag { .. }
926926
| StatementKind::PlaceMention(..)
927+
| StatementKind::BackwardIncompatibleDropHint { .. }
927928
| StatementKind::AscribeUserType(..) => {}
928929

929930
StatementKind::Coverage { .. } => unreachable!(),

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn clif_pair_type_from_ty<'tcx>(
103103

104104
/// Is a pointer to this type a wide ptr?
105105
pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
106-
if ty.is_sized(tcx, ty::ParamEnv::reveal_all()) {
106+
if ty.is_sized(tcx, ty::TypingEnv::fully_monomorphized()) {
107107
return false;
108108
}
109109

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
583583
| StatementKind::PlaceMention(..)
584584
| StatementKind::Coverage(_)
585585
| StatementKind::ConstEvalCounter
586+
| StatementKind::BackwardIncompatibleDropHint { .. }
586587
| StatementKind::Nop => {}
587588
}
588589
}

0 commit comments

Comments
 (0)