Skip to content

Commit bcf787a

Browse files
committed
Auto merge of #151183 - jhpratt:rollup-GxmJbns, r=jhpratt
Rollup of 5 pull requests Successful merges: - #150607 (Add amdgpu_dispatch_ptr intrinsic) - #150611 (Unify and deduplicate From<T> float tests) - #151082 (Silence unused type param error on struct parse error) - #151159 (Tidying up `tests/ui/issues` 15 tests [8/N]) - #151164 (Stabilise `EULER_GAMMA` and `GOLDEN_RATIO` constants for `f32` and `f64`.) r? @ghost
2 parents 18ae990 + c3120ff commit bcf787a

File tree

55 files changed

+461
-288
lines changed

Some content is hidden

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

55 files changed

+461
-288
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
560560
return Ok(());
561561
}
562562

563+
sym::amdgpu_dispatch_ptr => {
564+
let val = self.call_intrinsic("llvm.amdgcn.dispatch.ptr", &[], &[]);
565+
// Relying on `LLVMBuildPointerCast` to produce an addrspacecast
566+
self.pointercast(val, self.type_ptr())
567+
}
568+
563569
_ if name.as_str().starts_with("simd_") => {
564570
// Unpack non-power-of-2 #[repr(packed, simd)] arguments.
565571
// This gives them the expected layout of a regular #[repr(simd)] vector.

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
112112
| sym::unreachable
113113
| sym::cold_path
114114
| sym::breakpoint
115+
| sym::amdgpu_dispatch_ptr
115116
| sym::assert_zero_valid
116117
| sym::assert_mem_uninitialized_valid
117118
| sym::assert_inhabited

compiler/rustc_hir/src/hir.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4525,6 +4525,26 @@ impl ItemKind<'_> {
45254525
_ => return None,
45264526
})
45274527
}
4528+
4529+
pub fn recovered(&self) -> bool {
4530+
match self {
4531+
ItemKind::Struct(
4532+
_,
4533+
_,
4534+
VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4535+
) => true,
4536+
ItemKind::Union(
4537+
_,
4538+
_,
4539+
VariantData::Struct { recovered: ast::Recovered::Yes(_), .. },
4540+
) => true,
4541+
ItemKind::Enum(_, _, def) => def.variants.iter().any(|v| match v.data {
4542+
VariantData::Struct { recovered: ast::Recovered::Yes(_), .. } => true,
4543+
_ => false,
4544+
}),
4545+
_ => false,
4546+
}
4547+
}
45284548
}
45294549

45304550
// The bodies for items are stored "out of line", in a separate

compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ fn intrinsic_operation_unsafety(tcx: TyCtxt<'_>, intrinsic_id: LocalDefId) -> hi
7070
| sym::add_with_overflow
7171
| sym::aggregate_raw_ptr
7272
| sym::align_of
73+
| sym::amdgpu_dispatch_ptr
7374
| sym::assert_inhabited
7475
| sym::assert_mem_uninitialized_valid
7576
| sym::assert_zero_valid
@@ -286,6 +287,7 @@ pub(crate) fn check_intrinsic_type(
286287
let (n_tps, n_cts, inputs, output) = match intrinsic_name {
287288
sym::autodiff => (4, 0, vec![param(0), param(1), param(2)], param(3)),
288289
sym::abort => (0, 0, vec![], tcx.types.never),
290+
sym::amdgpu_dispatch_ptr => (0, 0, vec![], Ty::new_imm_ptr(tcx, tcx.types.unit)),
289291
sym::unreachable => (0, 0, vec![], tcx.types.never),
290292
sym::breakpoint => (0, 0, vec![], tcx.types.unit),
291293
sym::size_of | sym::align_of | sym::variant_count => (1, 0, vec![], tcx.types.usize),

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2160,7 +2160,12 @@ fn report_bivariance<'tcx>(
21602160
const_param_help,
21612161
});
21622162
diag.code(E0392);
2163-
diag.emit()
2163+
if item.kind.recovered() {
2164+
// Silence potentially redundant error, as the item had a parse error.
2165+
diag.delay_as_bug()
2166+
} else {
2167+
diag.emit()
2168+
}
21642169
}
21652170

21662171
/// Detects cases where an ADT/LTA is trivially cyclical -- we want to detect this so

compiler/rustc_span/src/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ symbols! {
458458
alu32,
459459
always,
460460
amdgpu,
461+
amdgpu_dispatch_ptr,
461462
analysis,
462463
and,
463464
and_then,

compiler/rustc_trait_selection/src/error_reporting/infer/need_type_info.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,30 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
488488
}
489489

490490
let Some(InferSource { span, kind }) = local_visitor.infer_source else {
491-
return self.bad_inference_failure_err(failure_span, arg_data, error_code);
491+
let silence = if let DefKind::AssocFn = self.tcx.def_kind(body_def_id)
492+
&& let parent = self.tcx.parent(body_def_id.into())
493+
&& self.tcx.is_automatically_derived(parent)
494+
&& let Some(parent) = parent.as_local()
495+
&& let hir::Node::Item(item) = self.tcx.hir_node_by_def_id(parent)
496+
&& let hir::ItemKind::Impl(imp) = item.kind
497+
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = imp.self_ty.kind
498+
&& let Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, def_id) = path.res
499+
&& let Some(def_id) = def_id.as_local()
500+
&& let hir::Node::Item(item) = self.tcx.hir_node_by_def_id(def_id)
501+
{
502+
// We have encountered an inference error within an automatically derived `impl`,
503+
// from a `#[derive(..)]` on an item that had a parse error. Because the parse
504+
// error might have caused the expanded code to be malformed, we silence the
505+
// inference error.
506+
item.kind.recovered()
507+
} else {
508+
false
509+
};
510+
let mut err = self.bad_inference_failure_err(failure_span, arg_data, error_code);
511+
if silence {
512+
err.downgrade_to_delayed_bug();
513+
}
514+
return err;
492515
};
493516

494517
let (source_kind, name, long_ty_path) = kind.ty_localized_msg(self);

library/core/src/intrinsics/gpu.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//! Intrinsics for GPU targets.
2+
//!
3+
//! Intrinsics in this module are intended for use on GPU targets.
4+
//! They can be target specific but in general GPU targets are similar.
5+
6+
#![unstable(feature = "gpu_intrinsics", issue = "none")]
7+
8+
/// Returns a pointer to the HSA kernel dispatch packet.
9+
///
10+
/// A `gpu-kernel` on amdgpu is always launched through a kernel dispatch packet.
11+
/// The dispatch packet contains the workgroup size, launch size and other data.
12+
/// The content is defined by the [HSA Platform System Architecture Specification],
13+
/// which is implemented e.g. in AMD's [hsa.h].
14+
/// The intrinsic returns a unit pointer so that rustc does not need to know the packet struct.
15+
/// The pointer is valid for the whole lifetime of the program.
16+
///
17+
/// [HSA Platform System Architecture Specification]: https://hsafoundation.com/wp-content/uploads/2021/02/HSA-SysArch-1.2.pdf
18+
/// [hsa.h]: https://github.com/ROCm/rocm-systems/blob/rocm-7.1.0/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa.h#L2959
19+
#[rustc_nounwind]
20+
#[rustc_intrinsic]
21+
#[cfg(target_arch = "amdgpu")]
22+
#[must_use = "returns a pointer that does nothing unless used"]
23+
pub fn amdgpu_dispatch_ptr() -> *const ();

library/core/src/intrinsics/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ use crate::{mem, ptr};
6060

6161
mod bounds;
6262
pub mod fallback;
63+
pub mod gpu;
6364
pub mod mir;
6465
pub mod simd;
6566

library/core/src/num/f128.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ pub mod consts {
3434

3535
/// The golden ratio (φ)
3636
#[unstable(feature = "f128", issue = "116909")]
37-
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
38-
pub const PHI: f128 = 1.61803398874989484820458683436563811772030917980576286213545_f128;
37+
pub const GOLDEN_RATIO: f128 =
38+
1.61803398874989484820458683436563811772030917980576286213545_f128;
3939

4040
/// The Euler-Mascheroni constant (γ)
4141
#[unstable(feature = "f128", issue = "116909")]
42-
// Also, #[unstable(feature = "more_float_constants", issue = "146939")]
43-
pub const EGAMMA: f128 = 0.577215664901532860606512090082402431042159335939923598805767_f128;
42+
pub const EULER_GAMMA: f128 =
43+
0.577215664901532860606512090082402431042159335939923598805767_f128;
4444

4545
/// π/2
4646
#[unstable(feature = "f128", issue = "116909")]

0 commit comments

Comments
 (0)