Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
38de102
Support eager and lazy methods for providing references and values
shepmaster Jul 21, 2022
260ec93
Add `Provider::{would_be_satisfied_by_value_of,would_be_satisfied_by_…
shepmaster Jul 22, 2022
81a583c
Try normalizing types without RevealAll in ParamEnv in mir validation
Noratrieb Aug 3, 2022
96d4137
Only normalize once in mir validator typechecker
Noratrieb Aug 6, 2022
c846a2a
Make `std::os::fd` public.
sunfishcode Jun 14, 2022
09bbc42
Update asrawfd.js.
sunfishcode Jun 22, 2022
bda1262
Clarify that the `fd` module is supported on Unix and WASI.
sunfishcode Jun 30, 2022
7d80510
Re-introduce `unstable` attributes.
sunfishcode Aug 23, 2022
b9d3f65
[drop tracking] Use parent expression for scope
eholk Aug 30, 2022
803e35a
Remove unneeded extra whitespace before where clause
GuillaumeGomez Aug 31, 2022
4304d1d
Update rustdoc tests
GuillaumeGomez Aug 31, 2022
b112bfe
Add rustdoc GUI test
GuillaumeGomez Aug 31, 2022
54645e8
set up rustc_metadata for SessionDiagnostics, port dependency_format.rs
CleanCut Aug 23, 2022
3ed9310
port native_libs.rs to SessionDiagnostics
CleanCut Aug 23, 2022
f7e462a
port encoder.rs to SessionDiagnostics
CleanCut Aug 23, 2022
32e1823
port creader.rs to SessionDiagnostics
CleanCut Aug 23, 2022
bd8e312
port fs.rs to SessionDiagnostics
CleanCut Aug 23, 2022
d0ba1fb
port of locator.rs to SessionDiagnostics, fix some of the errors
CleanCut Aug 24, 2022
0d65819
respond to review feedback: mainly eliminate as many conversions as p…
CleanCut Aug 26, 2022
30adfd6
port 5 new diagnostics that appeared in master
CleanCut Aug 27, 2022
f921f56
Use parent_iter instead of a find_parent_node loop
eholk Aug 31, 2022
a928255
Fix bad target name in Walkthrough
diminishedprime Aug 31, 2022
d8b572b
Tweaks to fuchsia doc walkthrough
andrewpollack Aug 31, 2022
eb14b5d
Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtri…
Dylan-DPC Sep 1, 2022
fbe63c2
Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc
Dylan-DPC Sep 1, 2022
6a3a886
Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obk
Dylan-DPC Sep 1, 2022
1116b4d
Rollup merge of #100928 - CleanCut:rustc_metadata_diagnostics, r=davi…
Dylan-DPC Sep 1, 2022
7298451
Rollup merge of #101217 - eholk:drop-tracking-73137, r=jyn514
Dylan-DPC Sep 1, 2022
4e07938
Rollup merge of #101245 - GuillaumeGomez:remove-unneeded-where-whites…
Dylan-DPC Sep 1, 2022
4c92e64
Rollup merge of #101251 - diminishedprime:patch-1, r=JohnTitor
Dylan-DPC Sep 1, 2022
8c9564e
Rollup merge of #101256 - andrewpollack:fuchsia-docs-adding, r=tmandry
Dylan-DPC Sep 1, 2022
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
Prev Previous commit
Next Next commit
port of locator.rs to SessionDiagnostics, fix some of the errors
revealed by tests, manually add a panic to test for dead code
  • Loading branch information
CleanCut committed Aug 31, 2022
commit d0ba1fbaa4f73b6edf27346817b1f74fb352945e
55 changes: 55 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/metadata.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,58 @@ metadata_failed_create_file =

metadata_failed_create_encoded_metadata =
failed to create encoded metadata from file: {$err}

metadata_non_ascii_name =
cannot load a crate with a non-ascii name `{$crate_name}`

metadata_extern_location_not_exist =
extern location for {$crate_name} does not exist: {$location}

metadata_extern_location_not_file =
extern location for {$crate_name} is not a file: {$location}

metadata_multiple_candidates =
multiple {$flavor} candidates for `{$crate_name}` found

metadata_multiple_matching_crates =
multiple matching crates for `{$crate_name}`
.note = candidates:{$candidates}

metadata_symbol_conflicts_current =
the current crate is indistinguishable from one of its dependencies: it has the same crate-name `{$crate_name}` and was compiled with the same `-C metadata` arguments. This will result in symbol conflicts between the two.

metadata_symbol_conflicts_others =
found two different crates with name `{$crate_name}` that are not distinguished by differing `-C metadata`. This will result in symbol conflicts between the two.

metadata_stable_crate_id_collision =
found crates (`{$crate_name0}` and `{$crate_name1}`) with colliding StableCrateId values.

metadata_dl_error =
{$err}

metadata_newer_crate_version =
found possibly newer version of crate `{$crate_name}`{$add_info}
.note = perhaps that crate needs to be recompiled?

metadata_found_crate_versions =
the following crate versions were found:{$found_crates}

metadata_no_crate_with_triple =
couldn't find crate `{$crate_name}` with expected target triple {$locator_triple}{$add_info}

metadata_found_staticlib =
found staticlib `{$crate_name}` instead of rlib or dylib{$add_info}
.help = please recompile that crate using --crate-type lib

metadata_incompatible_rustc =
found crate `{$crate_name}` compiled by an incompatible version of rustc{$add_info}
.help = please recompile that crate using this compiler ({$rustc_version}) (consider running `cargo clean` first)

metadata_invalid_meta_files =
found invalid metadata files for crate `{$crate_name}`{$add_info}

metadata_cannot_find_crate =
can't find crate for `{$crate_name}`{$add_info}

metadata_no_dylib_plugin =
plugin `{$crate_name}` only found in rlib format, but must be available in dylib format
257 changes: 252 additions & 5 deletions compiler/rustc_metadata/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// use rustc_errors::ErrorGuaranteed;
use std::path::PathBuf;

use rustc_errors::{DiagnosticId, ErrorGuaranteed};
use rustc_macros::SessionDiagnostic;
use rustc_span::Span;
use rustc_session::{config, SessionDiagnostic};
use rustc_span::{sym, Span, Symbol};
use rustc_target::spec::TargetTriple;

#[derive(SessionDiagnostic)]
#[diag(metadata::rlib_required)]
Expand Down Expand Up @@ -104,8 +108,8 @@ pub struct WasmImportForm {
#[derive(SessionDiagnostic)]
#[diag(metadata::empty_link_name, code = "E0454")]
pub struct EmptyLinkName {
#[label]
#[primary_span]
#[label]
pub span: Span,
}

Expand All @@ -126,8 +130,8 @@ pub struct FrameworkOnlyWindows {
#[derive(SessionDiagnostic)]
#[diag(metadata::unknown_link_kind, code = "E0458")]
pub struct UnknownLinkKind {
#[label]
#[primary_span]
#[label]
pub span: Span,
pub kind: String,
}
Expand Down Expand Up @@ -221,8 +225,8 @@ pub struct IncompatibleWasmLink {
#[derive(SessionDiagnostic)]
#[diag(metadata::link_requires_name, code = "E0459")]
pub struct LinkRequiresName {
#[label]
#[primary_span]
#[label]
pub span: Span,
}

Expand Down Expand Up @@ -378,3 +382,246 @@ pub struct FailedCreateFile {
pub struct FailedCreateEncodedMetadata {
pub err: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::non_ascii_name)]
pub struct NonAsciiName {
#[primary_span]
pub span: Span,
pub crate_name: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::extern_location_not_exist)]
pub struct ExternLocationNotExist {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub location: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::extern_location_not_file)]
pub struct ExternLocationNotFile {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub location: String,
}

pub struct MultipleCandidates {
pub span: Span,
pub flavor: String,
pub crate_name: String,
pub candidates: Vec<PathBuf>,
}

impl SessionDiagnostic<'_> for MultipleCandidates {
fn into_diagnostic(
self,
sess: &'_ rustc_session::parse::ParseSess,
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(rustc_errors::fluent::metadata::multiple_candidates);
diag.set_arg("crate_name", self.crate_name);
diag.set_arg("flavor", self.flavor);
diag.code(DiagnosticId::Error("E0465".into()));
diag.set_span(self.span);
for (i, candidate) in self.candidates.iter().enumerate() {
diag.span_note(self.span, &format!("candidate #{}: {}", i + 1, candidate.display()));
}
diag
}
}

#[derive(SessionDiagnostic)]
#[diag(metadata::multiple_matching_crates, code = "E0464")]
#[note]
pub struct MultipleMatchingCrates {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub candidates: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::symbol_conflicts_current, code = "E0519")]
pub struct SymbolConflictsCurrent {
#[primary_span]
pub span: Span,
pub crate_name: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::symbol_conflicts_others, code = "E0523")]
pub struct SymbolConflictsOthers {
#[primary_span]
pub span: Span,
pub crate_name: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::stable_crate_id_collision)]
pub struct StableCrateIdCollision {
#[primary_span]
pub span: Span,
pub crate_name0: String,
pub crate_name1: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::dl_error)]
pub struct DlError {
#[primary_span]
pub span: Span,
pub err: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::newer_crate_version, code = "E0460")]
#[note]
#[note(metadata::found_crate_versions)]
pub struct NewerCrateVersion {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub add_info: String,
pub found_crates: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::no_crate_with_triple, code = "E0461")]
#[note(metadata::found_crate_versions)]
pub struct NoCrateWithTriple {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub locator_triple: String,
pub add_info: String,
pub found_crates: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::found_staticlib, code = "E0462")]
#[note(metadata::found_crate_versions)]
#[help]
pub struct FoundStaticlib {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub add_info: String,
pub found_crates: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::incompatible_rustc, code = "E0514")]
#[note(metadata::found_crate_versions)]
#[help]
pub struct IncompatibleRustc {
#[primary_span]
pub span: Span,
pub crate_name: String,
pub add_info: String,
pub found_crates: String,
pub rustc_version: String,
}

pub struct InvalidMetadataFiles {
pub span: Span,
pub crate_name: String,
pub add_info: String,
pub crate_rejections: Vec<String>,
}

impl SessionDiagnostic<'_> for InvalidMetadataFiles {
fn into_diagnostic(
self,
sess: &'_ rustc_session::parse::ParseSess,
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(rustc_errors::fluent::metadata::invalid_meta_files);
diag.set_arg("crate_name", self.crate_name);
diag.set_arg("add_info", self.add_info);
diag.code(DiagnosticId::Error("E0786".into()));
diag.set_span(self.span);
for crate_rejection in self.crate_rejections {
diag.note(crate_rejection);
}
diag
}
}

pub struct CannotFindCrate {
pub span: Span,
pub crate_name: String,
pub crate_name_symbol: Symbol,
pub add_info: String,
pub missing_core: bool,
pub current_crate: String,
pub is_nightly_build: bool,
pub profiler_runtime: Symbol,
pub locator_triple: TargetTriple,
}

impl SessionDiagnostic<'_> for CannotFindCrate {
fn into_diagnostic(
self,
sess: &'_ rustc_session::parse::ParseSess,
) -> rustc_errors::DiagnosticBuilder<'_, ErrorGuaranteed> {
let mut diag = sess.struct_err(rustc_errors::fluent::metadata::cannot_find_crate);
diag.set_arg("crate_name", self.crate_name.clone());
diag.set_arg("add_info", self.add_info);
diag.code(DiagnosticId::Error("E0463".into()));
diag.set_span(self.span);
// FIXME: Find a way to distill this logic down into the derived SessionDiagnostic form
if (self.crate_name_symbol == sym::std || self.crate_name_symbol == sym::core)
&& self.locator_triple != TargetTriple::from_triple(config::host_triple())
{
if self.missing_core {
diag.note(&format!("the `{}` target may not be installed", self.locator_triple));
} else {
diag.note(&format!(
"the `{}` target may not support the standard library",
self.locator_triple
));
}
// NOTE: this suggests using rustup, even though the user may not have it installed.
// That's because they could choose to install it; or this may give them a hint which
// target they need to install from their distro.
if self.missing_core {
diag.help(&format!(
"consider downloading the target with `rustup target add {}`",
self.locator_triple
));
}
// Suggest using #![no_std]. #[no_core] is unstable and not really supported anyway.
// NOTE: this is a dummy span if `extern crate std` was injected by the compiler.
// If it's not a dummy, that means someone added `extern crate std` explicitly and
// `#![no_std]` won't help.
if !self.missing_core && self.span.is_dummy() {
diag.note(&format!(
"`std` is required by `{}` because it does not declare `#![no_std]`",
self.current_crate
));
}
if self.is_nightly_build {
diag.help("consider building the standard library from source with `cargo build -Zbuild-std`");
}
} else if self.crate_name_symbol == self.profiler_runtime {
diag.note("the compiler may have been built without the profiler runtime");
} else if self.crate_name.starts_with("rustc_") {
diag.help(
"maybe you need to install the missing components with: \
`rustup component add rust-src rustc-dev llvm-tools-preview`",
);
}
diag.span_label(self.span, "can't find crate");
diag
}
}

#[derive(SessionDiagnostic)]
#[diag(metadata::no_dylib_plugin, code = "E0457")]
pub struct NoDylibPlugin {
#[primary_span]
pub span: Span,
pub crate_name: String,
}
Loading