Skip to content

Commit 1d8b6ce

Browse files
committed
Auto merge of #66453 - Centril:rollup-w1ohzxs, r=Centril
Rollup of 5 pull requests Successful merges: - #66350 (protect creation of destructors by a mutex) - #66407 (Add more tests for fixed ICEs) - #66415 (Add --force-run-in-process unstable option to libtest) - #66427 (Move the JSON error emitter to librustc_errors) - #66441 (libpanic_unwind for Miri: make sure we have the SEH lang items when needed) Failed merges: r? @ghost
2 parents 82161cd + ae9a626 commit 1d8b6ce

33 files changed

+193
-198
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -4439,6 +4439,7 @@ version = "0.0.0"
44394439
dependencies = [
44404440
"arena",
44414441
"cfg-if",
4442+
"log",
44424443
"rustc_data_structures",
44434444
"rustc_index",
44444445
"rustc_macros",

src/libpanic_unwind/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ cfg_if::cfg_if! {
3939
if #[cfg(miri)] {
4040
#[path = "miri.rs"]
4141
mod imp;
42+
// On MSVC we need the SEH lang items as well...
43+
// This should match the conditions of the `seh.rs` import below.
44+
#[cfg(all(target_env = "msvc", not(target_arch = "aarch64")))]
45+
#[allow(unused)]
46+
mod seh;
4247
} else if #[cfg(target_os = "emscripten")] {
4348
#[path = "emcc.rs"]
4449
mod imp;

src/librustc/session/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use errors::emitter::HumanReadableErrorType;
2222
use errors::annotate_snippet_emitter_writer::{AnnotateSnippetEmitterWriter};
2323
use syntax::edition::Edition;
2424
use syntax::feature_gate::{self, AttributeType};
25-
use syntax::json::JsonEmitter;
25+
use errors::json::JsonEmitter;
2626
use syntax::source_map;
2727
use syntax::sess::{ParseSess, ProcessCfgMod};
2828
use syntax::symbol::Symbol;

src/librustc_codegen_ssa/back/write.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ use rustc_data_structures::profiling::SelfProfilerRef;
2323
use rustc_fs_util::link_or_copy;
2424
use rustc_data_structures::svh::Svh;
2525
use rustc_data_structures::sync::Lrc;
26-
use rustc_errors::{Handler, Level, FatalError, DiagnosticId, SourceMapperDyn};
26+
use rustc_errors::{Handler, Level, FatalError, DiagnosticId};
27+
use syntax_pos::source_map::SourceMap;
2728
use rustc_errors::emitter::{Emitter};
2829
use rustc_target::spec::MergeFunctions;
2930
use syntax::attr;
@@ -1679,7 +1680,7 @@ impl Emitter for SharedEmitter {
16791680
}
16801681
drop(self.sender.send(SharedEmitterMessage::AbortIfErrors));
16811682
}
1682-
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> {
1683+
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
16831684
None
16841685
}
16851686
}

src/librustc_errors/annotate_snippet_emitter_writer.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
//! [annotate_snippets]: https://docs.rs/crate/annotate-snippets/
77
88
use syntax_pos::{SourceFile, MultiSpan, Loc};
9+
use syntax_pos::source_map::SourceMap;
910
use crate::{
1011
Level, CodeSuggestion, Diagnostic, Emitter,
11-
SourceMapperDyn, SubDiagnostic, DiagnosticId
12+
SubDiagnostic, DiagnosticId
1213
};
1314
use crate::emitter::FileWithAnnotatedLines;
1415
use rustc_data_structures::sync::Lrc;
@@ -20,7 +21,7 @@ use annotate_snippets::formatter::DisplayListFormatter;
2021

2122
/// Generates diagnostics using annotate-snippet
2223
pub struct AnnotateSnippetEmitterWriter {
23-
source_map: Option<Lrc<SourceMapperDyn>>,
24+
source_map: Option<Lrc<SourceMap>>,
2425
/// If true, hides the longer explanation text
2526
short_message: bool,
2627
/// If true, will normalize line numbers with `LL` to prevent noise in UI test diffs.
@@ -49,7 +50,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
4950
&suggestions);
5051
}
5152

52-
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> {
53+
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
5354
self.source_map.as_ref()
5455
}
5556

@@ -61,7 +62,7 @@ impl Emitter for AnnotateSnippetEmitterWriter {
6162
/// Collects all the data needed to generate the data structures needed for the
6263
/// `annotate-snippets` library.
6364
struct DiagnosticConverter<'a> {
64-
source_map: Option<Lrc<SourceMapperDyn>>,
65+
source_map: Option<Lrc<SourceMap>>,
6566
level: Level,
6667
message: String,
6768
code: Option<DiagnosticId>,
@@ -168,7 +169,7 @@ impl<'a> DiagnosticConverter<'a> {
168169

169170
impl AnnotateSnippetEmitterWriter {
170171
pub fn new(
171-
source_map: Option<Lrc<SourceMapperDyn>>,
172+
source_map: Option<Lrc<SourceMap>>,
172173
short_message: bool,
173174
external_macro_backtrace: bool,
174175
) -> Self {

src/librustc_errors/emitter.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
use Destination::*;
1111

1212
use syntax_pos::{SourceFile, Span, MultiSpan};
13+
use syntax_pos::source_map::SourceMap;
1314

1415
use crate::{
1516
Level, CodeSuggestion, Diagnostic, SubDiagnostic, pluralize,
16-
SuggestionStyle, SourceMapper, SourceMapperDyn, DiagnosticId,
17+
SuggestionStyle, DiagnosticId,
1718
};
1819
use crate::Level::Error;
1920
use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style};
@@ -49,7 +50,7 @@ impl HumanReadableErrorType {
4950
pub fn new_emitter(
5051
self,
5152
dst: Box<dyn Write + Send>,
52-
source_map: Option<Lrc<SourceMapperDyn>>,
53+
source_map: Option<Lrc<SourceMap>>,
5354
teach: bool,
5455
terminal_width: Option<usize>,
5556
external_macro_backtrace: bool,
@@ -192,7 +193,7 @@ pub trait Emitter {
192193
true
193194
}
194195

195-
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>>;
196+
fn source_map(&self) -> Option<&Lrc<SourceMap>>;
196197

197198
/// Formats the substitutions of the primary_span
198199
///
@@ -271,7 +272,7 @@ pub trait Emitter {
271272
// point directly at <*macros>. Since these are often difficult to read, this
272273
// will change the span to point at the use site.
273274
fn fix_multispans_in_std_macros(&self,
274-
source_map: &Option<Lrc<SourceMapperDyn>>,
275+
source_map: &Option<Lrc<SourceMap>>,
275276
span: &mut MultiSpan,
276277
children: &mut Vec<SubDiagnostic>,
277278
level: &Level,
@@ -311,7 +312,7 @@ pub trait Emitter {
311312
// <*macros>. Since these locations are often difficult to read, we move these Spans from
312313
// <*macros> to their corresponding use site.
313314
fn fix_multispan_in_std_macros(&self,
314-
source_map: &Option<Lrc<SourceMapperDyn>>,
315+
source_map: &Option<Lrc<SourceMap>>,
315316
span: &mut MultiSpan,
316317
always_backtrace: bool) -> bool {
317318
let sm = match source_map {
@@ -397,7 +398,7 @@ pub trait Emitter {
397398
}
398399

399400
impl Emitter for EmitterWriter {
400-
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> {
401+
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
401402
self.sm.as_ref()
402403
}
403404

@@ -428,7 +429,7 @@ impl Emitter for EmitterWriter {
428429
pub struct SilentEmitter;
429430

430431
impl Emitter for SilentEmitter {
431-
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> { None }
432+
fn source_map(&self) -> Option<&Lrc<SourceMap>> { None }
432433
fn emit_diagnostic(&mut self, _: &Diagnostic) {}
433434
}
434435

@@ -476,7 +477,7 @@ impl ColorConfig {
476477
/// Handles the writing of `HumanReadableErrorType::Default` and `HumanReadableErrorType::Short`
477478
pub struct EmitterWriter {
478479
dst: Destination,
479-
sm: Option<Lrc<SourceMapperDyn>>,
480+
sm: Option<Lrc<SourceMap>>,
480481
short_message: bool,
481482
teach: bool,
482483
ui_testing: bool,
@@ -495,7 +496,7 @@ pub struct FileWithAnnotatedLines {
495496
impl EmitterWriter {
496497
pub fn stderr(
497498
color_config: ColorConfig,
498-
source_map: Option<Lrc<SourceMapperDyn>>,
499+
source_map: Option<Lrc<SourceMap>>,
499500
short_message: bool,
500501
teach: bool,
501502
terminal_width: Option<usize>,
@@ -515,7 +516,7 @@ impl EmitterWriter {
515516

516517
pub fn new(
517518
dst: Box<dyn Write + Send>,
518-
source_map: Option<Lrc<SourceMapperDyn>>,
519+
source_map: Option<Lrc<SourceMap>>,
519520
short_message: bool,
520521
teach: bool,
521522
colored: bool,
@@ -1685,7 +1686,7 @@ impl FileWithAnnotatedLines {
16851686
/// This helps us quickly iterate over the whole message (including secondary file spans)
16861687
pub fn collect_annotations(
16871688
msp: &MultiSpan,
1688-
source_map: &Option<Lrc<SourceMapperDyn>>
1689+
source_map: &Option<Lrc<SourceMap>>
16891690
) -> Vec<FileWithAnnotatedLines> {
16901691
fn add_annotation_to_file(file_vec: &mut Vec<FileWithAnnotatedLines>,
16911692
file: Lrc<SourceFile>,
@@ -2067,7 +2068,7 @@ impl<'a> Drop for WritableDst<'a> {
20672068
}
20682069

20692070
/// Whether the original and suggested code are visually similar enough to warrant extra wording.
2070-
pub fn is_case_difference(sm: &dyn SourceMapper, suggested: &str, sp: Span) -> bool {
2071+
pub fn is_case_difference(sm: &SourceMap, suggested: &str, sp: Span) -> bool {
20712072
// FIXME: this should probably be extended to also account for `FO0` → `FOO` and unicode.
20722073
let found = sm.span_to_snippet(sp).unwrap();
20732074
let ascii_confusables = &['c', 'f', 'i', 'k', 'o', 's', 'u', 'v', 'w', 'x', 'y', 'z'];

src/libsyntax/json.rs src/librustc_errors/json.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
1010
// FIXME: spec the JSON output properly.
1111

12-
use crate::source_map::{SourceMap, FilePathMapping};
12+
use syntax_pos::source_map::{SourceMap, FilePathMapping};
1313

14-
use errors::registry::Registry;
15-
use errors::{SubDiagnostic, CodeSuggestion, SourceMapper, SourceMapperDyn};
16-
use errors::{DiagnosticId, Applicability};
17-
use errors::emitter::{Emitter, HumanReadableErrorType};
14+
use crate::registry::Registry;
15+
use crate::{SubDiagnostic, CodeSuggestion};
16+
use crate::{DiagnosticId, Applicability};
17+
use crate::emitter::{Emitter, HumanReadableErrorType};
1818

1919
use syntax_pos::{MacroBacktrace, Span, SpanLabel, MultiSpan};
20-
use rustc_data_structures::sync::{self, Lrc};
20+
use rustc_data_structures::sync::Lrc;
2121
use std::io::{self, Write};
2222
use std::path::Path;
2323
use std::vec;
@@ -31,7 +31,7 @@ mod tests;
3131
pub struct JsonEmitter {
3232
dst: Box<dyn Write + Send>,
3333
registry: Option<Registry>,
34-
sm: Lrc<dyn SourceMapper + sync::Send + sync::Sync>,
34+
sm: Lrc<SourceMap>,
3535
pretty: bool,
3636
ui_testing: bool,
3737
json_rendered: HumanReadableErrorType,
@@ -92,7 +92,7 @@ impl JsonEmitter {
9292
}
9393

9494
impl Emitter for JsonEmitter {
95-
fn emit_diagnostic(&mut self, diag: &errors::Diagnostic) {
95+
fn emit_diagnostic(&mut self, diag: &crate::Diagnostic) {
9696
let data = Diagnostic::from_errors_diagnostic(diag, self);
9797
let result = if self.pretty {
9898
writeln!(&mut self.dst, "{}", as_pretty_json(&data))
@@ -116,7 +116,7 @@ impl Emitter for JsonEmitter {
116116
}
117117
}
118118

119-
fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> {
119+
fn source_map(&self) -> Option<&Lrc<SourceMap>> {
120120
Some(&self.sm)
121121
}
122122

@@ -212,7 +212,7 @@ struct ArtifactNotification<'a> {
212212
}
213213

214214
impl Diagnostic {
215-
fn from_errors_diagnostic(diag: &errors::Diagnostic,
215+
fn from_errors_diagnostic(diag: &crate::Diagnostic,
216216
je: &JsonEmitter)
217217
-> Diagnostic {
218218
let sugg = diag.suggestions.iter().map(|sugg| {

src/libsyntax/json/tests.rs src/librustc_errors/json/tests.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
use super::*;
22

33
use crate::json::JsonEmitter;
4-
use crate::source_map::{FilePathMapping, SourceMap};
5-
use crate::with_default_globals;
4+
use syntax_pos::source_map::{FilePathMapping, SourceMap};
65

7-
use errors::emitter::{ColorConfig, HumanReadableErrorType};
8-
use errors::Handler;
6+
use crate::emitter::{ColorConfig, HumanReadableErrorType};
7+
use crate::Handler;
98
use rustc_serialize::json::decode;
109
use syntax_pos::{BytePos, Span};
1110

@@ -40,6 +39,13 @@ impl<T: Write> Write for Shared<T> {
4039
}
4140
}
4241

42+
fn with_default_globals(f: impl FnOnce()) {
43+
let globals = syntax_pos::Globals::new(syntax_pos::edition::DEFAULT_EDITION);
44+
syntax_pos::GLOBALS.set(&globals, || {
45+
syntax_pos::GLOBALS.set(&globals, f)
46+
})
47+
}
48+
4349
/// Test the span yields correct positions in JSON.
4450
fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
4551
let expected_output = TestData { spans: vec![expected_output] };

0 commit comments

Comments
 (0)