Skip to content

Commit c96a690

Browse files
committed
Auto merge of #143407 - jhpratt:rollup-ekkoubw, r=jhpratt
Rollup of 11 pull requests Successful merges: - #142749 (Add methods for converting bool to `Result<(), E>`) - #143288 (Fix `x clean` with a fifo) - #143307 (Fast path nitpicks) - #143346 (update coherence example) - #143356 (use unsigned_abs instead of `abs` on signed int to silence clippy) - #143370 (remove redundant #[must_use]) - #143378 (simplify receivers for some array method calls) - #143380 (Replace kw_span by full span for generic const parameters.) - #143381 (rustdoc: don't treat methods under const impls or traits as const) - #143394 (compiler: Document and reduce `fn provide`s in hir crates) - #143395 (Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 837c5dd + e4e26d2 commit c96a690

File tree

43 files changed

+247
-125
lines changed

Some content is hidden

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

43 files changed

+247
-125
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ pub enum GenericParamKind {
385385
},
386386
Const {
387387
ty: P<Ty>,
388-
/// Span of the `const` keyword.
389-
kw_span: Span,
388+
/// Span of the whole parameter definition, including default.
389+
span: Span,
390390
/// Optional default value for the const generic param.
391391
default: Option<AnonConst>,
392392
},
@@ -410,10 +410,7 @@ impl GenericParam {
410410
self.ident.span
411411
}
412412
GenericParamKind::Type { default: Some(ty) } => self.ident.span.to(ty.span),
413-
GenericParamKind::Const { kw_span, default: Some(default), .. } => {
414-
kw_span.to(default.value.span)
415-
}
416-
GenericParamKind::Const { kw_span, default: None, ty } => kw_span.to(ty.span),
413+
GenericParamKind::Const { span, .. } => *span,
417414
}
418415
}
419416
}

compiler/rustc_ast/src/visit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,9 +1350,10 @@ macro_rules! common_visitor_and_walkers {
13501350
match kind {
13511351
GenericParamKind::Lifetime => (),
13521352
GenericParamKind::Type { default } => visit_opt!(vis, visit_ty, default),
1353-
GenericParamKind::Const { ty, default, kw_span: _ } => {
1353+
GenericParamKind::Const { ty, default, span } => {
13541354
try_visit!(vis.visit_ty(ty));
13551355
visit_opt!(vis, visit_anon_const, default);
1356+
try_visit!(visit_span(vis, span));
13561357
}
13571358
}
13581359
if let Some(sp) = colon_span {

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
19601960

19611961
(hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
19621962
}
1963-
GenericParamKind::Const { ty, kw_span: _, default } => {
1963+
GenericParamKind::Const { ty, span: _, default } => {
19641964
let ty = self
19651965
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::GenericDefault));
19661966

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,11 +909,11 @@ fn validate_generic_param_order(dcx: DiagCtxtHandle<'_>, generics: &[GenericPara
909909
}
910910
GenericParamKind::Type { default: None } => (),
911911
GenericParamKind::Lifetime => (),
912-
GenericParamKind::Const { ty: _, kw_span: _, default: Some(default) } => {
912+
GenericParamKind::Const { ty: _, span: _, default: Some(default) } => {
913913
ordered_params += " = ";
914914
ordered_params += &pprust::expr_to_string(&default.value);
915915
}
916-
GenericParamKind::Const { ty: _, kw_span: _, default: None } => (),
916+
GenericParamKind::Const { ty: _, span: _, default: None } => (),
917917
}
918918
first = false;
919919
}

compiler/rustc_builtin_macros/src/deriving/coerce_pointee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub(crate) fn expand_deriving_coerce_pointee(
124124
GenericParamKind::Type { default: _ } => {
125125
cx.typaram(p.span(), p.ident, p.bounds.clone(), None)
126126
}
127-
GenericParamKind::Const { ty, kw_span: _, default: _ } => cx
127+
GenericParamKind::Const { ty, span: _, default: _ } => cx
128128
.const_param(
129129
p.span(),
130130
p.ident,

compiler/rustc_builtin_macros/src/deriving/generic/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ impl<'a> TraitDef<'a> {
664664

665665
cx.typaram(param.ident.span.with_ctxt(ctxt), param.ident, bounds, None)
666666
}
667-
GenericParamKind::Const { ty, kw_span, .. } => {
667+
GenericParamKind::Const { ty, span, .. } => {
668668
let const_nodefault_kind = GenericParamKind::Const {
669669
ty: ty.clone(),
670-
kw_span: kw_span.with_ctxt(ctxt),
670+
span: span.with_ctxt(ctxt),
671671

672672
// We can't have default values inside impl block
673673
default: None,

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,23 +103,25 @@ fn call_simple_intrinsic<'ll, 'tcx>(
103103
sym::minnumf64 => ("llvm.minnum", &[bx.type_f64()]),
104104
sym::minnumf128 => ("llvm.minnum", &[bx.type_f128()]),
105105

106-
sym::minimumf16 => ("llvm.minimum", &[bx.type_f16()]),
107-
sym::minimumf32 => ("llvm.minimum", &[bx.type_f32()]),
108-
sym::minimumf64 => ("llvm.minimum", &[bx.type_f64()]),
109-
// There are issues on x86_64 and aarch64 with the f128 variant,
110-
// let's instead use the intrinsic fallback body.
111-
// sym::minimumf128 => ("llvm.minimum", &[cx.type_f128()]),
106+
// FIXME: LLVM currently mis-compile those intrinsics, re-enable them
107+
// when llvm/llvm-project#{139380,139381,140445} are fixed.
108+
//sym::minimumf16 => ("llvm.minimum", &[bx.type_f16()]),
109+
//sym::minimumf32 => ("llvm.minimum", &[bx.type_f32()]),
110+
//sym::minimumf64 => ("llvm.minimum", &[bx.type_f64()]),
111+
//sym::minimumf128 => ("llvm.minimum", &[cx.type_f128()]),
112+
//
112113
sym::maxnumf16 => ("llvm.maxnum", &[bx.type_f16()]),
113114
sym::maxnumf32 => ("llvm.maxnum", &[bx.type_f32()]),
114115
sym::maxnumf64 => ("llvm.maxnum", &[bx.type_f64()]),
115116
sym::maxnumf128 => ("llvm.maxnum", &[bx.type_f128()]),
116117

117-
sym::maximumf16 => ("llvm.maximum", &[bx.type_f16()]),
118-
sym::maximumf32 => ("llvm.maximum", &[bx.type_f32()]),
119-
sym::maximumf64 => ("llvm.maximum", &[bx.type_f64()]),
120-
// There are issues on x86_64 and aarch64 with the f128 variant,
121-
// let's instead use the intrinsic fallback body.
122-
// sym::maximumf128 => ("llvm.maximum", &[cx.type_f128()]),
118+
// FIXME: LLVM currently mis-compile those intrinsics, re-enable them
119+
// when llvm/llvm-project#{139380,139381,140445} are fixed.
120+
//sym::maximumf16 => ("llvm.maximum", &[bx.type_f16()]),
121+
//sym::maximumf32 => ("llvm.maximum", &[bx.type_f32()]),
122+
//sym::maximumf64 => ("llvm.maximum", &[bx.type_f64()]),
123+
//sym::maximumf128 => ("llvm.maximum", &[cx.type_f128()]),
124+
//
123125
sym::copysignf16 => ("llvm.copysign", &[bx.type_f16()]),
124126
sym::copysignf32 => ("llvm.copysign", &[bx.type_f32()]),
125127
sym::copysignf64 => ("llvm.copysign", &[bx.type_f64()]),

compiler/rustc_expand/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl<'a> ExtCtxt<'a> {
172172
attrs: AttrVec::new(),
173173
bounds,
174174
is_placeholder: false,
175-
kind: ast::GenericParamKind::Const { ty, kw_span: DUMMY_SP, default },
175+
kind: ast::GenericParamKind::Const { ty, span: DUMMY_SP, default },
176176
colon_span: None,
177177
}
178178
}

compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,17 @@ use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys;
100100
use self::region::region_scope_tree;
101101
use crate::{errors, require_c_abi_if_c_variadic};
102102

103-
pub fn provide(providers: &mut Providers) {
104-
wfcheck::provide(providers);
103+
/// Adds query implementations to the [Providers] vtable, see [`rustc_middle::query`]
104+
pub(super) fn provide(providers: &mut Providers) {
105105
*providers = Providers {
106106
adt_destructor,
107107
adt_async_destructor,
108108
region_scope_tree,
109109
collect_return_position_impl_trait_in_trait_tys,
110110
compare_impl_item: compare_impl_item::compare_impl_item,
111111
check_coroutine_obligations: check::check_coroutine_obligations,
112+
check_type_wf: wfcheck::check_type_wf,
113+
check_well_formed: wfcheck::check_well_formed,
112114
..*providers
113115
};
114116
}

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use rustc_infer::infer::{self, InferCtxt, SubregionOrigin, TyCtxtInferExt};
1515
use rustc_lint_defs::builtin::SUPERTRAIT_ITEM_SHADOWING_DEFINITION;
1616
use rustc_macros::LintDiagnostic;
1717
use rustc_middle::mir::interpret::ErrorHandled;
18-
use rustc_middle::query::Providers;
1918
use rustc_middle::traits::solve::NoSolution;
2019
use rustc_middle::ty::trait_def::TraitSpecializationKind;
2120
use rustc_middle::ty::{
@@ -189,7 +188,10 @@ where
189188
}
190189
}
191190

192-
fn check_well_formed(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(), ErrorGuaranteed> {
191+
pub(super) fn check_well_formed(
192+
tcx: TyCtxt<'_>,
193+
def_id: LocalDefId,
194+
) -> Result<(), ErrorGuaranteed> {
193195
let mut res = crate::check::check::check_item_type(tcx, def_id);
194196

195197
for param in &tcx.generics_of(def_id).own_params {
@@ -2249,7 +2251,7 @@ impl<'tcx> WfCheckingCtxt<'_, 'tcx> {
22492251
}
22502252
}
22512253

2252-
fn check_type_wf(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> {
2254+
pub(super) fn check_type_wf(tcx: TyCtxt<'_>, (): ()) -> Result<(), ErrorGuaranteed> {
22532255
let items = tcx.hir_crate_items(());
22542256
let res = items
22552257
.par_items(|item| tcx.ensure_ok().check_well_formed(item.owner_id.def_id))
@@ -2397,7 +2399,3 @@ struct RedundantLifetimeArgsLint<'tcx> {
23972399
// The lifetime we can replace the victim with.
23982400
candidate: ty::Region<'tcx>,
23992401
}
2400-
2401-
pub fn provide(providers: &mut Providers) {
2402-
*providers = Providers { check_type_wf, check_well_formed, ..*providers };
2403-
}

0 commit comments

Comments
 (0)