Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 082e4ca

Browse files
committedApr 26, 2022
Auto merge of #96428 - GuillaumeGomez:rollup-4noqr33, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #94022 (Clarify that `Cow::into_owned` returns owned data) - #94703 (Fix codegen bug in "ptx-kernel" abi related to arg passing) - #95949 (Implement Default for AssertUnwindSafe) - #96361 (Switch JS code to ES6) - #96372 (Suggest calling method on nested field when struct is missing method) - #96386 (simplify `describe_field` func in borrowck's diagnostics part) - #96400 (Correct documentation for `Rvalue::ShallowInitBox`) - #96415 (Remove references to git.io) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3d237ab + 223f107 commit 082e4ca

File tree

21 files changed

+721
-284
lines changed

21 files changed

+721
-284
lines changed
 

‎compiler/rustc_borrowck/src/diagnostics/mod.rs

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ crate use outlives_suggestion::OutlivesSuggestionBuilder;
4040
crate use region_errors::{ErrorConstraintInfo, RegionErrorKind, RegionErrors};
4141
crate use region_name::{RegionName, RegionNameSource};
4242
crate use rustc_const_eval::util::CallKind;
43+
use rustc_middle::mir::tcx::PlaceTy;
4344

4445
pub(super) struct IncludingDowncast(pub(super) bool);
4546

@@ -329,30 +330,20 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
329330

330331
/// End-user visible description of the `field`nth field of `base`
331332
fn describe_field(&self, place: PlaceRef<'tcx>, field: Field) -> String {
332-
// FIXME Place2 Make this work iteratively
333-
match place {
334-
PlaceRef { local, projection: [] } => {
335-
let local = &self.body.local_decls[local];
336-
self.describe_field_from_ty(local.ty, field, None)
337-
}
333+
let place_ty = match place {
334+
PlaceRef { local, projection: [] } => PlaceTy::from_ty(self.body.local_decls[local].ty),
338335
PlaceRef { local, projection: [proj_base @ .., elem] } => match elem {
339-
ProjectionElem::Deref => {
340-
self.describe_field(PlaceRef { local, projection: proj_base }, field)
341-
}
342-
ProjectionElem::Downcast(_, variant_index) => {
343-
let base_ty = place.ty(self.body, self.infcx.tcx).ty;
344-
self.describe_field_from_ty(base_ty, field, Some(*variant_index))
345-
}
346-
ProjectionElem::Field(_, field_type) => {
347-
self.describe_field_from_ty(*field_type, field, None)
348-
}
349-
ProjectionElem::Index(..)
336+
ProjectionElem::Deref
337+
| ProjectionElem::Index(..)
350338
| ProjectionElem::ConstantIndex { .. }
351339
| ProjectionElem::Subslice { .. } => {
352-
self.describe_field(PlaceRef { local, projection: proj_base }, field)
340+
PlaceRef { local, projection: proj_base }.ty(self.body, self.infcx.tcx)
353341
}
342+
ProjectionElem::Downcast(..) => place.ty(self.body, self.infcx.tcx),
343+
ProjectionElem::Field(_, field_type) => PlaceTy::from_ty(*field_type),
354344
},
355-
}
345+
};
346+
self.describe_field_from_ty(place_ty.ty, field, place_ty.variant_index)
356347
}
357348

358349
/// End-user visible description of the `field_index`nth field of `ty`

‎compiler/rustc_middle/src/mir/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2581,8 +2581,6 @@ pub enum Rvalue<'tcx> {
25812581
/// This is different from a normal transmute because dataflow analysis will treat the box as
25822582
/// initialized but its content as uninitialized. Like other pointer casts, this in general
25832583
/// affects alias analysis.
2584-
///
2585-
/// Disallowed after drop elaboration.
25862584
ShallowInitBox(Operand<'tcx>, Ty<'tcx>),
25872585
}
25882586

‎compiler/rustc_middle/src/ty/layout.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2592,6 +2592,22 @@ where
25922592

25932593
pointee_info
25942594
}
2595+
2596+
fn is_adt(this: TyAndLayout<'tcx>) -> bool {
2597+
matches!(this.ty.kind(), ty::Adt(..))
2598+
}
2599+
2600+
fn is_never(this: TyAndLayout<'tcx>) -> bool {
2601+
this.ty.kind() == &ty::Never
2602+
}
2603+
2604+
fn is_tuple(this: TyAndLayout<'tcx>) -> bool {
2605+
matches!(this.ty.kind(), ty::Tuple(..))
2606+
}
2607+
2608+
fn is_unit(this: TyAndLayout<'tcx>) -> bool {
2609+
matches!(this.ty.kind(), ty::Tuple(list) if list.len() == 0)
2610+
}
25952611
}
25962612

25972613
impl<'tcx> ty::Instance<'tcx> {

‎compiler/rustc_middle/src/ty/list.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ impl<T> List<T> {
6161
static EMPTY_SLICE: InOrder<usize, MaxAlign> = InOrder(0, MaxAlign);
6262
unsafe { &*(&EMPTY_SLICE as *const _ as *const List<T>) }
6363
}
64+
65+
pub fn len(&self) -> usize {
66+
self.len
67+
}
6468
}
6569

6670
impl<T: Copy> List<T> {

‎compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,13 @@ impl<'a, Ty> FnAbi<'a, Ty> {
696696
"sparc" => sparc::compute_abi_info(cx, self),
697697
"sparc64" => sparc64::compute_abi_info(cx, self),
698698
"nvptx" => nvptx::compute_abi_info(self),
699-
"nvptx64" => nvptx64::compute_abi_info(self),
699+
"nvptx64" => {
700+
if cx.target_spec().adjust_abi(abi) == spec::abi::Abi::PtxKernel {
701+
nvptx64::compute_ptx_kernel_abi_info(cx, self)
702+
} else {
703+
nvptx64::compute_abi_info(self)
704+
}
705+
}
700706
"hexagon" => hexagon::compute_abi_info(self),
701707
"riscv32" | "riscv64" => riscv::compute_abi_info(cx, self),
702708
"wasm32" | "wasm64" => {
Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
1-
// Reference: PTX Writer's Guide to Interoperability
2-
// https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability
3-
4-
use crate::abi::call::{ArgAbi, FnAbi};
1+
use crate::abi::call::{ArgAbi, FnAbi, PassMode, Reg, Size, Uniform};
2+
use crate::abi::{HasDataLayout, TyAbiInterface};
53

64
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
75
if ret.layout.is_aggregate() && ret.layout.size.bits() > 64 {
86
ret.make_indirect();
9-
} else {
10-
ret.extend_integer_width_to(64);
117
}
128
}
139

1410
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) {
1511
if arg.layout.is_aggregate() && arg.layout.size.bits() > 64 {
1612
arg.make_indirect();
17-
} else {
18-
arg.extend_integer_width_to(64);
13+
}
14+
}
15+
16+
fn classify_arg_kernel<'a, Ty, C>(_cx: &C, arg: &mut ArgAbi<'a, Ty>)
17+
where
18+
Ty: TyAbiInterface<'a, C> + Copy,
19+
C: HasDataLayout,
20+
{
21+
if matches!(arg.mode, PassMode::Pair(..)) && (arg.layout.is_adt() || arg.layout.is_tuple()) {
22+
let align_bytes = arg.layout.align.abi.bytes();
23+
24+
let unit = match align_bytes {
25+
1 => Reg::i8(),
26+
2 => Reg::i16(),
27+
4 => Reg::i32(),
28+
8 => Reg::i64(),
29+
16 => Reg::i128(),
30+
_ => unreachable!("Align is given as power of 2 no larger than 16 bytes"),
31+
};
32+
arg.cast_to(Uniform { unit, total: Size::from_bytes(2 * align_bytes) });
1933
}
2034
}
2135

@@ -31,3 +45,20 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
3145
classify_arg(arg);
3246
}
3347
}
48+
49+
pub fn compute_ptx_kernel_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
50+
where
51+
Ty: TyAbiInterface<'a, C> + Copy,
52+
C: HasDataLayout,
53+
{
54+
if !fn_abi.ret.layout.is_unit() && !fn_abi.ret.layout.is_never() {
55+
panic!("Kernels should not return anything other than () or !");
56+
}
57+
58+
for arg in &mut fn_abi.args {
59+
if arg.is_ignore() {
60+
continue;
61+
}
62+
classify_arg_kernel(cx, arg);
63+
}
64+
}

‎compiler/rustc_target/src/abi/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,10 @@ pub trait TyAbiInterface<'a, C>: Sized {
13551355
cx: &C,
13561356
offset: Size,
13571357
) -> Option<PointeeInfo>;
1358+
fn is_adt(this: TyAndLayout<'a, Self>) -> bool;
1359+
fn is_never(this: TyAndLayout<'a, Self>) -> bool;
1360+
fn is_tuple(this: TyAndLayout<'a, Self>) -> bool;
1361+
fn is_unit(this: TyAndLayout<'a, Self>) -> bool;
13581362
}
13591363

13601364
impl<'a, Ty> TyAndLayout<'a, Ty> {
@@ -1396,6 +1400,34 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
13961400
_ => false,
13971401
}
13981402
}
1403+
1404+
pub fn is_adt<C>(self) -> bool
1405+
where
1406+
Ty: TyAbiInterface<'a, C>,
1407+
{
1408+
Ty::is_adt(self)
1409+
}
1410+
1411+
pub fn is_never<C>(self) -> bool
1412+
where
1413+
Ty: TyAbiInterface<'a, C>,
1414+
{
1415+
Ty::is_never(self)
1416+
}
1417+
1418+
pub fn is_tuple<C>(self) -> bool
1419+
where
1420+
Ty: TyAbiInterface<'a, C>,
1421+
{
1422+
Ty::is_tuple(self)
1423+
}
1424+
1425+
pub fn is_unit<C>(self) -> bool
1426+
where
1427+
Ty: TyAbiInterface<'a, C>,
1428+
{
1429+
Ty::is_unit(self)
1430+
}
13991431
}
14001432

14011433
impl<'a, Ty> TyAndLayout<'a, Ty> {

‎compiler/rustc_target/src/asm/mips.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ impl MipsInlineAsmRegClass {
4343
}
4444
}
4545

46-
// The reserved registers are somewhat taken from <https://git.io/JUR1k#L150>.
46+
// The reserved registers are somewhat taken from
47+
// <https://github.com/llvm/llvm-project/blob/deb8f8bcf31540c657716ea5242183b0792702a1/llvm/lib/Target/Mips/MipsRegisterInfo.cpp#L150>.
4748
def_regs! {
4849
Mips MipsInlineAsmReg MipsInlineAsmRegClass {
4950
r2: reg = ["$2"],

‎compiler/rustc_typeck/src/check/expr.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,14 +2285,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22852285
// try to add a suggestion in case the field is a nested field of a field of the Adt
22862286
if let Some((fields, substs)) = self.get_field_candidates(span, expr_t) {
22872287
for candidate_field in fields.iter() {
2288-
if let Some(field_path) = self.check_for_nested_field(
2288+
if let Some(mut field_path) = self.check_for_nested_field_satisfying(
22892289
span,
2290-
field,
2290+
&|candidate_field, _| candidate_field.ident(self.tcx()) == field,
22912291
candidate_field,
22922292
substs,
22932293
vec![],
22942294
self.tcx.parent_module(id).to_def_id(),
22952295
) {
2296+
// field_path includes `field` that we're looking for, so pop it.
2297+
field_path.pop();
2298+
22962299
let field_path_str = field_path
22972300
.iter()
22982301
.map(|id| id.name.to_ident_string())
@@ -2312,7 +2315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23122315
err
23132316
}
23142317

2315-
fn get_field_candidates(
2318+
crate fn get_field_candidates(
23162319
&self,
23172320
span: Span,
23182321
base_t: Ty<'tcx>,
@@ -2337,49 +2340,42 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
23372340

23382341
/// This method is called after we have encountered a missing field error to recursively
23392342
/// search for the field
2340-
fn check_for_nested_field(
2343+
crate fn check_for_nested_field_satisfying(
23412344
&self,
23422345
span: Span,
2343-
target_field: Ident,
2346+
matches: &impl Fn(&ty::FieldDef, Ty<'tcx>) -> bool,
23442347
candidate_field: &ty::FieldDef,
23452348
subst: SubstsRef<'tcx>,
23462349
mut field_path: Vec<Ident>,
23472350
id: DefId,
23482351
) -> Option<Vec<Ident>> {
23492352
debug!(
2350-
"check_for_nested_field(span: {:?}, candidate_field: {:?}, field_path: {:?}",
2353+
"check_for_nested_field_satisfying(span: {:?}, candidate_field: {:?}, field_path: {:?}",
23512354
span, candidate_field, field_path
23522355
);
23532356

2354-
if candidate_field.ident(self.tcx) == target_field {
2355-
Some(field_path)
2356-
} else if field_path.len() > 3 {
2357+
if field_path.len() > 3 {
23572358
// For compile-time reasons and to avoid infinite recursion we only check for fields
23582359
// up to a depth of three
23592360
None
23602361
} else {
23612362
// recursively search fields of `candidate_field` if it's a ty::Adt
2362-
23632363
field_path.push(candidate_field.ident(self.tcx).normalize_to_macros_2_0());
23642364
let field_ty = candidate_field.ty(self.tcx, subst);
23652365
if let Some((nested_fields, subst)) = self.get_field_candidates(span, field_ty) {
23662366
for field in nested_fields.iter() {
2367-
let accessible = field.vis.is_accessible_from(id, self.tcx);
2368-
if accessible {
2369-
let ident = field.ident(self.tcx).normalize_to_macros_2_0();
2370-
if ident == target_field {
2367+
if field.vis.is_accessible_from(id, self.tcx) {
2368+
if matches(candidate_field, field_ty) {
23712369
return Some(field_path);
2372-
}
2373-
let field_path = field_path.clone();
2374-
if let Some(path) = self.check_for_nested_field(
2370+
} else if let Some(field_path) = self.check_for_nested_field_satisfying(
23752371
span,
2376-
target_field,
2372+
matches,
23772373
field,
23782374
subst,
2379-
field_path,
2375+
field_path.clone(),
23802376
id,
23812377
) {
2382-
return Some(path);
2378+
return Some(field_path);
23832379
}
23842380
}
23852381
}

‎compiler/rustc_typeck/src/check/method/suggest.rs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use rustc_trait_selection::traits::{
2828
use std::cmp::Ordering;
2929
use std::iter;
3030

31-
use super::probe::Mode;
31+
use super::probe::{Mode, ProbeScope};
3232
use super::{CandidateSource, MethodError, NoMatchData};
3333

3434
impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -1129,6 +1129,46 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11291129
label_span_not_found();
11301130
}
11311131

1132+
if let SelfSource::MethodCall(expr) = source
1133+
&& let Some((fields, substs)) = self.get_field_candidates(span, actual)
1134+
{
1135+
let call_expr =
1136+
self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(expr.hir_id));
1137+
for candidate_field in fields.iter() {
1138+
if let Some(field_path) = self.check_for_nested_field_satisfying(
1139+
span,
1140+
&|_, field_ty| {
1141+
self.lookup_probe(
1142+
span,
1143+
item_name,
1144+
field_ty,
1145+
call_expr,
1146+
ProbeScope::AllTraits,
1147+
)
1148+
.is_ok()
1149+
},
1150+
candidate_field,
1151+
substs,
1152+
vec![],
1153+
self.tcx.parent_module(expr.hir_id).to_def_id(),
1154+
) {
1155+
let field_path_str = field_path
1156+
.iter()
1157+
.map(|id| id.name.to_ident_string())
1158+
.collect::<Vec<String>>()
1159+
.join(".");
1160+
debug!("field_path_str: {:?}", field_path_str);
1161+
1162+
err.span_suggestion_verbose(
1163+
item_name.span.shrink_to_lo(),
1164+
"one of the expressions' fields has a method of the same name",
1165+
format!("{field_path_str}."),
1166+
Applicability::MaybeIncorrect,
1167+
);
1168+
}
1169+
}
1170+
}
1171+
11321172
bound_spans.sort();
11331173
bound_spans.dedup();
11341174
for (span, msg) in bound_spans.into_iter() {

‎library/alloc/src/borrow.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
292292
///
293293
/// # Examples
294294
///
295-
/// Calling `into_owned` on a `Cow::Borrowed` clones the underlying data
296-
/// and becomes a `Cow::Owned`:
295+
/// Calling `into_owned` on a `Cow::Borrowed` returns a clone of the borrowed data:
297296
///
298297
/// ```
299298
/// use std::borrow::Cow;
@@ -307,7 +306,8 @@ impl<B: ?Sized + ToOwned> Cow<'_, B> {
307306
/// );
308307
/// ```
309308
///
310-
/// Calling `into_owned` on a `Cow::Owned` is a no-op:
309+
/// Calling `into_owned` on a `Cow::Owned` returns the owned data. The data is moved out of the
310+
/// `Cow` without being cloned.
311311
///
312312
/// ```
313313
/// use std::borrow::Cow;

‎library/core/src/panic/unwind_safe.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ impl<T: fmt::Debug> fmt::Debug for AssertUnwindSafe<T> {
279279
}
280280
}
281281

282+
#[stable(feature = "assertunwindsafe_default", since = "1.62.0")]
283+
impl<T: Default> Default for AssertUnwindSafe<T> {
284+
fn default() -> Self {
285+
Self(Default::default())
286+
}
287+
}
288+
282289
#[stable(feature = "futures_api", since = "1.36.0")]
283290
impl<F: Future> Future for AssertUnwindSafe<F> {
284291
type Output = F::Output;

‎library/std/src/sys/unix/process/process_common.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ cfg_if::cfg_if! {
3535
// Android with api less than 21 define sig* functions inline, so it is not
3636
// available for dynamic link. Implementing sigemptyset and sigaddset allow us
3737
// to support older Android version (independent of libc version).
38-
// The following implementations are based on https://git.io/vSkNf
38+
// The following implementations are based on
39+
// https://github.com/aosp-mirror/platform_bionic/blob/ad8dcd6023294b646e5a8288c0ed431b0845da49/libc/include/android/legacy_signal_inlines.h
3940
cfg_if::cfg_if! {
4041
if #[cfg(target_os = "android")] {
4142
pub unsafe fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int {

‎src/librustdoc/html/static/js/search.js

Lines changed: 207 additions & 218 deletions
Large diffs are not rendered by default.

‎src/librustdoc/html/static/js/settings.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// Local js definitions:
2+
/* eslint-env es6 */
3+
/* eslint no-var: "error" */
4+
/* eslint prefer-const: "error" */
25
/* global getSettingValue, getVirtualKey, onEachLazy, updateLocalStorage, updateSystemTheme */
36
/* global addClass, removeClass */
47

@@ -55,9 +58,9 @@
5558
function setEvents() {
5659
updateLightAndDark();
5760
onEachLazy(document.getElementsByClassName("slider"), function(elem) {
58-
var toggle = elem.previousElementSibling;
59-
var settingId = toggle.id;
60-
var settingValue = getSettingValue(settingId);
61+
const toggle = elem.previousElementSibling;
62+
const settingId = toggle.id;
63+
const settingValue = getSettingValue(settingId);
6164
if (settingValue !== null) {
6265
toggle.checked = settingValue === "true";
6366
}
@@ -68,9 +71,9 @@
6871
toggle.onkeyrelease = handleKey;
6972
});
7073
onEachLazy(document.getElementsByClassName("select-wrapper"), function(elem) {
71-
var select = elem.getElementsByTagName("select")[0];
72-
var settingId = select.id;
73-
var settingValue = getSettingValue(settingId);
74+
const select = elem.getElementsByTagName("select")[0];
75+
const settingId = select.id;
76+
const settingValue = getSettingValue(settingId);
7477
if (settingValue !== null) {
7578
select.value = settingValue;
7679
}
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
// assembly-output: ptx-linker
2+
// compile-flags: --crate-type cdylib -C target-cpu=sm_86
3+
// only-nvptx64
4+
// ignore-nvptx64
5+
6+
// The following ABI tests are made with nvcc 11.6 does.
7+
//
8+
// The PTX ABI stability is tied to major versions of the PTX ISA
9+
// These tests assume major version 7
10+
//
11+
//
12+
// The following correspondence between types are assumed:
13+
// u<N> - uint<N>_t
14+
// i<N> - int<N>_t
15+
// [T, N] - std::array<T, N>
16+
// &T - T const*
17+
// &mut T - T*
18+
19+
// CHECK: .version 7
20+
21+
#![feature(abi_ptx, lang_items, no_core)]
22+
#![no_core]
23+
24+
#[lang = "sized"]
25+
trait Sized {}
26+
#[lang = "copy"]
27+
trait Copy {}
28+
29+
#[repr(C)]
30+
pub struct SingleU8 {
31+
f: u8,
32+
}
33+
34+
#[repr(C)]
35+
pub struct DoubleU8 {
36+
f: u8,
37+
g: u8,
38+
}
39+
40+
#[repr(C)]
41+
pub struct TripleU8 {
42+
f: u8,
43+
g: u8,
44+
h: u8,
45+
}
46+
47+
#[repr(C)]
48+
pub struct TripleU16 {
49+
f: u16,
50+
g: u16,
51+
h: u16,
52+
}
53+
#[repr(C)]
54+
pub struct TripleU32 {
55+
f: u32,
56+
g: u32,
57+
h: u32,
58+
}
59+
#[repr(C)]
60+
pub struct TripleU64 {
61+
f: u64,
62+
g: u64,
63+
h: u64,
64+
}
65+
66+
#[repr(C)]
67+
pub struct DoubleFloat {
68+
f: f32,
69+
g: f32,
70+
}
71+
72+
#[repr(C)]
73+
pub struct TripleFloat {
74+
f: f32,
75+
g: f32,
76+
h: f32,
77+
}
78+
79+
#[repr(C)]
80+
pub struct TripleDouble {
81+
f: f64,
82+
g: f64,
83+
h: f64,
84+
}
85+
86+
#[repr(C)]
87+
pub struct ManyIntegers {
88+
f: u8,
89+
g: u16,
90+
h: u32,
91+
i: u64,
92+
}
93+
94+
#[repr(C)]
95+
pub struct ManyNumerics {
96+
f: u8,
97+
g: u16,
98+
h: u32,
99+
i: u64,
100+
j: f32,
101+
k: f64,
102+
}
103+
104+
// CHECK: .visible .entry f_u8_arg(
105+
// CHECK: .param .u8 f_u8_arg_param_0
106+
#[no_mangle]
107+
pub unsafe extern "ptx-kernel" fn f_u8_arg(_a: u8) {}
108+
109+
// CHECK: .visible .entry f_u16_arg(
110+
// CHECK: .param .u16 f_u16_arg_param_0
111+
#[no_mangle]
112+
pub unsafe extern "ptx-kernel" fn f_u16_arg(_a: u16) {}
113+
114+
// CHECK: .visible .entry f_u32_arg(
115+
// CHECK: .param .u32 f_u32_arg_param_0
116+
#[no_mangle]
117+
pub unsafe extern "ptx-kernel" fn f_u32_arg(_a: u32) {}
118+
119+
// CHECK: .visible .entry f_u64_arg(
120+
// CHECK: .param .u64 f_u64_arg_param_0
121+
#[no_mangle]
122+
pub unsafe extern "ptx-kernel" fn f_u64_arg(_a: u64) {}
123+
124+
// CHECK: .visible .entry f_u128_arg(
125+
// CHECK: .param .align 16 .b8 f_u128_arg_param_0[16]
126+
#[no_mangle]
127+
pub unsafe extern "ptx-kernel" fn f_u128_arg(_a: u128) {}
128+
129+
// CHECK: .visible .entry f_i8_arg(
130+
// CHECK: .param .u8 f_i8_arg_param_0
131+
#[no_mangle]
132+
pub unsafe extern "ptx-kernel" fn f_i8_arg(_a: i8) {}
133+
134+
// CHECK: .visible .entry f_i16_arg(
135+
// CHECK: .param .u16 f_i16_arg_param_0
136+
#[no_mangle]
137+
pub unsafe extern "ptx-kernel" fn f_i16_arg(_a: i16) {}
138+
139+
// CHECK: .visible .entry f_i32_arg(
140+
// CHECK: .param .u32 f_i32_arg_param_0
141+
#[no_mangle]
142+
pub unsafe extern "ptx-kernel" fn f_i32_arg(_a: i32) {}
143+
144+
// CHECK: .visible .entry f_i64_arg(
145+
// CHECK: .param .u64 f_i64_arg_param_0
146+
#[no_mangle]
147+
pub unsafe extern "ptx-kernel" fn f_i64_arg(_a: i64) {}
148+
149+
// CHECK: .visible .entry f_i128_arg(
150+
// CHECK: .param .align 16 .b8 f_i128_arg_param_0[16]
151+
#[no_mangle]
152+
pub unsafe extern "ptx-kernel" fn f_i128_arg(_a: i128) {}
153+
154+
// CHECK: .visible .entry f_f32_arg(
155+
// CHECK: .param .f32 f_f32_arg_param_0
156+
#[no_mangle]
157+
pub unsafe extern "ptx-kernel" fn f_f32_arg(_a: f32) {}
158+
159+
// CHECK: .visible .entry f_f64_arg(
160+
// CHECK: .param .f64 f_f64_arg_param_0
161+
#[no_mangle]
162+
pub unsafe extern "ptx-kernel" fn f_f64_arg(_a: f64) {}
163+
164+
// CHECK: .visible .entry f_single_u8_arg(
165+
// CHECK: .param .align 1 .b8 f_single_u8_arg_param_0[1]
166+
#[no_mangle]
167+
pub unsafe extern "ptx-kernel" fn f_single_u8_arg(_a: SingleU8) {}
168+
169+
// CHECK: .visible .entry f_double_u8_arg(
170+
// CHECK: .param .align 1 .b8 f_double_u8_arg_param_0[2]
171+
#[no_mangle]
172+
pub unsafe extern "ptx-kernel" fn f_double_u8_arg(_a: DoubleU8) {}
173+
174+
// CHECK: .visible .entry f_triple_u8_arg(
175+
// CHECK: .param .align 1 .b8 f_triple_u8_arg_param_0[3]
176+
#[no_mangle]
177+
pub unsafe extern "ptx-kernel" fn f_triple_u8_arg(_a: TripleU8) {}
178+
179+
// CHECK: .visible .entry f_triple_u16_arg(
180+
// CHECK: .param .align 2 .b8 f_triple_u16_arg_param_0[6]
181+
#[no_mangle]
182+
pub unsafe extern "ptx-kernel" fn f_triple_u16_arg(_a: TripleU16) {}
183+
184+
// CHECK: .visible .entry f_triple_u32_arg(
185+
// CHECK: .param .align 4 .b8 f_triple_u32_arg_param_0[12]
186+
#[no_mangle]
187+
pub unsafe extern "ptx-kernel" fn f_triple_u32_arg(_a: TripleU32) {}
188+
189+
// CHECK: .visible .entry f_triple_u64_arg(
190+
// CHECK: .param .align 8 .b8 f_triple_u64_arg_param_0[24]
191+
#[no_mangle]
192+
pub unsafe extern "ptx-kernel" fn f_triple_u64_arg(_a: TripleU64) {}
193+
194+
// CHECK: .visible .entry f_many_integers_arg(
195+
// CHECK: .param .align 8 .b8 f_many_integers_arg_param_0[16]
196+
#[no_mangle]
197+
pub unsafe extern "ptx-kernel" fn f_many_integers_arg(_a: ManyIntegers) {}
198+
199+
// CHECK: .visible .entry f_double_float_arg(
200+
// CHECK: .param .align 4 .b8 f_double_float_arg_param_0[8]
201+
#[no_mangle]
202+
pub unsafe extern "ptx-kernel" fn f_double_float_arg(_a: DoubleFloat) {}
203+
204+
// CHECK: .visible .entry f_triple_float_arg(
205+
// CHECK: .param .align 4 .b8 f_triple_float_arg_param_0[12]
206+
#[no_mangle]
207+
pub unsafe extern "ptx-kernel" fn f_triple_float_arg(_a: TripleFloat) {}
208+
209+
// CHECK: .visible .entry f_triple_double_arg(
210+
// CHECK: .param .align 8 .b8 f_triple_double_arg_param_0[24]
211+
#[no_mangle]
212+
pub unsafe extern "ptx-kernel" fn f_triple_double_arg(_a: TripleDouble) {}
213+
214+
// CHECK: .visible .entry f_many_numerics_arg(
215+
// CHECK: .param .align 8 .b8 f_many_numerics_arg_param_0[32]
216+
#[no_mangle]
217+
pub unsafe extern "ptx-kernel" fn f_many_numerics_arg(_a: ManyNumerics) {}
218+
219+
// CHECK: .visible .entry f_byte_array_arg(
220+
// CHECK: .param .align 1 .b8 f_byte_array_arg_param_0[5]
221+
#[no_mangle]
222+
pub unsafe extern "ptx-kernel" fn f_byte_array_arg(_a: [u8; 5]) {}
223+
224+
// CHECK: .visible .entry f_float_array_arg(
225+
// CHECK: .param .align 4 .b8 f_float_array_arg_param_0[20]
226+
#[no_mangle]
227+
pub unsafe extern "ptx-kernel" fn f_float_array_arg(_a: [f32; 5]) {}
228+
229+
// CHECK: .visible .entry f_u128_array_arg(
230+
// CHECK: .param .align 16 .b8 f_u128_array_arg_param_0[80]
231+
#[no_mangle]
232+
pub unsafe extern "ptx-kernel" fn f_u128_array_arg(_a: [u128; 5]) {}
233+
234+
// CHECK: .visible .entry f_u32_slice_arg(
235+
// CHECK: .param .u64 f_u32_slice_arg_param_0
236+
// CHECK: .param .u64 f_u32_slice_arg_param_1
237+
#[no_mangle]
238+
pub unsafe extern "ptx-kernel" fn f_u32_slice_arg(_a: &[u32]) {}
239+
240+
// CHECK: .visible .entry f_tuple_u8_u8_arg(
241+
// CHECK: .param .align 1 .b8 f_tuple_u8_u8_arg_param_0[2]
242+
#[no_mangle]
243+
pub unsafe extern "ptx-kernel" fn f_tuple_u8_u8_arg(_a: (u8, u8)) {}
244+
245+
// CHECK: .visible .entry f_tuple_u32_u32_arg(
246+
// CHECK: .param .align 4 .b8 f_tuple_u32_u32_arg_param_0[8]
247+
#[no_mangle]
248+
pub unsafe extern "ptx-kernel" fn f_tuple_u32_u32_arg(_a: (u32, u32)) {}
249+
250+
251+
// CHECK: .visible .entry f_tuple_u8_u8_u32_arg(
252+
// CHECK: .param .align 4 .b8 f_tuple_u8_u8_u32_arg_param_0[8]
253+
#[no_mangle]
254+
pub unsafe extern "ptx-kernel" fn f_tuple_u8_u8_u32_arg(_a: (u8, u8, u32)) {}

‎src/test/ui/hrtb/issue-30786.migrate.stderr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ note: the following trait bounds were not satisfied:
1818
|
1919
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
2020
| --------- - ^^^^^^ unsatisfied trait bound introduced here
21+
help: one of the expressions' fields has a method of the same name
22+
|
23+
LL | let filter = map.stream.filterx(|x: &_| true);
24+
| +++++++
2125

2226
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>`, but its trait bounds were not satisfied
2327
--> $DIR/issue-30786.rs:140:24
@@ -39,6 +43,10 @@ note: the following trait bounds were not satisfied:
3943
|
4044
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
4145
| --------- - ^^^^^^ unsatisfied trait bound introduced here
46+
help: one of the expressions' fields has a method of the same name
47+
|
48+
LL | let count = filter.stream.countx();
49+
| +++++++
4250

4351
error: aborting due to 2 previous errors
4452

‎src/test/ui/hrtb/issue-30786.nll.stderr

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ note: the following trait bounds were not satisfied:
1818
|
1919
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
2020
| --------- - ^^^^^^ unsatisfied trait bound introduced here
21+
help: one of the expressions' fields has a method of the same name
22+
|
23+
LL | let filter = map.stream.filterx(|x: &_| true);
24+
| +++++++
2125

2226
error[E0599]: the method `countx` exists for struct `Filter<Map<Repeat, for<'r> fn(&'r u64) -> &'r u64 {identity::<u64>}>, [closure@$DIR/issue-30786.rs:139:30: 139:42]>`, but its trait bounds were not satisfied
2327
--> $DIR/issue-30786.rs:140:24
@@ -39,6 +43,10 @@ note: the following trait bounds were not satisfied:
3943
|
4044
LL | impl<T> StreamExt for T where for<'a> &'a mut T: Stream {}
4145
| --------- - ^^^^^^ unsatisfied trait bound introduced here
46+
help: one of the expressions' fields has a method of the same name
47+
|
48+
LL | let count = filter.stream.countx();
49+
| +++++++
4250

4351
error: aborting due to 2 previous errors
4452

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
struct Kind;
2+
3+
struct Ty {
4+
kind: Kind,
5+
}
6+
7+
impl Ty {
8+
fn kind(&self) -> Kind {
9+
todo!()
10+
}
11+
}
12+
13+
struct InferOk<T> {
14+
value: T,
15+
predicates: Vec<()>,
16+
}
17+
18+
fn foo(i: InferOk<Ty>) {
19+
let k = i.kind();
20+
//~^ no method named `kind` found for struct `InferOk` in the current scope
21+
}
22+
23+
fn main() {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0599]: no method named `kind` found for struct `InferOk` in the current scope
2+
--> $DIR/field-has-method.rs:19:15
3+
|
4+
LL | struct InferOk<T> {
5+
| ----------------- method `kind` not found for this
6+
...
7+
LL | let k = i.kind();
8+
| ^^^^ method not found in `InferOk<Ty>`
9+
|
10+
help: one of the expressions' fields has a method of the same name
11+
|
12+
LL | let k = i.value.kind();
13+
| ++++++
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0599`.

‎src/tools/rustdoc-js/tester.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ function extractFunction(content, functionName) {
8585
}
8686

8787
// Stupid function extractor for array.
88-
function extractArrayVariable(content, arrayName) {
89-
var splitter = "var " + arrayName;
88+
function extractArrayVariable(content, arrayName, kind) {
89+
if (typeof kind === "undefined") {
90+
kind = "let ";
91+
}
92+
var splitter = kind + arrayName;
9093
while (true) {
9194
var start = content.indexOf(splitter);
9295
if (start === -1) {
@@ -126,12 +129,18 @@ function extractArrayVariable(content, arrayName) {
126129
}
127130
content = content.slice(start + 1);
128131
}
132+
if (kind === "let ") {
133+
return extractArrayVariable(content, arrayName, "const ");
134+
}
129135
return null;
130136
}
131137

132138
// Stupid function extractor for variable.
133-
function extractVariable(content, varName) {
134-
var splitter = "var " + varName;
139+
function extractVariable(content, varName, kind) {
140+
if (typeof kind === "undefined") {
141+
kind = "let ";
142+
}
143+
var splitter = kind + varName;
135144
while (true) {
136145
var start = content.indexOf(splitter);
137146
if (start === -1) {
@@ -162,6 +171,9 @@ function extractVariable(content, varName) {
162171
}
163172
content = content.slice(start + 1);
164173
}
174+
if (kind === "let ") {
175+
return extractVariable(content, varName, "const ");
176+
}
165177
return null;
166178
}
167179

0 commit comments

Comments
 (0)
Please sign in to comment.