Skip to content

Commit 451b7b6

Browse files
committed
Auto merge of #150682 - matthiaskrgr:rollup-jrkhivl, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #149681 (resolve: Split `Scope::Module` into two scopes for non-glob and glob bindings ) - #150426 (Update offload test and verify that tgt_(un)register_lib have the right type) - #150678 (relate.rs: tiny cleanup: eliminate temp vars) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e29fcf4 + 8b1f449 commit 451b7b6

21 files changed

Lines changed: 297 additions & 296 deletions

compiler/rustc_codegen_llvm/src/base.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,13 @@ pub(crate) fn compile_codegen_unit(
9393
// They are necessary for correct offload execution. We do this here to simplify the
9494
// `offload` intrinsic, avoiding the need for tracking whether it's the first
9595
// intrinsic call or not.
96-
let has_host_offload =
97-
cx.sess().opts.unstable_opts.offload.iter().any(|o| matches!(o, Offload::Host(_)));
96+
let has_host_offload = cx
97+
.sess()
98+
.opts
99+
.unstable_opts
100+
.offload
101+
.iter()
102+
.any(|o| matches!(o, Offload::Host(_) | Offload::Test));
98103
if has_host_offload && !cx.sess().target.is_like_gpu {
99104
cx.offload_globals.replace(Some(OffloadGlobals::declare(&cx)));
100105
}

compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ impl<'ll> OffloadGlobals<'ll> {
4949
let bin_desc = cx.type_named_struct("struct.__tgt_bin_desc");
5050
cx.set_struct_body(bin_desc, &tgt_bin_desc_ty, false);
5151

52-
let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", mapper_fn_ty);
53-
let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", mapper_fn_ty);
52+
let reg_lib_decl = cx.type_func(&[cx.type_ptr()], cx.type_void());
53+
let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", reg_lib_decl);
54+
let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", reg_lib_decl);
5455
let init_ty = cx.type_func(&[], cx.type_void());
5556
let init_rtls = declare_offload_fn(cx, "__tgt_init_all_rtls", init_ty);
5657

compiler/rustc_middle/src/metadata.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,9 @@ pub struct ModChild {
4545
pub reexport_chain: SmallVec<[Reexport; 2]>,
4646
}
4747

48-
#[derive(Debug, TyEncodable, TyDecodable, HashStable)]
49-
pub enum AmbigModChildKind {
50-
GlobVsGlob,
51-
GlobVsExpanded,
52-
}
53-
5448
/// Same as `ModChild`, however, it includes ambiguity error.
5549
#[derive(Debug, TyEncodable, TyDecodable, HashStable)]
5650
pub struct AmbigModChild {
5751
pub main: ModChild,
5852
pub second: ModChild,
59-
pub kind: AmbigModChildKind,
6053
}

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_hir::def::{self, *};
2222
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
2323
use rustc_index::bit_set::DenseBitSet;
2424
use rustc_metadata::creader::LoadedMacro;
25-
use rustc_middle::metadata::{AmbigModChildKind, ModChild, Reexport};
25+
use rustc_middle::metadata::{ModChild, Reexport};
2626
use rustc_middle::ty::{Feed, Visibility};
2727
use rustc_middle::{bug, span_bug};
2828
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
@@ -36,9 +36,9 @@ use crate::imports::{ImportData, ImportKind};
3636
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
3737
use crate::ref_mut::CmCell;
3838
use crate::{
39-
AmbiguityKind, BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind,
40-
ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult,
41-
ResolutionError, Resolver, Segment, Used, VisResolutionError, errors,
39+
BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, ModuleOrUniformRoot,
40+
NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult, ResolutionError,
41+
Resolver, Segment, Used, VisResolutionError, errors,
4242
};
4343

4444
type Res = def::Res<NodeId>;
@@ -82,7 +82,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
8282
vis: Visibility<DefId>,
8383
span: Span,
8484
expansion: LocalExpnId,
85-
ambiguity: Option<(NameBinding<'ra>, AmbiguityKind)>,
85+
ambiguity: Option<NameBinding<'ra>>,
8686
) {
8787
let binding = self.arenas.alloc_name_binding(NameBindingData {
8888
kind: NameBindingKind::Res(res),
@@ -254,7 +254,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
254254
&child.main,
255255
parent_scope,
256256
children.len() + i,
257-
Some((&child.second, child.kind)),
257+
Some(&child.second),
258258
)
259259
}
260260
}
@@ -265,7 +265,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
265265
child: &ModChild,
266266
parent_scope: ParentScope<'ra>,
267267
child_index: usize,
268-
ambig_child: Option<(&ModChild, AmbigModChildKind)>,
268+
ambig_child: Option<&ModChild>,
269269
) {
270270
let parent = parent_scope.module;
271271
let child_span = |this: &Self, reexport_chain: &[Reexport], res: def::Res<_>| {
@@ -280,15 +280,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
280280
let span = child_span(self, reexport_chain, res);
281281
let res = res.expect_non_local();
282282
let expansion = parent_scope.expansion;
283-
let ambig = ambig_child.map(|(ambig_child, ambig_kind)| {
283+
let ambig = ambig_child.map(|ambig_child| {
284284
let ModChild { ident: _, res, vis, ref reexport_chain } = *ambig_child;
285285
let span = child_span(self, reexport_chain, res);
286286
let res = res.expect_non_local();
287-
let ambig_kind = match ambig_kind {
288-
AmbigModChildKind::GlobVsGlob => AmbiguityKind::GlobVsGlob,
289-
AmbigModChildKind::GlobVsExpanded => AmbiguityKind::GlobVsExpanded,
290-
};
291-
(self.arenas.new_res_binding(res, vis, span, expansion), ambig_kind)
287+
self.arenas.new_res_binding(res, vis, span, expansion)
292288
});
293289

294290
// Record primary definitions.

compiler/rustc_resolve/src/diagnostics.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,9 +1206,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
12061206
}
12071207
}
12081208
}
1209-
Scope::Module(module, _) => {
1209+
Scope::ModuleNonGlobs(module, _) => {
12101210
this.add_module_candidates(module, suggestions, filter_fn, None);
12111211
}
1212+
Scope::ModuleGlobs(..) => {
1213+
// Already handled in `ModuleNonGlobs`.
1214+
}
12121215
Scope::MacroUsePrelude => {
12131216
suggestions.extend(this.macro_use_prelude.iter().filter_map(
12141217
|(name, binding)| {
@@ -2033,7 +2036,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
20332036
help_msgs.push(format!("use `::{ident}` to refer to this {thing} unambiguously"))
20342037
}
20352038

2036-
if let Scope::Module(module, _) = scope {
2039+
if let Scope::ModuleNonGlobs(module, _) | Scope::ModuleGlobs(module, _) = scope {
20372040
if module == self.graph_root {
20382041
help_msgs.push(format!(
20392042
"use `crate::{ident}` to refer to this {thing} unambiguously"

0 commit comments

Comments
 (0)