Skip to content

Commit eb17695

Browse files
committed
Auto merge of #157114 - JonathanBrouwer:rollup-z0XiMA0, r=JonathanBrouwer
Rollup of 11 pull requests Successful merges: - #149195 (resolve: Partially convert `ambiguous_glob_imports` lint into a hard error) - #156960 (Some cleanups around passing extra lifetime params from the resolver to ast lowering) - #156963 (definitions: remove `DefPathTable`, use `LocalDefId` instead of `DefIndex`) - #157053 (Eagerly resolve delegations in late resolution) - #157068 (NVPTX: Remove the unstable ptx linker flavor) - #157076 (Various proc-macro related code cleanups) - #157106 (add ABI check logic for wasm) - #154835 (std::offload sharedmem) - #157065 (Stabilize `Path::is_empty`) - #157088 (Improve suggestions for malformed deprecated attribute) - #157103 (Add reproducibly failing tests for parallel frontend) Failed merges: - #157100 (Some more per owner things)
2 parents 6368fd5 + 05bfc77 commit eb17695

105 files changed

Lines changed: 864 additions & 1540 deletions

File tree

Some content is hidden

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

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
124124
// Delegation can be unresolved in illegal places such as function bodies in extern blocks (see #151356)
125125
let sig_id = if let Some(delegation_info) = self.resolver.delegation_info(self.owner.def_id)
126126
{
127-
self.get_sig_id(delegation_info.resolution_node, span)
127+
self.get_sig_id(delegation_info.resolution_id, span)
128128
} else {
129129
self.dcx().span_delayed_bug(
130130
span,
@@ -230,22 +230,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
230230
.collect::<Vec<_>>()
231231
}
232232

233-
fn get_sig_id(&self, mut node_id: NodeId, span: Span) -> Result<DefId, ErrorGuaranteed> {
234-
let mut visited: FxHashSet<NodeId> = Default::default();
233+
fn get_sig_id(&self, mut def_id: DefId, span: Span) -> Result<DefId, ErrorGuaranteed> {
234+
let mut visited: FxHashSet<DefId> = Default::default();
235235
let mut path: SmallVec<[DefId; 1]> = Default::default();
236236

237237
loop {
238-
visited.insert(node_id);
239-
240-
let Some(def_id) = self.get_resolution_id(node_id) else {
241-
return Err(self.tcx.dcx().span_delayed_bug(
242-
span,
243-
format!(
244-
"LoweringContext: couldn't resolve node {:?} in delegation item",
245-
node_id
246-
),
247-
));
248-
};
238+
visited.insert(def_id);
249239

250240
path.push(def_id);
251241

@@ -255,8 +245,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
255245
if let Some(local_id) = def_id.as_local()
256246
&& let Some(delegation_info) = self.resolver.delegation_info(local_id)
257247
{
258-
node_id = delegation_info.resolution_node;
259-
if visited.contains(&node_id) {
248+
def_id = delegation_info.resolution_id;
249+
if visited.contains(&def_id) {
260250
// We encountered a cycle in the resolution, or delegation callee refers to non-existent
261251
// entity, in this case emit an error.
262252
return Err(match visited.len() {

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,11 +1928,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
19281928

19291929
// Introduce extra lifetimes if late resolution tells us to.
19301930
let extra_lifetimes = self.resolver.extra_lifetime_params(parent_node_id);
1931-
params.extend(extra_lifetimes.into_iter().filter_map(|&(ident, node_id, res)| {
1931+
params.extend(extra_lifetimes.into_iter().map(|&(ident, node_id, kind)| {
19321932
self.lifetime_res_to_generic_param(
19331933
ident,
19341934
node_id,
1935-
res,
1935+
kind,
19361936
hir::GenericParamSource::Generics,
19371937
)
19381938
}));

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use rustc_hir::definitions::PerParentDisambiguatorState;
5555
use rustc_hir::lints::DelayedLint;
5656
use rustc_hir::{
5757
self as hir, AngleBrackets, ConstArg, GenericArg, HirId, ItemLocalMap, LifetimeSource,
58-
LifetimeSyntax, ParamName, Target, TraitCandidate, find_attr,
58+
LifetimeSyntax, MissingLifetimeKind, ParamName, Target, TraitCandidate, find_attr,
5959
};
6060
use rustc_index::{Idx, IndexSlice, IndexVec};
6161
use rustc_macros::extension;
@@ -310,7 +310,7 @@ impl<'tcx> ResolverAstLowering<'tcx> {
310310
///
311311
/// The extra lifetimes that appear from the parenthesized `Fn`-trait desugaring
312312
/// should appear at the enclosing `PolyTraitRef`.
313-
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, LifetimeRes)] {
313+
fn extra_lifetime_params(&self, id: NodeId) -> &[(Ident, NodeId, MissingLifetimeKind)] {
314314
self.extra_lifetime_params_map.get(&id).map_or(&[], |v| &v[..])
315315
}
316316

@@ -542,7 +542,7 @@ pub fn lower_to_hir(tcx: TyCtxt<'_>, (): ()) -> mid_hir::Crate<'_> {
542542
let ast_index = index_crate(&resolver, &krate);
543543
let mut owners = IndexVec::from_fn_n(
544544
|_| hir::MaybeOwner::Phantom,
545-
tcx.definitions_untracked().def_index_count(),
545+
tcx.definitions_untracked().num_definitions(),
546546
);
547547

548548
let mut lowerer = item::ItemLowerer {
@@ -948,43 +948,30 @@ impl<'hir> LoweringContext<'_, 'hir> {
948948
&mut self,
949949
ident: Ident,
950950
node_id: NodeId,
951-
res: LifetimeRes,
951+
kind: MissingLifetimeKind,
952952
source: hir::GenericParamSource,
953-
) -> Option<hir::GenericParam<'hir>> {
954-
let (name, kind) = match res {
955-
LifetimeRes::Param { .. } => {
956-
(hir::ParamName::Plain(ident), hir::LifetimeParamKind::Explicit)
957-
}
958-
LifetimeRes::Fresh { param, kind, .. } => {
959-
// Late resolution delegates to us the creation of the `LocalDefId`.
960-
let _def_id = self.create_def(
961-
param,
962-
Some(kw::UnderscoreLifetime),
963-
DefKind::LifetimeParam,
964-
ident.span,
965-
);
966-
debug!(?_def_id);
953+
) -> hir::GenericParam<'hir> {
954+
// Late resolution delegates to us the creation of the `LocalDefId`.
955+
let _def_id = self.create_def(
956+
node_id,
957+
Some(kw::UnderscoreLifetime),
958+
DefKind::LifetimeParam,
959+
ident.span,
960+
);
961+
debug!(?_def_id);
967962

968-
(hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind))
969-
}
970-
LifetimeRes::Static { .. } | LifetimeRes::Error(..) => return None,
971-
res => panic!(
972-
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
973-
res, ident, ident.span
974-
),
975-
};
976963
let hir_id = self.lower_node_id(node_id);
977964
let def_id = self.local_def_id(node_id);
978-
Some(hir::GenericParam {
965+
hir::GenericParam {
979966
hir_id,
980967
def_id,
981-
name,
968+
name: hir::ParamName::Fresh,
982969
span: self.lower_span(ident.span),
983970
pure_wrt_drop: false,
984-
kind: hir::GenericParamKind::Lifetime { kind },
971+
kind: hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Elided(kind) },
985972
colon_span: None,
986973
source,
987-
})
974+
}
988975
}
989976

990977
/// Lowers a lifetime binder that defines `generic_params`, returning the corresponding HIR
@@ -1005,7 +992,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1005992
debug!(?extra_lifetimes);
1006993
let extra_lifetimes: Vec<_> = extra_lifetimes
1007994
.iter()
1008-
.filter_map(|&(ident, node_id, res)| {
995+
.map(|&(ident, node_id, res)| {
1009996
self.lifetime_res_to_generic_param(
1010997
ident,
1011998
node_id,

compiler/rustc_attr_parsing/src/attributes/deprecation.rs

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rustc_ast::LitKind;
12
use rustc_hir::attrs::{DeprecatedSince, Deprecation};
23
use rustc_hir::{RustcVersion, VERSION_PLACEHOLDER};
34

@@ -76,6 +77,38 @@ impl SingleAttributeParser for DeprecatedParser {
7677
// ok
7778
}
7879
ArgParser::List(list) => {
80+
// If the argument list contains a single string literal:
81+
// check whether it may be a version and suggest since field
82+
// otherwise, suggest using NameValue syntax
83+
if let Some(elem) = list.as_single()
84+
&& let Some(lit) = elem.as_lit()
85+
&& let LitKind::Str(text, _) = lit.kind
86+
{
87+
let mut adcx = cx.adcx();
88+
89+
match parse_since(text, true) {
90+
DeprecatedSince::Future | DeprecatedSince::RustcVersion(_) => {
91+
adcx.push_suggestion(
92+
String::from("try specifying a deprecated since version"),
93+
elem.span(),
94+
format!("since = {}", lit.kind),
95+
);
96+
}
97+
_ => {
98+
if let Some(span) = args.span() {
99+
adcx.push_suggestion(
100+
String::from("try using `=` instead"),
101+
span,
102+
format!(" = {}", lit.kind),
103+
);
104+
}
105+
}
106+
};
107+
108+
adcx.expected_not_literal(elem.span());
109+
return None;
110+
}
111+
79112
for param in list.mixed() {
80113
let Some(param) = param.meta_item() else {
81114
cx.adcx().expected_not_literal(param.span());
@@ -133,18 +166,11 @@ impl SingleAttributeParser for DeprecatedParser {
133166
}
134167

135168
let since = if let Some(since) = since {
136-
if since.as_str() == "TBD" {
137-
DeprecatedSince::Future
138-
} else if !is_rustc {
139-
DeprecatedSince::NonStandard(since)
140-
} else if since.as_str() == VERSION_PLACEHOLDER {
141-
DeprecatedSince::RustcVersion(RustcVersion::CURRENT)
142-
} else if let Some(version) = parse_version(since) {
143-
DeprecatedSince::RustcVersion(version)
144-
} else {
169+
let since = parse_since(since, is_rustc);
170+
if matches!(since, DeprecatedSince::Err) {
145171
cx.emit_err(InvalidSince { span: cx.attr_span });
146-
DeprecatedSince::Err
147172
}
173+
since
148174
} else if is_rustc {
149175
cx.emit_err(MissingSince { span: cx.attr_span });
150176
DeprecatedSince::Err
@@ -163,3 +189,17 @@ impl SingleAttributeParser for DeprecatedParser {
163189
})
164190
}
165191
}
192+
193+
fn parse_since(since: Symbol, is_rustc: bool) -> DeprecatedSince {
194+
if since.as_str() == "TBD" {
195+
DeprecatedSince::Future
196+
} else if !is_rustc {
197+
DeprecatedSince::NonStandard(since)
198+
} else if since.as_str() == VERSION_PLACEHOLDER {
199+
DeprecatedSince::RustcVersion(RustcVersion::CURRENT)
200+
} else if let Some(version) = parse_version(since) {
201+
DeprecatedSince::RustcVersion(version)
202+
} else {
203+
DeprecatedSince::Err
204+
}
205+
}

compiler/rustc_codegen_gcc/build_system/src/test.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,6 @@ fn valid_ui_error_pattern_test(file: &str) -> bool {
886886
"type-alias-impl-trait/auxiliary/cross_crate_ice.rs",
887887
"type-alias-impl-trait/auxiliary/cross_crate_ice2.rs",
888888
"macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs",
889-
"imports/ambiguous-1.rs",
890-
"imports/ambiguous-4-extern.rs",
891889
"entry-point/auxiliary/bad_main_functions.rs",
892890
]
893891
.iter()

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -319,25 +319,26 @@ impl KernelArgsTy {
319319
geps: [&'ll Value; 3],
320320
workgroup_dims: &'ll Value,
321321
thread_dims: &'ll Value,
322-
) -> [(Align, &'ll Value); 13] {
322+
dyn_cache: &'ll Value,
323+
) -> [(Align, &'ll str, &'ll Value); 13] {
323324
let four = Align::from_bytes(4).expect("4 Byte alignment should work");
324325
let eight = Align::EIGHT;
325326

326327
[
327-
(four, cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)),
328-
(four, cx.get_const_i32(num_args)),
329-
(eight, geps[0]),
330-
(eight, geps[1]),
331-
(eight, geps[2]),
332-
(eight, memtransfer_types),
328+
(four, "Version", cx.get_const_i32(KernelArgsTy::OFFLOAD_VERSION)),
329+
(four, "NumArgs", cx.get_const_i32(num_args)),
330+
(eight, "ArgBasePtrs", geps[0]),
331+
(eight, "ArgPtrs", geps[1]),
332+
(eight, "ArgSizes", geps[2]),
333+
(eight, "ArgTypes", memtransfer_types),
333334
// The next two are debug infos. FIXME(offload): set them
334-
(eight, cx.const_null(cx.type_ptr())), // dbg
335-
(eight, cx.const_null(cx.type_ptr())), // dbg
336-
(eight, cx.get_const_i64(KernelArgsTy::TRIPCOUNT)),
337-
(eight, cx.get_const_i64(KernelArgsTy::FLAGS)),
338-
(four, workgroup_dims),
339-
(four, thread_dims),
340-
(four, cx.get_const_i32(0)),
335+
(eight, "ArgNames", cx.const_null(cx.type_ptr())), // dbg
336+
(eight, "ArgMappers", cx.const_null(cx.type_ptr())), // dbg
337+
(eight, "Tripcount", cx.get_const_i64(KernelArgsTy::TRIPCOUNT)),
338+
(eight, "Flags", cx.get_const_i64(KernelArgsTy::FLAGS)),
339+
(four, "NumTeams", workgroup_dims),
340+
(four, "ThreadLimit", thread_dims),
341+
(four, "DynCGroupMem", dyn_cache),
341342
]
342343
}
343344
}
@@ -589,6 +590,7 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
589590
metadata: &[OffloadMetadata],
590591
offload_globals: &OffloadGlobals<'ll>,
591592
offload_dims: &OffloadKernelDims<'ll>,
593+
dyn_cache: &'ll Value,
592594
) {
593595
let cx = builder.cx;
594596
let OffloadKernelGlobals {
@@ -753,14 +755,24 @@ pub(crate) fn gen_call_handling<'ll, 'tcx>(
753755
num_args,
754756
s_ident_t,
755757
);
756-
let values =
757-
KernelArgsTy::new(&cx, num_args, memtransfer_kernel, geps, workgroup_dims, thread_dims);
758+
let values = KernelArgsTy::new(
759+
&cx,
760+
num_args,
761+
memtransfer_kernel,
762+
geps,
763+
workgroup_dims,
764+
thread_dims,
765+
dyn_cache,
766+
);
758767

759768
// Step 3)
760769
// Here we fill the KernelArgsTy, see the documentation above
761770
for (i, value) in values.iter().enumerate() {
762771
let ptr = builder.inbounds_gep(tgt_kernel_decl, a5, &[i32_0, cx.get_const_i32(i as u64)]);
763-
builder.store(value.1, ptr, value.0);
772+
let name = std::ffi::CString::new(value.1).unwrap();
773+
llvm::set_value_name(ptr, &name.as_bytes());
774+
775+
builder.store(value.2, ptr, value.0);
764776
}
765777

766778
let args = vec![

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,11 @@ fn codegen_offload<'ll, 'tcx>(
19261926
};
19271927

19281928
let offload_dims = OffloadKernelDims::from_operands(bx, &args[1], &args[2]);
1929-
let args = get_args_from_tuple(bx, args[3], fn_target);
1929+
let dyn_cache = match args[3].val {
1930+
OperandValue::Immediate(val) => val,
1931+
_ => panic!("unparsable"),
1932+
};
1933+
let args = get_args_from_tuple(bx, args[4], fn_target);
19301934
let target_symbol = symbol_name_for_instance_in_crate(tcx, fn_target, LOCAL_CRATE);
19311935

19321936
let sig = tcx.fn_sig(fn_target.def_id()).skip_binder();
@@ -1958,7 +1962,16 @@ fn codegen_offload<'ll, 'tcx>(
19581962
};
19591963
register_offload(cx);
19601964
let offload_data = gen_define_handling(&cx, &metadata, target_symbol, offload_globals);
1961-
gen_call_handling(bx, &offload_data, &args, &types, &metadata, offload_globals, &offload_dims);
1965+
gen_call_handling(
1966+
bx,
1967+
&offload_data,
1968+
&args,
1969+
&types,
1970+
&metadata,
1971+
offload_globals,
1972+
&offload_dims,
1973+
&dyn_cache,
1974+
);
19621975
}
19631976

19641977
fn get_args_from_tuple<'ll, 'tcx>(

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
15301530
}
15311531
LinkerFlavor::Bpf => "bpf-linker",
15321532
LinkerFlavor::Llbc => "llvm-bitcode-linker",
1533-
LinkerFlavor::Ptx => "rust-ptx-linker",
15341533
}),
15351534
flavor,
15361535
)),
@@ -1571,7 +1570,6 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
15711570
let linker_flavor = match sess.opts.cg.linker_flavor {
15721571
// The linker flavors that are non-target specific can be directly translated to LinkerFlavor
15731572
Some(LinkerFlavorCli::Llbc) => Some(LinkerFlavor::Llbc),
1574-
Some(LinkerFlavorCli::Ptx) => Some(LinkerFlavor::Ptx),
15751573
// The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor
15761574
linker_flavor => {
15771575
linker_flavor.map(|flavor| sess.target.linker_flavor.with_cli_hints(flavor))
@@ -2764,8 +2762,6 @@ fn add_order_independent_options(
27642762
if crate_info.target_features.len() > 0 {
27652763
cmd.link_arg(&format!("--target-feature={}", &crate_info.target_features.join(",")));
27662764
}
2767-
} else if flavor == LinkerFlavor::Ptx {
2768-
cmd.link_args(&["--fallback-arch", &crate_info.target_cpu]);
27692765
} else if flavor == LinkerFlavor::Bpf {
27702766
cmd.link_args(&["--cpu", &crate_info.target_cpu]);
27712767
if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features]

0 commit comments

Comments
 (0)