| author | bors <bors@rust-lang.org> 2024-09-12 12:56:55 UTC |
| committer | bors <bors@rust-lang.org> 2024-09-12 12:56:55 UTC |
| log | 394c4060d2d971b0ce6b9c86f9f5ef6dff7ae00e |
| tree | c4f3ec42008bc271abfa608381ce9e0f2da96662 |
| parent | f753bc769b16ca9673f11a4cc06e5cc681efd84e |
| parent | 458a57adeba49fb5b9dcf379e96622ff93b567e0 |
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: rollup90 files changed, 740 insertions(+), 761 deletions(-)
compiler/rustc_ast/src/ast.rs+8-10| ... | ... | @@ -2602,12 +2602,12 @@ impl CoroutineKind { |
| 2602 | 2602 | } |
| 2603 | 2603 | } |
| 2604 | 2604 | |
| 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 | } | |
| 2611 | 2611 | } |
| 2612 | 2612 | |
| 2613 | 2613 | pub fn closure_id(self) -> NodeId { |
| ... | ... | @@ -3486,7 +3486,7 @@ impl From<ForeignItemKind> for ItemKind { |
| 3486 | 3486 | fn from(foreign_item_kind: ForeignItemKind) -> ItemKind { |
| 3487 | 3487 | match foreign_item_kind { |
| 3488 | 3488 | ForeignItemKind::Static(box static_foreign_item) => { |
| 3489 | ItemKind::Static(Box::new(static_foreign_item.into())) | |
| 3489 | ItemKind::Static(Box::new(static_foreign_item)) | |
| 3490 | 3490 | } |
| 3491 | 3491 | ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind), |
| 3492 | 3492 | ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind), |
| ... | ... | @@ -3500,9 +3500,7 @@ impl TryFrom<ItemKind> for ForeignItemKind { |
| 3500 | 3500 | |
| 3501 | 3501 | fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> { |
| 3502 | 3502 | 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)), | |
| 3506 | 3504 | ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind), |
| 3507 | 3505 | ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind), |
| 3508 | 3506 | ItemKind::MacCall(a) => ForeignItemKind::MacCall(a), |
compiler/rustc_ast/src/entry.rs+9-11| ... | ... | @@ -45,18 +45,16 @@ pub fn entry_point_type( |
| 45 | 45 | EntryPointType::Start |
| 46 | 46 | } else if attr::contains_name(attrs, sym::rustc_main) { |
| 47 | 47 | 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 | |
| 58 | 54 | } else { |
| 59 | EntryPointType::None | |
| 55 | EntryPointType::OtherMain | |
| 60 | 56 | } |
| 57 | } else { | |
| 58 | EntryPointType::None | |
| 61 | 59 | } |
| 62 | 60 | } |
compiler/rustc_ast_lowering/src/index.rs+17-19| ... | ... | @@ -78,26 +78,24 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { |
| 78 | 78 | |
| 79 | 79 | // Make sure that the DepNode of some node coincides with the HirId |
| 80 | 80 | // 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 `{:?}`: \ | |
| 86 | 85 | 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 | ) | |
| 101 | 99 | } |
| 102 | 100 | |
| 103 | 101 | 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> { |
| 628 | 628 | .map_or(Const::No, |attr| Const::Yes(attr.span)), |
| 629 | 629 | _ => Const::No, |
| 630 | 630 | } |
| 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()) | |
| 631 | 634 | } 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 | |
| 638 | 636 | } |
| 639 | 637 | } else { |
| 640 | 638 | Const::No |
compiler/rustc_ast_passes/messages.ftl+5-5| ... | ... | @@ -40,15 +40,15 @@ ast_passes_body_in_extern = incorrect `{$kind}` inside `extern` block |
| 40 | 40 | |
| 41 | 41 | ast_passes_bound_in_context = bounds on `type`s in {$ctx} have no effect |
| 42 | 42 | |
| 43 | ast_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 | ||
| 48 | 43 | ast_passes_const_and_c_variadic = functions cannot be both `const` and C-variadic |
| 49 | 44 | .const = `const` because of this |
| 50 | 45 | .variadic = C-variadic because of this |
| 51 | 46 | |
| 47 | ast_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 | ||
| 52 | 52 | ast_passes_const_bound_trait_object = const trait bounds are not allowed in trait object types |
| 53 | 53 | |
| 54 | 54 | ast_passes_const_without_body = |
compiler/rustc_ast_passes/src/ast_validation.rs+13-18| ... | ... | @@ -447,13 +447,13 @@ impl<'a> AstValidator<'a> { |
| 447 | 447 | fn check_item_safety(&self, span: Span, safety: Safety) { |
| 448 | 448 | match self.extern_mod_safety { |
| 449 | 449 | 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 | }); | |
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | None => { |
| ... | ... | @@ -1418,21 +1418,16 @@ impl<'a> Visitor<'a> for AstValidator<'a> { |
| 1418 | 1418 | |
| 1419 | 1419 | // Functions cannot both be `const async` or `const gen` |
| 1420 | 1420 | if let Some(&FnHeader { |
| 1421 | constness: Const::Yes(cspan), | |
| 1421 | constness: Const::Yes(const_span), | |
| 1422 | 1422 | coroutine_kind: Some(coroutine_kind), |
| 1423 | 1423 | .. |
| 1424 | 1424 | }) = fk.header() |
| 1425 | 1425 | { |
| 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(), | |
| 1436 | 1431 | span, |
| 1437 | 1432 | }); |
| 1438 | 1433 | } |
compiler/rustc_ast_passes/src/errors.rs+6-5| ... | ... | @@ -657,16 +657,17 @@ pub(crate) enum TildeConstReason { |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | #[derive(Diagnostic)] |
| 660 | #[diag(ast_passes_const_and_async)] | |
| 661 | pub(crate) struct ConstAndAsync { | |
| 660 | #[diag(ast_passes_const_and_coroutine)] | |
| 661 | pub(crate) struct ConstAndCoroutine { | |
| 662 | 662 | #[primary_span] |
| 663 | 663 | pub spans: Vec<Span>, |
| 664 | 664 | #[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, | |
| 668 | 668 | #[label] |
| 669 | 669 | pub span: Span, |
| 670 | pub coroutine_kind: &'static str, | |
| 670 | 671 | } |
| 671 | 672 | |
| 672 | 673 | #[derive(Diagnostic)] |
compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs+22-25| ... | ... | @@ -2574,33 +2574,31 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { |
| 2574 | 2574 | } |
| 2575 | 2575 | impl<'hir> Visitor<'hir> for ExpressionFinder<'hir> { |
| 2576 | 2576 | 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 { | |
| 2579 | 2579 | kind: hir::ClosureKind::Closure, |
| 2580 | 2580 | body, |
| 2581 | 2581 | fn_arg_span, |
| 2582 | 2582 | fn_decl: hir::FnDecl { inputs, .. }, |
| 2583 | 2583 | .. |
| 2584 | 2584 | }) = 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(", "); | |
| 2595 | 2590 | } |
| 2591 | self.in_closure = true; | |
| 2592 | self.closure_arg_span = fn_arg_span; | |
| 2593 | self.visit_expr(body); | |
| 2594 | self.in_closure = false; | |
| 2596 | 2595 | } |
| 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); | |
| 2604 | 2602 | } |
| 2605 | 2603 | hir::intravisit::walk_expr(self, e); |
| 2606 | 2604 | } |
| ... | ... | @@ -2609,8 +2607,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { |
| 2609 | 2607 | if let hir::Pat { kind: hir::PatKind::Binding(_, hir_id, _ident, _), .. } = |
| 2610 | 2608 | local.pat |
| 2611 | 2609 | && let Some(init) = local.init |
| 2612 | { | |
| 2613 | if let hir::Expr { | |
| 2610 | && let hir::Expr { | |
| 2614 | 2611 | kind: |
| 2615 | 2612 | hir::ExprKind::Closure(&hir::Closure { |
| 2616 | 2613 | kind: hir::ClosureKind::Closure, |
| ... | ... | @@ -2618,11 +2615,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> { |
| 2618 | 2615 | }), |
| 2619 | 2616 | .. |
| 2620 | 2617 | } = 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); | |
| 2625 | 2621 | } |
| 2622 | ||
| 2626 | 2623 | hir::intravisit::walk_local(self, local); |
| 2627 | 2624 | } |
| 2628 | 2625 |
compiler/rustc_borrowck/src/lib.rs+5-5| ... | ... | @@ -2069,12 +2069,12 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> { |
| 2069 | 2069 | // no move out from an earlier location) then this is an attempt at initialization |
| 2070 | 2070 | // of the union - we should error in that case. |
| 2071 | 2071 | 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| { | |
| 2074 | 2074 | this.move_data.moves[*moi].source.is_predecessor_of(location, this.body) |
| 2075 | }) { | |
| 2076 | return; | |
| 2077 | } | |
| 2075 | }) | |
| 2076 | { | |
| 2077 | return; | |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | this.report_use_of_moved_or_uninitialized( |
compiler/rustc_borrowck/src/region_infer/values.rs+4-8| ... | ... | @@ -118,10 +118,8 @@ impl LivenessValues { |
| 118 | 118 | debug!("LivenessValues::add_location(region={:?}, location={:?})", region, location); |
| 119 | 119 | if let Some(points) = &mut self.points { |
| 120 | 120 | 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); | |
| 125 | 123 | } |
| 126 | 124 | |
| 127 | 125 | // When available, record the loans flowing into this region as live at the given point. |
| ... | ... | @@ -137,10 +135,8 @@ impl LivenessValues { |
| 137 | 135 | debug!("LivenessValues::add_points(region={:?}, points={:?})", region, points); |
| 138 | 136 | if let Some(this) = &mut self.points { |
| 139 | 137 | 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); | |
| 144 | 140 | } |
| 145 | 141 | |
| 146 | 142 | // 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> { |
| 353 | 353 | let location = self.cx.elements.to_location(drop_point); |
| 354 | 354 | debug_assert_eq!(self.cx.body.terminator_loc(location.block), location,); |
| 355 | 355 | |
| 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); | |
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 |
compiler/rustc_builtin_macros/src/asm.rs+4-6| ... | ... | @@ -235,13 +235,11 @@ pub fn parse_asm_args<'a>( |
| 235 | 235 | continue; |
| 236 | 236 | } |
| 237 | 237 | 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(); | |
| 242 | 241 | |
| 243 | dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit }); | |
| 244 | } | |
| 242 | dcx.emit_err(errors::AsmPositionalAfter { span, named, explicit }); | |
| 245 | 243 | } |
| 246 | 244 | } |
| 247 | 245 |
compiler/rustc_codegen_llvm/src/back/lto.rs+3-5| ... | ... | @@ -92,11 +92,9 @@ fn prepare_lto( |
| 92 | 92 | dcx.emit_err(LtoDylib); |
| 93 | 93 | return Err(FatalError); |
| 94 | 94 | } |
| 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); | |
| 100 | 98 | } |
| 101 | 99 | } |
| 102 | 100 |
compiler/rustc_codegen_ssa/src/back/link.rs+10-18| ... | ... | @@ -281,12 +281,10 @@ pub fn each_linked_rlib( |
| 281 | 281 | let used_crate_source = &info.used_crate_source[&cnum]; |
| 282 | 282 | if let Some((path, _)) = &used_crate_source.rlib { |
| 283 | 283 | f(cnum, path); |
| 284 | } else if used_crate_source.rmeta.is_some() { | |
| 285 | return Err(errors::LinkRlibError::OnlyRmetaFound { crate_name }); | |
| 284 | 286 | } 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 }); | |
| 290 | 288 | } |
| 291 | 289 | } |
| 292 | 290 | Ok(()) |
| ... | ... | @@ -628,12 +626,10 @@ fn link_staticlib( |
| 628 | 626 | let used_crate_source = &codegen_results.crate_info.used_crate_source[&cnum]; |
| 629 | 627 | if let Some((path, _)) = &used_crate_source.dylib { |
| 630 | 628 | all_rust_dylibs.push(&**path); |
| 629 | } else if used_crate_source.rmeta.is_some() { | |
| 630 | sess.dcx().emit_fatal(errors::LinkRlibError::OnlyRmetaFound { crate_name }); | |
| 631 | 631 | } 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 }); | |
| 637 | 633 | } |
| 638 | 634 | } |
| 639 | 635 | |
| ... | ... | @@ -1972,10 +1968,8 @@ fn add_late_link_args( |
| 1972 | 1968 | if let Some(args) = sess.target.late_link_args_dynamic.get(&flavor) { |
| 1973 | 1969 | cmd.verbatim_args(args.iter().map(Deref::deref)); |
| 1974 | 1970 | } |
| 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)); | |
| 1979 | 1973 | } |
| 1980 | 1974 | if let Some(args) = sess.target.late_link_args.get(&flavor) { |
| 1981 | 1975 | cmd.verbatim_args(args.iter().map(Deref::deref)); |
| ... | ... | @@ -2635,10 +2629,8 @@ fn add_native_libs_from_crate( |
| 2635 | 2629 | if link_static { |
| 2636 | 2630 | cmd.link_staticlib_by_name(name, verbatim, false); |
| 2637 | 2631 | } |
| 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); | |
| 2642 | 2634 | } |
| 2643 | 2635 | } |
| 2644 | 2636 | NativeLibKind::Framework { as_needed } => { |
compiler/rustc_codegen_ssa/src/back/linker.rs+5-7| ... | ... | @@ -791,14 +791,12 @@ impl<'a> Linker for GccLinker<'a> { |
| 791 | 791 | self.link_arg("-exported_symbols_list").link_arg(path); |
| 792 | 792 | } else if self.sess.target.is_like_solaris { |
| 793 | 793 | self.link_arg("-M").link_arg(path); |
| 794 | } else if is_windows { | |
| 795 | self.link_arg(path); | |
| 794 | 796 | } 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"); | |
| 802 | 800 | } |
| 803 | 801 | } |
| 804 | 802 |
compiler/rustc_codegen_ssa/src/codegen_attrs.rs+19-22| ... | ... | @@ -617,32 +617,29 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { |
| 617 | 617 | // purpose functions as they wouldn't have the right target features |
| 618 | 618 | // enabled. For that reason we also forbid #[inline(always)] as it can't be |
| 619 | 619 | // 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 \ | |
| 626 | 626 | `#[target_feature]`", |
| 627 | ); | |
| 628 | } | |
| 627 | ); | |
| 629 | 628 | } |
| 630 | 629 | } |
| 631 | 630 | |
| 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 | ) | |
| 646 | 643 | } |
| 647 | 644 | } |
| 648 | 645 |
compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs+6-8| ... | ... | @@ -236,15 +236,13 @@ fn push_debuginfo_type_name<'tcx>( |
| 236 | 236 | let has_enclosing_parens = if cpp_like_debuginfo { |
| 237 | 237 | output.push_str("dyn$<"); |
| 238 | 238 | 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 | |
| 239 | 243 | } 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 | |
| 248 | 246 | }; |
| 249 | 247 | |
| 250 | 248 | 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>>( |
| 75 | 75 | |
| 76 | 76 | // This can't use `init_stack_frame` since `body` is not a function, |
| 77 | 77 | // 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 })?; | |
| 84 | 79 | ecx.storage_live_for_always_live_locals()?; |
| 85 | 80 | |
| 86 | 81 | // 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> { |
| 823 | 823 | (Abi::Rust, fn_abi), |
| 824 | 824 | &[FnArg::Copy(arg.into())], |
| 825 | 825 | false, |
| 826 | &ret.into(), | |
| 826 | &ret, | |
| 827 | 827 | Some(target), |
| 828 | 828 | unwind, |
| 829 | 829 | ) |
compiler/rustc_const_eval/src/interpret/eval_context.rs+15-7| ... | ... | @@ -16,7 +16,7 @@ use rustc_span::Span; |
| 16 | 16 | use rustc_target::abi::call::FnAbi; |
| 17 | 17 | use rustc_target::abi::{Align, HasDataLayout, Size, TargetDataLayout}; |
| 18 | 18 | use rustc_trait_selection::traits::ObligationCtxt; |
| 19 | use tracing::{debug, trace}; | |
| 19 | use tracing::{debug, instrument, trace}; | |
| 20 | 20 | |
| 21 | 21 | use super::{ |
| 22 | 22 | 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> { |
| 315 | 315 | |
| 316 | 316 | /// Check if the two things are equal in the current param_env, using an infctx to get proper |
| 317 | 317 | /// equality checks. |
| 318 | #[instrument(level = "trace", skip(self), ret)] | |
| 318 | 319 | pub(super) fn eq_in_param_env<T>(&self, a: T, b: T) -> bool |
| 319 | 320 | where |
| 320 | 321 | T: PartialEq + TypeFoldable<TyCtxt<'tcx>> + ToTrace<'tcx>, |
| ... | ... | @@ -330,13 +331,20 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { |
| 330 | 331 | // equate the two trait refs after normalization |
| 331 | 332 | let a = ocx.normalize(&cause, self.param_env, a); |
| 332 | 333 | 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; | |
| 338 | 344 | } |
| 339 | return false; | |
| 345 | ||
| 346 | // All good. | |
| 347 | true | |
| 340 | 348 | } |
| 341 | 349 | |
| 342 | 350 | /// 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> { |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | pub 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(); | |
| 229 | 227 | } |
| 230 | 228 | |
| 231 | 229 | 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> { |
| 681 | 681 | " ".repeat(expected_padding), |
| 682 | 682 | expected_label |
| 683 | 683 | ))]; |
| 684 | msg.extend(expected.0.into_iter()); | |
| 684 | msg.extend(expected.0); | |
| 685 | 685 | msg.push(StringPart::normal(format!("`{expected_extra}\n"))); |
| 686 | 686 | msg.push(StringPart::normal(format!("{}{} `", " ".repeat(found_padding), found_label))); |
| 687 | msg.extend(found.0.into_iter()); | |
| 687 | msg.extend(found.0); | |
| 688 | 688 | msg.push(StringPart::normal(format!("`{found_extra}"))); |
| 689 | 689 | |
| 690 | 690 | // 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<'_>) { |
| 1151 | 1151 | "type has conflicting packed and align representation hints" |
| 1152 | 1152 | ) |
| 1153 | 1153 | .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 | ); | |
| 1162 | 1161 | |
| 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 | ); | |
| 1167 | 1166 | |
| 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; | |
| 1186 | 1184 | } |
| 1187 | ||
| 1188 | err.emit(); | |
| 1189 | 1185 | } |
| 1186 | ||
| 1187 | err.emit(); | |
| 1190 | 1188 | } |
| 1191 | 1189 | } |
| 1192 | 1190 | } |
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) { |
| 186 | 186 | |
| 187 | 187 | if let Ok(alloc) = tcx.eval_static_initializer(id.to_def_id()) |
| 188 | 188 | && alloc.inner().provenance().ptrs().len() != 0 |
| 189 | { | |
| 190 | if attrs | |
| 189 | && attrs | |
| 191 | 190 | .link_section |
| 192 | 191 | .map(|link_section| !link_section.as_str().starts_with(".init_array")) |
| 193 | 192 | .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 \ | |
| 196 | 195 | simple list of bytes on the wasm target with no \ |
| 197 | 196 | 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); | |
| 200 | 198 | } |
| 201 | 199 | } |
| 202 | 200 |
compiler/rustc_hir_analysis/src/check/wfcheck.rs+2-2| ... | ... | @@ -1602,7 +1602,7 @@ fn check_fn_or_method<'tcx>( |
| 1602 | 1602 | function: def_id, |
| 1603 | 1603 | // Note that the `param_idx` of the output type is |
| 1604 | 1604 | // one greater than the index of the last input type. |
| 1605 | param_idx: idx.try_into().unwrap(), | |
| 1605 | param_idx: idx, | |
| 1606 | 1606 | }), |
| 1607 | 1607 | ty, |
| 1608 | 1608 | ) |
| ... | ... | @@ -1611,7 +1611,7 @@ fn check_fn_or_method<'tcx>( |
| 1611 | 1611 | for (idx, ty) in sig.inputs_and_output.iter().enumerate() { |
| 1612 | 1612 | wfcx.register_wf_obligation( |
| 1613 | 1613 | 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 }), | |
| 1615 | 1615 | ty.into(), |
| 1616 | 1616 | ); |
| 1617 | 1617 | } |
compiler/rustc_hir_analysis/src/coherence/mod.rs+9-11| ... | ... | @@ -53,17 +53,15 @@ fn enforce_trait_manually_implementable( |
| 53 | 53 | ) -> Result<(), ErrorGuaranteed> { |
| 54 | 54 | let impl_header_span = tcx.def_span(impl_def_id); |
| 55 | 55 | |
| 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(); | |
| 67 | 65 | } |
| 68 | 66 | |
| 69 | 67 | // 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>( |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | 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) | |
| 384 | 388 | } 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 | |
| 389 | 392 | } 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) | |
| 402 | 400 | } |
| 403 | 401 | } |
| 404 | 402 | } |
compiler/rustc_hir_analysis/src/errors/wrong_number_of_generic_args.rs+10-12| ... | ... | @@ -827,20 +827,18 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> { |
| 827 | 827 | |
| 828 | 828 | if num_generic_args_supplied_to_trait + num_assoc_fn_excess_args |
| 829 | 829 | == 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) | |
| 830 | 832 | { |
| 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 | ]; | |
| 841 | 840 | |
| 842 | err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect); | |
| 843 | } | |
| 841 | err.multipart_suggestion(msg, sugg, Applicability::MaybeIncorrect); | |
| 844 | 842 | } |
| 845 | 843 | } |
| 846 | 844 | } |
compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs+4-6| ... | ... | @@ -562,13 +562,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ { |
| 562 | 562 | tcx.const_param_default(param.def_id) |
| 563 | 563 | .instantiate(tcx, preceding_args) |
| 564 | 564 | .into() |
| 565 | } else if infer_args { | |
| 566 | self.lowerer.ct_infer(Some(param), self.span).into() | |
| 565 | 567 | } 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() | |
| 572 | 570 | } |
| 573 | 571 | } |
| 574 | 572 | } |
compiler/rustc_hir_typeck/src/cast.rs+5-6| ... | ... | @@ -732,12 +732,11 @@ impl<'a, 'tcx> CastCheck<'tcx> { |
| 732 | 732 | } |
| 733 | 733 | _ => return Err(CastError::NonScalar), |
| 734 | 734 | }; |
| 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); | |
| 741 | 740 | } |
| 742 | 741 | match (t_from, t_cast) { |
| 743 | 742 | // 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> { |
| 1780 | 1780 | } |
| 1781 | 1781 | |
| 1782 | 1782 | // 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(); | |
| 1793 | 1791 | } |
| 1794 | 1792 | |
| 1795 | 1793 | // If check_expr_struct_fields hit an error, do not attempt to populate |
| ... | ... | @@ -2904,21 +2902,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2904 | 2902 | candidate_fields.iter().map(|path| format!("{unwrap}{path}")), |
| 2905 | 2903 | Applicability::MaybeIncorrect, |
| 2906 | 2904 | ); |
| 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 | ); | |
| 2922 | 2919 | } |
| 2923 | 2920 | } |
| 2924 | 2921 | err |
compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs+1-1| ... | ... | @@ -2565,7 +2565,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 2565 | 2565 | other_generic_param.name.ident() == generic_param.name.ident() |
| 2566 | 2566 | }, |
| 2567 | 2567 | ) { |
| 2568 | idxs_matched.push(other_idx.into()); | |
| 2568 | idxs_matched.push(other_idx); | |
| 2569 | 2569 | } |
| 2570 | 2570 | |
| 2571 | 2571 | 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> { |
| 158 | 158 | ), |
| 159 | 159 | ); |
| 160 | 160 | } |
| 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 | ); | |
| 169 | 167 | } |
| 170 | 168 | |
| 171 | 169 | debug!( |
compiler/rustc_hir_typeck/src/method/suggest.rs+9-10| ... | ... | @@ -1252,11 +1252,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1252 | 1252 | && suggested_bounds.contains(parent) |
| 1253 | 1253 | { |
| 1254 | 1254 | // 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); | |
| 1260 | 1260 | } |
| 1261 | 1261 | ( |
| 1262 | 1262 | match parent_pred { |
| ... | ... | @@ -1267,14 +1267,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 1267 | 1267 | if !suggested |
| 1268 | 1268 | && !suggested_bounds.contains(pred) |
| 1269 | 1269 | && !suggested_bounds.contains(parent_pred) |
| 1270 | { | |
| 1271 | if collect_type_param_suggestions( | |
| 1270 | && collect_type_param_suggestions( | |
| 1272 | 1271 | self_ty, |
| 1273 | 1272 | *parent_pred, |
| 1274 | 1273 | &p, |
| 1275 | ) { | |
| 1276 | suggested_bounds.insert(pred); | |
| 1277 | } | |
| 1274 | ) | |
| 1275 | { | |
| 1276 | suggested_bounds.insert(pred); | |
| 1278 | 1277 | } |
| 1279 | 1278 | format!("`{p}`\nwhich is required by `{parent_p}`") |
| 1280 | 1279 | } |
compiler/rustc_incremental/src/persist/dirty_clean.rs+3-5| ... | ... | @@ -417,12 +417,10 @@ fn check_config(tcx: TyCtxt<'_>, attr: &Attribute) -> bool { |
| 417 | 417 | fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol { |
| 418 | 418 | if let Some(value) = item.value_str() { |
| 419 | 419 | value |
| 420 | } else if let Some(ident) = item.ident() { | |
| 421 | tcx.dcx().emit_fatal(errors::AssociatedValueExpectedFor { span: item.span(), ident }); | |
| 420 | 422 | } 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() }); | |
| 426 | 424 | } |
| 427 | 425 | } |
| 428 | 426 |
compiler/rustc_lint/src/builtin.rs+2-4| ... | ... | @@ -429,10 +429,8 @@ impl MissingDoc { |
| 429 | 429 | // Only check publicly-visible items, using the result from the privacy pass. |
| 430 | 430 | // It's an option so the crate root can also use this function (it doesn't |
| 431 | 431 | // 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; | |
| 436 | 434 | } |
| 437 | 435 | |
| 438 | 436 | 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> { |
| 444 | 444 | // the `-Z force-unstable-if-unmarked` flag present (we're |
| 445 | 445 | // compiling a compiler crate), then let this missing feature |
| 446 | 446 | // 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; | |
| 451 | 452 | } |
| 452 | 453 | |
| 453 | 454 | 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> |
| 448 | 448 | bad: uninit_range, |
| 449 | 449 | })) |
| 450 | 450 | })?; |
| 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 | }))); | |
| 467 | 465 | } |
| 468 | 466 | Ok(self.get_bytes_unchecked(range)) |
| 469 | 467 | } |
compiler/rustc_middle/src/mir/pretty.rs+3-5| ... | ... | @@ -208,12 +208,10 @@ fn dump_path<'tcx>( |
| 208 | 208 | |
| 209 | 209 | let pass_num = if tcx.sess.opts.unstable_opts.dump_mir_exclude_pass_number { |
| 210 | 210 | String::new() |
| 211 | } else if pass_num { | |
| 212 | format!(".{:03}-{:03}", body.phase.phase_index(), body.pass_count) | |
| 211 | 213 | } 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() | |
| 217 | 215 | }; |
| 218 | 216 | |
| 219 | 217 | 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> { |
| 396 | 396 | Ok((tcx.type_of(unevaluated.def).instantiate(tcx, unevaluated.args), c)) |
| 397 | 397 | } |
| 398 | 398 | Ok(Err(bad_ty)) => Err(Either::Left(bad_ty)), |
| 399 | Err(err) => Err(Either::Right(err.into())), | |
| 399 | Err(err) => Err(Either::Right(err)), | |
| 400 | 400 | } |
| 401 | 401 | } |
| 402 | 402 | ConstKind::Value(ty, val) => Ok((ty, val)), |
compiler/rustc_middle/src/ty/context.rs+24-26| ... | ... | @@ -2606,33 +2606,31 @@ impl<'tcx> TyCtxt<'tcx> { |
| 2606 | 2606 | /// With `cfg(debug_assertions)`, assert that args are compatible with their generics, |
| 2607 | 2607 | /// and print out the args if not. |
| 2608 | 2608 | 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() | |
| 2626 | 2624 | ) |
| 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 | ); | |
| 2636 | 2634 | } |
| 2637 | 2635 | } |
| 2638 | 2636 | } |
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) -> |
| 1183 | 1183 | // |
| 1184 | 1184 | // This is not part of `codegen_fn_attrs` as it can differ between crates |
| 1185 | 1185 | // 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; | |
| 1190 | 1190 | } |
| 1191 | 1191 | } |
| 1192 | 1192 |
compiler/rustc_middle/src/ty/print/pretty.rs+3-5| ... | ... | @@ -1526,7 +1526,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { |
| 1526 | 1526 | |
| 1527 | 1527 | let precedence = |binop: rustc_middle::mir::BinOp| { |
| 1528 | 1528 | 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() | |
| 1530 | 1530 | }; |
| 1531 | 1531 | let op_precedence = precedence(op); |
| 1532 | 1532 | let formatted_op = op.to_hir_binop().as_str(); |
| ... | ... | @@ -3361,10 +3361,8 @@ pub fn trimmed_def_paths(tcx: TyCtxt<'_>, (): ()) -> DefIdMap<Symbol> { |
| 3361 | 3361 | // name. |
| 3362 | 3362 | // |
| 3363 | 3363 | // 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); | |
| 3368 | 3366 | } |
| 3369 | 3367 | } |
| 3370 | 3368 | Vacant(v) => { |
compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs+2-3| ... | ... | @@ -268,10 +268,9 @@ impl Builder<'_, '_> { |
| 268 | 268 | pub(crate) fn mcdc_decrement_depth_if_enabled(&mut self) { |
| 269 | 269 | if let Some(coverage_info) = self.coverage_info.as_mut() |
| 270 | 270 | && let Some(mcdc_info) = coverage_info.mcdc_info.as_mut() |
| 271 | && mcdc_info.state.decision_ctx_stack.pop().is_none() | |
| 271 | 272 | { |
| 272 | if mcdc_info.state.decision_ctx_stack.pop().is_none() { | |
| 273 | bug!("Unexpected empty decision stack"); | |
| 274 | } | |
| 273 | bug!("Unexpected empty decision stack"); | |
| 275 | 274 | }; |
| 276 | 275 | } |
| 277 | 276 | } |
compiler/rustc_mir_transform/src/check_const_item_mutation.rs+12-12| ... | ... | @@ -95,19 +95,19 @@ impl<'tcx> Visitor<'tcx> for ConstMutationChecker<'_, 'tcx> { |
| 95 | 95 | // Check for assignment to fields of a constant |
| 96 | 96 | // Assigning directly to a constant (e.g. `FOO = true;`) is a hard error, |
| 97 | 97 | // 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 | ); | |
| 110 | 109 | } |
| 110 | ||
| 111 | 111 | // We are looking for MIR of the form: |
| 112 | 112 | // |
| 113 | 113 | // ``` |
compiler/rustc_mir_transform/src/deduce_param_attrs.rs+4-5| ... | ... | @@ -168,17 +168,16 @@ pub(super) fn deduced_param_attrs<'tcx>( |
| 168 | 168 | // Codegen won't use this information for anything if all the function parameters are passed |
| 169 | 169 | // directly. Detect that and bail, for compilation speed. |
| 170 | 170 | 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 | |
| 173 | 173 | .fn_sig(tcx) |
| 174 | 174 | .inputs() |
| 175 | 175 | .skip_binder() |
| 176 | 176 | .iter() |
| 177 | 177 | .cloned() |
| 178 | 178 | .all(type_will_always_be_passed_directly) |
| 179 | { | |
| 180 | return &[]; | |
| 181 | } | |
| 179 | { | |
| 180 | return &[]; | |
| 182 | 181 | } |
| 183 | 182 | |
| 184 | 183 | // 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> { |
| 378 | 378 | if let (Some(l), Some(r)) = (l, r) |
| 379 | 379 | && l.layout.ty.is_integral() |
| 380 | 380 | && op.is_overflowing() |
| 381 | { | |
| 382 | if self.use_ecx(|this| { | |
| 381 | && self.use_ecx(|this| { | |
| 383 | 382 | let (_res, overflow) = this.ecx.binary_op(op, &l, &r)?.to_scalar_pair(); |
| 384 | 383 | 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; | |
| 393 | 392 | } |
| 393 | ||
| 394 | 394 | Some(()) |
| 395 | 395 | } |
| 396 | 396 |
compiler/rustc_monomorphize/src/partitioning.rs+2-4| ... | ... | @@ -504,10 +504,8 @@ fn compute_inlined_overlap<'tcx>(cgu1: &CodegenUnit<'tcx>, cgu2: &CodegenUnit<'t |
| 504 | 504 | |
| 505 | 505 | let mut overlap = 0; |
| 506 | 506 | 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; | |
| 511 | 509 | } |
| 512 | 510 | } |
| 513 | 511 | 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> { |
| 185 | 185 | for var in var_infos.iter_mut() { |
| 186 | 186 | // We simply put all regions from the input into the highest |
| 187 | 187 | // 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) | |
| 192 | 190 | } |
| 193 | 191 | } |
| 194 | 192 | } |
compiler/rustc_next_trait_solver/src/solve/trait_goals.rs-1| ... | ... | @@ -883,7 +883,6 @@ where |
| 883 | 883 | .into_iter() |
| 884 | 884 | .chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| { |
| 885 | 885 | elaborate::supertrait_def_ids(self.cx(), principal_def_id) |
| 886 | .into_iter() | |
| 887 | 886 | .filter(|def_id| self.cx().trait_is_auto(*def_id)) |
| 888 | 887 | })) |
| 889 | 888 | .collect(); |
compiler/rustc_parse/src/parser/attr_wrapper.rs+1-1| ... | ... | @@ -383,7 +383,7 @@ impl<'a> Parser<'a> { |
| 383 | 383 | self.capture_state |
| 384 | 384 | .parser_replacements |
| 385 | 385 | .drain(parser_replacements_start..parser_replacements_end) |
| 386 | .chain(inner_attr_parser_replacements.into_iter()) | |
| 386 | .chain(inner_attr_parser_replacements) | |
| 387 | 387 | .map(|(parser_range, data)| { |
| 388 | 388 | (NodeRange::new(parser_range, collect_pos.start_pos), data) |
| 389 | 389 | }) |
compiler/rustc_parse/src/parser/expr.rs+5-7| ... | ... | @@ -2554,13 +2554,12 @@ impl<'a> Parser<'a> { |
| 2554 | 2554 | let maybe_fatarrow = self.token.clone(); |
| 2555 | 2555 | let block = if self.check(&token::OpenDelim(Delimiter::Brace)) { |
| 2556 | 2556 | self.parse_block()? |
| 2557 | } else if let Some(block) = recover_block_from_condition(self) { | |
| 2558 | block | |
| 2557 | 2559 | } 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| { | |
| 2564 | 2563 | if self.prev_token == token::Semi |
| 2565 | 2564 | && self.token == token::AndAnd |
| 2566 | 2565 | && let maybe_let = self.look_ahead(1, |t| t.clone()) |
| ... | ... | @@ -2592,7 +2591,6 @@ impl<'a> Parser<'a> { |
| 2592 | 2591 | } |
| 2593 | 2592 | err |
| 2594 | 2593 | })? |
| 2595 | } | |
| 2596 | 2594 | }; |
| 2597 | 2595 | self.error_on_if_block_attrs(lo, false, block.span, attrs); |
| 2598 | 2596 | block |
compiler/rustc_parse/src/parser/item.rs+5-5| ... | ... | @@ -1588,7 +1588,7 @@ impl<'a> Parser<'a> { |
| 1588 | 1588 | (thin_vec![], Recovered::Yes(guar)) |
| 1589 | 1589 | } |
| 1590 | 1590 | }; |
| 1591 | VariantData::Struct { fields, recovered: recovered.into() } | |
| 1591 | VariantData::Struct { fields, recovered } | |
| 1592 | 1592 | } else if this.check(&token::OpenDelim(Delimiter::Parenthesis)) { |
| 1593 | 1593 | let body = match this.parse_tuple_struct_body() { |
| 1594 | 1594 | Ok(body) => body, |
| ... | ... | @@ -1672,7 +1672,7 @@ impl<'a> Parser<'a> { |
| 1672 | 1672 | class_name.span, |
| 1673 | 1673 | generics.where_clause.has_where_token, |
| 1674 | 1674 | )?; |
| 1675 | VariantData::Struct { fields, recovered: recovered.into() } | |
| 1675 | VariantData::Struct { fields, recovered } | |
| 1676 | 1676 | } |
| 1677 | 1677 | // No `where` so: `struct Foo<T>;` |
| 1678 | 1678 | } else if self.eat(&token::Semi) { |
| ... | ... | @@ -1684,7 +1684,7 @@ impl<'a> Parser<'a> { |
| 1684 | 1684 | class_name.span, |
| 1685 | 1685 | generics.where_clause.has_where_token, |
| 1686 | 1686 | )?; |
| 1687 | VariantData::Struct { fields, recovered: recovered.into() } | |
| 1687 | VariantData::Struct { fields, recovered } | |
| 1688 | 1688 | // Tuple-style struct definition with optional where-clause. |
| 1689 | 1689 | } else if self.token == token::OpenDelim(Delimiter::Parenthesis) { |
| 1690 | 1690 | let body = VariantData::Tuple(self.parse_tuple_struct_body()?, DUMMY_NODE_ID); |
| ... | ... | @@ -1713,14 +1713,14 @@ impl<'a> Parser<'a> { |
| 1713 | 1713 | class_name.span, |
| 1714 | 1714 | generics.where_clause.has_where_token, |
| 1715 | 1715 | )?; |
| 1716 | VariantData::Struct { fields, recovered: recovered.into() } | |
| 1716 | VariantData::Struct { fields, recovered } | |
| 1717 | 1717 | } else if self.token == token::OpenDelim(Delimiter::Brace) { |
| 1718 | 1718 | let (fields, recovered) = self.parse_record_struct_body( |
| 1719 | 1719 | "union", |
| 1720 | 1720 | class_name.span, |
| 1721 | 1721 | generics.where_clause.has_where_token, |
| 1722 | 1722 | )?; |
| 1723 | VariantData::Struct { fields, recovered: recovered.into() } | |
| 1723 | VariantData::Struct { fields, recovered } | |
| 1724 | 1724 | } else { |
| 1725 | 1725 | let token_str = super::token_descr(&self.token); |
| 1726 | 1726 | 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> { |
| 1359 | 1359 | fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> { |
| 1360 | 1360 | Ok(if let Some(args) = self.parse_delim_args_inner() { |
| 1361 | 1361 | 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()?)) | |
| 1362 | 1365 | } 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 | |
| 1369 | 1367 | }) |
| 1370 | 1368 | } |
| 1371 | 1369 |
compiler/rustc_parse/src/parser/pat.rs+13-15| ... | ... | @@ -1336,21 +1336,19 @@ impl<'a> Parser<'a> { |
| 1336 | 1336 | vec![(first_etc_span, String::new())], |
| 1337 | 1337 | Applicability::MachineApplicable, |
| 1338 | 1338 | ); |
| 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 | ); | |
| 1354 | 1352 | } |
| 1355 | 1353 | } |
| 1356 | 1354 | err.emit(); |
compiler/rustc_parse/src/parser/path.rs+6-6| ... | ... | @@ -671,12 +671,12 @@ impl<'a> Parser<'a> { |
| 671 | 671 | err.emit(); |
| 672 | 672 | continue; |
| 673 | 673 | } |
| 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; | |
| 680 | 680 | } |
| 681 | 681 | break; |
| 682 | 682 | } |
compiler/rustc_parse/src/validate_attr.rs+5-7| ... | ... | @@ -192,13 +192,11 @@ pub fn check_attribute_safety(psess: &ParseSess, safety: AttributeSafety, attr: |
| 192 | 192 | ); |
| 193 | 193 | } |
| 194 | 194 | } |
| 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 | }); | |
| 202 | 200 | } |
| 203 | 201 | } |
| 204 | 202 |
compiler/rustc_passes/src/check_attr.rs+7-11| ... | ... | @@ -2169,17 +2169,13 @@ impl<'tcx> CheckAttrVisitor<'tcx> { |
| 2169 | 2169 | attr.span, |
| 2170 | 2170 | errors::MacroExport::TooManyItems, |
| 2171 | 2171 | ); |
| 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 | ); | |
| 2183 | 2179 | } |
| 2184 | 2180 | } else { |
| 2185 | 2181 | // 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> { |
| 1500 | 1500 | ); |
| 1501 | 1501 | } |
| 1502 | 1502 | } |
| 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 | ); | |
| 1512 | 1510 | } |
| 1513 | 1511 | } |
| 1514 | 1512 | } |
compiler/rustc_passes/src/stability.rs+8-10| ... | ... | @@ -174,16 +174,14 @@ impl<'a, 'tcx> Annotator<'a, 'tcx> { |
| 174 | 174 | |
| 175 | 175 | // If the current node is a function, has const stability attributes and if it doesn not have an intrinsic ABI, |
| 176 | 176 | // 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 }); | |
| 187 | 185 | } |
| 188 | 186 | |
| 189 | 187 | // `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> { |
| 1233 | 1233 | && ns == namespace |
| 1234 | 1234 | && in_module != parent_scope.module |
| 1235 | 1235 | && !ident.span.normalize_to_macros_2_0().from_expansion() |
| 1236 | && filter_fn(res) | |
| 1236 | 1237 | { |
| 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()); | |
| 1247 | 1247 | |
| 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 }; | |
| 1250 | 1250 | |
| 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); | |
| 1259 | 1258 | } |
| 1259 | } | |
| 1260 | 1260 | |
| 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 | }); | |
| 1294 | 1293 | } |
| 1295 | 1294 | } |
| 1296 | 1295 |
compiler/rustc_resolve/src/ident.rs+6-6| ... | ... | @@ -958,12 +958,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { |
| 958 | 958 | }); |
| 959 | 959 | } |
| 960 | 960 | |
| 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)); | |
| 967 | 967 | } |
| 968 | 968 | |
| 969 | 969 | self.record_use(ident, binding, used); |
compiler/rustc_resolve/src/imports.rs+15-21| ... | ... | @@ -1256,28 +1256,23 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { |
| 1256 | 1256 | extern_crate_span: self.tcx.source_span(self.local_def_id(extern_crate_id)), |
| 1257 | 1257 | }, |
| 1258 | 1258 | ); |
| 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(); | |
| 1259 | 1267 | } 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 }) | |
| 1271 | 1271 | } 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 | }; | |
| 1279 | 1274 | |
| 1280 | match binding.kind { | |
| 1275 | match binding.kind { | |
| 1281 | 1276 | NameBindingKind::Res(Res::Def(DefKind::Macro(_), def_id)) |
| 1282 | 1277 | // exclude decl_macro |
| 1283 | 1278 | if self.get_macro_by_def_id(def_id).macro_rules => |
| ... | ... | @@ -1293,8 +1288,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { |
| 1293 | 1288 | }); |
| 1294 | 1289 | } |
| 1295 | 1290 | } |
| 1296 | err.emit(); | |
| 1297 | } | |
| 1291 | err.emit(); | |
| 1298 | 1292 | } |
| 1299 | 1293 | } |
| 1300 | 1294 |
compiler/rustc_resolve/src/late.rs+7-9| ... | ... | @@ -4781,16 +4781,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> { |
| 4781 | 4781 | if let Some(res) = res |
| 4782 | 4782 | && let Some(def_id) = res.opt_def_id() |
| 4783 | 4783 | && !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 | ) | |
| 4784 | 4789 | { |
| 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; | |
| 4794 | 4792 | } |
| 4795 | 4793 | res |
| 4796 | 4794 | }); |
compiler/rustc_resolve/src/late/diagnostics.rs+16-17| ... | ... | @@ -2255,25 +2255,24 @@ impl<'a: 'ast, 'ast, 'tcx> LateResolutionVisitor<'a, '_, 'ast, 'tcx> { |
| 2255 | 2255 | fn let_binding_suggestion(&mut self, err: &mut Diag<'_>, ident_span: Span) -> bool { |
| 2256 | 2256 | if let Some(Expr { kind: ExprKind::Assign(lhs, ..), .. }) = self.diag_metadata.in_assignment |
| 2257 | 2257 | && let ast::ExprKind::Path(None, ref path) = lhs.kind |
| 2258 | && !ident_span.from_expansion() | |
| 2258 | 2259 | { |
| 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 | }; | |
| 2268 | 2268 | |
| 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; | |
| 2277 | 2276 | } |
| 2278 | 2277 | false |
| 2279 | 2278 | } |
compiler/rustc_resolve/src/rustdoc.rs+3-5| ... | ... | @@ -270,12 +270,10 @@ fn strip_generics_from_path_segment(segment: Vec<char>) -> Result<String, Malfor |
| 270 | 270 | // Give a helpful error message instead of completely ignoring the angle brackets. |
| 271 | 271 | return Err(MalformedGenerics::HasFullyQualifiedSyntax); |
| 272 | 272 | } |
| 273 | } else if param_depth == 0 { | |
| 274 | stripped_segment.push(c); | |
| 273 | 275 | } 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); | |
| 279 | 277 | } |
| 280 | 278 | } |
| 281 | 279 |
compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/encode.rs+5-7| ... | ... | @@ -207,14 +207,12 @@ fn encode_fnsig<'tcx>( |
| 207 | 207 | if fn_sig.c_variadic { |
| 208 | 208 | s.push('z'); |
| 209 | 209 | } |
| 210 | } else if fn_sig.c_variadic { | |
| 211 | s.push('z'); | |
| 210 | 212 | } 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') | |
| 218 | 216 | } |
| 219 | 217 | |
| 220 | 218 | // 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> { |
| 381 | 381 | let consts = [ |
| 382 | 382 | start.unwrap_or(self.tcx.consts.unit), |
| 383 | 383 | 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), | |
| 385 | 385 | ]; |
| 386 | 386 | // HACK: Represent as tuple until we have something better. |
| 387 | 387 | // 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 |
| 69 | 69 | |
| 70 | 70 | if must_use_stack { |
| 71 | 71 | 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. | |
| 76 | 75 | |
| 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()); | |
| 87 | 81 | } 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); | |
| 95 | 93 | } |
| 96 | 94 | } |
| 97 | 95 | } |
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) { |
| 351 | 351 | }; |
| 352 | 352 | |
| 353 | 353 | // 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> | |
| 354 | 357 | let min = match (os, arch, abi) { |
| 355 | // Use 11.0 on Aarch64 as that's the earliest version with M1 support. | |
| 356 | 358 | ("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), | |
| 358 | 362 | // Mac Catalyst defaults to 13.1 in Clang. |
| 359 | 363 | ("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), | |
| 360 | 366 | _ => os_min, |
| 361 | 367 | }; |
| 362 | 368 |
compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs+13-15| ... | ... | @@ -1323,23 +1323,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { |
| 1323 | 1323 | label_or_note(span, terr.to_string(self.tcx)); |
| 1324 | 1324 | label_or_note(sp, msg); |
| 1325 | 1325 | } |
| 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 { | |
| 1341 | 1335 | label_or_note(span, terr.to_string(self.tcx)); |
| 1336 | } else { | |
| 1337 | label_or_note(span, Cow::from(format!("expected {expected}, found {found}"))); | |
| 1342 | 1338 | } |
| 1339 | } else { | |
| 1340 | label_or_note(span, terr.to_string(self.tcx)); | |
| 1343 | 1341 | } |
| 1344 | 1342 | |
| 1345 | 1343 | 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> { |
| 3237 | 3237 | // then the tuple must be the one containing capture types. |
| 3238 | 3238 | let is_upvar_tys_infer_tuple = if !matches!(ty.kind(), ty::Tuple(..)) { |
| 3239 | 3239 | 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(..)) | |
| 3240 | 3245 | } 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 | |
| 3250 | 3247 | }; |
| 3251 | 3248 | |
| 3252 | 3249 | 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>( |
| 408 | 408 | debug!("opt_normalize_projection_type: found error"); |
| 409 | 409 | let result = normalize_to_error(selcx, param_env, projection_term, cause, depth); |
| 410 | 410 | obligations.extend(result.obligations); |
| 411 | return Ok(Some(result.value.into())); | |
| 411 | return Ok(Some(result.value)); | |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| ... | ... | @@ -478,7 +478,7 @@ pub(super) fn opt_normalize_projection_term<'a, 'b, 'tcx>( |
| 478 | 478 | } |
| 479 | 479 | let result = normalize_to_error(selcx, param_env, projection_term, cause, depth); |
| 480 | 480 | obligations.extend(result.obligations); |
| 481 | Ok(Some(result.value.into())) | |
| 481 | Ok(Some(result.value)) | |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | 484 | } |
compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs+6-9| ... | ... | @@ -426,13 +426,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 426 | 426 | } else if kind == ty::ClosureKind::FnOnce { |
| 427 | 427 | candidates.vec.push(ClosureCandidate { is_const }); |
| 428 | 428 | } |
| 429 | } else if kind == ty::ClosureKind::FnOnce { | |
| 430 | candidates.vec.push(ClosureCandidate { is_const }); | |
| 429 | 431 | } 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; | |
| 436 | 434 | } |
| 437 | 435 | } |
| 438 | 436 | ty::Infer(ty::TyVar(_)) => { |
| ... | ... | @@ -513,10 +511,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 513 | 511 | // then there's nothing else to check. |
| 514 | 512 | if let Some(closure_kind) = self_ty.to_opt_closure_kind() |
| 515 | 513 | && let Some(goal_kind) = target_kind_ty.to_opt_closure_kind() |
| 514 | && closure_kind.extends(goal_kind) | |
| 516 | 515 | { |
| 517 | if closure_kind.extends(goal_kind) { | |
| 518 | candidates.vec.push(AsyncFnKindHelperCandidate); | |
| 519 | } | |
| 516 | candidates.vec.push(AsyncFnKindHelperCandidate); | |
| 520 | 517 | } |
| 521 | 518 | } |
| 522 | 519 |
compiler/rustc_trait_selection/src/traits/select/mod.rs+17-21| ... | ... | @@ -1334,16 +1334,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 1334 | 1334 | return; |
| 1335 | 1335 | } |
| 1336 | 1336 | |
| 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; | |
| 1347 | 1345 | } |
| 1348 | 1346 | |
| 1349 | 1347 | debug!(?trait_pred, ?result, "insert_evaluation_cache"); |
| ... | ... | @@ -1584,13 +1582,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |
| 1584 | 1582 | if self.can_use_global_caches(param_env) { |
| 1585 | 1583 | if let Err(Overflow(OverflowError::Canonical)) = candidate { |
| 1586 | 1584 | // 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; | |
| 1594 | 1590 | } |
| 1595 | 1591 | } |
| 1596 | 1592 | |
| ... | ... | @@ -1980,10 +1976,10 @@ impl<'tcx> SelectionContext<'_, 'tcx> { |
| 1980 | 1976 | // impls have to be always applicable, meaning that the only allowed |
| 1981 | 1977 | // region constraints may be constraints also present on the default impl. |
| 1982 | 1978 | 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; | |
| 1987 | 1983 | } |
| 1988 | 1984 | |
| 1989 | 1985 | 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> { |
| 143 | 143 | match origin { |
| 144 | 144 | rustc_hir::OpaqueTyOrigin::FnReturn(_) | rustc_hir::OpaqueTyOrigin::AsyncFn(_) => {} |
| 145 | 145 | 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; | |
| 150 | 148 | } |
| 151 | 149 | } |
| 152 | 150 | } |
library/core/src/slice/mod.rs+1-1| ... | ... | @@ -156,7 +156,7 @@ impl<T> [T] { |
| 156 | 156 | if let [first, ..] = self { Some(first) } else { None } |
| 157 | 157 | } |
| 158 | 158 | |
| 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. | |
| 160 | 160 | /// |
| 161 | 161 | /// # Examples |
| 162 | 162 | /// |
library/std/src/path.rs+24| ... | ... | @@ -1153,6 +1153,21 @@ impl FusedIterator for Ancestors<'_> {} |
| 1153 | 1153 | /// ``` |
| 1154 | 1154 | /// |
| 1155 | 1155 | /// 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. | |
| 1156 | 1171 | #[cfg_attr(not(test), rustc_diagnostic_item = "PathBuf")] |
| 1157 | 1172 | #[stable(feature = "rust1", since = "1.0.0")] |
| 1158 | 1173 | pub struct PathBuf { |
| ... | ... | @@ -1391,6 +1406,9 @@ impl PathBuf { |
| 1391 | 1406 | /// `file_name`. The new path will be a sibling of the original path. |
| 1392 | 1407 | /// (That is, it will have the same parent.) |
| 1393 | 1408 | /// |
| 1409 | /// The argument is not sanitized, so can include separators. This | |
| 1410 | /// behaviour may be changed to a panic in the future. | |
| 1411 | /// | |
| 1394 | 1412 | /// [`self.file_name`]: Path::file_name |
| 1395 | 1413 | /// [`pop`]: PathBuf::pop |
| 1396 | 1414 | /// |
| ... | ... | @@ -1411,6 +1429,12 @@ impl PathBuf { |
| 1411 | 1429 | /// |
| 1412 | 1430 | /// buf.set_file_name("baz"); |
| 1413 | 1431 | /// 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")); | |
| 1414 | 1438 | /// ``` |
| 1415 | 1439 | #[stable(feature = "rust1", since = "1.0.0")] |
| 1416 | 1440 | 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. |
| 24 | 24 | |
| 25 | 25 | ### OS version |
| 26 | 26 | |
| 27 | The minimum supported version is iOS 13.1. | |
| 27 | The minimum supported version is iOS 13.1 on x86 and 14.0 on Aarch64. | |
| 28 | 28 | |
| 29 | 29 | This can be raised per-binary by changing the deployment target. `rustc` |
| 30 | 30 | respects 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 @@ |
| 2 | 2 | |
| 3 | 3 | **Tier: 3** |
| 4 | 4 | |
| 5 | ARM64e iOS (12.0+) | |
| 5 | ARM64e iOS (14.0+) | |
| 6 | 6 | |
| 7 | 7 | ## Target maintainers |
| 8 | 8 |
src/tools/clippy/clippy_utils/src/ast_utils.rs+11-1| ... | ... | @@ -221,7 +221,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool { |
| 221 | 221 | ) => { |
| 222 | 222 | eq_closure_binder(lb, rb) |
| 223 | 223 | && lc == rc |
| 224 | && la.map_or(false, CoroutineKind::is_async) == ra.map_or(false, CoroutineKind::is_async) | |
| 224 | && eq_coroutine_kind(*la, *ra) | |
| 225 | 225 | && lm == rm |
| 226 | 226 | && eq_fn_decl(lf, rf) |
| 227 | 227 | && eq_expr(le, re) |
| ... | ... | @@ -241,6 +241,16 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool { |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | fn 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 | ||
| 244 | 254 | pub fn eq_field(l: &ExprField, r: &ExprField) -> bool { |
| 245 | 255 | l.is_placeholder == r.is_placeholder |
| 246 | 256 | && eq_id(l.ident, r.ident) |
src/tools/compiletest/src/lib.rs+6| ... | ... | @@ -647,6 +647,12 @@ fn common_inputs_stamp(config: &Config) -> Stamp { |
| 647 | 647 | stamp.add_path(&rust_src_dir.join("src/etc/htmldocck.py")); |
| 648 | 648 | } |
| 649 | 649 | |
| 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 | ||
| 650 | 656 | stamp.add_dir(&rust_src_dir.join("src/tools/run-make-support")); |
| 651 | 657 | |
| 652 | 658 | // Compiletest itself. |
src/tools/run-make-support/src/external_deps/llvm.rs+6| ... | ... | @@ -54,6 +54,12 @@ pub fn llvm_dwarfdump() -> LlvmDwarfdump { |
| 54 | 54 | LlvmDwarfdump::new() |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | /// Construct a new `llvm-pdbutil` invocation. This assumes that `llvm-pdbutil` is available | |
| 58 | /// at `$LLVM_BIN_DIR/llvm-pdbutil`. | |
| 59 | pub fn llvm_pdbutil() -> LlvmPdbutil { | |
| 60 | LlvmPdbutil::new() | |
| 61 | } | |
| 62 | ||
| 57 | 63 | /// A `llvm-readobj` invocation builder. |
| 58 | 64 | #[derive(Debug)] |
| 59 | 65 | #[must_use] |
tests/run-make/apple-deployment-target/rmake.rs+16-12| ... | ... | @@ -55,11 +55,8 @@ fn main() { |
| 55 | 55 | rustc().env(env_var, example_version).run(); |
| 56 | 56 | minos("foo.o", example_version); |
| 57 | 57 | |
| 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); | |
| 63 | 60 | }); |
| 64 | 61 | |
| 65 | 62 | // Test that version makes it to the linker when linking dylibs. |
| ... | ... | @@ -104,8 +101,18 @@ fn main() { |
| 104 | 101 | rustc |
| 105 | 102 | }; |
| 106 | 103 | |
| 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" { | |
| 109 | 116 | rustc().env(env_var, example_version).run(); |
| 110 | 117 | minos("foo", example_version); |
| 111 | 118 | |
| ... | ... | @@ -146,10 +153,7 @@ fn main() { |
| 146 | 153 | rustc().env(env_var, higher_example_version).run(); |
| 147 | 154 | minos("foo.o", higher_example_version); |
| 148 | 155 | |
| 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); | |
| 154 | 158 | }); |
| 155 | 159 | } |
tests/run-make/pdb-buildinfo-cl-cmd/filecheck.txt created+4| ... | ... | @@ -0,0 +1,4 @@ |
| 1 | CHECK: LF_BUILDINFO | |
| 2 | CHECK: rustc.exe | |
| 3 | CHECK: main.rs | |
| 4 | CHECK: "-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 @@ |
| 7 | 7 | //@ only-windows-msvc |
| 8 | 8 | // Reason: pdb files are unique to this architecture |
| 9 | 9 | |
| 10 | use run_make_support::{assert_contains, bstr, env_var, rfs, rustc}; | |
| 10 | use run_make_support::{llvm, rustc}; | |
| 11 | 11 | |
| 12 | 12 | fn main() { |
| 13 | 13 | rustc() |
| ... | ... | @@ -17,23 +17,9 @@ fn main() { |
| 17 | 17 | .crate_type("bin") |
| 18 | 18 | .metadata("dc9ef878b0a48666") |
| 19 | 19 | .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 | } | |
| 34 | 20 | |
| 35 | fn 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(); | |
| 39 | 25 | } |
tests/run-make/pdb-sobjname/main.rs created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | fn 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 | ||
| 9 | use run_make_support::{llvm, rustc}; | |
| 10 | ||
| 11 | fn 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 | ||
| 6 | const gen fn a() {} | |
| 7 | //~^ ERROR functions cannot be both `const` and `gen` | |
| 8 | ||
| 9 | const async gen fn b() {} | |
| 10 | //~^ ERROR functions cannot be both `const` and `async gen` | |
| 11 | ||
| 12 | fn main() {} |
tests/ui/coroutine/const_gen_fn.stderr created+20| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | error: functions cannot be both `const` and `gen` | |
| 2 | --> $DIR/const_gen_fn.rs:6:1 | |
| 3 | | | |
| 4 | LL | const gen fn a() {} | |
| 5 | | ^^^^^-^^^---------- | |
| 6 | | | | | |
| 7 | | | `gen` because of this | |
| 8 | | `const` because of this | |
| 9 | ||
| 10 | error: functions cannot be both `const` and `async gen` | |
| 11 | --> $DIR/const_gen_fn.rs:9:1 | |
| 12 | | | |
| 13 | LL | const async gen fn b() {} | |
| 14 | | ^^^^^-^^^^^^^^^---------- | |
| 15 | | | | | |
| 16 | | | `async gen` because of this | |
| 17 | | `const` because of this | |
| 18 | ||
| 19 | error: aborting due to 2 previous errors | |
| 20 |