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 #121804

Merged
merged 43 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
d51e703
As Windows 10 requires certain features like CMPXCHG16B and a few oth…
CKingX Feb 9, 2024
d6766e2
Update x86_64_pc_windows_msvc.rs
CKingX Feb 9, 2024
fcb06f7
Update x86_64_pc_windows_msvc.rs
CKingX Feb 9, 2024
abeac8f
Update x86_64_uwp_windows_gnu.rs
CKingX Feb 9, 2024
1c6dda7
Possibly removed merge policy
CKingX Feb 9, 2024
376c7b9
Added sahf feature to windows targets
CKingX Feb 13, 2024
2d25c3b
Updated test to account for added previous features (thanks erikdesja…
CKingX Feb 20, 2024
2fc091f
Use volatile to make `p_thread_callback` used
ChrisDenton Feb 24, 2024
ad4c4f4
Remove _tls_used trickery unless needed
ChrisDenton Feb 24, 2024
205319d
Skip unnecessary comparison with half-open ranges
Nadrieril Feb 20, 2024
7c6960e
Document invariant in `thir::PatRange`
Nadrieril Feb 27, 2024
be01e28
Push down the decision to skip fields
Nadrieril Feb 6, 2024
ab06037
Push the decision to skip fields further down
Nadrieril Feb 6, 2024
4f7f067
Add special `Skip` constructor
Nadrieril Feb 6, 2024
ea38166
Don't filter out skipped fields
Nadrieril Feb 6, 2024
39441e4
Simplify
Nadrieril Feb 6, 2024
c918893
Rename `Skip` to `PrivateUninhabited`
Nadrieril Feb 28, 2024
c4ec196
Don't cancel stashed `OpaqueHiddenTypeMismatch` errors.
nnethercote Feb 26, 2024
ec25d6d
Don't cancel stashed `TraitMissingMethod` errors.
nnethercote Feb 26, 2024
260ae70
Overhaul how stashed diagnostics work, again.
nnethercote Feb 26, 2024
b4e9f93
Mark some once-again-unreachable paths as unreachable.
nnethercote Feb 27, 2024
9aff357
Stop miri if delayed bugs are present.
nnethercote Feb 27, 2024
82961c0
Reinstate `emit_stashed_diagnostics` in `DiagCtxtInner::drop`.
nnethercote Feb 28, 2024
c1f0163
Minor visibility and formatting improvements.
nnethercote Feb 28, 2024
869bd03
Simplify `UnusedExterns` lifetimes.
nnethercote Feb 28, 2024
3c3f15c
Use `Destination` more.
nnethercote Feb 28, 2024
805e50e
Remove unnecessary `diagnostic_width` call.
nnethercote Feb 29, 2024
ca5b79d
Remove unnecessary `output` local variable.
nnethercote Feb 29, 2024
f9eef38
Inline and remove `DiagCtxt::with_tty_emitter`
nnethercote Feb 29, 2024
880c1c5
Rename `DiagCtxt::with_emitter` as `DiagCtxt::new`.
nnethercote Feb 29, 2024
d372741
Merge HumanEmitter::{new,create}.
nnethercote Feb 28, 2024
437325b
Inline and remove `HumanReadableErrorType::new_emitter`.
nnethercote Feb 29, 2024
067d7c3
Inline and remove `HumanEmitter::stderr`.
nnethercote Feb 29, 2024
2999d8d
Inline and remove `JsonEmitter::{basic,stderr}`.
nnethercote Feb 28, 2024
9ff4487
Make `JsonEmitter` more like `HumanEmitter`.
nnethercote Feb 29, 2024
58f4505
Add a useful comment.
nnethercote Feb 29, 2024
607bf65
Avoid unnecessary `color` local variable.
nnethercote Feb 29, 2024
36bd9ef
Rollup merge of #120820 - CKingX:cpu-base-minimum, r=petrochenkov,Chr…
GuillaumeGomez Feb 29, 2024
9df7f26
Rollup merge of #121000 - Nadrieril:keep_all_fields, r=compiler-errors
GuillaumeGomez Feb 29, 2024
2e0a26a
Rollup merge of #121376 - Nadrieril:mir-half-ranges, r=pnkfelix
GuillaumeGomez Feb 29, 2024
eea8cee
Rollup merge of #121596 - ChrisDenton:tls, r=joboet
GuillaumeGomez Feb 29, 2024
a5945b5
Rollup merge of #121669 - nnethercote:count-stashed-errs-again, r=est…
GuillaumeGomez Feb 29, 2024
0e9f02d
Rollup merge of #121783 - nnethercote:emitter-cleanups, r=oli-obk
GuillaumeGomez Feb 29, 2024
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 compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ pub struct CodegenContext<B: WriteBackendMethods> {

impl<B: WriteBackendMethods> CodegenContext<B> {
pub fn create_dcx(&self) -> DiagCtxt {
DiagCtxt::with_emitter(Box::new(self.diag_emitter.clone()))
DiagCtxt::new(Box::new(self.diag_emitter.clone()))
}

pub fn config(&self, kind: ModuleKind) -> &ModuleConfig {
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
use rustc_data_structures::profiling::{
get_resident_set_size, print_time_passes_entry, TimePassesFormat,
};
use rustc_errors::emitter::stderr_destination;
use rustc_errors::registry::Registry;
use rustc_errors::{
markdown, ColorConfig, DiagCtxt, ErrCode, ErrorGuaranteed, FatalError, PResult,
Expand Down Expand Up @@ -1384,11 +1385,11 @@ fn report_ice(
) {
let fallback_bundle =
rustc_errors::fallback_fluent_bundle(crate::DEFAULT_LOCALE_RESOURCES.to_vec(), false);
let emitter = Box::new(rustc_errors::emitter::HumanEmitter::stderr(
rustc_errors::ColorConfig::Auto,
let emitter = Box::new(rustc_errors::emitter::HumanEmitter::new(
stderr_destination(rustc_errors::ColorConfig::Auto),
fallback_bundle,
));
let dcx = rustc_errors::DiagCtxt::with_emitter(emitter);
let dcx = rustc_errors::DiagCtxt::new(emitter);

// a .span_bug or .bug call has already printed what
// it wants to print.
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,11 +1308,9 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
drop(self);
}

/// Stashes diagnostic for possible later improvement in a different,
/// later stage of the compiler. The diagnostic can be accessed with
/// the provided `span` and `key` through [`DiagCtxt::steal_diagnostic()`].
pub fn stash(mut self, span: Span, key: StashKey) {
self.dcx.stash_diagnostic(span, key, self.take_diag());
/// See `DiagCtxt::stash_diagnostic` for details.
pub fn stash(mut self, span: Span, key: StashKey) -> Option<ErrorGuaranteed> {
self.dcx.stash_diagnostic(span, key, self.take_diag())
}

/// Delay emission of this diagnostic as a bug.
Expand Down
61 changes: 16 additions & 45 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ use crate::{
FluentBundle, LazyFallbackBundle, Level, MultiSpan, Subdiag, SubstitutionHighlight,
SuggestionStyle, TerminalUrl,
};
use rustc_lint_defs::pluralize;

use derive_setters::Setters;
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
use rustc_data_structures::sync::{DynSend, IntoDynSyncSend, Lrc};
use rustc_error_messages::{FluentArgs, SpanLabel};
use rustc_lint_defs::pluralize;
use rustc_span::hygiene::{ExpnKind, MacroKind};
use std::borrow::Cow;
use std::cmp::{max, min, Reverse};
Expand All @@ -35,7 +34,7 @@ use std::io::prelude::*;
use std::io::{self, IsTerminal};
use std::iter;
use std::path::Path;
use termcolor::{Ansi, Buffer, BufferWriter, ColorChoice, ColorSpec, StandardStream};
use termcolor::{Buffer, BufferWriter, ColorChoice, ColorSpec, StandardStream};
use termcolor::{Color, WriteColor};

/// Default column width, used in tests and when terminal dimensions cannot be determined.
Expand All @@ -58,18 +57,6 @@ impl HumanReadableErrorType {
HumanReadableErrorType::AnnotateSnippet(cc) => (false, cc),
}
}
pub fn new_emitter(
self,
mut dst: Box<dyn WriteColor + Send>,
fallback_bundle: LazyFallbackBundle,
) -> HumanEmitter {
let (short, color_config) = self.unzip();
let color = color_config.suggests_using_colors();
if !dst.supports_color() && color {
dst = Box::new(Ansi::new(dst));
}
HumanEmitter::new(dst, fallback_bundle).short_message(short)
}
}

#[derive(Clone, Copy, Debug)]
Expand Down Expand Up @@ -130,8 +117,8 @@ impl Margin {
fn was_cut_right(&self, line_len: usize) -> bool {
let right =
if self.computed_right == self.span_right || self.computed_right == self.label_right {
// Account for the "..." padding given above. Otherwise we end up with code lines that
// do fit but end in "..." as if they were trimmed.
// Account for the "..." padding given above. Otherwise we end up with code lines
// that do fit but end in "..." as if they were trimmed.
self.computed_right - 6
} else {
self.computed_right
Expand Down Expand Up @@ -628,12 +615,6 @@ impl ColorConfig {
ColorConfig::Auto => ColorChoice::Never,
}
}
fn suggests_using_colors(self) -> bool {
match self {
ColorConfig::Always | ColorConfig::Auto => true,
ColorConfig::Never => false,
}
}
}

/// Handles the writing of `HumanReadableErrorType::Default` and `HumanReadableErrorType::Short`
Expand All @@ -657,19 +638,14 @@ pub struct HumanEmitter {
}

#[derive(Debug)]
pub struct FileWithAnnotatedLines {
pub file: Lrc<SourceFile>,
pub lines: Vec<Line>,
pub(crate) struct FileWithAnnotatedLines {
pub(crate) file: Lrc<SourceFile>,
pub(crate) lines: Vec<Line>,
multiline_depth: usize,
}

impl HumanEmitter {
pub fn stderr(color_config: ColorConfig, fallback_bundle: LazyFallbackBundle) -> HumanEmitter {
let dst = from_stderr(color_config);
Self::create(dst, fallback_bundle)
}

fn create(dst: Destination, fallback_bundle: LazyFallbackBundle) -> HumanEmitter {
pub fn new(dst: Destination, fallback_bundle: LazyFallbackBundle) -> HumanEmitter {
HumanEmitter {
dst: IntoDynSyncSend(dst),
sm: None,
Expand All @@ -686,13 +662,6 @@ impl HumanEmitter {
}
}

pub fn new(
dst: Box<dyn WriteColor + Send>,
fallback_bundle: LazyFallbackBundle,
) -> HumanEmitter {
Self::create(dst, fallback_bundle)
}

fn maybe_anonymized(&self, line_num: usize) -> Cow<'static, str> {
if self.ui_testing {
Cow::Borrowed(ANONYMIZED_LINE_NUM)
Expand Down Expand Up @@ -724,8 +693,9 @@ impl HumanEmitter {
.skip(left)
.take_while(|ch| {
// Make sure that the trimming on the right will fall within the terminal width.
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char` is.
// For now, just accept that sometimes the code line will be longer than desired.
// FIXME: `unicode_width` sometimes disagrees with terminals on how wide a `char`
// is. For now, just accept that sometimes the code line will be longer than
// desired.
let next = unicode_width::UnicodeWidthChar::width(*ch).unwrap_or(1);
if taken + next > right - left {
return false;
Expand Down Expand Up @@ -2228,8 +2198,8 @@ impl HumanEmitter {
buffer.puts(*row_num - 1, max_line_num_len + 3, &line, Style::NoStyle);
*row_num += 1;
}
// If the last line is exactly equal to the line we need to add, we can skip both of them.
// This allows us to avoid output like the following:
// If the last line is exactly equal to the line we need to add, we can skip both of
// them. This allows us to avoid output like the following:
// 2 - &
// 2 + if true { true } else { false }
// 3 - if true { true } else { false }
Expand Down Expand Up @@ -2586,6 +2556,7 @@ fn num_overlap(
let extra = if inclusive { 1 } else { 0 };
(b_start..b_end + extra).contains(&a_start) || (a_start..a_end + extra).contains(&b_start)
}

fn overlaps(a1: &Annotation, a2: &Annotation, padding: usize) -> bool {
num_overlap(
a1.start_col.display,
Expand Down Expand Up @@ -2632,7 +2603,7 @@ fn emit_to_destination(
Ok(())
}

pub type Destination = Box<(dyn WriteColor + Send)>;
pub type Destination = Box<dyn WriteColor + Send>;

struct Buffy {
buffer_writer: BufferWriter,
Expand Down Expand Up @@ -2674,7 +2645,7 @@ impl WriteColor for Buffy {
}
}

fn from_stderr(color: ColorConfig) -> Destination {
pub fn stderr_destination(color: ColorConfig) -> Destination {
let choice = color.to_color_choice();
// On Windows we'll be performing global synchronization on the entire
// system for emitting rustc errors, so there's no need to buffer
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_errors/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ impl<'args> TranslateError<'args> {
pub fn message(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
Self::One { id, args, kind: TranslateErrorKind::MessageMissing }
}

pub fn primary(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
Self::One { id, args, kind: TranslateErrorKind::PrimaryBundleMissing }
}

pub fn attribute(
id: &'args Cow<'args, str>,
args: &'args FluentArgs<'args>,
attr: &'args str,
) -> Self {
Self::One { id, args, kind: TranslateErrorKind::AttributeMissing { attr } }
}

pub fn value(id: &'args Cow<'args, str>, args: &'args FluentArgs<'args>) -> Self {
Self::One { id, args, kind: TranslateErrorKind::ValueMissing }
}
Expand Down
Loading
Loading