Skip to content
Open
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
2 changes: 1 addition & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4649,7 +4649,6 @@ dependencies = [
"rustc_ast_lowering",
"rustc_attr_ir",
"rustc_attr_parsing",
"rustc_crate_store",
"rustc_data_structures",
"rustc_errors",
"rustc_feature",
Expand Down Expand Up @@ -4774,6 +4773,7 @@ dependencies = [
"rustc_ast_pretty",
"rustc_attr_ir",
"rustc_attr_parsing",
"rustc_crate_store",
"rustc_data_structures",
"rustc_errors",
"rustc_expand",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
providers.queries.analysis = analysis;
providers.queries.resolver_for_lowering_raw = resolver_for_lowering_raw;
providers.queries.stripped_cfg_items = |tcx, _| &tcx.resolutions(()).stripped_cfg_items[..];
providers.queries.get_lang_items = |tcx, ()| &tcx.resolutions(()).lang_items;
providers.queries.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).2;
providers.queries.early_lint_checks = early_lint_checks;
providers.queries.env_var_os = env_var_os;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use rustc_ast::node_id::NodeMap;
use rustc_ast::{self as ast, NodeId};
use rustc_attr_ir::StrippedCfgItem;
use rustc_attr_ir::{LanguageItems, StrippedCfgItem};
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
use rustc_data_structures::steal::Steal;
use rustc_data_structures::unord::{UnordMap, UnordSet};
Expand Down Expand Up @@ -197,6 +197,7 @@ pub struct ResolverGlobalCtxt {
pub delegation_infos: FxIndexMap<LocalDefId, DelegationInfo>,
pub delegation_inherent_fn_map:
FxIndexMap<LocalDefId, FxIndexMap<Ident, DelegationInherentFnKind>>,
pub lang_items: LanguageItems,
}

#[derive(Debug)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2295,7 +2295,6 @@ rustc_queries! {
/// Returns the lang items defined in all crates by loading them from metadata of dependencies
/// and collecting the ones from the current crate.
query get_lang_items(_: ()) -> &'tcx LanguageItems {
arena_cache
eval_always
desc { "calculating the lang items map" }
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_passes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_attr_ir = { path = "../rustc_attr_ir" }
rustc_attr_parsing = { path = "../rustc_attr_parsing" }
rustc_crate_store = { path = "../rustc_crate_store" }
rustc_data_structures = { path = "../rustc_data_structures" }
rustc_errors = { path = "../rustc_errors" }
rustc_feature = { path = "../rustc_feature" }
Expand Down
131 changes: 0 additions & 131 deletions compiler/rustc_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use rustc_middle::ty::Ty;
use rustc_span::{DUMMY_SP, Ident, Span, Symbol};

use crate::check_attr::ProcMacroKind;
use crate::lang_items::Duplicate;

#[derive(Diagnostic)]
#[diag("`{$no_mangle_attr}` attribute may not be used in combination with `{$export_name_attr}`")]
Expand Down Expand Up @@ -180,30 +179,6 @@ pub(crate) struct InvalidMayDangle {
pub attr_span: Span,
}

#[derive(Diagnostic)]
#[diag("`#[panic_handler]` function required, but not found")]
pub(crate) struct MissingPanicHandler;

#[derive(Diagnostic)]
#[diag("unwinding panics are not supported without std")]
#[help("using nightly cargo, use -Zbuild-std with panic=\"abort\" to avoid unwinding")]
#[note(
"since the core library is usually precompiled with panic=\"unwind\", rebuilding your crate with panic=\"abort\" may not be enough to fix the problem"
)]
pub(crate) struct PanicUnwindWithoutStd;

#[derive(Diagnostic)]
#[diag("lang item required, but not found: `{$name}`")]
#[note(
"this can occur when a binary crate with `#![no_std]` is compiled for a target where `{$name}` is defined in the standard library"
)]
#[help(
"you may be able to compile for a target that doesn't need `{$name}`, specify a target with `--target` or in `.cargo/config`"
)]
pub(crate) struct MissingLangItem {
pub name: Symbol,
}

#[derive(Diagnostic)]
#[diag("duplicate diagnostic item in crate `{$crate_name}`: `{$name}`")]
pub(crate) struct DuplicateDiagnosticItemInCrate {
Expand Down Expand Up @@ -370,112 +345,6 @@ impl<'a> Diagnostic<'a> for NoMainErr {
diag
}
}
pub(crate) struct DuplicateLangItem {
pub local_span: Option<Span>,
pub lang_item_name: Symbol,
pub crate_name: Symbol,
pub dependency_of: Option<Symbol>,
pub is_local: bool,
pub path: String,
pub first_defined_span: Option<Span>,
pub orig_crate_name: Option<Symbol>,
pub orig_dependency_of: Option<Symbol>,
pub orig_is_local: bool,
pub orig_path: String,
pub(crate) duplicate: Duplicate,
}

impl Diagnostic<'_> for DuplicateLangItem {
#[track_caller]
fn into_diag(self, dcx: DiagCtxtHandle<'_>, level: Level) -> Diag<'_> {
let mut diag = Diag::new(
dcx,
level,
match self.duplicate {
Duplicate::Plain => msg!("found duplicate lang item `{$lang_item_name}`"),
Duplicate::Crate => {
msg!("duplicate lang item in crate `{$crate_name}`: `{$lang_item_name}`")
}
Duplicate::CrateDepends => msg!(
"duplicate lang item in crate `{$crate_name}` (which `{$dependency_of}` depends on): `{$lang_item_name}`"
),
},
);
diag.code(E0152);
diag.arg("lang_item_name", self.lang_item_name);
diag.arg("crate_name", self.crate_name);
if let Some(dependency_of) = self.dependency_of {
diag.arg("dependency_of", dependency_of);
}
diag.arg("path", self.path);
if let Some(orig_crate_name) = self.orig_crate_name {
diag.arg("orig_crate_name", orig_crate_name);
}
if let Some(orig_dependency_of) = self.orig_dependency_of {
diag.arg("orig_dependency_of", orig_dependency_of);
}
diag.arg("orig_path", self.orig_path);
if let Some(span) = self.local_span {
diag.span(span);
}
if let Some(span) = self.first_defined_span {
diag.span_note(span, msg!("the lang item is first defined here"));
} else {
if self.orig_dependency_of.is_none() {
diag.note(msg!("the lang item is first defined in crate `{$orig_crate_name}`"));
} else {
diag.note(msg!("the lang item is first defined in crate `{$orig_crate_name}` (which `{$orig_dependency_of}` depends on)"));
}

if self.orig_is_local {
diag.note(msg!("first definition in the local crate (`{$orig_crate_name}`)"));
} else {
diag.note(msg!(
"first definition in `{$orig_crate_name}` loaded from {$orig_path}"
));
}

if self.is_local {
diag.note(msg!("second definition in the local crate (`{$crate_name}`)"));
} else {
diag.note(msg!("second definition in `{$crate_name}` loaded from {$path}"));
}
}
diag
}
}

#[derive(Diagnostic)]
#[diag("`{$name}` lang item must be applied to a {$kind} with {$at_least ->
[true] at least {$num}
*[false] {$num}
} generic {$num ->
[one] argument
*[other] arguments
}", code = E0718)]
pub(crate) struct IncorrectTarget<'a> {
#[primary_span]
pub span: Span,
#[label(
"this {$kind} has {$actual_num} generic {$actual_num ->
[one] argument
*[other] arguments
}"
)]
pub generics_span: Span,
pub name: &'a str, // cannot be symbol because it renders e.g. `r#fn` instead of `fn`
pub kind: &'static str,
pub num: usize,
pub actual_num: usize,
pub at_least: bool,
}

#[derive(Diagnostic)]
#[diag("lang items are not allowed in stable dylibs")]
pub(crate) struct IncorrectCrateType {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(
Expand Down
Loading
Loading