Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #101317

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6b68921
Change implementation of `-Z gcc-ld` and `lld-wrapper` again
petrochenkov Aug 6, 2022
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
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
1171697
Generate error index with mdbook instead of raw HTML pages
GuillaumeGomez Aug 29, 2022
630f831
Use `FILE_ATTRIBUTE_TAG_INFO` to get reparse tag
ChrisDenton Sep 1, 2022
f5857d5
Move error code book into a sub folder
GuillaumeGomez Aug 31, 2022
096efc2
rustdoc: remove unused CSS `#main-content > .since`
notriddle Sep 1, 2022
e5d60af
Simplify MIR opt tests
JakobDegen Aug 21, 2022
4038521
Rollup merge of #99583 - shepmaster:provider-plus-plus, r=yaahc
Dylan-DPC Sep 2, 2022
34a430c
Rollup merge of #100121 - Nilstrieb:mir-validator-param-env, r=oli-obk
Dylan-DPC Sep 2, 2022
d9f11d2
Rollup merge of #100200 - petrochenkov:zgccld2, r=lqd,Mark-Simulacrum
Dylan-DPC Sep 2, 2022
85d68d6
Rollup merge of #100827 - JakobDegen:better-tests, r=wesleywiser
Dylan-DPC Sep 2, 2022
4c05e77
Rollup merge of #100928 - CleanCut:rustc_metadata_diagnostics, r=davi…
Dylan-DPC Sep 2, 2022
f865d5a
Rollup merge of #101166 - GuillaumeGomez:error-index-mdbook, r=notriddle
Dylan-DPC Sep 2, 2022
4fe796a
Rollup merge of #101260 - ChrisDenton:attribute-tag, r=thomcc
Dylan-DPC Sep 2, 2022
27b8d0c
Rollup merge of #101298 - notriddle:notriddle/rustdoc-main-since, r=G…
Dylan-DPC Sep 2, 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 creader.rs to SessionDiagnostics
  • Loading branch information
CleanCut committed Aug 31, 2022
commit 32e1823b2275cf55a598e65c5093a28122b4039f
28 changes: 28 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/metadata.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,31 @@ metadata_fail_seek_file =

metadata_fail_write_file =
failed to write to the file: {$err}

metadata_crate_not_panic_runtime =
the crate `{$crate_name}` is not a panic runtime

metadata_no_panic_strategy =
the crate `{$crate_name}` does not have the panic strategy `{$strategy}`

metadata_profiler_builtins_needs_core =
`profiler_builtins` crate (required by compiler options) is not compatible with crate attribute `#![no_core]`

metadata_not_profiler_runtime =
the crate `{$crate_name}` is not a profiler runtime

metadata_no_multiple_global_alloc =
cannot define multiple global allocators
.label = cannot define a new global allocator

metadata_prev_global_alloc =
previous global allocator defined here

metadata_conflicting_global_alloc =
the `#[global_allocator]` in {$other_crate_name} conflicts with global allocator in: {$crate_name}

metadata_global_alloc_required =
no global memory allocator found but one is required; link to std or add `#[global_allocator]` to a static item that implements the GlobalAlloc trait

metadata_no_transitive_needs_dep =
the crate `{$crate_name}` cannot depend on a crate that needs {$needs_crate_name}, but it depends on `{$deps_crate_name}`
56 changes: 22 additions & 34 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//! Validates all used crates and extern libraries and loads their metadata

use crate::errors::{
ConflictingGlobalAlloc, CrateNotPanicRuntime, GlobalAllocRequired, NoMultipleGlobalAlloc,
NoPanicStrategy, NoTransitiveNeedsDep, NotProfilerRuntime, ProfilerBuiltinsNeedsCore,
};
use crate::locator::{CrateError, CrateLocator, CratePaths};
use crate::rmeta::{CrateDep, CrateMetadata, CrateNumMap, CrateRoot, MetadataBlob};

Expand Down Expand Up @@ -746,15 +750,13 @@ impl<'a> CrateLoader<'a> {
// Sanity check the loaded crate to ensure it is indeed a panic runtime
// and the panic strategy is indeed what we thought it was.
if !data.is_panic_runtime() {
self.sess.err(&format!("the crate `{}` is not a panic runtime", name));
self.sess.emit_err(CrateNotPanicRuntime { crate_name: name.to_string() });
}
if data.required_panic_strategy() != Some(desired_strategy) {
self.sess.err(&format!(
"the crate `{}` does not have the panic \
strategy `{}`",
name,
desired_strategy.desc()
));
self.sess.emit_err(NoPanicStrategy {
crate_name: name.to_string(),
strategy: desired_strategy.desc().to_string(),
});
}

self.cstore.injected_panic_runtime = Some(cnum);
Expand All @@ -774,29 +776,22 @@ impl<'a> CrateLoader<'a> {

let name = Symbol::intern(&self.sess.opts.unstable_opts.profiler_runtime);
if name == sym::profiler_builtins && self.sess.contains_name(&krate.attrs, sym::no_core) {
self.sess.err(
"`profiler_builtins` crate (required by compiler options) \
is not compatible with crate attribute `#![no_core]`",
);
self.sess.emit_err(ProfilerBuiltinsNeedsCore);
}

let Some(cnum) = self.resolve_crate(name, DUMMY_SP, CrateDepKind::Implicit) else { return; };
let data = self.cstore.get_crate_data(cnum);

// Sanity check the loaded crate to ensure it is indeed a profiler runtime
if !data.is_profiler_runtime() {
self.sess.err(&format!("the crate `{}` is not a profiler runtime", name));
self.sess.emit_err(NotProfilerRuntime { crate_name: name.to_string() });
}
}

fn inject_allocator_crate(&mut self, krate: &ast::Crate) {
self.cstore.has_global_allocator = match &*global_allocator_spans(&self.sess, krate) {
[span1, span2, ..] => {
self.sess
.struct_span_err(*span2, "cannot define multiple global allocators")
.span_label(*span2, "cannot define a new global allocator")
.span_label(*span1, "previous global allocator defined here")
.emit();
self.sess.emit_err(NoMultipleGlobalAlloc { span2: *span2, span1: *span1 });
true
}
spans => !spans.is_empty(),
Expand Down Expand Up @@ -832,11 +827,10 @@ impl<'a> CrateLoader<'a> {
if data.has_global_allocator() {
match global_allocator {
Some(other_crate) => {
self.sess.err(&format!(
"the `#[global_allocator]` in {} conflicts with global allocator in: {}",
other_crate,
data.name()
));
self.sess.emit_err(ConflictingGlobalAlloc {
crate_name: data.name().to_string(),
other_crate_name: other_crate.to_string(),
});
}
None => global_allocator = Some(data.name()),
}
Expand All @@ -855,10 +849,7 @@ impl<'a> CrateLoader<'a> {
if !self.sess.contains_name(&krate.attrs, sym::default_lib_allocator)
&& !self.cstore.iter_crate_data().any(|(_, data)| data.has_default_lib_allocator())
{
self.sess.err(
"no global memory allocator found but one is required; link to std or add \
`#[global_allocator]` to a static item that implements the GlobalAlloc trait",
);
self.sess.emit_err(GlobalAllocRequired);
}
self.cstore.allocator_kind = Some(AllocatorKind::Default);
}
Expand All @@ -882,14 +873,11 @@ impl<'a> CrateLoader<'a> {
for dep in self.cstore.crate_dependencies_in_reverse_postorder(krate) {
let data = self.cstore.get_crate_data(dep);
if needs_dep(&data) {
self.sess.err(&format!(
"the crate `{}` cannot depend \
on a crate that needs {}, but \
it depends on `{}`",
self.cstore.get_crate_data(krate).name(),
what,
data.name()
));
self.sess.emit_err(NoTransitiveNeedsDep {
crate_name: self.cstore.get_crate_data(krate).name().to_string(),
needs_crate_name: what.to_string(),
deps_crate_name: data.name().to_string(),
});
}
}

Expand Down
52 changes: 52 additions & 0 deletions compiler/rustc_metadata/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,55 @@ pub struct FailSeekFile {
pub struct FailWriteFile {
pub err: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::crate_not_panic_runtime)]
pub struct CrateNotPanicRuntime {
pub crate_name: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::no_panic_strategy)]
pub struct NoPanicStrategy {
pub crate_name: String,
pub strategy: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::profiler_builtins_needs_core)]
pub struct ProfilerBuiltinsNeedsCore;

#[derive(SessionDiagnostic)]
#[diag(metadata::not_profiler_runtime)]
pub struct NotProfilerRuntime {
pub crate_name: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::no_multiple_global_alloc)]
pub struct NoMultipleGlobalAlloc {
#[primary_span]
#[label]
pub span2: Span,
#[label(metadata::prev_global_alloc)]
pub span1: Span,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::conflicting_global_alloc)]
pub struct ConflictingGlobalAlloc {
pub crate_name: String,
pub other_crate_name: String,
}

#[derive(SessionDiagnostic)]
#[diag(metadata::global_alloc_required)]
pub struct GlobalAllocRequired;

#[derive(SessionDiagnostic)]
#[diag(metadata::no_transitive_needs_dep)]
pub struct NoTransitiveNeedsDep {
pub crate_name: String,
pub needs_crate_name: String,
pub deps_crate_name: String,
}