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 7 pull requests #102916

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b0b9f5b
std: never panic in `thread::park` and `thread::park_timeout`
joboet Sep 28, 2022
99182dd
std: use semaphore for thread parking on Apple platforms
joboet Oct 6, 2022
0ad4dd4
std: add thread parking tests
joboet Oct 6, 2022
bde80f7
Add lint for diagnostic migration
rdvdev2 Aug 22, 2022
2f74d1d
Migrate weak_lang_items.rs
rdvdev2 Aug 22, 2022
17a4a68
Migrate derivable diagnostics in lang_items.rs
rdvdev2 Sep 1, 2022
0315d7c
Migrate derivable diagnostics in check_attr.rs
rdvdev2 Sep 2, 2022
2c3351c
Migrate InvalidAttrAtCrateLevel
rdvdev2 Sep 2, 2022
c24a873
always put ftl message on next line, resolve all but 1 output compari…
CleanCut Sep 21, 2022
b8e03cf
use consistent names
CleanCut Sep 22, 2022
1222541
resolve merge conflict from cherry-picking 6a47326a0452cc8d5cb5767650…
diegooliveira Sep 14, 2022
c103c30
migrate the rest of weak_lang_items.rs to translateable diagnostics
CleanCut Sep 22, 2022
1e86226
migrate debugger_visualizer.rs to translateable diagnostics
CleanCut Sep 22, 2022
f8ebc72
errors: add `emit_note`/`create_note`
davidtwco Sep 1, 2022
3a74833
use cherry-picked commit from #100754 to emit note without error
CleanCut Sep 22, 2022
0609c0f
migrate diagnostic_items.rs to translateable diagnostics
CleanCut Sep 23, 2022
40d5f00
migrate layout_test.rs to translateable diagnostics
CleanCut Sep 23, 2022
c457abe
migrate lib_features.rs to translateable diagnostics
CleanCut Sep 24, 2022
572f341
migrate check_const.rs to translateable diagnostics
CleanCut Sep 24, 2022
69766e4
migrate loops.rs to translateable diagnostics
CleanCut Sep 26, 2022
96f92ea
migrate naked_functions.rs to translateable diagnostics
CleanCut Sep 27, 2022
b17ec43
migrate entry.rs to translateable diagnostics
CleanCut Sep 28, 2022
f0afb88
migrate lang_items.rs to translateable diagnostics
CleanCut Oct 1, 2022
a7aa185
migrate dead.rs to translateable diagnostics
CleanCut Oct 2, 2022
3fe8e00
migrate the rest of check_attr.rs to translateable diagnostics
CleanCut Oct 2, 2022
be4059d
migrate stability.rs to translateable diagnostics
CleanCut Oct 3, 2022
965dbf6
First batch of review feedback changes from #102110
CleanCut Oct 3, 2022
8e07a85
Remove code that was removed in master, and the corresponding diagnostic
CleanCut Oct 5, 2022
57eba4f
avoid string dispatch in fluent
CleanCut Oct 5, 2022
31c269a
avoid string dispatch in fluent
CleanCut Oct 7, 2022
b4c8a7b
std: remove unused linker attribute
joboet Oct 8, 2022
c320ab9
std: do not use dispatch semaphore under miri (yet)
joboet Oct 8, 2022
88bb4e4
impl AsFd for io::{Stdin, Stdout, Stderr}, not the sys versions
joshtriplett Oct 9, 2022
ef68327
Consolidate AsFd instances for stdio types into `library/std/src/os/f…
joshtriplett Oct 10, 2022
50e2795
remove out-of-date fixme
CleanCut Oct 10, 2022
5ef1c03
make up your mind, rustfmt
CleanCut Oct 10, 2022
a474ec5
Move lifetime resolution module to rustc_hir_analysis.
cjgillot Oct 9, 2022
6826028
fix #102878
TaKO8Ki Oct 10, 2022
b63b02f
rustdoc: remove unneeded `<div>` wrapper from sidebar DOM
notriddle Oct 10, 2022
44f466c
Remove outdated comment
notriddle Oct 11, 2022
91509c9
Rollup merge of #102110 - CleanCut:migrate_rustc_passes_diagnostics, …
Dylan-DPC Oct 11, 2022
652e46b
Rollup merge of #102412 - joboet:dont_panic, r=m-ou-se
Dylan-DPC Oct 11, 2022
8cb570d
Rollup merge of #102773 - joboet:apple_parker, r=thomcc
Dylan-DPC Oct 11, 2022
6e3f2e6
Rollup merge of #102847 - joshtriplett:bugfix-impl-fd-traits-for-io-t…
Dylan-DPC Oct 11, 2022
868d35f
Rollup merge of #102859 - cjgillot:collect-lifetimes, r=oli-obk
Dylan-DPC Oct 11, 2022
7f08482
Rollup merge of #102893 - TaKO8Ki:fix-102878, r=davidtwco
Dylan-DPC Oct 11, 2022
f09bc51
Rollup merge of #102898 - notriddle:notriddle/sidebar-block, r=Guilla…
Dylan-DPC Oct 11, 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
9 changes: 9 additions & 0 deletions compiler/rustc_error_messages/locales/en-US/middle.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ middle_limit_invalid =

middle_const_eval_non_int =
constant evaluation of enum discriminant resulted in non-integer

middle_unknown_layout =
the type `{$ty}` has an unknown layout

middle_values_too_big =
values of the type `{$ty}` are too big for the current architecture

middle_cannot_be_normalized =
unable to determine layout for `{$ty}` because `{$failure_ty}` cannot be normalized
559 changes: 478 additions & 81 deletions compiler/rustc_error_messages/locales/en-US/passes.ftl

Large diffs are not rendered by default.

13 changes: 0 additions & 13 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,19 +336,6 @@ impl DiagnosticMessage {
}
}
}

/// Returns the `String` contained within the `DiagnosticMessage::Str` variant, assuming that
/// this diagnostic message is of the legacy, non-translatable variety. Panics if this
/// assumption does not hold.
///
/// Don't use this - it exists to support some places that do comparison with diagnostic
/// strings.
pub fn expect_str(&self) -> &str {
match self {
DiagnosticMessage::Str(s) => s,
_ => panic!("expected non-translatable diagnostic message"),
}
}
}

/// `From` impl that enables existing diagnostic calls to functions which now take
Expand Down
50 changes: 50 additions & 0 deletions compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,56 @@ impl EmissionGuarantee for () {
}
}

/// Marker type which enables implementation of `create_note` and `emit_note` functions for
/// note-without-error struct diagnostics.
#[derive(Copy, Clone)]
pub struct Noted;

impl<'a> DiagnosticBuilder<'a, Noted> {
/// Convenience function for internal use, clients should use one of the
/// `struct_*` methods on [`Handler`].
pub(crate) fn new_note(handler: &'a Handler, message: impl Into<DiagnosticMessage>) -> Self {
let diagnostic = Diagnostic::new_with_code(Level::Note, None, message);
Self::new_diagnostic_note(handler, diagnostic)
}

/// Creates a new `DiagnosticBuilder` with an already constructed
/// diagnostic.
pub(crate) fn new_diagnostic_note(handler: &'a Handler, diagnostic: Diagnostic) -> Self {
debug!("Created new diagnostic");
Self {
inner: DiagnosticBuilderInner {
state: DiagnosticBuilderState::Emittable(handler),
diagnostic: Box::new(diagnostic),
},
_marker: PhantomData,
}
}
}

impl EmissionGuarantee for Noted {
fn diagnostic_builder_emit_producing_guarantee(db: &mut DiagnosticBuilder<'_, Self>) -> Self {
match db.inner.state {
// First `.emit()` call, the `&Handler` is still available.
DiagnosticBuilderState::Emittable(handler) => {
db.inner.state = DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation;
handler.emit_diagnostic(&mut db.inner.diagnostic);
}
// `.emit()` was previously called, disallowed from repeating it.
DiagnosticBuilderState::AlreadyEmittedOrDuringCancellation => {}
}

Noted
}

fn make_diagnostic_builder(
handler: &Handler,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, Self> {
DiagnosticBuilder::new_note(handler, msg)
}
}

impl<'a> DiagnosticBuilder<'a, !> {
/// Convenience function for internal use, clients should use one of the
/// `struct_*` methods on [`Handler`].
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ pub use diagnostic::{
AddToDiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgFromDisplay,
DiagnosticArgValue, DiagnosticId, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
};
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee};
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, Noted};
use std::backtrace::Backtrace;

/// A handler deals with errors and other compiler output.
Expand Down
19 changes: 11 additions & 8 deletions compiler/rustc_expand/src/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rustc_ast::{NodeId, DUMMY_NODE_ID};
use rustc_ast_pretty::pprust;
use rustc_attr::{self as attr, TransparencyError};
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder};
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, DiagnosticMessage};
use rustc_feature::Features;
use rustc_lint_defs::builtin::{
RUST_2021_INCOMPATIBLE_OR_PATTERNS, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
Expand Down Expand Up @@ -68,19 +68,22 @@ fn emit_frag_parse_err(
kind: AstFragmentKind,
) {
// FIXME(davidtwco): avoid depending on the error message text
if parser.token == token::Eof && e.message[0].0.expect_str().ends_with(", found `<eof>`") {
if !e.span.is_dummy() {
// early end of macro arm (#52866)
e.replace_span_with(parser.sess.source_map().next_point(parser.token.span));
}
if parser.token == token::Eof
&& let DiagnosticMessage::Str(message) = &e.message[0].0
&& message.ends_with(", found `<eof>`")
{
let msg = &e.message[0];
e.message[0] = (
rustc_errors::DiagnosticMessage::Str(format!(
DiagnosticMessage::Str(format!(
"macro expansion ends with an incomplete expression: {}",
msg.0.expect_str().replace(", found `<eof>`", ""),
message.replace(", found `<eof>`", ""),
)),
msg.1,
);
if !e.span.is_dummy() {
// early end of macro arm (#52866)
e.replace_span_with(parser.sess.source_map().next_point(parser.token.span));
}
}
if e.span.is_dummy() {
// Get around lack of span in error (#30128)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_hir_analysis/src/collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use std::iter;

mod generics_of;
mod item_bounds;
mod lifetimes;
mod predicates_of;
mod type_of;

Expand All @@ -57,6 +58,7 @@ fn collect_mod_item_types(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
}

pub fn provide(providers: &mut Providers) {
lifetimes::provide(providers);
*providers = Providers {
opt_const_param_of: type_of::opt_const_param_of,
type_of: type_of::type_of,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ trait RegionExt {
fn id(&self) -> Option<DefId>;

fn shifted(self, amount: u32) -> Region;

fn shifted_out_to_binder(self, binder: ty::DebruijnIndex) -> Region;
}

impl RegionExt for Region {
Expand Down Expand Up @@ -69,15 +67,6 @@ impl RegionExt for Region {
_ => self,
}
}

fn shifted_out_to_binder(self, binder: ty::DebruijnIndex) -> Region {
match self {
Region::LateBound(debruijn, index, id) => {
Region::LateBound(debruijn.shifted_out_to_binder(binder), index, id)
}
_ => self,
}
}
}

/// Maps the id of each lifetime reference to the lifetime decl
Expand All @@ -101,8 +90,8 @@ struct NamedRegionMap {
late_bound_vars: HirIdMap<Vec<ty::BoundVariableKind>>,
}

pub(crate) struct LifetimeContext<'a, 'tcx> {
pub(crate) tcx: TyCtxt<'tcx>,
struct LifetimeContext<'a, 'tcx> {
tcx: TyCtxt<'tcx>,
map: &'a mut NamedRegionMap,
scope: ScopeRef<'a>,

Expand Down Expand Up @@ -234,7 +223,7 @@ type ScopeRef<'a> = &'a Scope<'a>;

const ROOT_SCOPE: ScopeRef<'static> = &Scope::Root;

pub fn provide(providers: &mut ty::query::Providers) {
pub(crate) fn provide(providers: &mut ty::query::Providers) {
*providers = ty::query::Providers {
resolve_lifetimes_trait_definition,
resolve_lifetimes,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_interface/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,6 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
ty::provide(providers);
traits::provide(providers);
rustc_passes::provide(providers);
rustc_resolve::provide(providers);
rustc_traits::provide(providers);
rustc_ty_utils::provide(providers);
rustc_metadata::provide(providers);
Expand Down
21 changes: 20 additions & 1 deletion compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,29 @@ pub enum LayoutError<'tcx> {

impl<'a> IntoDiagnostic<'a, !> for LayoutError<'a> {
fn into_diagnostic(self, handler: &'a Handler) -> DiagnosticBuilder<'a, !> {
handler.struct_fatal(self.to_string())
let mut diag = handler.struct_fatal("");

match self {
LayoutError::Unknown(ty) => {
diag.set_arg("ty", ty);
diag.set_primary_message(rustc_errors::fluent::middle::unknown_layout);
}
LayoutError::SizeOverflow(ty) => {
diag.set_arg("ty", ty);
diag.set_primary_message(rustc_errors::fluent::middle::values_too_big);
}
LayoutError::NormalizationFailure(ty, e) => {
diag.set_arg("ty", ty);
diag.set_arg("failure_ty", e.get_type_for_failure());
diag.set_primary_message(rustc_errors::fluent::middle::cannot_be_normalized);
}
}
diag
}
}

// FIXME: Once the other errors that embed this error have been converted to translateable
// diagnostics, this Display impl should be removed.
impl<'tcx> fmt::Display for LayoutError<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
Expand Down
Loading