Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/rustc_codegen_llvm/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,13 @@ pub(crate) fn compile_codegen_unit(
// They are necessary for correct offload execution. We do this here to simplify the
// `offload` intrinsic, avoiding the need for tracking whether it's the first
// intrinsic call or not.
let has_host_offload =
cx.sess().opts.unstable_opts.offload.iter().any(|o| matches!(o, Offload::Host(_)));
let has_host_offload = cx
.sess()
.opts
.unstable_opts
.offload
.iter()
.any(|o| matches!(o, Offload::Host(_) | Offload::Test));
if has_host_offload && !cx.sess().target.is_like_gpu {
cx.offload_globals.replace(Some(OffloadGlobals::declare(&cx)));
}
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/builder/gpu_offload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ impl<'ll> OffloadGlobals<'ll> {
let bin_desc = cx.type_named_struct("struct.__tgt_bin_desc");
cx.set_struct_body(bin_desc, &tgt_bin_desc_ty, false);

let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", mapper_fn_ty);
let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", mapper_fn_ty);
let reg_lib_decl = cx.type_func(&[cx.type_ptr()], cx.type_void());
let register_lib = declare_offload_fn(&cx, "__tgt_register_lib", reg_lib_decl);
let unregister_lib = declare_offload_fn(&cx, "__tgt_unregister_lib", reg_lib_decl);
let init_ty = cx.type_func(&[], cx.type_void());
let init_rtls = declare_offload_fn(cx, "__tgt_init_all_rtls", init_ty);

Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_middle/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,9 @@ pub struct ModChild {
pub reexport_chain: SmallVec<[Reexport; 2]>,
}

#[derive(Debug, TyEncodable, TyDecodable, HashStable)]
pub enum AmbigModChildKind {
GlobVsGlob,
GlobVsExpanded,
}

/// Same as `ModChild`, however, it includes ambiguity error.
#[derive(Debug, TyEncodable, TyDecodable, HashStable)]
pub struct AmbigModChild {
pub main: ModChild,
pub second: ModChild,
pub kind: AmbigModChildKind,
}
22 changes: 9 additions & 13 deletions compiler/rustc_resolve/src/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_hir::def::{self, *};
use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
use rustc_index::bit_set::DenseBitSet;
use rustc_metadata::creader::LoadedMacro;
use rustc_middle::metadata::{AmbigModChildKind, ModChild, Reexport};
use rustc_middle::metadata::{ModChild, Reexport};
use rustc_middle::ty::{Feed, Visibility};
use rustc_middle::{bug, span_bug};
use rustc_span::hygiene::{ExpnId, LocalExpnId, MacroKind};
Expand All @@ -36,9 +36,9 @@ use crate::imports::{ImportData, ImportKind};
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
use crate::ref_mut::CmCell;
use crate::{
AmbiguityKind, BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind,
ModuleOrUniformRoot, NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult,
ResolutionError, Resolver, Segment, Used, VisResolutionError, errors,
BindingKey, ExternPreludeEntry, Finalize, MacroData, Module, ModuleKind, ModuleOrUniformRoot,
NameBinding, NameBindingData, NameBindingKind, ParentScope, PathResult, ResolutionError,
Resolver, Segment, Used, VisResolutionError, errors,
};

type Res = def::Res<NodeId>;
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
vis: Visibility<DefId>,
span: Span,
expansion: LocalExpnId,
ambiguity: Option<(NameBinding<'ra>, AmbiguityKind)>,
ambiguity: Option<NameBinding<'ra>>,
) {
let binding = self.arenas.alloc_name_binding(NameBindingData {
kind: NameBindingKind::Res(res),
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
&child.main,
parent_scope,
children.len() + i,
Some((&child.second, child.kind)),
Some(&child.second),
)
}
}
Expand All @@ -265,7 +265,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
child: &ModChild,
parent_scope: ParentScope<'ra>,
child_index: usize,
ambig_child: Option<(&ModChild, AmbigModChildKind)>,
ambig_child: Option<&ModChild>,
) {
let parent = parent_scope.module;
let child_span = |this: &Self, reexport_chain: &[Reexport], res: def::Res<_>| {
Expand All @@ -280,15 +280,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let span = child_span(self, reexport_chain, res);
let res = res.expect_non_local();
let expansion = parent_scope.expansion;
let ambig = ambig_child.map(|(ambig_child, ambig_kind)| {
let ambig = ambig_child.map(|ambig_child| {
let ModChild { ident: _, res, vis, ref reexport_chain } = *ambig_child;
let span = child_span(self, reexport_chain, res);
let res = res.expect_non_local();
let ambig_kind = match ambig_kind {
AmbigModChildKind::GlobVsGlob => AmbiguityKind::GlobVsGlob,
AmbigModChildKind::GlobVsExpanded => AmbiguityKind::GlobVsExpanded,
};
(self.arenas.new_res_binding(res, vis, span, expansion), ambig_kind)
self.arenas.new_res_binding(res, vis, span, expansion)
});

// Record primary definitions.
Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1206,9 +1206,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
}
}
}
Scope::Module(module, _) => {
Scope::ModuleNonGlobs(module, _) => {
this.add_module_candidates(module, suggestions, filter_fn, None);
}
Scope::ModuleGlobs(..) => {
// Already handled in `ModuleNonGlobs`.
}
Scope::MacroUsePrelude => {
suggestions.extend(this.macro_use_prelude.iter().filter_map(
|(name, binding)| {
Expand Down Expand Up @@ -2033,7 +2036,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
help_msgs.push(format!("use `::{ident}` to refer to this {thing} unambiguously"))
}

if let Scope::Module(module, _) = scope {
if let Scope::ModuleNonGlobs(module, _) | Scope::ModuleGlobs(module, _) = scope {
if module == self.graph_root {
help_msgs.push(format!(
"use `crate::{ident}` to refer to this {thing} unambiguously"
Expand Down
Loading
Loading