authorbors <bors@rust-lang.org> 2024-09-12 12:56:55 UTC
committerbors <bors@rust-lang.org> 2024-09-12 12:56:55 UTC
log394c4060d2d971b0ce6b9c86f9f5ef6dff7ae00e
treec4f3ec42008bc271abfa608381ce9e0f2da96662
parentf753bc769b16ca9673f11a4cc06e5cc681efd84e
parent458a57adeba49fb5b9dcf379e96622ff93b567e0

Auto merge of #130269 - Zalathar:rollup-coxzt2t, r=Zalathar

Rollup of 8 pull requests Successful merges: - #125060 (Expand documentation of PathBuf, discussing lack of sanitization) - #129367 (Fix default/minimum deployment target for Aarch64 simulator targets) - #130156 (Add test for S_OBJNAME & update test for LF_BUILDINFO cl and cmd) - #130160 (Fix `slice::first_mut` docs) - #130235 (Simplify some nested `if` statements) - #130250 (Fix `clippy::useless_conversion`) - #130252 (Properly report error on `const gen fn`) - #130256 (Re-run coverage tests if `coverage-dump` was modified) r? `@ghost` `@rustbot` modify labels: rollup

90 files changed, 740 insertions(+), 761 deletions(-)

compiler/rustc_ast/src/ast.rs+8-10
......@@ -2602,12 +2602,12 @@ impl CoroutineKind {
26022602 }
26032603 }
26042604
2605 pub fn is_async(self) -> bool {
2606 matches!(self, CoroutineKind::Async { .. })
2607 }
2608
2609 pub fn is_gen(self) -> bool {
2610 matches!(self, CoroutineKind::Gen { .. })
2605 pub fn as_str(self) -> &'static str {
2606 match self {
2607 CoroutineKind::Async { .. } => "async",
2608 CoroutineKind::Gen { .. } => "gen",
2609 CoroutineKind::AsyncGen { .. } => "async gen",
2610 }
26112611 }
26122612
26132613 pub fn closure_id(self) -> NodeId {
......@@ -3486,7 +3486,7 @@ impl From<ForeignItemKind> for ItemKind {
34863486 fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
34873487 match foreign_item_kind {
34883488 ForeignItemKind::Static(box static_foreign_item) => {
3489 ItemKind::Static(Box::new(static_foreign_item.into()))
3489 ItemKind::Static(Box::new(static_foreign_item))
34903490 }
34913491 ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
34923492 ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
......@@ -3500,9 +3500,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
35003500
35013501 fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
35023502 Ok(match item_kind {
3503 ItemKind::Static(box static_item) => {
3504 ForeignItemKind::Static(Box::new(static_item.into()))
3505 }
3503 ItemKind::Static(box static_item) => ForeignItemKind::Static(Box::new(static_item)),
35063504 ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),
35073505 ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind),
35083506 ItemKind::MacCall(a) => ForeignItemKind::MacCall(a),
compiler/rustc_ast/src/entry.rs+9-11
......@@ -45,18 +45,16 @@ pub fn entry_point_type(
4545 EntryPointType::Start
4646 } else if attr::contains_name(attrs, sym::rustc_main) {
4747 EntryPointType::RustcMainAttr
48 } else {
49 if let Some(name) = name
50 && name == sym::main
51 {
52 if at_root {
53 // This is a top-level function so it can be `main`.
54 EntryPointType::MainNamed
55 } else {
56 EntryPointType::OtherMain
57 }
48 } else if let Some(name) = name
49 && name == sym::main
50 {
51 if at_root {
52 // This is a top-level function so it can be `main`.
53 EntryPointType::MainNamed
5854 } else {
59 EntryPointType::None
55 EntryPointType::OtherMain
6056 }
57 } else {
58 EntryPointType::None
6159 }
6260}
compiler/rustc_ast_lowering/src/index.rs+17-19
......@@ -78,26 +78,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
7878
7979 // Make sure that the DepNode of some node coincides with the HirId
8080 // owner of that node.
81 if cfg!(debug_assertions) {
82 if hir_id.owner != self.owner {
83 span_bug!(
84 span,
85 "inconsistent HirId at `{:?}` for `{:?}`: \
81 if cfg!(debug_assertions) && hir_id.owner != self.owner {
82 span_bug!(
83 span,
84 "inconsistent HirId at `{:?}` for `{:?}`: \
8685 current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
87 self.tcx.sess.source_map().span_to_diagnostic_string(span),
88 node,
89 self.tcx
90 .definitions_untracked()
91 .def_path(self.owner.def_id)
92 .to_string_no_crate_verbose(),
93 self.owner,
94 self.tcx
95 .definitions_untracked()
96 .def_path(hir_id.owner.def_id)
97 .to_string_no_crate_verbose(),
98 hir_id.owner,
99 )
100 }
86 self.tcx.sess.source_map().span_to_diagnostic_string(span),
87 node,
88 self.tcx
89 .definitions_untracked()
90 .def_path(self.owner.def_id)
91 .to_string_no_crate_verbose(),
92 self.owner,
93 self.tcx
94 .definitions_untracked()
95 .def_path(hir_id.owner.def_id)
96 .to_string_no_crate_verbose(),
97 hir_id.owner,
98 )
10199 }
102100
103101 self.nodes[hir_id.local_id] = ParentedNode { parent: self.parent_node, node };
compiler/rustc_ast_lowering/src/item.rs+4-6
......@@ -628,13 +628,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
628628 .map_or(Const::No, |attr| Const::Yes(attr.span)),
629629 _ => Const::No,
630630 }
631 } else if self.tcx.is_const_trait(def_id) {
632 // FIXME(effects) span
633 Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
631634 } else {
632 if self.tcx.is_const_trait(def_id) {
633 // FIXME(effects) span
634 Const::Yes(self.tcx.def_ident_span(def_id).unwrap())
635 } else {
636 Const::No
637 }
635 Const::No
638636 }
639637 } else {
640638 Const::No
compiler/rustc_ast_passes/messages.ftl+5-5
......@@ -40,15 +40,15 @@ ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block
4040
4141ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect
4242
43ast_passes_const_and_async = functions cannot be both `const` and `async`
44 .const = `const` because of this
45 .async = `async` because of this
46 .label = {""}
47
4843ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic
4944 .const = `const` because of this
5045 .variadic = C-variadic because of this
5146
47ast_passes_const_and_coroutine = functions cannot be both `const` and `{$coroutine_kind}`
48 .const = `const` because of this
49 .coroutine = `{$coroutine_kind}` because of this
50 .label = {""}
51
5252ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types
5353
5454ast_passes_const_without_body =
compiler/rustc_ast_passes/src/ast_validation.rs+13-18
......@@ -447,13 +447,13 @@ impl<'a> AstValidator<'a> {
447447 fn check_item_safety(&self, span: Span, safety: Safety) {
448448 match self.extern_mod_safety {
449449 Some(extern_safety) => {
450 if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_)) {
451 if extern_safety == Safety::Default {
452 self.dcx().emit_err(errors::InvalidSafetyOnExtern {
453 item_span: span,
454 block: Some(self.current_extern_span().shrink_to_lo()),
455 });
456 }
450 if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_))
451 && extern_safety == Safety::Default
452 {
453 self.dcx().emit_err(errors::InvalidSafetyOnExtern {
454 item_span: span,
455 block: Some(self.current_extern_span().shrink_to_lo()),
456 });
457457 }
458458 }
459459 None => {
......@@ -1418,21 +1418,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
14181418
14191419 // Functions cannot both be `const async` or `const gen`
14201420 if let Some(&FnHeader {
1421 constness: Const::Yes(cspan),
1421 constness: Const::Yes(const_span),
14221422 coroutine_kind: Some(coroutine_kind),
14231423 ..
14241424 }) = fk.header()
14251425 {
1426 let aspan = match coroutine_kind {
1427 CoroutineKind::Async { span: aspan, .. }
1428 | CoroutineKind::Gen { span: aspan, .. }
1429 | CoroutineKind::AsyncGen { span: aspan, .. } => aspan,
1430 };
1431 // FIXME(gen_blocks): Report a different error for `const gen`
1432 self.dcx().emit_err(errors::ConstAndAsync {
1433 spans: vec![cspan, aspan],
1434 cspan,
1435 aspan,
1426 self.dcx().emit_err(errors::ConstAndCoroutine {
1427 spans: vec![coroutine_kind.span(), const_span],
1428 const_span,
1429 coroutine_span: coroutine_kind.span(),
1430 coroutine_kind: coroutine_kind.as_str(),
14361431 span,
14371432 });
14381433 }
compiler/rustc_ast_passes/src/errors.rs+6-5
......@@ -657,16 +657,17 @@ pub(crate) enum TildeConstReason {
657657}
658658
659659#[derive(Diagnostic)]
660#[diag(ast_passes_const_and_async)]
661pub(crate) struct ConstAndAsync {
660#[diag(ast_passes_const_and_coroutine)]
661pub(crate) struct ConstAndCoroutine {
662662 #[primary_span]
663663 pub spans: Vec<Span>,
664664 #[label(ast_passes_const)]
665 pub cspan: Span,
666 #[label(ast_passes_async)]
667 pub aspan: Span,
665 pub const_span: Span,
666 #[label(ast_passes_coroutine)]
667 pub coroutine_span: Span,
668668 #[label]
669669 pub span: Span,
670 pub coroutine_kind: &'static str,
670671}
671672
672673#[derive(Diagnostic)]
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs+22-25
......@@ -2574,33 +2574,31 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
25742574 }
25752575 impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> {
25762576 fn visit_expr(&mut self, e: &'hir hir::Expr<'hir>) {
2577 if e.span.contains(self.capture_span) {
2578 if let hir::ExprKind::Closure(&hir::Closure {
2577 if e.span.contains(self.capture_span)
2578 && let hir::ExprKind::Closure(&hir::Closure {
25792579 kind: hir::ClosureKind::Closure,
25802580 body,
25812581 fn_arg_span,
25822582 fn_decl: hir::FnDecl { inputs, .. },
25832583 ..
25842584 }) = e.kind
2585 && let hir::Node::Expr(body) = self.tcx.hir_node(body.hir_id)
2586 {
2587 self.suggest_arg = "this: &Self".to_string();
2588 if inputs.len() > 0 {
2589 self.suggest_arg.push_str(", ");
2590 }
2591 self.in_closure = true;
2592 self.closure_arg_span = fn_arg_span;
2593 self.visit_expr(body);
2594 self.in_closure = false;
2585 && let hir::Node::Expr(body) = self.tcx.hir_node(body.hir_id)
2586 {
2587 self.suggest_arg = "this: &Self".to_string();
2588 if inputs.len() > 0 {
2589 self.suggest_arg.push_str(", ");
25952590 }
2591 self.in_closure = true;
2592 self.closure_arg_span = fn_arg_span;
2593 self.visit_expr(body);
2594 self.in_closure = false;
25962595 }
2597 if let hir::Expr { kind: hir::ExprKind::Path(path), .. } = e {
2598 if let hir::QPath::Resolved(_, hir::Path { segments: [seg], .. }) = path
2599 && seg.ident.name == kw::SelfLower
2600 && self.in_closure
2601 {
2602 self.closure_change_spans.push(e.span);
2603 }
2596 if let hir::Expr { kind: hir::ExprKind::Path(path), .. } = e
2597 && let hir::QPath::Resolved(_, hir::Path { segments: [seg], .. }) = path
2598 && seg.ident.name == kw::SelfLower
2599 && self.in_closure
2600 {
2601 self.closure_change_spans.push(e.span);
26042602 }
26052603 hir::intravisit::walk_expr(self, e);
26062604 }
......@@ -2609,8 +2607,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
26092607 if let hir::Pat { kind: hir::PatKind::Binding(_, hir_id, _ident, _), .. } =
26102608 local.pat
26112609 && let Some(init) = local.init
2612 {
2613 if let hir::Expr {
2610 && let hir::Expr {
26142611 kind:
26152612 hir::ExprKind::Closure(&hir::Closure {
26162613 kind: hir::ClosureKind::Closure,
......@@ -2618,11 +2615,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
26182615 }),
26192616 ..
26202617 } = init
2621 && init.span.contains(self.capture_span)
2622 {
2623 self.closure_local_id = Some(*hir_id);
2624 }
2618 && init.span.contains(self.capture_span)
2619 {
2620 self.closure_local_id = Some(*hir_id);
26252621 }
2622
26262623 hir::intravisit::walk_local(self, local);
26272624 }
26282625
compiler/rustc_borrowck/src/lib.rs+5-5
......@@ -2069,12 +2069,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
20692069 // no move out from an earlier location) then this is an attempt at initialization
20702070 // of the union - we should error in that case.
20712071 let tcx = this.infcx.tcx;
2072 if base.ty(this.body(), tcx).ty.is_union() {
2073 if this.move_data.path_map[mpi].iter().any(|moi| {
2072 if base.ty(this.body(), tcx).ty.is_union()
2073 && this.move_data.path_map[mpi].iter().any(|moi| {
20742074 this.move_data.moves[*moi].source.is_predecessor_of(location, this.body)
2075 }) {
2076 return;
2077 }
2075 })
2076 {
2077 return;
20782078 }
20792079
20802080 this.report_use_of_moved_or_uninitialized(
compiler/rustc_borrowck/src/region_infer/values.rs+4-8
......@@ -118,10 +118,8 @@ impl LivenessValues {
118118 debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location);
119119 if let Some(points) = &mut self.points {
120120 points.insert(region, point);
121 } else {
122 if self.elements.point_in_range(point) {
123 self.live_regions.as_mut().unwrap().insert(region);
124 }
121 } else if self.elements.point_in_range(point) {
122 self.live_regions.as_mut().unwrap().insert(region);
125123 }
126124
127125 // When available, record the loans flowing into this region as live at the given point.
......@@ -137,10 +135,8 @@ impl LivenessValues {
137135 debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points);
138136 if let Some(this) = &mut self.points {
139137 this.union_row(region, points);
140 } else {
141 if points.iter().any(|point| self.elements.point_in_range(point)) {
142 self.live_regions.as_mut().unwrap().insert(region);
143 }
138 } else if points.iter().any(|point| self.elements.point_in_range(point)) {
139 self.live_regions.as_mut().unwrap().insert(region);
144140 }
145141
146142 // When available, record the loans flowing into this region as live at the given points.
compiler/rustc_borrowck/src/type_check/liveness/trace.rs+5-5
......@@ -353,11 +353,11 @@ impl<'a, 'typeck, 'b, 'tcx> LivenessResults<'a, 'typeck, 'b, 'tcx> {
353353 let location = self.cx.elements.to_location(drop_point);
354354 debug_assert_eq!(self.cx.body.terminator_loc(location.block), location,);
355355
356 if self.cx.initialized_at_terminator(location.block, mpi) {
357 if self.drop_live_at.insert(drop_point) {
358 self.drop_locations.push(location);
359 self.stack.push(drop_point);
360 }
356 if self.cx.initialized_at_terminator(location.block, mpi)
357 && self.drop_live_at.insert(drop_point)
358 {
359 self.drop_locations.push(location);
360 self.stack.push(drop_point);
361361 }
362362 }
363363
compiler/rustc_builtin_macros/src/asm.rs+4-6
......@@ -235,13 +235,11 @@ pub fn parse_asm_args<'a>(
235235 continue;
236236 }
237237 args.named_args.insert(name, slot);
238 } else {
239 if !args.named_args.is_empty() || !args.reg_args.is_empty() {
240 let named = args.named_args.values().map(|p| args.operands[*p].1).collect();
241 let explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
238 } else if !args.named_args.is_empty() || !args.reg_args.is_empty() {
239 let named = args.named_args.values().map(|p| args.operands[*p].1).collect();
240 let explicit = args.reg_args.iter().map(|p| args.operands[p].1).collect();
242241
243 dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
244 }
242 dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit });
245243 }
246244 }
247245
compiler/rustc_codegen_llvm/src/back/lto.rs+3-5
......@@ -92,11 +92,9 @@ fn prepare_lto(
9292 dcx.emit_err(LtoDylib);
9393 return Err(FatalError);
9494 }
95 } else if *crate_type == CrateType::ProcMacro {
96 if !cgcx.opts.unstable_opts.dylib_lto {
97 dcx.emit_err(LtoProcMacro);
98 return Err(FatalError);
99 }
95 } else if *crate_type == CrateType::ProcMacro && !cgcx.opts.unstable_opts.dylib_lto {
96 dcx.emit_err(LtoProcMacro);
97 return Err(FatalError);
10098 }
10199 }
102100
compiler/rustc_codegen_ssa/src/back/link.rs+10-18
......@@ -281,12 +281,10 @@ pub fn each_linked_rlib(
281281 let used_crate_source = &info.used_crate_source[&cnum];
282282 if let Some((path, _)) = &used_crate_source.rlib {
283283 f(cnum, path);
284 } else if used_crate_source.rmeta.is_some() {
285 return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
284286 } else {
285 if used_crate_source.rmeta.is_some() {
286 return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name });
287 } else {
288 return Err(errors::LinkRlibError::NotFound { crate_name });
289 }
287 return Err(errors::LinkRlibError::NotFound { crate_name });
290288 }
291289 }
292290 Ok(())
......@@ -628,12 +626,10 @@ fn link_staticlib(
628626 let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum];
629627 if let Some((path, _)) = &used_crate_source.dylib {
630628 all_rust_dylibs.push(&**path);
629 } else if used_crate_source.rmeta.is_some() {
630 sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
631631 } else {
632 if used_crate_source.rmeta.is_some() {
633 sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name });
634 } else {
635 sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
636 }
632 sess.dcx().emit_fatal(errors::LinkRlibError::NotFound { crate_name });
637633 }
638634 }
639635
......@@ -1972,10 +1968,8 @@ fn add_late_link_args(
19721968 if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) {
19731969 cmd.verbatim_args(args.iter().map(Deref::deref));
19741970 }
1975 } else {
1976 if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
1977 cmd.verbatim_args(args.iter().map(Deref::deref));
1978 }
1971 } else if let Some(args) = sess.target.late_link_args_static.get(&flavor) {
1972 cmd.verbatim_args(args.iter().map(Deref::deref));
19791973 }
19801974 if let Some(args) = sess.target.late_link_args.get(&flavor) {
19811975 cmd.verbatim_args(args.iter().map(Deref::deref));
......@@ -2635,10 +2629,8 @@ fn add_native_libs_from_crate(
26352629 if link_static {
26362630 cmd.link_staticlib_by_name(name, verbatim, false);
26372631 }
2638 } else {
2639 if link_dynamic {
2640 cmd.link_dylib_by_name(name, verbatim, true);
2641 }
2632 } else if link_dynamic {
2633 cmd.link_dylib_by_name(name, verbatim, true);
26422634 }
26432635 }
26442636 NativeLibKind::Framework { as_needed } => {
compiler/rustc_codegen_ssa/src/back/linker.rs+5-7
......@@ -791,14 +791,12 @@ impl<'a> Linker for GccLinker<'a> {
791791 self.link_arg("-exported_symbols_list").link_arg(path);
792792 } else if self.sess.target.is_like_solaris {
793793 self.link_arg("-M").link_arg(path);
794 } else if is_windows {
795 self.link_arg(path);
794796 } else {
795 if is_windows {
796 self.link_arg(path);
797 } else {
798 let mut arg = OsString::from("--version-script=");
799 arg.push(path);
800 self.link_arg(arg).link_arg("--no-undefined-version");
801 }
797 let mut arg = OsString::from("--version-script=");
798 arg.push(path);
799 self.link_arg(arg).link_arg("--no-undefined-version");
802800 }
803801 }
804802
compiler/rustc_codegen_ssa/src/codegen_attrs.rs+19-22
......@@ -617,32 +617,29 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
617617 // purpose functions as they wouldn't have the right target features
618618 // enabled. For that reason we also forbid #[inline(always)] as it can't be
619619 // respected.
620 if !codegen_fn_attrs.target_features.is_empty() {
621 if codegen_fn_attrs.inline == InlineAttr::Always {
622 if let Some(span) = inline_span {
623 tcx.dcx().span_err(
624 span,
625 "cannot use `#[inline(always)]` with \
620 if !codegen_fn_attrs.target_features.is_empty() && codegen_fn_attrs.inline == InlineAttr::Always
621 {
622 if let Some(span) = inline_span {
623 tcx.dcx().span_err(
624 span,
625 "cannot use `#[inline(always)]` with \
626626 `#[target_feature]`",
627 );
628 }
627 );
629628 }
630629 }
631630
632 if !codegen_fn_attrs.no_sanitize.is_empty() {
633 if codegen_fn_attrs.inline == InlineAttr::Always {
634 if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
635 let hir_id = tcx.local_def_id_to_hir_id(did);
636 tcx.node_span_lint(
637 lint::builtin::INLINE_NO_SANITIZE,
638 hir_id,
639 no_sanitize_span,
640 |lint| {
641 lint.primary_message("`no_sanitize` will have no effect after inlining");
642 lint.span_note(inline_span, "inlining requested here");
643 },
644 )
645 }
631 if !codegen_fn_attrs.no_sanitize.is_empty() && codegen_fn_attrs.inline == InlineAttr::Always {
632 if let (Some(no_sanitize_span), Some(inline_span)) = (no_sanitize_span, inline_span) {
633 let hir_id = tcx.local_def_id_to_hir_id(did);
634 tcx.node_span_lint(
635 lint::builtin::INLINE_NO_SANITIZE,
636 hir_id,
637 no_sanitize_span,
638 |lint| {
639 lint.primary_message("`no_sanitize` will have no effect after inlining");
640 lint.span_note(inline_span, "inlining requested here");
641 },
642 )
646643 }
647644 }
648645
compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs+6-8
......@@ -236,15 +236,13 @@ fn push_debuginfo_type_name<'tcx>(
236236 let has_enclosing_parens = if cpp_like_debuginfo {
237237 output.push_str("dyn$<");
238238 false
239 } else if trait_data.len() > 1 && auto_traits.len() != 0 {
240 // We need enclosing parens because there is more than one trait
241 output.push_str("(dyn ");
242 true
239243 } else {
240 if trait_data.len() > 1 && auto_traits.len() != 0 {
241 // We need enclosing parens because there is more than one trait
242 output.push_str("(dyn ");
243 true
244 } else {
245 output.push_str("dyn ");
246 false
247 }
244 output.push_str("dyn ");
245 false
248246 };
249247
250248 if let Some(principal) = trait_data.principal() {
compiler/rustc_const_eval/src/const_eval/eval_queries.rs+1-6
......@@ -75,12 +75,7 @@ fn eval_body_using_ecx<'tcx, R: InterpretationResult<'tcx>>(
7575
7676 // This can't use `init_stack_frame` since `body` is not a function,
7777 // so computing its ABI would fail. It's also not worth it since there are no arguments to pass.
78 ecx.push_stack_frame_raw(
79 cid.instance,
80 body,
81 &ret.clone().into(),
82 StackPopCleanup::Root { cleanup: false },
83 )?;
78 ecx.push_stack_frame_raw(cid.instance, body, &ret, StackPopCleanup::Root { cleanup: false })?;
8479 ecx.storage_live_for_always_live_locals()?;
8580
8681 // The main interpreter loop.
compiler/rustc_const_eval/src/interpret/call.rs+1-1
......@@ -823,7 +823,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
823823 (Abi::Rust, fn_abi),
824824 &[FnArg::Copy(arg.into())],
825825 false,
826 &ret.into(),
826 &ret,
827827 Some(target),
828828 unwind,
829829 )
compiler/rustc_const_eval/src/interpret/eval_context.rs+15-7
......@@ -16,7 +16,7 @@ use rustc_span::Span;
1616use rustc_target::abi::call::FnAbi;
1717use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout};
1818use rustc_trait_selection::traits::ObligationCtxt;
19use tracing::{debug, trace};
19use tracing::{debug, instrument, trace};
2020
2121use super::{
2222 err_inval, throw_inval, throw_ub, throw_ub_custom, Frame, FrameInfo, GlobalId, InterpErrorInfo,
......@@ -315,6 +315,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
315315
316316 /// Check if the two things are equal in the current param_env, using an infctx to get proper
317317 /// equality checks.
318 #[instrument(level = "trace", skip(self), ret)]
318319 pub(super) fn eq_in_param_env<T>(&self, a: T, b: T) -> bool
319320 where
320321 T: PartialEq + TypeFoldable<TyCtxt<'tcx>> + ToTrace<'tcx>,
......@@ -330,13 +331,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
330331 // equate the two trait refs after normalization
331332 let a = ocx.normalize(&cause, self.param_env, a);
332333 let b = ocx.normalize(&cause, self.param_env, b);
333 if ocx.eq(&cause, self.param_env, a, b).is_ok() {
334 if ocx.select_all_or_error().is_empty() {
335 // All good.
336 return true;
337 }
334
335 if let Err(terr) = ocx.eq(&cause, self.param_env, a, b) {
336 trace!(?terr);
337 return false;
338 }
339
340 let errors = ocx.select_all_or_error();
341 if !errors.is_empty() {
342 trace!(?errors);
343 return false;
338344 }
339 return false;
345
346 // All good.
347 true
340348 }
341349
342350 /// Walks up the callstack from the intrinsic's callsite, searching for the first callsite in a
compiler/rustc_driver_impl/src/pretty.rs+2-4
......@@ -222,10 +222,8 @@ impl<'tcx> PrintExtra<'tcx> {
222222}
223223
224224pub fn print<'tcx>(sess: &Session, ppm: PpMode, ex: PrintExtra<'tcx>) {
225 if ppm.needs_analysis() {
226 if ex.tcx().analysis(()).is_err() {
227 FatalError.raise();
228 }
225 if ppm.needs_analysis() && ex.tcx().analysis(()).is_err() {
226 FatalError.raise();
229227 }
230228
231229 let (src, src_name) = get_source(sess);
compiler/rustc_errors/src/diagnostic.rs+2-2
......@@ -681,10 +681,10 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
681681 " ".repeat(expected_padding),
682682 expected_label
683683 ))];
684 msg.extend(expected.0.into_iter());
684 msg.extend(expected.0);
685685 msg.push(StringPart::normal(format!("`{expected_extra}\n")));
686686 msg.push(StringPart::normal(format!("{}{} `", " ".repeat(found_padding), found_label)));
687 msg.extend(found.0.into_iter());
687 msg.extend(found.0);
688688 msg.push(StringPart::normal(format!("`{found_extra}")));
689689
690690 // For now, just attach these as notes.
compiler/rustc_hir_analysis/src/check/check.rs+30-32
......@@ -1151,42 +1151,40 @@ pub(super) fn check_packed(tcx: TyCtxt<'_>, sp: Span, def: ty::AdtDef<'_>) {
11511151 "type has conflicting packed and align representation hints"
11521152 )
11531153 .emit();
1154 } else {
1155 if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
1156 let mut err = struct_span_code_err!(
1157 tcx.dcx(),
1158 sp,
1159 E0588,
1160 "packed type cannot transitively contain a `#[repr(align)]` type"
1161 );
1154 } else if let Some(def_spans) = check_packed_inner(tcx, def.did(), &mut vec![]) {
1155 let mut err = struct_span_code_err!(
1156 tcx.dcx(),
1157 sp,
1158 E0588,
1159 "packed type cannot transitively contain a `#[repr(align)]` type"
1160 );
11621161
1163 err.span_note(
1164 tcx.def_span(def_spans[0].0),
1165 format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
1166 );
1162 err.span_note(
1163 tcx.def_span(def_spans[0].0),
1164 format!("`{}` has a `#[repr(align)]` attribute", tcx.item_name(def_spans[0].0)),
1165 );
11671166
1168 if def_spans.len() > 2 {
1169 let mut first = true;
1170 for (adt_def, span) in def_spans.iter().skip(1).rev() {
1171 let ident = tcx.item_name(*adt_def);
1172 err.span_note(
1173 *span,
1174 if first {
1175 format!(
1176 "`{}` contains a field of type `{}`",
1177 tcx.type_of(def.did()).instantiate_identity(),
1178 ident
1179 )
1180 } else {
1181 format!("...which contains a field of type `{ident}`")
1182 },
1183 );
1184 first = false;
1185 }
1167 if def_spans.len() > 2 {
1168 let mut first = true;
1169 for (adt_def, span) in def_spans.iter().skip(1).rev() {
1170 let ident = tcx.item_name(*adt_def);
1171 err.span_note(
1172 *span,
1173 if first {
1174 format!(
1175 "`{}` contains a field of type `{}`",
1176 tcx.type_of(def.did()).instantiate_identity(),
1177 ident
1178 )
1179 } else {
1180 format!("...which contains a field of type `{ident}`")
1181 },
1182 );
1183 first = false;
11861184 }
1187
1188 err.emit();
11891185 }
1186
1187 err.emit();
11901188 }
11911189 }
11921190}
compiler/rustc_hir_analysis/src/check/mod.rs+4-6
......@@ -186,17 +186,15 @@ fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
186186
187187 if let Ok(alloc) = tcx.eval_static_initializer(id.to_def_id())
188188 && alloc.inner().provenance().ptrs().len() != 0
189 {
190 if attrs
189 && attrs
191190 .link_section
192191 .map(|link_section| !link_section.as_str().starts_with(".init_array"))
193192 .unwrap()
194 {
195 let msg = "statics with a custom `#[link_section]` must be a \
193 {
194 let msg = "statics with a custom `#[link_section]` must be a \
196195 simple list of bytes on the wasm target with no \
197196 extra levels of indirection such as references";
198 tcx.dcx().span_err(tcx.def_span(id), msg);
199 }
197 tcx.dcx().span_err(tcx.def_span(id), msg);
200198 }
201199}
202200
compiler/rustc_hir_analysis/src/check/wfcheck.rs+2-2
......@@ -1602,7 +1602,7 @@ fn check_fn_or_method<'tcx>(
16021602 function: def_id,
16031603 // Note that the `param_idx` of the output type is
16041604 // one greater than the index of the last input type.
1605 param_idx: idx.try_into().unwrap(),
1605 param_idx: idx,
16061606 }),
16071607 ty,
16081608 )
......@@ -1611,7 +1611,7 @@ fn check_fn_or_method<'tcx>(
16111611 for (idx, ty) in sig.inputs_and_output.iter().enumerate() {
16121612 wfcx.register_wf_obligation(
16131613 arg_span(idx),
1614 Some(WellFormedLoc::Param { function: def_id, param_idx: idx.try_into().unwrap() }),
1614 Some(WellFormedLoc::Param { function: def_id, param_idx: idx }),
16151615 ty.into(),
16161616 );
16171617 }
compiler/rustc_hir_analysis/src/coherence/mod.rs+9-11
......@@ -53,17 +53,15 @@ fn enforce_trait_manually_implementable(
5353) -> Result<(), ErrorGuaranteed> {
5454 let impl_header_span = tcx.def_span(impl_def_id);
5555
56 if tcx.is_lang_item(trait_def_id, LangItem::Freeze) {
57 if !tcx.features().freeze_impls {
58 feature_err(
59 &tcx.sess,
60 sym::freeze_impls,
61 impl_header_span,
62 "explicit impls for the `Freeze` trait are not permitted",
63 )
64 .with_span_label(impl_header_span, format!("impl of `Freeze` not allowed"))
65 .emit();
66 }
56 if tcx.is_lang_item(trait_def_id, LangItem::Freeze) && !tcx.features().freeze_impls {
57 feature_err(
58 &tcx.sess,
59 sym::freeze_impls,
60 impl_header_span,
61 "explicit impls for the `Freeze` trait are not permitted",
62 )
63 .with_span_label(impl_header_span, format!("impl of `Freeze` not allowed"))
64 .emit();
6765 }
6866
6967 // Disallow *all* explicit impls of traits marked `#[rustc_deny_explicit_impl]`
compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs+14-16
......@@ -381,24 +381,22 @@ pub(super) fn find_opaque_ty_constraints_for_rpit<'tcx>(
381381 }
382382
383383 mir_opaque_ty.ty
384 } else if let Some(guar) = tables.tainted_by_errors {
385 // Some error in the owner fn prevented us from populating
386 // the `concrete_opaque_types` table.
387 Ty::new_error(tcx, guar)
384388 } else {
385 if let Some(guar) = tables.tainted_by_errors {
386 // Some error in the owner fn prevented us from populating
387 // the `concrete_opaque_types` table.
388 Ty::new_error(tcx, guar)
389 // Fall back to the RPIT we inferred during HIR typeck
390 if let Some(hir_opaque_ty) = hir_opaque_ty {
391 hir_opaque_ty.ty
389392 } else {
390 // Fall back to the RPIT we inferred during HIR typeck
391 if let Some(hir_opaque_ty) = hir_opaque_ty {
392 hir_opaque_ty.ty
393 } else {
394 // We failed to resolve the opaque type or it
395 // resolves to itself. We interpret this as the
396 // no values of the hidden type ever being constructed,
397 // so we can just make the hidden type be `!`.
398 // For backwards compatibility reasons, we fall back to
399 // `()` until we the diverging default is changed.
400 Ty::new_diverging_default(tcx)
401 }
393 // We failed to resolve the opaque type or it
394 // resolves to itself. We interpret this as the
395 // no values of the hidden type ever being constructed,
396 // so we can just make the hidden type be `!`.
397 // For backwards compatibility reasons, we fall back to
398 // `()` until we the diverging default is changed.
399 Ty::new_diverging_default(tcx)
402400 }
403401 }
404402}
compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs+10-12
......@@ -827,20 +827,18 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
827827
828828 if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args
829829 == num_trait_generics_except_self
830 && let Some(span) = self.gen_args.span_ext()
831 && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
830832 {
831 if let Some(span) = self.gen_args.span_ext()
832 && let Ok(snippet) = self.tcx.sess.source_map().span_to_snippet(span)
833 {
834 let sugg = vec![
835 (
836 self.path_segment.ident.span,
837 format!("{}::{}", snippet, self.path_segment.ident),
838 ),
839 (span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()),
840 ];
833 let sugg = vec![
834 (
835 self.path_segment.ident.span,
836 format!("{}::{}", snippet, self.path_segment.ident),
837 ),
838 (span.with_lo(self.path_segment.ident.span.hi()), "".to_owned()),
839 ];
841840
842 err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
843 }
841 err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect);
844842 }
845843 }
846844 }
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+4-6
......@@ -562,13 +562,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
562562 tcx.const_param_default(param.def_id)
563563 .instantiate(tcx, preceding_args)
564564 .into()
565 } else if infer_args {
566 self.lowerer.ct_infer(Some(param), self.span).into()
565567 } else {
566 if infer_args {
567 self.lowerer.ct_infer(Some(param), self.span).into()
568 } else {
569 // We've already errored above about the mismatch.
570 ty::Const::new_misc_error(tcx).into()
571 }
568 // We've already errored above about the mismatch.
569 ty::Const::new_misc_error(tcx).into()
572570 }
573571 }
574572 }
compiler/rustc_hir_typeck/src/cast.rs+5-6
......@@ -732,12 +732,11 @@ impl<'a, 'tcx> CastCheck<'tcx> {
732732 }
733733 _ => return Err(CastError::NonScalar),
734734 };
735 if let ty::Adt(adt_def, _) = *self.expr_ty.kind() {
736 if adt_def.did().krate != LOCAL_CRATE {
737 if adt_def.variants().iter().any(VariantDef::is_field_list_non_exhaustive) {
738 return Err(CastError::ForeignNonExhaustiveAdt);
739 }
740 }
735 if let ty::Adt(adt_def, _) = *self.expr_ty.kind()
736 && adt_def.did().krate != LOCAL_CRATE
737 && adt_def.variants().iter().any(VariantDef::is_field_list_non_exhaustive)
738 {
739 return Err(CastError::ForeignNonExhaustiveAdt);
741740 }
742741 match (t_from, t_cast) {
743742 // These types have invariants! can't cast into them.
compiler/rustc_hir_typeck/src/expr.rs+22-25
......@@ -1780,16 +1780,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17801780 }
17811781
17821782 // Make sure the programmer specified correct number of fields.
1783 if adt_kind == AdtKind::Union {
1784 if hir_fields.len() != 1 {
1785 struct_span_code_err!(
1786 self.dcx(),
1787 span,
1788 E0784,
1789 "union expressions should have exactly one field",
1790 )
1791 .emit();
1792 }
1783 if adt_kind == AdtKind::Union && hir_fields.len() != 1 {
1784 struct_span_code_err!(
1785 self.dcx(),
1786 span,
1787 E0784,
1788 "union expressions should have exactly one field",
1789 )
1790 .emit();
17931791 }
17941792
17951793 // If check_expr_struct_fields hit an error, do not attempt to populate
......@@ -2904,21 +2902,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
29042902 candidate_fields.iter().map(|path| format!("{unwrap}{path}")),
29052903 Applicability::MaybeIncorrect,
29062904 );
2907 } else {
2908 if let Some(field_name) = find_best_match_for_name(&field_names, field.name, None) {
2909 err.span_suggestion_verbose(
2910 field.span,
2911 "a field with a similar name exists",
2912 format!("{unwrap}{}", field_name),
2913 Applicability::MaybeIncorrect,
2914 );
2915 } else if !field_names.is_empty() {
2916 let is = if field_names.len() == 1 { " is" } else { "s are" };
2917 err.note(format!(
2918 "available field{is}: {}",
2919 self.name_series_display(field_names),
2920 ));
2921 }
2905 } else if let Some(field_name) =
2906 find_best_match_for_name(&field_names, field.name, None)
2907 {
2908 err.span_suggestion_verbose(
2909 field.span,
2910 "a field with a similar name exists",
2911 format!("{unwrap}{}", field_name),
2912 Applicability::MaybeIncorrect,
2913 );
2914 } else if !field_names.is_empty() {
2915 let is = if field_names.len() == 1 { " is" } else { "s are" };
2916 err.note(
2917 format!("available field{is}: {}", self.name_series_display(field_names),),
2918 );
29222919 }
29232920 }
29242921 err
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs+1-1
......@@ -2565,7 +2565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
25652565 other_generic_param.name.ident() == generic_param.name.ident()
25662566 },
25672567 ) {
2568 idxs_matched.push(other_idx.into());
2568 idxs_matched.push(other_idx);
25692569 }
25702570
25712571 if idxs_matched.is_empty() {
compiler/rustc_hir_typeck/src/gather_locals.rs+6-8
......@@ -158,14 +158,12 @@ impl<'a, 'tcx> Visitor<'tcx> for GatherLocalsVisitor<'a, 'tcx> {
158158 ),
159159 );
160160 }
161 } else {
162 if !self.fcx.tcx.features().unsized_locals {
163 self.fcx.require_type_is_sized(
164 var_ty,
165 p.span,
166 ObligationCauseCode::VariableType(p.hir_id),
167 );
168 }
161 } else if !self.fcx.tcx.features().unsized_locals {
162 self.fcx.require_type_is_sized(
163 var_ty,
164 p.span,
165 ObligationCauseCode::VariableType(p.hir_id),
166 );
169167 }
170168
171169 debug!(
compiler/rustc_hir_typeck/src/method/suggest.rs+9-10
......@@ -1252,11 +1252,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12521252 && suggested_bounds.contains(parent)
12531253 {
12541254 // We don't suggest `PartialEq` when we already suggest `Eq`.
1255 } else if !suggested_bounds.contains(pred) {
1256 if collect_type_param_suggestions(self_ty, *pred, &p) {
1257 suggested = true;
1258 suggested_bounds.insert(pred);
1259 }
1255 } else if !suggested_bounds.contains(pred)
1256 && collect_type_param_suggestions(self_ty, *pred, &p)
1257 {
1258 suggested = true;
1259 suggested_bounds.insert(pred);
12601260 }
12611261 (
12621262 match parent_pred {
......@@ -1267,14 +1267,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12671267 if !suggested
12681268 && !suggested_bounds.contains(pred)
12691269 && !suggested_bounds.contains(parent_pred)
1270 {
1271 if collect_type_param_suggestions(
1270 && collect_type_param_suggestions(
12721271 self_ty,
12731272 *parent_pred,
12741273 &p,
1275 ) {
1276 suggested_bounds.insert(pred);
1277 }
1274 )
1275 {
1276 suggested_bounds.insert(pred);
12781277 }
12791278 format!("`{p}`\nwhich is required by `{parent_p}`")
12801279 }
compiler/rustc_incremental/src/persist/dirty_clean.rs+3-5
......@@ -417,12 +417,10 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool {
417417fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
418418 if let Some(value) = item.value_str() {
419419 value
420 } else if let Some(ident) = item.ident() {
421 tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
420422 } else {
421 if let Some(ident) = item.ident() {
422 tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident });
423 } else {
424 tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
425 }
423 tcx.dcx().emit_fatal(errors::AssociatedValueExpected { span: item.span() });
426424 }
427425}
428426
compiler/rustc_lint/src/builtin.rs+2-4
......@@ -429,10 +429,8 @@ impl MissingDoc {
429429 // Only check publicly-visible items, using the result from the privacy pass.
430430 // It's an option so the crate root can also use this function (it doesn't
431431 // have a `NodeId`).
432 if def_id != CRATE_DEF_ID {
433 if !cx.effective_visibilities.is_exported(def_id) {
434 return;
435 }
432 if def_id != CRATE_DEF_ID && !cx.effective_visibilities.is_exported(def_id) {
433 return;
436434 }
437435
438436 let attrs = cx.tcx.hir().attrs(cx.tcx.local_def_id_to_hir_id(def_id));
compiler/rustc_middle/src/middle/stability.rs+5-4
......@@ -444,10 +444,11 @@ impl<'tcx> TyCtxt<'tcx> {
444444 // the `-Z force-unstable-if-unmarked` flag present (we're
445445 // compiling a compiler crate), then let this missing feature
446446 // annotation slide.
447 if feature == sym::rustc_private && issue == NonZero::new(27812) {
448 if self.sess.opts.unstable_opts.force_unstable_if_unmarked {
449 return EvalResult::Allow;
450 }
447 if feature == sym::rustc_private
448 && issue == NonZero::new(27812)
449 && self.sess.opts.unstable_opts.force_unstable_if_unmarked
450 {
451 return EvalResult::Allow;
451452 }
452453
453454 if matches!(allow_unstable, AllowUnstable::Yes) {
compiler/rustc_middle/src/mir/interpret/allocation.rs+14-16
......@@ -448,22 +448,20 @@ impl<Prov: Provenance, Extra, Bytes: AllocBytes> Allocation<Prov, Extra, Bytes>
448448 bad: uninit_range,
449449 }))
450450 })?;
451 if !Prov::OFFSET_IS_ADDR {
452 if !self.provenance.range_empty(range, cx) {
453 // Find the provenance.
454 let (offset, _prov) = self
455 .provenance
456 .range_get_ptrs(range, cx)
457 .first()
458 .copied()
459 .expect("there must be provenance somewhere here");
460 let start = offset.max(range.start); // the pointer might begin before `range`!
461 let end = (offset + cx.pointer_size()).min(range.end()); // the pointer might end after `range`!
462 return Err(AllocError::ReadPointerAsInt(Some(BadBytesAccess {
463 access: range,
464 bad: AllocRange::from(start..end),
465 })));
466 }
451 if !Prov::OFFSET_IS_ADDR && !self.provenance.range_empty(range, cx) {
452 // Find the provenance.
453 let (offset, _prov) = self
454 .provenance
455 .range_get_ptrs(range, cx)
456 .first()
457 .copied()
458 .expect("there must be provenance somewhere here");
459 let start = offset.max(range.start); // the pointer might begin before `range`!
460 let end = (offset + cx.pointer_size()).min(range.end()); // the pointer might end after `range`!
461 return Err(AllocError::ReadPointerAsInt(Some(BadBytesAccess {
462 access: range,
463 bad: AllocRange::from(start..end),
464 })));
467465 }
468466 Ok(self.get_bytes_unchecked(range))
469467 }
compiler/rustc_middle/src/mir/pretty.rs+3-5
......@@ -208,12 +208,10 @@ fn dump_path<'tcx>(
208208
209209 let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number {
210210 String::new()
211 } else if pass_num {
212 format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
211213 } else {
212 if pass_num {
213 format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count)
214 } else {
215 ".-------".to_string()
216 }
214 ".-------".to_string()
217215 };
218216
219217 let crate_name = tcx.crate_name(source.def_id().krate);
compiler/rustc_middle/src/ty/consts.rs+1-1
......@@ -396,7 +396,7 @@ impl<'tcx> Const<'tcx> {
396396 Ok((tcx.type_of(unevaluated.def).instantiate(tcx, unevaluated.args), c))
397397 }
398398 Ok(Err(bad_ty)) => Err(Either::Left(bad_ty)),
399 Err(err) => Err(Either::Right(err.into())),
399 Err(err) => Err(Either::Right(err)),
400400 }
401401 }
402402 ConstKind::Value(ty, val) => Ok((ty, val)),
compiler/rustc_middle/src/ty/context.rs+24-26
......@@ -2606,33 +2606,31 @@ impl<'tcx> TyCtxt<'tcx> {
26062606 /// With `cfg(debug_assertions)`, assert that args are compatible with their generics,
26072607 /// and print out the args if not.
26082608 pub fn debug_assert_args_compatible(self, def_id: DefId, args: &'tcx [ty::GenericArg<'tcx>]) {
2609 if cfg!(debug_assertions) {
2610 if !self.check_args_compatible(def_id, args) {
2611 if let DefKind::AssocTy = self.def_kind(def_id)
2612 && let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id))
2613 {
2614 bug!(
2615 "args not compatible with generics for {}: args={:#?}, generics={:#?}",
2616 self.def_path_str(def_id),
2617 args,
2618 // Make `[Self, GAT_ARGS...]` (this could be simplified)
2619 self.mk_args_from_iter(
2620 [self.types.self_param.into()].into_iter().chain(
2621 self.generics_of(def_id)
2622 .own_args(ty::GenericArgs::identity_for_item(self, def_id))
2623 .iter()
2624 .copied()
2625 )
2609 if cfg!(debug_assertions) && !self.check_args_compatible(def_id, args) {
2610 if let DefKind::AssocTy = self.def_kind(def_id)
2611 && let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id))
2612 {
2613 bug!(
2614 "args not compatible with generics for {}: args={:#?}, generics={:#?}",
2615 self.def_path_str(def_id),
2616 args,
2617 // Make `[Self, GAT_ARGS...]` (this could be simplified)
2618 self.mk_args_from_iter(
2619 [self.types.self_param.into()].into_iter().chain(
2620 self.generics_of(def_id)
2621 .own_args(ty::GenericArgs::identity_for_item(self, def_id))
2622 .iter()
2623 .copied()
26262624 )
2627 );
2628 } else {
2629 bug!(
2630 "args not compatible with generics for {}: args={:#?}, generics={:#?}",
2631 self.def_path_str(def_id),
2632 args,
2633 ty::GenericArgs::identity_for_item(self, def_id)
2634 );
2635 }
2625 )
2626 );
2627 } else {
2628 bug!(
2629 "args not compatible with generics for {}: args={:#?}, generics={:#?}",
2630 self.def_path_str(def_id),
2631 args,
2632 ty::GenericArgs::identity_for_item(self, def_id)
2633 );
26362634 }
26372635 }
26382636 }
compiler/rustc_middle/src/ty/layout.rs+4-4
......@@ -1183,10 +1183,10 @@ pub fn fn_can_unwind(tcx: TyCtxt<'_>, fn_def_id: Option<DefId>, abi: SpecAbi) ->
11831183 //
11841184 // This is not part of `codegen_fn_attrs` as it can differ between crates
11851185 // and therefore cannot be computed in core.
1186 if tcx.sess.opts.unstable_opts.panic_in_drop == PanicStrategy::Abort {
1187 if tcx.is_lang_item(did, LangItem::DropInPlace) {
1188 return false;
1189 }
1186 if tcx.sess.opts.unstable_opts.panic_in_drop == PanicStrategy::Abort
1187 && tcx.is_lang_item(did, LangItem::DropInPlace)
1188 {
1189 return false;
11901190 }
11911191 }
11921192
compiler/rustc_middle/src/ty/print/pretty.rs+3-5
......@@ -1526,7 +1526,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
15261526
15271527 let precedence = |binop: rustc_middle::mir::BinOp| {
15281528 use rustc_ast::util::parser::AssocOp;
1529 AssocOp::from_ast_binop(binop.to_hir_binop().into()).precedence()
1529 AssocOp::from_ast_binop(binop.to_hir_binop()).precedence()
15301530 };
15311531 let op_precedence = precedence(op);
15321532 let formatted_op = op.to_hir_binop().as_str();
......@@ -3361,10 +3361,8 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> {
33613361 // name.
33623362 //
33633363 // Any stable ordering would be fine here though.
3364 if *v.get() != symbol {
3365 if v.get().as_str() > symbol.as_str() {
3366 v.insert(symbol);
3367 }
3364 if *v.get() != symbol && v.get().as_str() > symbol.as_str() {
3365 v.insert(symbol);
33683366 }
33693367 }
33703368 Vacant(v) => {
compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs+2-3
......@@ -268,10 +268,9 @@ impl Builder<'_, '_> {
268268 pub(crate) fn mcdc_decrement_depth_if_enabled(&mut self) {
269269 if let Some(coverage_info) = self.coverage_info.as_mut()
270270 && let Some(mcdc_info) = coverage_info.mcdc_info.as_mut()
271 && mcdc_info.state.decision_ctx_stack.pop().is_none()
271272 {
272 if mcdc_info.state.decision_ctx_stack.pop().is_none() {
273 bug!("Unexpected empty decision stack");
274 }
273 bug!("Unexpected empty decision stack");
275274 };
276275 }
277276}
compiler/rustc_mir_transform/src/check_const_item_mutation.rs+12-12
......@@ -95,19 +95,19 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> {
9595 // Check for assignment to fields of a constant
9696 // Assigning directly to a constant (e.g. `FOO = true;`) is a hard error,
9797 // so emitting a lint would be redundant.
98 if !lhs.projection.is_empty() {
99 if let Some(def_id) = self.is_const_item_without_destructor(lhs.local)
100 && let Some((lint_root, span, item)) =
101 self.should_lint_const_item_usage(lhs, def_id, loc)
102 {
103 self.tcx.emit_node_span_lint(
104 CONST_ITEM_MUTATION,
105 lint_root,
106 span,
107 errors::ConstMutate::Modify { konst: item },
108 );
109 }
98 if !lhs.projection.is_empty()
99 && let Some(def_id) = self.is_const_item_without_destructor(lhs.local)
100 && let Some((lint_root, span, item)) =
101 self.should_lint_const_item_usage(lhs, def_id, loc)
102 {
103 self.tcx.emit_node_span_lint(
104 CONST_ITEM_MUTATION,
105 lint_root,
106 span,
107 errors::ConstMutate::Modify { konst: item },
108 );
110109 }
110
111111 // We are looking for MIR of the form:
112112 //
113113 // ```
compiler/rustc_mir_transform/src/deduce_param_attrs.rs+4-5
......@@ -168,17 +168,16 @@ pub(super) fn deduced_param_attrs<'tcx>(
168168 // Codegen won't use this information for anything if all the function parameters are passed
169169 // directly. Detect that and bail, for compilation speed.
170170 let fn_ty = tcx.type_of(def_id).instantiate_identity();
171 if matches!(fn_ty.kind(), ty::FnDef(..)) {
172 if fn_ty
171 if matches!(fn_ty.kind(), ty::FnDef(..))
172 && fn_ty
173173 .fn_sig(tcx)
174174 .inputs()
175175 .skip_binder()
176176 .iter()
177177 .cloned()
178178 .all(type_will_always_be_passed_directly)
179 {
180 return &[];
181 }
179 {
180 return &[];
182181 }
183182
184183 // Don't deduce any attributes for functions that have no MIR.
compiler/rustc_mir_transform/src/known_panics_lint.rs+10-10
......@@ -378,19 +378,19 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
378378 if let (Some(l), Some(r)) = (l, r)
379379 && l.layout.ty.is_integral()
380380 && op.is_overflowing()
381 {
382 if self.use_ecx(|this| {
381 && self.use_ecx(|this| {
383382 let (_res, overflow) = this.ecx.binary_op(op, &l, &r)?.to_scalar_pair();
384383 overflow.to_bool()
385 })? {
386 self.report_assert_as_lint(
387 location,
388 AssertLintKind::ArithmeticOverflow,
389 AssertKind::Overflow(op, l.to_const_int(), r.to_const_int()),
390 );
391 return None;
392 }
384 })?
385 {
386 self.report_assert_as_lint(
387 location,
388 AssertLintKind::ArithmeticOverflow,
389 AssertKind::Overflow(op, l.to_const_int(), r.to_const_int()),
390 );
391 return None;
393392 }
393
394394 Some(())
395395 }
396396
compiler/rustc_monomorphize/src/partitioning.rs+2-4
......@@ -504,10 +504,8 @@ fn compute_inlined_overlap<'tcx>(cgu1: &CodegenUnit<'tcx>, cgu2: &CodegenUnit<'t
504504
505505 let mut overlap = 0;
506506 for (item, data) in src_cgu.items().iter() {
507 if data.inlined {
508 if dst_cgu.items().contains_key(item) {
509 overlap += data.size_estimate;
510 }
507 if data.inlined && dst_cgu.items().contains_key(item) {
508 overlap += data.size_estimate;
511509 }
512510 }
513511 overlap
compiler/rustc_next_trait_solver/src/canonicalizer.rs+2-4
......@@ -185,10 +185,8 @@ impl<'a, D: SolverDelegate<Interner = I>, I: Interner> Canonicalizer<'a, D, I> {
185185 for var in var_infos.iter_mut() {
186186 // We simply put all regions from the input into the highest
187187 // compressed universe, so we only deal with them at the end.
188 if !var.is_region() {
189 if is_existential == var.is_existential() {
190 update_uv(var, orig_uv, is_existential)
191 }
188 if !var.is_region() && is_existential == var.is_existential() {
189 update_uv(var, orig_uv, is_existential)
192190 }
193191 }
194192 }
compiler/rustc_next_trait_solver/src/solve/trait_goals.rs-1
......@@ -883,7 +883,6 @@ where
883883 .into_iter()
884884 .chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
885885 elaborate::supertrait_def_ids(self.cx(), principal_def_id)
886 .into_iter()
887886 .filter(|def_id| self.cx().trait_is_auto(*def_id))
888887 }))
889888 .collect();
compiler/rustc_parse/src/parser/attr_wrapper.rs+1-1
......@@ -383,7 +383,7 @@ impl<'a> Parser<'a> {
383383 self.capture_state
384384 .parser_replacements
385385 .drain(parser_replacements_start..parser_replacements_end)
386 .chain(inner_attr_parser_replacements.into_iter())
386 .chain(inner_attr_parser_replacements)
387387 .map(|(parser_range, data)| {
388388 (NodeRange::new(parser_range, collect_pos.start_pos), data)
389389 })
compiler/rustc_parse/src/parser/expr.rs+5-7
......@@ -2554,13 +2554,12 @@ impl<'a> Parser<'a> {
25542554 let maybe_fatarrow = self.token.clone();
25552555 let block = if self.check(&token::OpenDelim(Delimiter::Brace)) {
25562556 self.parse_block()?
2557 } else if let Some(block) = recover_block_from_condition(self) {
2558 block
25572559 } else {
2558 if let Some(block) = recover_block_from_condition(self) {
2559 block
2560 } else {
2561 self.error_on_extra_if(&cond)?;
2562 // Parse block, which will always fail, but we can add a nice note to the error
2563 self.parse_block().map_err(|mut err| {
2560 self.error_on_extra_if(&cond)?;
2561 // Parse block, which will always fail, but we can add a nice note to the error
2562 self.parse_block().map_err(|mut err| {
25642563 if self.prev_token == token::Semi
25652564 && self.token == token::AndAnd
25662565 && let maybe_let = self.look_ahead(1, |t| t.clone())
......@@ -2592,7 +2591,6 @@ impl<'a> Parser<'a> {
25922591 }
25932592 err
25942593 })?
2595 }
25962594 };
25972595 self.error_on_if_block_attrs(lo, false, block.span, attrs);
25982596 block
compiler/rustc_parse/src/parser/item.rs+5-5
......@@ -1588,7 +1588,7 @@ impl<'a> Parser<'a> {
15881588 (thin_vec![], Recovered::Yes(guar))
15891589 }
15901590 };
1591 VariantData::Struct { fields, recovered: recovered.into() }
1591 VariantData::Struct { fields, recovered }
15921592 } else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) {
15931593 let body = match this.parse_tuple_struct_body() {
15941594 Ok(body) => body,
......@@ -1672,7 +1672,7 @@ impl<'a> Parser<'a> {
16721672 class_name.span,
16731673 generics.where_clause.has_where_token,
16741674 )?;
1675 VariantData::Struct { fields, recovered: recovered.into() }
1675 VariantData::Struct { fields, recovered }
16761676 }
16771677 // No `where` so: `struct Foo<T>;`
16781678 } else if self.eat(&token::Semi) {
......@@ -1684,7 +1684,7 @@ impl<'a> Parser<'a> {
16841684 class_name.span,
16851685 generics.where_clause.has_where_token,
16861686 )?;
1687 VariantData::Struct { fields, recovered: recovered.into() }
1687 VariantData::Struct { fields, recovered }
16881688 // Tuple-style struct definition with optional where-clause.
16891689 } else if self.token == token::OpenDelim(Delimiter::Parenthesis) {
16901690 let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID);
......@@ -1713,14 +1713,14 @@ impl<'a> Parser<'a> {
17131713 class_name.span,
17141714 generics.where_clause.has_where_token,
17151715 )?;
1716 VariantData::Struct { fields, recovered: recovered.into() }
1716 VariantData::Struct { fields, recovered }
17171717 } else if self.token == token::OpenDelim(Delimiter::Brace) {
17181718 let (fields, recovered) = self.parse_record_struct_body(
17191719 "union",
17201720 class_name.span,
17211721 generics.where_clause.has_where_token,
17221722 )?;
1723 VariantData::Struct { fields, recovered: recovered.into() }
1723 VariantData::Struct { fields, recovered }
17241724 } else {
17251725 let token_str = super::token_descr(&self.token);
17261726 let msg = format!("expected `where` or `{{` after union name, found {token_str}");
compiler/rustc_parse/src/parser/mod.rs+4-6
......@@ -1359,13 +1359,11 @@ impl<'a> Parser<'a> {
13591359 fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> {
13601360 Ok(if let Some(args) = self.parse_delim_args_inner() {
13611361 AttrArgs::Delimited(args)
1362 } else if self.eat(&token::Eq) {
1363 let eq_span = self.prev_token.span;
1364 AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
13621365 } else {
1363 if self.eat(&token::Eq) {
1364 let eq_span = self.prev_token.span;
1365 AttrArgs::Eq(eq_span, AttrArgsEq::Ast(self.parse_expr_force_collect()?))
1366 } else {
1367 AttrArgs::Empty
1368 }
1366 AttrArgs::Empty
13691367 })
13701368 }
13711369
compiler/rustc_parse/src/parser/pat.rs+13-15
......@@ -1336,21 +1336,19 @@ impl<'a> Parser<'a> {
13361336 vec![(first_etc_span, String::new())],
13371337 Applicability::MachineApplicable,
13381338 );
1339 } else {
1340 if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
1341 // We have `.., x`.
1342 err.multipart_suggestion(
1343 "move the `..` to the end of the field list",
1344 vec![
1345 (first_etc_span, String::new()),
1346 (
1347 self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()),
1348 format!("{} .. }}", if ate_comma { "" } else { "," }),
1349 ),
1350 ],
1351 Applicability::MachineApplicable,
1352 );
1353 }
1339 } else if let Some(last_non_comma_dotdot_span) = last_non_comma_dotdot_span {
1340 // We have `.., x`.
1341 err.multipart_suggestion(
1342 "move the `..` to the end of the field list",
1343 vec![
1344 (first_etc_span, String::new()),
1345 (
1346 self.token.span.to(last_non_comma_dotdot_span.shrink_to_hi()),
1347 format!("{} .. }}", if ate_comma { "" } else { "," }),
1348 ),
1349 ],
1350 Applicability::MachineApplicable,
1351 );
13541352 }
13551353 }
13561354 err.emit();
compiler/rustc_parse/src/parser/path.rs+6-6
......@@ -671,12 +671,12 @@ impl<'a> Parser<'a> {
671671 err.emit();
672672 continue;
673673 }
674 if !self.token.kind.should_end_const_arg() {
675 if self.handle_ambiguous_unbraced_const_arg(&mut args)? {
676 // We've managed to (partially) recover, so continue trying to parse
677 // arguments.
678 continue;
679 }
674 if !self.token.kind.should_end_const_arg()
675 && self.handle_ambiguous_unbraced_const_arg(&mut args)?
676 {
677 // We've managed to (partially) recover, so continue trying to parse
678 // arguments.
679 continue;
680680 }
681681 break;
682682 }
compiler/rustc_parse/src/validate_attr.rs+5-7
......@@ -192,13 +192,11 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr:
192192 );
193193 }
194194 }
195 } else {
196 if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
197 psess.dcx().emit_err(errors::InvalidAttrUnsafe {
198 span: unsafe_span,
199 name: attr_item.path.clone(),
200 });
201 }
195 } else if let Safety::Unsafe(unsafe_span) = attr_item.unsafety {
196 psess.dcx().emit_err(errors::InvalidAttrUnsafe {
197 span: unsafe_span,
198 name: attr_item.path.clone(),
199 });
202200 }
203201}
204202
compiler/rustc_passes/src/check_attr.rs+7-11
......@@ -2169,17 +2169,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
21692169 attr.span,
21702170 errors::MacroExport::TooManyItems,
21712171 );
2172 } else {
2173 if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
2174 self.tcx.emit_node_span_lint(
2175 INVALID_MACRO_EXPORT_ARGUMENTS,
2176 hir_id,
2177 meta_item_list[0].span(),
2178 errors::MacroExport::UnknownItem {
2179 name: meta_item_list[0].name_or_empty(),
2180 },
2181 );
2182 }
2172 } else if meta_item_list[0].name_or_empty() != sym::local_inner_macros {
2173 self.tcx.emit_node_span_lint(
2174 INVALID_MACRO_EXPORT_ARGUMENTS,
2175 hir_id,
2176 meta_item_list[0].span(),
2177 errors::MacroExport::UnknownItem { name: meta_item_list[0].name_or_empty() },
2178 );
21832179 }
21842180 } else {
21852181 // special case when `#[macro_export]` is applied to a macro 2.0
compiler/rustc_passes/src/liveness.rs+7-9
......@@ -1500,15 +1500,13 @@ impl<'tcx> Liveness<'_, 'tcx> {
15001500 );
15011501 }
15021502 }
1503 } else {
1504 if let Some(name) = self.should_warn(var) {
1505 self.ir.tcx.emit_node_span_lint(
1506 lint::builtin::UNUSED_VARIABLES,
1507 var_hir_id,
1508 vec![span],
1509 errors::UnusedVarMaybeCaptureRef { name },
1510 );
1511 }
1503 } else if let Some(name) = self.should_warn(var) {
1504 self.ir.tcx.emit_node_span_lint(
1505 lint::builtin::UNUSED_VARIABLES,
1506 var_hir_id,
1507 vec![span],
1508 errors::UnusedVarMaybeCaptureRef { name },
1509 );
15121510 }
15131511 }
15141512 }
compiler/rustc_passes/src/stability.rs+8-10
......@@ -174,16 +174,14 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> {
174174
175175 // If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI,
176176 // check if the function/method is const or the parent impl block is const
177 if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig) {
178 if fn_sig.header.abi != Abi::RustIntrinsic && !fn_sig.header.is_const() {
179 if !self.in_trait_impl
180 || (self.in_trait_impl && !self.tcx.is_const_fn_raw(def_id.to_def_id()))
181 {
182 self.tcx
183 .dcx()
184 .emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span, const_span });
185 }
186 }
177 if let (Some(const_span), Some(fn_sig)) = (const_span, fn_sig)
178 && fn_sig.header.abi != Abi::RustIntrinsic
179 && !fn_sig.header.is_const()
180 && (!self.in_trait_impl || !self.tcx.is_const_fn_raw(def_id.to_def_id()))
181 {
182 self.tcx
183 .dcx()
184 .emit_err(errors::MissingConstErr { fn_sig_span: fn_sig.span, const_span });
187185 }
188186
189187 // `impl const Trait for Type` items forward their const stability to their
compiler/rustc_resolve/src/diagnostics.rs+52-53
......@@ -1233,64 +1233,63 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12331233 && ns == namespace
12341234 && in_module != parent_scope.module
12351235 && !ident.span.normalize_to_macros_2_0().from_expansion()
1236 && filter_fn(res)
12361237 {
1237 if filter_fn(res) {
1238 // create the path
1239 let mut segms = if lookup_ident.span.at_least_rust_2018() {
1240 // crate-local absolute paths start with `crate::` in edition 2018
1241 // FIXME: may also be stabilized for Rust 2015 (Issues #45477, #44660)
1242 crate_path.clone()
1243 } else {
1244 ThinVec::new()
1245 };
1246 segms.append(&mut path_segments.clone());
1238 // create the path
1239 let mut segms = if lookup_ident.span.at_least_rust_2018() {
1240 // crate-local absolute paths start with `crate::` in edition 2018
1241 // FIXME: may also be stabilized for Rust 2015 (Issues #45477, #44660)
1242 crate_path.clone()
1243 } else {
1244 ThinVec::new()
1245 };
1246 segms.append(&mut path_segments.clone());
12471247
1248 segms.push(ast::PathSegment::from_ident(ident));
1249 let path = Path { span: name_binding.span, segments: segms, tokens: None };
1248 segms.push(ast::PathSegment::from_ident(ident));
1249 let path = Path { span: name_binding.span, segments: segms, tokens: None };
12501250
1251 if child_accessible {
1252 // Remove invisible match if exists
1253 if let Some(idx) = candidates
1254 .iter()
1255 .position(|v: &ImportSuggestion| v.did == did && !v.accessible)
1256 {
1257 candidates.remove(idx);
1258 }
1251 if child_accessible {
1252 // Remove invisible match if exists
1253 if let Some(idx) = candidates
1254 .iter()
1255 .position(|v: &ImportSuggestion| v.did == did && !v.accessible)
1256 {
1257 candidates.remove(idx);
12591258 }
1259 }
12601260
1261 if candidates.iter().all(|v: &ImportSuggestion| v.did != did) {
1262 // See if we're recommending TryFrom, TryInto, or FromIterator and add
1263 // a note about editions
1264 let note = if let Some(did) = did {
1265 let requires_note = !did.is_local()
1266 && this.tcx.get_attrs(did, sym::rustc_diagnostic_item).any(
1267 |attr| {
1268 [sym::TryInto, sym::TryFrom, sym::FromIterator]
1269 .map(|x| Some(x))
1270 .contains(&attr.value_str())
1271 },
1272 );
1273
1274 requires_note.then(|| {
1275 format!(
1276 "'{}' is included in the prelude starting in Edition 2021",
1277 path_names_to_string(&path)
1278 )
1279 })
1280 } else {
1281 None
1282 };
1283
1284 candidates.push(ImportSuggestion {
1285 did,
1286 descr: res.descr(),
1287 path,
1288 accessible: child_accessible,
1289 doc_visible: child_doc_visible,
1290 note,
1291 via_import,
1292 });
1293 }
1261 if candidates.iter().all(|v: &ImportSuggestion| v.did != did) {
1262 // See if we're recommending TryFrom, TryInto, or FromIterator and add
1263 // a note about editions
1264 let note = if let Some(did) = did {
1265 let requires_note = !did.is_local()
1266 && this.tcx.get_attrs(did, sym::rustc_diagnostic_item).any(
1267 |attr| {
1268 [sym::TryInto, sym::TryFrom, sym::FromIterator]
1269 .map(|x| Some(x))
1270 .contains(&attr.value_str())
1271 },
1272 );
1273
1274 requires_note.then(|| {
1275 format!(
1276 "'{}' is included in the prelude starting in Edition 2021",
1277 path_names_to_string(&path)
1278 )
1279 })
1280 } else {
1281 None
1282 };
1283
1284 candidates.push(ImportSuggestion {
1285 did,
1286 descr: res.descr(),
1287 path,
1288 accessible: child_accessible,
1289 doc_visible: child_doc_visible,
1290 note,
1291 via_import,
1292 });
12941293 }
12951294 }
12961295
compiler/rustc_resolve/src/ident.rs+6-6
......@@ -958,12 +958,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
958958 });
959959 }
960960
961 if !restricted_shadowing && binding.expansion != LocalExpnId::ROOT {
962 if let NameBindingKind::Import { import, .. } = binding.kind
963 && matches!(import.kind, ImportKind::MacroExport)
964 {
965 self.macro_expanded_macro_export_errors.insert((path_span, binding.span));
966 }
961 if !restricted_shadowing
962 && binding.expansion != LocalExpnId::ROOT
963 && let NameBindingKind::Import { import, .. } = binding.kind
964 && matches!(import.kind, ImportKind::MacroExport)
965 {
966 self.macro_expanded_macro_export_errors.insert((path_span, binding.span));
967967 }
968968
969969 self.record_use(ident, binding, used);
compiler/rustc_resolve/src/imports.rs+15-21
......@@ -1256,28 +1256,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12561256 extern_crate_span: self.tcx.source_span(self.local_def_id(extern_crate_id)),
12571257 },
12581258 );
1259 } else if ns == TypeNS {
1260 let err = if crate_private_reexport {
1261 self.dcx()
1262 .create_err(CannotBeReexportedCratePublicNS { span: import.span, ident })
1263 } else {
1264 self.dcx().create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
1265 };
1266 err.emit();
12591267 } else {
1260 if ns == TypeNS {
1261 let err = if crate_private_reexport {
1262 self.dcx().create_err(CannotBeReexportedCratePublicNS {
1263 span: import.span,
1264 ident,
1265 })
1266 } else {
1267 self.dcx()
1268 .create_err(CannotBeReexportedPrivateNS { span: import.span, ident })
1269 };
1270 err.emit();
1268 let mut err = if crate_private_reexport {
1269 self.dcx()
1270 .create_err(CannotBeReexportedCratePublic { span: import.span, ident })
12711271 } else {
1272 let mut err = if crate_private_reexport {
1273 self.dcx()
1274 .create_err(CannotBeReexportedCratePublic { span: import.span, ident })
1275 } else {
1276 self.dcx()
1277 .create_err(CannotBeReexportedPrivate { span: import.span, ident })
1278 };
1272 self.dcx().create_err(CannotBeReexportedPrivate { span: import.span, ident })
1273 };
12791274
1280 match binding.kind {
1275 match binding.kind {
12811276 NameBindingKind::Res(Res::Def(DefKind::Macro(_), def_id))
12821277 // exclude decl_macro
12831278 if self.get_macro_by_def_id(def_id).macro_rules =>
......@@ -1293,8 +1288,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
12931288 });
12941289 }
12951290 }
1296 err.emit();
1297 }
1291 err.emit();
12981292 }
12991293 }
13001294
compiler/rustc_resolve/src/late.rs+7-9
......@@ -4781,16 +4781,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
47814781 if let Some(res) = res
47824782 && let Some(def_id) = res.opt_def_id()
47834783 && !def_id.is_local()
4784 && self.r.tcx.crate_types().contains(&CrateType::ProcMacro)
4785 && matches!(
4786 self.r.tcx.sess.opts.resolve_doc_links,
4787 ResolveDocLinks::ExportedMetadata
4788 )
47844789 {
4785 if self.r.tcx.crate_types().contains(&CrateType::ProcMacro)
4786 && matches!(
4787 self.r.tcx.sess.opts.resolve_doc_links,
4788 ResolveDocLinks::ExportedMetadata
4789 )
4790 {
4791 // Encoding foreign def ids in proc macro crate metadata will ICE.
4792 return None;
4793 }
4790 // Encoding foreign def ids in proc macro crate metadata will ICE.
4791 return None;
47944792 }
47954793 res
47964794 });
compiler/rustc_resolve/src/late/diagnostics.rs+16-17
......@@ -2255,25 +2255,24 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> {
22552255 fn let_binding_suggestion(&mut self, err: &mut Diag<'_>, ident_span: Span) -> bool {
22562256 if let Some(Expr { kind: ExprKind::Assign(lhs, ..), .. }) = self.diag_metadata.in_assignment
22572257 && let ast::ExprKind::Path(None, ref path) = lhs.kind
2258 && !ident_span.from_expansion()
22582259 {
2259 if !ident_span.from_expansion() {
2260 let (span, text) = match path.segments.first() {
2261 Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => {
2262 // a special case for #117894
2263 let name = name.strip_prefix('_').unwrap_or(name);
2264 (ident_span, format!("let {name}"))
2265 }
2266 _ => (ident_span.shrink_to_lo(), "let ".to_string()),
2267 };
2260 let (span, text) = match path.segments.first() {
2261 Some(seg) if let Some(name) = seg.ident.as_str().strip_prefix("let") => {
2262 // a special case for #117894
2263 let name = name.strip_prefix('_').unwrap_or(name);
2264 (ident_span, format!("let {name}"))
2265 }
2266 _ => (ident_span.shrink_to_lo(), "let ".to_string()),
2267 };
22682268
2269 err.span_suggestion_verbose(
2270 span,
2271 "you might have meant to introduce a new binding",
2272 text,
2273 Applicability::MaybeIncorrect,
2274 );
2275 return true;
2276 }
2269 err.span_suggestion_verbose(
2270 span,
2271 "you might have meant to introduce a new binding",
2272 text,
2273 Applicability::MaybeIncorrect,
2274 );
2275 return true;
22772276 }
22782277 false
22792278 }
compiler/rustc_resolve/src/rustdoc.rs+3-5
......@@ -270,12 +270,10 @@ fn strip_generics_from_path_segment(segment: Vec<char>) -> Result<String, Malfor
270270 // Give a helpful error message instead of completely ignoring the angle brackets.
271271 return Err(MalformedGenerics::HasFullyQualifiedSyntax);
272272 }
273 } else if param_depth == 0 {
274 stripped_segment.push(c);
273275 } else {
274 if param_depth == 0 {
275 stripped_segment.push(c);
276 } else {
277 latest_generics_chunk.push(c);
278 }
276 latest_generics_chunk.push(c);
279277 }
280278 }
281279
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs+5-7
......@@ -207,14 +207,12 @@ fn encode_fnsig<'tcx>(
207207 if fn_sig.c_variadic {
208208 s.push('z');
209209 }
210 } else if fn_sig.c_variadic {
211 s.push('z');
210212 } else {
211 if fn_sig.c_variadic {
212 s.push('z');
213 } else {
214 // Empty parameter lists, whether declared as () or conventionally as (void), are
215 // encoded with a void parameter specifier "v".
216 s.push('v')
217 }
213 // Empty parameter lists, whether declared as () or conventionally as (void), are
214 // encoded with a void parameter specifier "v".
215 s.push('v')
218216 }
219217
220218 // Close the "F..E" pair
compiler/rustc_symbol_mangling/src/v0.rs+1-1
......@@ -381,7 +381,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
381381 let consts = [
382382 start.unwrap_or(self.tcx.consts.unit),
383383 end.unwrap_or(self.tcx.consts.unit),
384 ty::Const::from_bool(self.tcx, include_end).into(),
384 ty::Const::from_bool(self.tcx, include_end),
385385 ];
386386 // HACK: Represent as tuple until we have something better.
387387 // HACK: constants are used in arrays, even if the types don't match.
compiler/rustc_target/src/abi/call/xtensa.rs+19-21
......@@ -69,29 +69,27 @@ where
6969
7070 if must_use_stack {
7171 arg.make_indirect_byval(None);
72 } else {
73 if is_xtensa_aggregate(arg) {
74 // Aggregates which are <= max_size will be passed in
75 // registers if possible, so coerce to integers.
72 } else if is_xtensa_aggregate(arg) {
73 // Aggregates which are <= max_size will be passed in
74 // registers if possible, so coerce to integers.
7675
77 // Use a single `xlen` int if possible, 2 * `xlen` if 2 * `xlen` alignment
78 // is required, and a 2-element `xlen` array if only `xlen` alignment is
79 // required.
80 if size <= 32 {
81 arg.cast_to(Reg::i32());
82 } else {
83 let reg = if needed_align == 2 * 32 { Reg::i64() } else { Reg::i32() };
84 let total = Size::from_bits(((size + 32 - 1) / 32) * 32);
85 arg.cast_to(Uniform::new(reg, total));
86 }
76 // Use a single `xlen` int if possible, 2 * `xlen` if 2 * `xlen` alignment
77 // is required, and a 2-element `xlen` array if only `xlen` alignment is
78 // required.
79 if size <= 32 {
80 arg.cast_to(Reg::i32());
8781 } else {
88 // All integral types are promoted to `xlen`
89 // width.
90 //
91 // We let the LLVM backend handle integral types >= xlen.
92 if size < 32 {
93 arg.extend_integer_width_to(32);
94 }
82 let reg = if needed_align == 2 * 32 { Reg::i64() } else { Reg::i32() };
83 let total = Size::from_bits(((size + 32 - 1) / 32) * 32);
84 arg.cast_to(Uniform::new(reg, total));
85 }
86 } else {
87 // All integral types are promoted to `xlen`
88 // width.
89 //
90 // We let the LLVM backend handle integral types >= xlen.
91 if size < 32 {
92 arg.extend_integer_width_to(32);
9593 }
9694 }
9795}
compiler/rustc_target/src/spec/base/apple/mod.rs+8-2
......@@ -351,12 +351,18 @@ fn deployment_target(os: &str, arch: Arch, abi: TargetAbi) -> (u16, u8, u8) {
351351 };
352352
353353 // On certain targets it makes sense to raise the minimum OS version.
354 //
355 // This matches what LLVM does, see:
356 // <https://github.com/llvm/llvm-project/blob/llvmorg-18.1.8/llvm/lib/TargetParser/Triple.cpp#L1900-L1932>
354357 let min = match (os, arch, abi) {
355 // Use 11.0 on Aarch64 as that's the earliest version with M1 support.
356358 ("macos", Arch::Arm64 | Arch::Arm64e, _) => (11, 0, 0),
357 ("ios", Arch::Arm64e, _) => (14, 0, 0),
359 ("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::MacCatalyst) => (14, 0, 0),
360 ("ios", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
361 ("ios", Arch::Arm64e, TargetAbi::Normal) => (14, 0, 0),
358362 // Mac Catalyst defaults to 13.1 in Clang.
359363 ("ios", _, TargetAbi::MacCatalyst) => (13, 1, 0),
364 ("tvos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (14, 0, 0),
365 ("watchos", Arch::Arm64 | Arch::Arm64e, TargetAbi::Simulator) => (7, 0, 0),
360366 _ => os_min,
361367 };
362368
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs+13-15
......@@ -1323,23 +1323,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
13231323 label_or_note(span, terr.to_string(self.tcx));
13241324 label_or_note(sp, msg);
13251325 }
1326 } else {
1327 if let Some(values) = values
1328 && let Some((e, f)) = values.ty()
1329 && let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
1330 {
1331 let e = self.tcx.erase_regions(e);
1332 let f = self.tcx.erase_regions(f);
1333 let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
1334 let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
1335 if expected == found {
1336 label_or_note(span, terr.to_string(self.tcx));
1337 } else {
1338 label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
1339 }
1340 } else {
1326 } else if let Some(values) = values
1327 && let Some((e, f)) = values.ty()
1328 && let TypeError::ArgumentSorts(..) | TypeError::Sorts(_) = terr
1329 {
1330 let e = self.tcx.erase_regions(e);
1331 let f = self.tcx.erase_regions(f);
1332 let expected = with_forced_trimmed_paths!(e.sort_string(self.tcx));
1333 let found = with_forced_trimmed_paths!(f.sort_string(self.tcx));
1334 if expected == found {
13411335 label_or_note(span, terr.to_string(self.tcx));
1336 } else {
1337 label_or_note(span, Cow::from(format!("expected {expected}, found {found}")));
13421338 }
1339 } else {
1340 label_or_note(span, terr.to_string(self.tcx));
13431341 }
13441342
13451343 if let Some((expected, found, path)) = expected_found {
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs+6-9
......@@ -3237,16 +3237,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
32373237 // then the tuple must be the one containing capture types.
32383238 let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) {
32393239 false
3240 } else if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
3241 let parent_trait_ref = self.resolve_vars_if_possible(data.parent_trait_pred);
3242 let nested_ty = parent_trait_ref.skip_binder().self_ty();
3243 matches!(nested_ty.kind(), ty::Coroutine(..))
3244 || matches!(nested_ty.kind(), ty::Closure(..))
32403245 } else {
3241 if let ObligationCauseCode::BuiltinDerived(data) = &*data.parent_code {
3242 let parent_trait_ref =
3243 self.resolve_vars_if_possible(data.parent_trait_pred);
3244 let nested_ty = parent_trait_ref.skip_binder().self_ty();
3245 matches!(nested_ty.kind(), ty::Coroutine(..))
3246 || matches!(nested_ty.kind(), ty::Closure(..))
3247 } else {
3248 false
3249 }
3246 false
32503247 };
32513248
32523249 if !is_upvar_tys_infer_tuple {
compiler/rustc_trait_selection/src/traits/project.rs+2-2
......@@ -408,7 +408,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
408408 debug!("opt_normalize_projection_type: found error");
409409 let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
410410 obligations.extend(result.obligations);
411 return Ok(Some(result.value.into()));
411 return Ok(Some(result.value));
412412 }
413413 }
414414
......@@ -478,7 +478,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>(
478478 }
479479 let result = normalize_to_error(selcx, param_env, projection_term, cause, depth);
480480 obligations.extend(result.obligations);
481 Ok(Some(result.value.into()))
481 Ok(Some(result.value))
482482 }
483483 }
484484}
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs+6-9
......@@ -426,13 +426,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
426426 } else if kind == ty::ClosureKind::FnOnce {
427427 candidates.vec.push(ClosureCandidate { is_const });
428428 }
429 } else if kind == ty::ClosureKind::FnOnce {
430 candidates.vec.push(ClosureCandidate { is_const });
429431 } else {
430 if kind == ty::ClosureKind::FnOnce {
431 candidates.vec.push(ClosureCandidate { is_const });
432 } else {
433 // This stays ambiguous until kind+upvars are determined.
434 candidates.ambiguous = true;
435 }
432 // This stays ambiguous until kind+upvars are determined.
433 candidates.ambiguous = true;
436434 }
437435 }
438436 ty::Infer(ty::TyVar(_)) => {
......@@ -513,10 +511,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
513511 // then there's nothing else to check.
514512 if let Some(closure_kind) = self_ty.to_opt_closure_kind()
515513 && let Some(goal_kind) = target_kind_ty.to_opt_closure_kind()
514 && closure_kind.extends(goal_kind)
516515 {
517 if closure_kind.extends(goal_kind) {
518 candidates.vec.push(AsyncFnKindHelperCandidate);
519 }
516 candidates.vec.push(AsyncFnKindHelperCandidate);
520517 }
521518 }
522519
compiler/rustc_trait_selection/src/traits/select/mod.rs+17-21
......@@ -1334,16 +1334,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
13341334 return;
13351335 }
13361336
1337 if self.can_use_global_caches(param_env) {
1338 if !trait_pred.has_infer() {
1339 debug!(?trait_pred, ?result, "insert_evaluation_cache global");
1340 // This may overwrite the cache with the same value
1341 // FIXME: Due to #50507 this overwrites the different values
1342 // This should be changed to use HashMapExt::insert_same
1343 // when that is fixed
1344 self.tcx().evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1345 return;
1346 }
1337 if self.can_use_global_caches(param_env) && !trait_pred.has_infer() {
1338 debug!(?trait_pred, ?result, "insert_evaluation_cache global");
1339 // This may overwrite the cache with the same value
1340 // FIXME: Due to #50507 this overwrites the different values
1341 // This should be changed to use HashMapExt::insert_same
1342 // when that is fixed
1343 self.tcx().evaluation_cache.insert((param_env, trait_pred), dep_node, result);
1344 return;
13471345 }
13481346
13491347 debug!(?trait_pred, ?result, "insert_evaluation_cache");
......@@ -1584,13 +1582,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
15841582 if self.can_use_global_caches(param_env) {
15851583 if let Err(Overflow(OverflowError::Canonical)) = candidate {
15861584 // Don't cache overflow globally; we only produce this in certain modes.
1587 } else if !pred.has_infer() {
1588 if !candidate.has_infer() {
1589 debug!(?pred, ?candidate, "insert_candidate_cache global");
1590 // This may overwrite the cache with the same value.
1591 tcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1592 return;
1593 }
1585 } else if !pred.has_infer() && !candidate.has_infer() {
1586 debug!(?pred, ?candidate, "insert_candidate_cache global");
1587 // This may overwrite the cache with the same value.
1588 tcx.selection_cache.insert((param_env, pred), dep_node, candidate);
1589 return;
15941590 }
15951591 }
15961592
......@@ -1980,10 +1976,10 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
19801976 // impls have to be always applicable, meaning that the only allowed
19811977 // region constraints may be constraints also present on the default impl.
19821978 let tcx = self.tcx();
1983 if other.evaluation.must_apply_modulo_regions() {
1984 if tcx.specializes((other_def, victim_def)) {
1985 return DropVictim::Yes;
1986 }
1979 if other.evaluation.must_apply_modulo_regions()
1980 && tcx.specializes((other_def, victim_def))
1981 {
1982 return DropVictim::Yes;
19871983 }
19881984
19891985 match tcx.impls_are_allowed_to_overlap(other_def, victim_def) {
compiler/rustc_ty_utils/src/opaque_types.rs+2-4
......@@ -143,10 +143,8 @@ impl<'tcx> OpaqueTypeCollector<'tcx> {
143143 match origin {
144144 rustc_hir::OpaqueTyOrigin::FnReturn(_) | rustc_hir::OpaqueTyOrigin::AsyncFn(_) => {}
145145 rustc_hir::OpaqueTyOrigin::TyAlias { in_assoc_ty, .. } => {
146 if !in_assoc_ty {
147 if !self.check_tait_defining_scope(alias_ty.def_id.expect_local()) {
148 return;
149 }
146 if !in_assoc_ty && !self.check_tait_defining_scope(alias_ty.def_id.expect_local()) {
147 return;
150148 }
151149 }
152150 }
library/core/src/slice/mod.rs+1-1
......@@ -156,7 +156,7 @@ impl<T> [T] {
156156 if let [first, ..] = self { Some(first) } else { None }
157157 }
158158
159 /// Returns a mutable pointer to the first element of the slice, or `None` if it is empty.
159 /// Returns a mutable reference to the first element of the slice, or `None` if it is empty.
160160 ///
161161 /// # Examples
162162 ///
library/std/src/path.rs+24
......@@ -1153,6 +1153,21 @@ impl FusedIterator for Ancestors<'_> {}
11531153/// ```
11541154///
11551155/// Which method works best depends on what kind of situation you're in.
1156///
1157/// Note that `PathBuf` does not always sanitize arguments, for example
1158/// [`push`] allows paths built from strings which include separators:
1159///
1160/// use std::path::PathBuf;
1161///
1162/// let mut path = PathBuf::new();
1163///
1164/// path.push(r"C:\");
1165/// path.push("windows");
1166/// path.push(r"..\otherdir");
1167/// path.push("system32");
1168///
1169/// The behaviour of `PathBuf` may be changed to a panic on such inputs
1170/// in the future. [`Extend::extend`] should be used to add multi-part paths.
11561171#[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")]
11571172#[stable(feature = "rust1", since = "1.0.0")]
11581173pub struct PathBuf {
......@@ -1391,6 +1406,9 @@ impl PathBuf {
13911406 /// `file_name`. The new path will be a sibling of the original path.
13921407 /// (That is, it will have the same parent.)
13931408 ///
1409 /// The argument is not sanitized, so can include separators. This
1410 /// behaviour may be changed to a panic in the future.
1411 ///
13941412 /// [`self.file_name`]: Path::file_name
13951413 /// [`pop`]: PathBuf::pop
13961414 ///
......@@ -1411,6 +1429,12 @@ impl PathBuf {
14111429 ///
14121430 /// buf.set_file_name("baz");
14131431 /// assert!(buf == PathBuf::from("/baz"));
1432 ///
1433 /// buf.set_file_name("../b/c.txt");
1434 /// assert!(buf == PathBuf::from("/../b/c.txt"));
1435 ///
1436 /// buf.set_file_name("baz");
1437 /// assert!(buf == PathBuf::from("/../b/baz"));
14141438 /// ```
14151439 #[stable(feature = "rust1", since = "1.0.0")]
14161440 pub fn set_file_name<S: AsRef<OsStr>>(&mut self, file_name: S) {
src/doc/rustc/src/platform-support/apple-ios-macabi.md+1-1
......@@ -24,7 +24,7 @@ environment variable.
2424
2525### OS version
2626
27The minimum supported version is iOS 13.1.
27The minimum supported version is iOS 13.1 on x86 and 14.0 on Aarch64.
2828
2929This can be raised per-binary by changing the deployment target. `rustc`
3030respects the common environment variables used by Xcode to do so, in this
src/doc/rustc/src/platform-support/arm64e-apple-ios.md+1-1
......@@ -2,7 +2,7 @@
22
33**Tier: 3**
44
5ARM64e iOS (12.0+)
5ARM64e iOS (14.0+)
66
77## Target maintainers
88
src/tools/clippy/clippy_utils/src/ast_utils.rs+11-1
......@@ -221,7 +221,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
221221 ) => {
222222 eq_closure_binder(lb, rb)
223223 && lc == rc
224 && la.map_or(false, CoroutineKind::is_async) == ra.map_or(false, CoroutineKind::is_async)
224 && eq_coroutine_kind(*la, *ra)
225225 && lm == rm
226226 && eq_fn_decl(lf, rf)
227227 && eq_expr(le, re)
......@@ -241,6 +241,16 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
241241 }
242242}
243243
244fn eq_coroutine_kind(a: Option<CoroutineKind>, b: Option<CoroutineKind>) -> bool {
245 match (a, b) {
246 (Some(CoroutineKind::Async { .. }), Some(CoroutineKind::Async { .. }))
247 | (Some(CoroutineKind::Gen { .. }), Some(CoroutineKind::Gen { .. }))
248 | (Some(CoroutineKind::AsyncGen { .. }), Some(CoroutineKind::AsyncGen { .. }))
249 | (None, None) => true,
250 _ => false,
251 }
252}
253
244254pub fn eq_field(l: &ExprField, r: &ExprField) -> bool {
245255 l.is_placeholder == r.is_placeholder
246256 && eq_id(l.ident, r.ident)
src/tools/compiletest/src/lib.rs+6
......@@ -647,6 +647,12 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
647647 stamp.add_path(&rust_src_dir.join("src/etc/htmldocck.py"));
648648 }
649649
650 // Re-run coverage tests if the `coverage-dump` tool was modified,
651 // because its output format might have changed.
652 if let Some(coverage_dump_path) = &config.coverage_dump_path {
653 stamp.add_path(coverage_dump_path)
654 }
655
650656 stamp.add_dir(&rust_src_dir.join("src/tools/run-make-support"));
651657
652658 // Compiletest itself.
src/tools/run-make-support/src/external_deps/llvm.rs+6
......@@ -54,6 +54,12 @@ pub fn llvm_dwarfdump() -> LlvmDwarfdump {
5454 LlvmDwarfdump::new()
5555}
5656
57/// Construct a new `llvm-pdbutil` invocation. This assumes that `llvm-pdbutil` is available
58/// at `$LLVM_BIN_DIR/llvm-pdbutil`.
59pub fn llvm_pdbutil() -> LlvmPdbutil {
60 LlvmPdbutil::new()
61}
62
5763/// A `llvm-readobj` invocation builder.
5864#[derive(Debug)]
5965#[must_use]
tests/run-make/apple-deployment-target/rmake.rs+16-12
......@@ -55,11 +55,8 @@ fn main() {
5555 rustc().env(env_var, example_version).run();
5656 minos("foo.o", example_version);
5757
58 // FIXME(madsmtm): Doesn't work on Mac Catalyst and the simulator.
59 if !target().contains("macabi") && !target().contains("sim") {
60 rustc().env_remove(env_var).run();
61 minos("foo.o", default_version);
62 }
58 rustc().env_remove(env_var).run();
59 minos("foo.o", default_version);
6360 });
6461
6562 // Test that version makes it to the linker when linking dylibs.
......@@ -104,8 +101,18 @@ fn main() {
104101 rustc
105102 };
106103
107 // FIXME(madsmtm): Doesn't work on watchOS for some reason?
108 if !target().contains("watchos") {
104 // FIXME(madsmtm): Xcode's version of Clang seems to require a minimum
105 // version of 9.0 on aarch64-apple-watchos for some reason? Which is
106 // odd, because the first Aarch64 watch was Apple Watch Series 4,
107 // which runs on as low as watchOS 5.0.
108 //
109 // You can see Clang's behaviour by running:
110 // ```
111 // echo "int main() { return 0; }" > main.c
112 // xcrun --sdk watchos clang --target=aarch64-apple-watchos main.c
113 // vtool -show a.out
114 // ```
115 if target() != "aarch64-apple-watchos" {
109116 rustc().env(env_var, example_version).run();
110117 minos("foo", example_version);
111118
......@@ -146,10 +153,7 @@ fn main() {
146153 rustc().env(env_var, higher_example_version).run();
147154 minos("foo.o", higher_example_version);
148155
149 // FIXME(madsmtm): Doesn't work on Mac Catalyst and the simulator.
150 if !target().contains("macabi") && !target().contains("sim") {
151 rustc().env_remove(env_var).run();
152 minos("foo.o", default_version);
153 }
156 rustc().env_remove(env_var).run();
157 minos("foo.o", default_version);
154158 });
155159}
tests/run-make/pdb-buildinfo-cl-cmd/filecheck.txt created+4
......@@ -0,0 +1,4 @@
1CHECK: LF_BUILDINFO
2CHECK: rustc.exe
3CHECK: main.rs
4CHECK: "-g" "--crate-name" "my_crate_name" "--crate-type" "bin" "-Cmetadata=dc9ef878b0a48666"
tests/run-make/pdb-buildinfo-cl-cmd/rmake.rs+5-19
......@@ -7,7 +7,7 @@
77//@ only-windows-msvc
88// Reason: pdb files are unique to this architecture
99
10use run_make_support::{assert_contains, bstr, env_var, rfs, rustc};
10use run_make_support::{llvm, rustc};
1111
1212fn main() {
1313 rustc()
......@@ -17,23 +17,9 @@ fn main() {
1717 .crate_type("bin")
1818 .metadata("dc9ef878b0a48666")
1919 .run();
20 let tests = [
21 &env_var("RUSTC"),
22 r#""main.rs""#,
23 r#""-g""#,
24 r#""--crate-name""#,
25 r#""my_crate_name""#,
26 r#""--crate-type""#,
27 r#""bin""#,
28 r#""-Cmetadata=dc9ef878b0a48666""#,
29 ];
30 for test in tests {
31 assert_pdb_contains(test);
32 }
33}
3420
35fn assert_pdb_contains(needle: &str) {
36 let needle = needle.as_bytes();
37 use bstr::ByteSlice;
38 assert!(&rfs::read("my_crate_name.pdb").find(needle).is_some());
21 let pdbutil_result =
22 llvm::llvm_pdbutil().arg("dump").arg("-ids").input("my_crate_name.pdb").run();
23
24 llvm::llvm_filecheck().patterns("filecheck.txt").stdin_buf(pdbutil_result.stdout_utf8()).run();
3925}
tests/run-make/pdb-sobjname/main.rs created+1
......@@ -0,0 +1 @@
1fn main() {}
tests/run-make/pdb-sobjname/rmake.rs created+20
......@@ -0,0 +1,20 @@
1// Check if the pdb file contains an S_OBJNAME entry with the name of the .o file
2
3// This is because it used to be missing in #96475.
4// See https://github.com/rust-lang/rust/pull/115704
5
6//@ only-windows-msvc
7// Reason: pdb files are unique to this architecture
8
9use run_make_support::{llvm, rustc};
10
11fn main() {
12 rustc().input("main.rs").arg("-g").crate_name("my_great_crate_name").crate_type("bin").run();
13
14 let pdbutil_result = llvm::llvm_pdbutil()
15 .arg("dump")
16 .arg("-symbols")
17 .input("my_great_crate_name.pdb")
18 .run()
19 .assert_stdout_contains_regex("S_OBJNAME.+my_great_crate_name.*\\.o");
20}
tests/ui/coroutine/const_gen_fn.rs created+12
......@@ -0,0 +1,12 @@
1//@ edition:2024
2//@ compile-flags: -Zunstable-options
3
4#![feature(gen_blocks)]
5
6const gen fn a() {}
7//~^ ERROR functions cannot be both `const` and `gen`
8
9const async gen fn b() {}
10//~^ ERROR functions cannot be both `const` and `async gen`
11
12fn main() {}
tests/ui/coroutine/const_gen_fn.stderr created+20
......@@ -0,0 +1,20 @@
1error: functions cannot be both `const` and `gen`
2 --> $DIR/const_gen_fn.rs:6:1
3 |
4LL | const gen fn a() {}
5 | ^^^^^-^^^----------
6 | | |
7 | | `gen` because of this
8 | `const` because of this
9
10error: functions cannot be both `const` and `async gen`
11 --> $DIR/const_gen_fn.rs:9:1
12 |
13LL | const async gen fn b() {}
14 | ^^^^^-^^^^^^^^^----------
15 | | |
16 | | `async gen` because of this
17 | `const` because of this
18
19error: aborting due to 2 previous errors
20