Skip to content

Commit 66701c4

Browse files
committed
Auto merge of rust-lang#132251 - jieyouxu:rollup-mtv9mpd, r=jieyouxu
Rollup of 7 pull requests Successful merges: - rust-lang#131633 (error on alignments greater than `isize::MAX`) - rust-lang#132086 (Tweak E0277 highlighting and "long type" path printing) - rust-lang#132220 (Add GUI regression test for doc struct fields margins) - rust-lang#132225 (Dynamically link run-make support) - rust-lang#132227 (Pass constness with span into lower_poly_trait_ref) - rust-lang#132242 (Support `char::is_digit` in const contexts.) - rust-lang#132243 (Remove `ObligationCause::span()` method) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6929a48 + 3e3feac commit 66701c4

File tree

66 files changed

+572
-337
lines changed

Some content is hidden

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

66 files changed

+572
-337
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
611611
Err(terr) => {
612612
let mut diag = struct_span_code_err!(
613613
tcx.dcx(),
614-
cause.span(),
614+
cause.span,
615615
E0053,
616616
"method `{}` has an incompatible return type for trait",
617617
trait_m.name
@@ -1169,7 +1169,7 @@ fn extract_spans_for_error_reporting<'tcx>(
11691169
TypeError::ArgumentMutability(i) | TypeError::ArgumentSorts(ExpectedFound { .. }, i) => {
11701170
(impl_args.nth(i).unwrap(), trait_args.and_then(|mut args| args.nth(i)))
11711171
}
1172-
_ => (cause.span(), tcx.hir().span_if_local(trait_m.def_id)),
1172+
_ => (cause.span, tcx.hir().span_if_local(trait_m.def_id)),
11731173
}
11741174
}
11751175

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub fn check_function_signature<'tcx>(
612612
match err {
613613
TypeError::ArgumentMutability(i)
614614
| TypeError::ArgumentSorts(ExpectedFound { .. }, i) => args.nth(i).unwrap(),
615-
_ => cause.span(),
615+
_ => cause.span,
616616
}
617617
}
618618

compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
168168
match hir_bound {
169169
hir::GenericBound::Trait(poly_trait_ref) => {
170170
let hir::TraitBoundModifiers { constness, polarity } = poly_trait_ref.modifiers;
171-
// FIXME: We could pass these directly into `lower_poly_trait_ref`
172-
// so that we could use these spans in diagnostics within that function...
173-
let constness = match constness {
174-
hir::BoundConstness::Never => None,
175-
hir::BoundConstness::Always(_) => Some(ty::BoundConstness::Const),
176-
hir::BoundConstness::Maybe(_) => Some(ty::BoundConstness::ConstIfConst),
177-
};
178171
let polarity = match polarity {
179172
rustc_ast::BoundPolarity::Positive => ty::PredicatePolarity::Positive,
180173
rustc_ast::BoundPolarity::Negative(_) => ty::PredicatePolarity::Negative,

compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
5050
} = self.lower_poly_trait_ref(
5151
&trait_bound.trait_ref,
5252
trait_bound.span,
53-
None,
53+
hir::BoundConstness::Never,
5454
ty::PredicatePolarity::Positive,
5555
dummy_self,
5656
&mut bounds,

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
658658
&self,
659659
trait_ref: &hir::TraitRef<'tcx>,
660660
span: Span,
661-
constness: Option<ty::BoundConstness>,
661+
constness: hir::BoundConstness,
662662
polarity: ty::PredicatePolarity,
663663
self_ty: Ty<'tcx>,
664664
bounds: &mut Bounds<'tcx>,
@@ -681,11 +681,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
681681
Some(self_ty),
682682
);
683683

684-
if let Some(constness) = constness
684+
if let hir::BoundConstness::Always(span) | hir::BoundConstness::Maybe(span) = constness
685685
&& !self.tcx().is_const_trait(trait_def_id)
686686
{
687687
self.dcx().emit_err(crate::errors::ConstBoundForNonConstTrait {
688-
span: trait_ref.path.span,
688+
span,
689689
modifier: constness.as_str(),
690690
});
691691
}
@@ -708,7 +708,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
708708
bounds.push_trait_bound(tcx, poly_trait_ref, span, polarity);
709709

710710
match constness {
711-
Some(ty::BoundConstness::Const) => {
711+
hir::BoundConstness::Always(span) => {
712712
if polarity == ty::PredicatePolarity::Positive {
713713
bounds.push_const_bound(
714714
tcx,
@@ -718,13 +718,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
718718
);
719719
}
720720
}
721-
Some(ty::BoundConstness::ConstIfConst) => {
721+
hir::BoundConstness::Maybe(_) => {
722722
// We don't emit a const bound here, since that would mean that we
723723
// unconditionally need to prove a `HostEffect` predicate, even when
724724
// the predicates are being instantiated in a non-const context. This
725725
// is instead handled in the `const_conditions` query.
726726
}
727-
None => {}
727+
hir::BoundConstness::Never => {}
728728
}
729729
}
730730
// On the flip side, when filtering `ConstIfConst` bounds, we only need to convert
@@ -734,12 +734,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
734734
// here because we only call this on self bounds, and deal with the recursive case
735735
// in `lower_assoc_item_constraint`.
736736
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => match constness {
737-
Some(ty::BoundConstness::ConstIfConst) => {
737+
hir::BoundConstness::Maybe(span) => {
738738
if polarity == ty::PredicatePolarity::Positive {
739739
bounds.push_const_bound(tcx, poly_trait_ref, ty::HostPolarity::Maybe, span);
740740
}
741741
}
742-
None | Some(ty::BoundConstness::Const) => {}
742+
hir::BoundConstness::Always(_) | hir::BoundConstness::Never => {}
743743
},
744744
}
745745

compiler/rustc_hir_typeck/src/_match.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
9494
(None, arm.body.span)
9595
};
9696

97-
let (span, code) = match prior_arm {
97+
let code = match prior_arm {
9898
// The reason for the first arm to fail is not that the match arms diverge,
9999
// but rather that there's a prior obligation that doesn't hold.
100-
None => {
101-
(arm_span, ObligationCauseCode::BlockTailExpression(arm.body.hir_id, match_src))
102-
}
103-
Some((prior_arm_block_id, prior_arm_ty, prior_arm_span)) => (
104-
expr.span,
100+
None => ObligationCauseCode::BlockTailExpression(arm.body.hir_id, match_src),
101+
Some((prior_arm_block_id, prior_arm_ty, prior_arm_span)) => {
105102
ObligationCauseCode::MatchExpressionArm(Box::new(MatchExpressionArmCause {
106103
arm_block_id,
107104
arm_span,
@@ -110,13 +107,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
110107
prior_arm_ty,
111108
prior_arm_span,
112109
scrut_span: scrut.span,
110+
expr_span: expr.span,
113111
source: match_src,
114112
prior_non_diverging_arms: prior_non_diverging_arms.clone(),
115113
tail_defines_return_position_impl_trait,
116-
})),
117-
),
114+
}))
115+
}
118116
};
119-
let cause = self.cause(span, code);
117+
let cause = self.cause(arm_span, code);
120118

121119
// This is the moral equivalent of `coercion.coerce(self, cause, arm.body, arm_ty)`.
122120
// We use it this way to be able to expand on the potential error and detect when a

compiler/rustc_hir_typeck/src/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20272027
}
20282028
Err(_) => {
20292029
span_bug!(
2030-
cause.span(),
2030+
cause.span,
20312031
"subtyping remaining fields of type changing FRU failed: {target_ty} != {fru_ty}: {}::{}",
20322032
variant.name,
20332033
ident.name,

compiler/rustc_hir_typeck/src/method/confirm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
550550
// This has/will have errored in wfcheck, which we cannot depend on from here, as typeck on functions
551551
// may run before wfcheck if the function is used in const eval.
552552
self.dcx().span_delayed_bug(
553-
cause.span(),
553+
cause.span,
554554
format!("{self_ty} was a subtype of {method_self_ty} but now is not?"),
555555
);
556556
}

compiler/rustc_middle/src/traits/mod.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,6 @@ impl<'tcx> ObligationCause<'tcx> {
9292
ObligationCause { span, body_id: CRATE_DEF_ID, code: Default::default() }
9393
}
9494

95-
pub fn span(&self) -> Span {
96-
match *self.code() {
97-
ObligationCauseCode::MatchExpressionArm(box MatchExpressionArmCause {
98-
arm_span,
99-
..
100-
}) => arm_span,
101-
_ => self.span,
102-
}
103-
}
104-
10595
#[inline]
10696
pub fn code(&self) -> &ObligationCauseCode<'tcx> {
10797
&self.code
@@ -517,10 +507,17 @@ pub struct MatchExpressionArmCause<'tcx> {
517507
pub prior_arm_block_id: Option<HirId>,
518508
pub prior_arm_ty: Ty<'tcx>,
519509
pub prior_arm_span: Span,
510+
/// Span of the scrutinee of the match (the matched value).
520511
pub scrut_span: Span,
512+
/// Source of the match, i.e. `match` or a desugaring.
521513
pub source: hir::MatchSource,
514+
/// Span of the *whole* match expr.
515+
pub expr_span: Span,
516+
/// Spans of the previous arms except for those that diverge (i.e. evaluate to `!`).
517+
///
518+
/// These are used for pointing out errors that may affect several arms.
522519
pub prior_non_diverging_arms: Vec<Span>,
523-
// Is the expectation of this match expression an RPIT?
520+
/// Is the expectation of this match expression an RPIT?
524521
pub tail_defines_return_position_impl_trait: Option<LocalDefId>,
525522
}
526523

compiler/rustc_passes/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,10 @@ passes_remove_fields =
622622
passes_repr_align_function =
623623
`repr(align)` attributes on functions are unstable
624624
625+
passes_repr_align_greater_than_target_max =
626+
alignment must not be greater than `isize::MAX` bytes
627+
.note = `isize::MAX` is {$size} for the current target
628+
625629
passes_repr_conflicting =
626630
conflicting representation hints
627631

0 commit comments

Comments
 (0)