1use std::any::Any;
2use std::path::PathBuf;
3use std::str::FromStr;
4use std::sync::Arc;
5use std::sync::atomic::AtomicBool;
6use std::{env, io};
7
8use rand::{RngCore, rng};
9use rustc_data_structures::base_n::{CASE_INSENSITIVE, ToBaseN};
10use rustc_data_structures::flock;
11use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
12use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
13use rustc_data_structures::sync::{DynSend, DynSync, Lock, MappedReadGuard, ReadGuard, RwLock};
14use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitter;
15use rustc_errors::codes::*;
16use rustc_errors::emitter::{DynEmitter, HumanReadableErrorType, OutputTheme, stderr_destination};
17use rustc_errors::json::JsonEmitter;
18use rustc_errors::timings::TimingSectionHandler;
19use rustc_errors::translation::Translator;
20use rustc_errors::{
21 Diag, DiagCtxt, DiagCtxtHandle, DiagMessage, Diagnostic, ErrorGuaranteed, FatalAbort,
22 TerminalUrl, fallback_fluent_bundle,
23};
24use rustc_hir::limit::Limit;
25use rustc_macros::HashStable_Generic;
26pub use rustc_span::def_id::StableCrateId;
27use rustc_span::edition::Edition;
28use rustc_span::source_map::{FilePathMapping, SourceMap};
29use rustc_span::{RealFileName, Span, Symbol};
30use rustc_target::asm::InlineAsmArch;
31use rustc_target::spec::{
32 Arch, CodeModel, DebuginfoKind, Os, PanicStrategy, RelocModel, RelroLevel, SanitizerSet,
33 SmallDataThresholdSupport, SplitDebuginfo, StackProtector, SymbolVisibility, Target,
34 TargetTuple, TlsModel, apple,
35};
36
37use crate::code_stats::CodeStats;
38pub use crate::code_stats::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo};
39use crate::config::{
40 self, CoverageLevel, CoverageOptions, CrateType, DebugInfo, ErrorOutputType, FunctionReturn,
41 Input, InstrumentCoverage, OptLevel, OutFileName, OutputType, SwitchWithOptPath,
42};
43use crate::filesearch::FileSearch;
44use crate::lint::LintId;
45use crate::parse::{ParseSess, add_feature_diagnostics};
46use crate::search_paths::SearchPath;
47use crate::{errors, filesearch, lint};
48
49#[derive(#[automatically_derived]
impl ::core::clone::Clone for CtfeBacktrace {
#[inline]
fn clone(&self) -> CtfeBacktrace { *self }
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CtfeBacktrace { }Copy)]
51pub enum CtfeBacktrace {
52 Disabled,
54 Capture,
57 Immediate,
59}
60
61#[derive(#[automatically_derived]
impl ::core::clone::Clone for Limits {
#[inline]
fn clone(&self) -> Limits {
let _: ::core::clone::AssertParamIsClone<Limit>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Limits { }Copy, #[automatically_derived]
impl ::core::fmt::Debug for Limits {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Limits",
"recursion_limit", &self.recursion_limit, "move_size_limit",
&self.move_size_limit, "type_length_limit",
&self.type_length_limit, "pattern_complexity_limit",
&&self.pattern_complexity_limit)
}
}Debug, const _: () =
{
impl<__CTX> ::rustc_data_structures::stable_hasher::HashStable<__CTX>
for Limits where __CTX: crate::HashStableContext {
#[inline]
fn hash_stable(&self, __hcx: &mut __CTX,
__hasher:
&mut ::rustc_data_structures::stable_hasher::StableHasher) {
match *self {
Limits {
recursion_limit: ref __binding_0,
move_size_limit: ref __binding_1,
type_length_limit: ref __binding_2,
pattern_complexity_limit: ref __binding_3 } => {
{ __binding_0.hash_stable(__hcx, __hasher); }
{ __binding_1.hash_stable(__hcx, __hasher); }
{ __binding_2.hash_stable(__hcx, __hasher); }
{ __binding_3.hash_stable(__hcx, __hasher); }
}
}
}
}
};HashStable_Generic)]
62pub struct Limits {
63 pub recursion_limit: Limit,
66 pub move_size_limit: Limit,
69 pub type_length_limit: Limit,
71 pub pattern_complexity_limit: Limit,
73}
74
75pub struct CompilerIO {
76 pub input: Input,
77 pub output_dir: Option<PathBuf>,
78 pub output_file: Option<OutFileName>,
79 pub temps_dir: Option<PathBuf>,
80}
81
82pub trait DynLintStore: Any + DynSync + DynSend {
83 fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_>;
85}
86
87pub struct Session {
90 pub target: Target,
91 pub host: Target,
92 pub opts: config::Options,
93 pub target_tlib_path: Arc<SearchPath>,
94 pub psess: ParseSess,
95 pub io: CompilerIO,
97
98 incr_comp_session: RwLock<IncrCompSession>,
99
100 pub prof: SelfProfilerRef,
102
103 pub timings: TimingSectionHandler,
105
106 pub code_stats: CodeStats,
108
109 pub lint_store: Option<Arc<dyn DynLintStore>>,
111
112 pub driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
114
115 pub ctfe_backtrace: Lock<CtfeBacktrace>,
122
123 miri_unleashed_features: Lock<Vec<(Span, Option<Symbol>)>>,
128
129 pub asm_arch: Option<InlineAsmArch>,
131
132 pub target_features: FxIndexSet<Symbol>,
134
135 pub unstable_target_features: FxIndexSet<Symbol>,
137
138 pub cfg_version: &'static str,
140
141 pub using_internal_features: &'static AtomicBool,
146
147 target_filesearch: FileSearch,
148 host_filesearch: FileSearch,
149
150 pub invocation_temp: Option<String>,
157}
158
159#[derive(#[automatically_derived]
impl ::core::clone::Clone for CodegenUnits {
#[inline]
fn clone(&self) -> CodegenUnits {
let _: ::core::clone::AssertParamIsClone<usize>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for CodegenUnits { }Copy)]
160pub enum CodegenUnits {
161 User(usize),
164
165 Default(usize),
169}
170
171impl CodegenUnits {
172 pub fn as_usize(self) -> usize {
173 match self {
174 CodegenUnits::User(n) => n,
175 CodegenUnits::Default(n) => n,
176 }
177 }
178}
179
180pub struct LintGroup {
181 pub name: &'static str,
182 pub lints: Vec<LintId>,
183 pub is_externally_loaded: bool,
184}
185
186impl Session {
187 pub fn miri_unleashed_feature(&self, span: Span, feature_gate: Option<Symbol>) {
188 self.miri_unleashed_features.lock().push((span, feature_gate));
189 }
190
191 pub fn local_crate_source_file(&self) -> Option<RealFileName> {
192 Some(
193 self.source_map()
194 .path_mapping()
195 .to_real_filename(self.source_map().working_dir(), self.io.input.opt_path()?),
196 )
197 }
198
199 fn check_miri_unleashed_features(&self) -> Option<ErrorGuaranteed> {
200 let mut guar = None;
201 let unleashed_features = self.miri_unleashed_features.lock();
202 if !unleashed_features.is_empty() {
203 let mut must_err = false;
204 self.dcx().emit_warn(errors::SkippingConstChecks {
206 unleashed_features: unleashed_features
207 .iter()
208 .map(|(span, gate)| {
209 gate.map(|gate| {
210 must_err = true;
211 errors::UnleashedFeatureHelp::Named { span: *span, gate }
212 })
213 .unwrap_or(errors::UnleashedFeatureHelp::Unnamed { span: *span })
214 })
215 .collect(),
216 });
217
218 if must_err && self.dcx().has_errors().is_none() {
220 guar = Some(self.dcx().emit_err(errors::NotCircumventFeature));
222 }
223 }
224 guar
225 }
226
227 pub fn finish_diagnostics(&self) -> Option<ErrorGuaranteed> {
229 let mut guar = None;
230 guar = guar.or(self.check_miri_unleashed_features());
231 guar = guar.or(self.dcx().emit_stashed_diagnostics());
232 self.dcx().print_error_count();
233 if self.opts.json_future_incompat {
234 self.dcx().emit_future_breakage_report();
235 }
236 guar
237 }
238
239 pub fn is_test_crate(&self) -> bool {
241 self.opts.test
242 }
243
244 #[track_caller]
246 pub fn create_feature_err<'a>(&'a self, err: impl Diagnostic<'a>, feature: Symbol) -> Diag<'a> {
247 let mut err = self.dcx().create_err(err);
248 if err.code.is_none() {
249 err.code(E0658);
250 }
251 add_feature_diagnostics(&mut err, self, feature);
252 err
253 }
254
255 pub fn record_trimmed_def_paths(&self) {
258 if self.opts.unstable_opts.print_type_sizes
259 || self.opts.unstable_opts.query_dep_graph
260 || self.opts.unstable_opts.dump_mir.is_some()
261 || self.opts.unstable_opts.unpretty.is_some()
262 || self.prof.is_args_recording_enabled()
263 || self.opts.output_types.contains_key(&OutputType::Mir)
264 || std::env::var_os("RUSTC_LOG").is_some()
265 {
266 return;
267 }
268
269 self.dcx().set_must_produce_diag()
270 }
271
272 #[inline]
273 pub fn dcx(&self) -> DiagCtxtHandle<'_> {
274 self.psess.dcx()
275 }
276
277 #[inline]
278 pub fn source_map(&self) -> &SourceMap {
279 self.psess.source_map()
280 }
281
282 pub fn enable_internal_lints(&self) -> bool {
286 self.unstable_options() && !self.opts.actually_rustdoc
287 }
288
289 pub fn instrument_coverage(&self) -> bool {
290 self.opts.cg.instrument_coverage() != InstrumentCoverage::No
291 }
292
293 pub fn instrument_coverage_branch(&self) -> bool {
294 self.instrument_coverage()
295 && self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Branch
296 }
297
298 pub fn instrument_coverage_condition(&self) -> bool {
299 self.instrument_coverage()
300 && self.opts.unstable_opts.coverage_options.level >= CoverageLevel::Condition
301 }
302
303 pub fn coverage_options(&self) -> &CoverageOptions {
307 &self.opts.unstable_opts.coverage_options
308 }
309
310 pub fn is_sanitizer_cfi_enabled(&self) -> bool {
311 self.sanitizers().contains(SanitizerSet::CFI)
312 }
313
314 pub fn is_sanitizer_cfi_canonical_jump_tables_disabled(&self) -> bool {
315 self.opts.unstable_opts.sanitizer_cfi_canonical_jump_tables == Some(false)
316 }
317
318 pub fn is_sanitizer_cfi_canonical_jump_tables_enabled(&self) -> bool {
319 self.opts.unstable_opts.sanitizer_cfi_canonical_jump_tables == Some(true)
320 }
321
322 pub fn is_sanitizer_cfi_generalize_pointers_enabled(&self) -> bool {
323 self.opts.unstable_opts.sanitizer_cfi_generalize_pointers == Some(true)
324 }
325
326 pub fn is_sanitizer_cfi_normalize_integers_enabled(&self) -> bool {
327 self.opts.unstable_opts.sanitizer_cfi_normalize_integers == Some(true)
328 }
329
330 pub fn is_sanitizer_kcfi_arity_enabled(&self) -> bool {
331 self.opts.unstable_opts.sanitizer_kcfi_arity == Some(true)
332 }
333
334 pub fn is_sanitizer_kcfi_enabled(&self) -> bool {
335 self.sanitizers().contains(SanitizerSet::KCFI)
336 }
337
338 pub fn is_split_lto_unit_enabled(&self) -> bool {
339 self.opts.unstable_opts.split_lto_unit == Some(true)
340 }
341
342 pub fn crt_static(&self, crate_type: Option<CrateType>) -> bool {
344 if !self.target.crt_static_respected {
345 return self.target.crt_static_default;
347 }
348
349 let requested_features = self.opts.cg.target_feature.split(',');
350 let found_negative = requested_features.clone().any(|r| r == "-crt-static");
351 let found_positive = requested_features.clone().any(|r| r == "+crt-static");
352
353 #[allow(rustc::bad_opt_access)]
355 if found_positive || found_negative {
356 found_positive
357 } else if crate_type == Some(CrateType::ProcMacro)
358 || crate_type == None && self.opts.crate_types.contains(&CrateType::ProcMacro)
359 {
360 false
364 } else {
365 self.target.crt_static_default
366 }
367 }
368
369 pub fn is_wasi_reactor(&self) -> bool {
370 self.target.options.os == Os::Wasi
371 && #[allow(non_exhaustive_omitted_patterns)] match self.opts.unstable_opts.wasi_exec_model
{
Some(config::WasiExecModel::Reactor) => true,
_ => false,
}matches!(
372 self.opts.unstable_opts.wasi_exec_model,
373 Some(config::WasiExecModel::Reactor)
374 )
375 }
376
377 pub fn target_can_use_split_dwarf(&self) -> bool {
379 self.target.debuginfo_kind == DebuginfoKind::Dwarf
380 }
381
382 pub fn generate_proc_macro_decls_symbol(&self, stable_crate_id: StableCrateId) -> String {
383 ::alloc::__export::must_use({
::alloc::fmt::format(format_args!("__rustc_proc_macro_decls_{0:08x}__",
stable_crate_id.as_u64()))
})format!("__rustc_proc_macro_decls_{:08x}__", stable_crate_id.as_u64())
384 }
385
386 pub fn target_filesearch(&self) -> &filesearch::FileSearch {
387 &self.target_filesearch
388 }
389 pub fn host_filesearch(&self) -> &filesearch::FileSearch {
390 &self.host_filesearch
391 }
392
393 pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
397 let search_paths = self
398 .opts
399 .sysroot
400 .all_paths()
401 .map(|sysroot| filesearch::make_target_bin_path(&sysroot, config::host_tuple()));
402
403 if self_contained {
404 search_paths.flat_map(|path| [path.clone(), path.join("self-contained")]).collect()
408 } else {
409 search_paths.collect()
410 }
411 }
412
413 pub fn init_incr_comp_session(&self, session_dir: PathBuf, lock_file: flock::Lock) {
414 let mut incr_comp_session = self.incr_comp_session.borrow_mut();
415
416 if let IncrCompSession::NotInitialized = *incr_comp_session {
417 } else {
418 {
::core::panicking::panic_fmt(format_args!("Trying to initialize IncrCompSession `{0:?}`",
*incr_comp_session));
}panic!("Trying to initialize IncrCompSession `{:?}`", *incr_comp_session)
419 }
420
421 *incr_comp_session =
422 IncrCompSession::Active { session_directory: session_dir, _lock_file: lock_file };
423 }
424
425 pub fn finalize_incr_comp_session(&self, new_directory_path: PathBuf) {
426 let mut incr_comp_session = self.incr_comp_session.borrow_mut();
427
428 if let IncrCompSession::Active { .. } = *incr_comp_session {
429 } else {
430 {
::core::panicking::panic_fmt(format_args!("trying to finalize `IncrCompSession` `{0:?}`",
*incr_comp_session));
};panic!("trying to finalize `IncrCompSession` `{:?}`", *incr_comp_session);
431 }
432
433 *incr_comp_session = IncrCompSession::Finalized { session_directory: new_directory_path };
435 }
436
437 pub fn mark_incr_comp_session_as_invalid(&self) {
438 let mut incr_comp_session = self.incr_comp_session.borrow_mut();
439
440 let session_directory = match *incr_comp_session {
441 IncrCompSession::Active { ref session_directory, .. } => session_directory.clone(),
442 IncrCompSession::InvalidBecauseOfErrors { .. } => return,
443 _ => {
::core::panicking::panic_fmt(format_args!("trying to invalidate `IncrCompSession` `{0:?}`",
*incr_comp_session));
}panic!("trying to invalidate `IncrCompSession` `{:?}`", *incr_comp_session),
444 };
445
446 *incr_comp_session = IncrCompSession::InvalidBecauseOfErrors { session_directory };
448 }
449
450 pub fn incr_comp_session_dir(&self) -> MappedReadGuard<'_, PathBuf> {
451 let incr_comp_session = self.incr_comp_session.borrow();
452 ReadGuard::map(incr_comp_session, |incr_comp_session| match *incr_comp_session {
453 IncrCompSession::NotInitialized => {
::core::panicking::panic_fmt(format_args!("trying to get session directory from `IncrCompSession`: {0:?}",
*incr_comp_session));
}panic!(
454 "trying to get session directory from `IncrCompSession`: {:?}",
455 *incr_comp_session,
456 ),
457 IncrCompSession::Active { ref session_directory, .. }
458 | IncrCompSession::Finalized { ref session_directory }
459 | IncrCompSession::InvalidBecauseOfErrors { ref session_directory } => {
460 session_directory
461 }
462 })
463 }
464
465 pub fn incr_comp_session_dir_opt(&self) -> Option<MappedReadGuard<'_, PathBuf>> {
466 self.opts.incremental.as_ref().map(|_| self.incr_comp_session_dir())
467 }
468
469 pub fn is_rust_2015(&self) -> bool {
471 self.edition().is_rust_2015()
472 }
473
474 pub fn at_least_rust_2018(&self) -> bool {
476 self.edition().at_least_rust_2018()
477 }
478
479 pub fn at_least_rust_2021(&self) -> bool {
481 self.edition().at_least_rust_2021()
482 }
483
484 pub fn at_least_rust_2024(&self) -> bool {
486 self.edition().at_least_rust_2024()
487 }
488
489 pub fn needs_plt(&self) -> bool {
491 let want_plt = self.target.plt_by_default;
494
495 let dbg_opts = &self.opts.unstable_opts;
496
497 let relro_level = self.opts.cg.relro_level.unwrap_or(self.target.relro_level);
498
499 let full_relro = RelroLevel::Full == relro_level;
503
504 dbg_opts.plt.unwrap_or(want_plt || !full_relro)
507 }
508
509 pub fn emit_lifetime_markers(&self) -> bool {
511 self.opts.optimize != config::OptLevel::No
512 || self.sanitizers().intersects(SanitizerSet::ADDRESS | SanitizerSet::KERNELADDRESS | SanitizerSet::MEMORY | SanitizerSet::HWADDRESS)
516 }
517
518 pub fn diagnostic_width(&self) -> usize {
519 let default_column_width = 140;
520 if let Some(width) = self.opts.diagnostic_width {
521 width
522 } else if self.opts.unstable_opts.ui_testing {
523 default_column_width
524 } else {
525 termize::dimensions().map_or(default_column_width, |(w, _)| w)
526 }
527 }
528
529 pub fn default_visibility(&self) -> SymbolVisibility {
531 self.opts
532 .unstable_opts
533 .default_visibility
534 .or(self.target.options.default_visibility)
535 .unwrap_or(SymbolVisibility::Interposable)
536 }
537
538 pub fn staticlib_components(&self, verbatim: bool) -> (&str, &str) {
539 if verbatim {
540 ("", "")
541 } else {
542 (&*self.target.staticlib_prefix, &*self.target.staticlib_suffix)
543 }
544 }
545
546 pub fn lint_groups_iter(&self) -> Box<dyn Iterator<Item = LintGroup> + '_> {
547 match self.lint_store {
548 Some(ref lint_store) => lint_store.lint_groups_iter(),
549 None => Box::new(std::iter::empty()),
550 }
551 }
552}
553
554#[allow(rustc::bad_opt_access)]
556impl Session {
557 pub fn verbose_internals(&self) -> bool {
558 self.opts.unstable_opts.verbose_internals
559 }
560
561 pub fn print_llvm_stats(&self) -> bool {
562 self.opts.unstable_opts.print_codegen_stats
563 }
564
565 pub fn verify_llvm_ir(&self) -> bool {
566 self.opts.unstable_opts.verify_llvm_ir || ::core::option::Option::None::<&'static str>option_env!("RUSTC_VERIFY_LLVM_IR").is_some()
567 }
568
569 pub fn binary_dep_depinfo(&self) -> bool {
570 self.opts.unstable_opts.binary_dep_depinfo
571 }
572
573 pub fn mir_opt_level(&self) -> usize {
574 self.opts
575 .unstable_opts
576 .mir_opt_level
577 .unwrap_or_else(|| if self.opts.optimize != OptLevel::No { 2 } else { 1 })
578 }
579
580 pub fn lto(&self) -> config::Lto {
582 if self.target.requires_lto {
584 return config::Lto::Fat;
585 }
586
587 match self.opts.cg.lto {
591 config::LtoCli::Unspecified => {
592 }
595 config::LtoCli::No => {
596 return config::Lto::No;
598 }
599 config::LtoCli::Yes | config::LtoCli::Fat | config::LtoCli::NoParam => {
600 return config::Lto::Fat;
602 }
603 config::LtoCli::Thin => {
604 return config::Lto::Thin;
606 }
607 }
608
609 if self.opts.cli_forced_local_thinlto_off {
618 return config::Lto::No;
619 }
620
621 if let Some(enabled) = self.opts.unstable_opts.thinlto {
624 if enabled {
625 return config::Lto::ThinLocal;
626 } else {
627 return config::Lto::No;
628 }
629 }
630
631 if self.codegen_units().as_usize() == 1 {
634 return config::Lto::No;
635 }
636
637 match self.opts.optimize {
640 config::OptLevel::No => config::Lto::No,
641 _ => config::Lto::ThinLocal,
642 }
643 }
644
645 pub fn panic_strategy(&self) -> PanicStrategy {
648 self.opts.cg.panic.unwrap_or(self.target.panic_strategy)
649 }
650
651 pub fn fewer_names(&self) -> bool {
652 if let Some(fewer_names) = self.opts.unstable_opts.fewer_names {
653 fewer_names
654 } else {
655 let more_names = self.opts.output_types.contains_key(&OutputType::LlvmAssembly)
656 || self.opts.output_types.contains_key(&OutputType::Bitcode)
657 || self.opts.unstable_opts.sanitizer.intersects(SanitizerSet::ADDRESS | SanitizerSet::MEMORY);
659 !more_names
660 }
661 }
662
663 pub fn unstable_options(&self) -> bool {
664 self.opts.unstable_opts.unstable_options
665 }
666
667 pub fn is_nightly_build(&self) -> bool {
668 self.opts.unstable_features.is_nightly_build()
669 }
670
671 pub fn overflow_checks(&self) -> bool {
672 self.opts.cg.overflow_checks.unwrap_or(self.opts.debug_assertions)
673 }
674
675 pub fn ub_checks(&self) -> bool {
676 self.opts.unstable_opts.ub_checks.unwrap_or(self.opts.debug_assertions)
677 }
678
679 pub fn contract_checks(&self) -> bool {
680 self.opts.unstable_opts.contract_checks.unwrap_or(false)
681 }
682
683 pub fn relocation_model(&self) -> RelocModel {
684 self.opts.cg.relocation_model.unwrap_or(self.target.relocation_model)
685 }
686
687 pub fn code_model(&self) -> Option<CodeModel> {
688 self.opts.cg.code_model.or(self.target.code_model)
689 }
690
691 pub fn tls_model(&self) -> TlsModel {
692 self.opts.unstable_opts.tls_model.unwrap_or(self.target.tls_model)
693 }
694
695 pub fn direct_access_external_data(&self) -> Option<bool> {
696 self.opts
697 .unstable_opts
698 .direct_access_external_data
699 .or(self.target.direct_access_external_data)
700 }
701
702 pub fn split_debuginfo(&self) -> SplitDebuginfo {
703 self.opts.cg.split_debuginfo.unwrap_or(self.target.split_debuginfo)
704 }
705
706 pub fn dwarf_version(&self) -> u32 {
708 self.opts
709 .cg
710 .dwarf_version
711 .or(self.opts.unstable_opts.dwarf_version)
712 .unwrap_or(self.target.default_dwarf_version)
713 }
714
715 pub fn stack_protector(&self) -> StackProtector {
716 if self.target.options.supports_stack_protector {
717 self.opts.unstable_opts.stack_protector
718 } else {
719 StackProtector::None
720 }
721 }
722
723 pub fn must_emit_unwind_tables(&self) -> bool {
724 self.target.requires_uwtable
753 || self
754 .opts
755 .cg
756 .force_unwind_tables
757 .unwrap_or(self.panic_strategy().unwinds() || self.target.default_uwtable)
758 }
759
760 #[inline]
763 pub fn threads(&self) -> usize {
764 self.opts.unstable_opts.threads
765 }
766
767 pub fn codegen_units(&self) -> CodegenUnits {
770 if let Some(n) = self.opts.cli_forced_codegen_units {
771 return CodegenUnits::User(n);
772 }
773 if let Some(n) = self.target.default_codegen_units {
774 return CodegenUnits::Default(n as usize);
775 }
776
777 if self.opts.incremental.is_some() {
781 return CodegenUnits::Default(256);
782 }
783
784 CodegenUnits::Default(16)
835 }
836
837 pub fn teach(&self, code: ErrCode) -> bool {
838 self.opts.unstable_opts.teach && self.dcx().must_teach(code)
839 }
840
841 pub fn edition(&self) -> Edition {
842 self.opts.edition
843 }
844
845 pub fn link_dead_code(&self) -> bool {
846 self.opts.cg.link_dead_code.unwrap_or(false)
847 }
848
849 pub fn apple_deployment_target(&self) -> apple::OSVersion {
854 let min = apple::OSVersion::minimum_deployment_target(&self.target);
855 let env_var = apple::deployment_target_env_var(&self.target.os);
856
857 if let Ok(deployment_target) = env::var(env_var) {
859 match apple::OSVersion::from_str(&deployment_target) {
860 Ok(version) => {
861 let os_min = apple::OSVersion::os_minimum_deployment_target(&self.target.os);
862 if version < os_min {
867 self.dcx().emit_warn(errors::AppleDeploymentTarget::TooLow {
868 env_var,
869 version: version.fmt_pretty().to_string(),
870 os_min: os_min.fmt_pretty().to_string(),
871 });
872 }
873
874 version.max(min)
876 }
877 Err(error) => {
878 self.dcx().emit_err(errors::AppleDeploymentTarget::Invalid { env_var, error });
879 min
880 }
881 }
882 } else {
883 min
885 }
886 }
887
888 pub fn sanitizers(&self) -> SanitizerSet {
889 return self.opts.unstable_opts.sanitizer | self.target.options.default_sanitizers;
890 }
891}
892
893#[allow(rustc::bad_opt_access)]
895fn default_emitter(
896 sopts: &config::Options,
897 source_map: Arc<SourceMap>,
898 translator: Translator,
899) -> Box<DynEmitter> {
900 let macro_backtrace = sopts.unstable_opts.macro_backtrace;
901 let track_diagnostics = sopts.unstable_opts.track_diagnostics;
902 let terminal_url = match sopts.unstable_opts.terminal_urls {
903 TerminalUrl::Auto => {
904 match (std::env::var("COLORTERM").as_deref(), std::env::var("TERM").as_deref()) {
905 (Ok("truecolor"), Ok("xterm-256color"))
906 if sopts.unstable_features.is_nightly_build() =>
907 {
908 TerminalUrl::Yes
909 }
910 _ => TerminalUrl::No,
911 }
912 }
913 t => t,
914 };
915
916 let source_map = if sopts.unstable_opts.link_only { None } else { Some(source_map) };
917
918 match sopts.error_format {
919 config::ErrorOutputType::HumanReadable { kind, color_config } => match kind {
920 HumanReadableErrorType { short, unicode } => {
921 let emitter =
922 AnnotateSnippetEmitter::new(stderr_destination(color_config), translator)
923 .sm(source_map)
924 .short_message(short)
925 .diagnostic_width(sopts.diagnostic_width)
926 .macro_backtrace(macro_backtrace)
927 .track_diagnostics(track_diagnostics)
928 .terminal_url(terminal_url)
929 .theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii })
930 .ignored_directories_in_source_blocks(
931 sopts
932 .unstable_opts
933 .ignore_directory_in_diagnostics_source_blocks
934 .clone(),
935 );
936 Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing))
937 }
938 },
939 config::ErrorOutputType::Json { pretty, json_rendered, color_config } => Box::new(
940 JsonEmitter::new(
941 Box::new(io::BufWriter::new(io::stderr())),
942 source_map,
943 translator,
944 pretty,
945 json_rendered,
946 color_config,
947 )
948 .ui_testing(sopts.unstable_opts.ui_testing)
949 .ignored_directories_in_source_blocks(
950 sopts.unstable_opts.ignore_directory_in_diagnostics_source_blocks.clone(),
951 )
952 .diagnostic_width(sopts.diagnostic_width)
953 .macro_backtrace(macro_backtrace)
954 .track_diagnostics(track_diagnostics)
955 .terminal_url(terminal_url),
956 ),
957 }
958}
959
960#[allow(rustc::bad_opt_access)]
962pub fn build_session(
963 sopts: config::Options,
964 io: CompilerIO,
965 fluent_bundle: Option<Arc<rustc_errors::FluentBundle>>,
966 registry: rustc_errors::registry::Registry,
967 fluent_resources: Vec<&'static str>,
968 driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
969 target: Target,
970 cfg_version: &'static str,
971 ice_file: Option<PathBuf>,
972 using_internal_features: &'static AtomicBool,
973) -> Session {
974 let warnings_allow = sopts
978 .lint_opts
979 .iter()
980 .rfind(|&(key, _)| *key == "warnings")
981 .is_some_and(|&(_, level)| level == lint::Allow);
982 let cap_lints_allow = sopts.lint_cap.is_some_and(|cap| cap == lint::Allow);
983 let can_emit_warnings = !(warnings_allow || cap_lints_allow);
984
985 let translator = Translator {
986 fluent_bundle,
987 fallback_fluent_bundle: fallback_fluent_bundle(
988 fluent_resources,
989 sopts.unstable_opts.translate_directionality_markers,
990 ),
991 };
992 let source_map = rustc_span::source_map::get_source_map().unwrap();
993 let emitter = default_emitter(&sopts, Arc::clone(&source_map), translator);
994
995 let mut dcx = DiagCtxt::new(emitter)
996 .with_flags(sopts.unstable_opts.dcx_flags(can_emit_warnings))
997 .with_registry(registry);
998 if let Some(ice_file) = ice_file {
999 dcx = dcx.with_ice_file(ice_file);
1000 }
1001
1002 let host_triple = TargetTuple::from_tuple(config::host_tuple());
1003 let (host, target_warnings) =
1004 Target::search(&host_triple, sopts.sysroot.path(), sopts.unstable_opts.unstable_options)
1005 .unwrap_or_else(|e| {
1006 dcx.handle().fatal(::alloc::__export::must_use({
::alloc::fmt::format(format_args!("Error loading host specification: {0}",
e))
})format!("Error loading host specification: {e}"))
1007 });
1008 for warning in target_warnings.warning_messages() {
1009 dcx.handle().warn(warning)
1010 }
1011
1012 let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile
1013 {
1014 let directory = if let Some(directory) = d { directory } else { std::path::Path::new(".") };
1015
1016 let profiler = SelfProfiler::new(
1017 directory,
1018 sopts.crate_name.as_deref(),
1019 sopts.unstable_opts.self_profile_events.as_deref(),
1020 &sopts.unstable_opts.self_profile_counter,
1021 );
1022 match profiler {
1023 Ok(profiler) => Some(Arc::new(profiler)),
1024 Err(e) => {
1025 dcx.handle().emit_warn(errors::FailedToCreateProfiler { err: e.to_string() });
1026 None
1027 }
1028 }
1029 } else {
1030 None
1031 };
1032
1033 let mut psess = ParseSess::with_dcx(dcx, source_map);
1034 psess.assume_incomplete_release = sopts.unstable_opts.assume_incomplete_release;
1035
1036 let host_triple = config::host_tuple();
1037 let target_triple = sopts.target_triple.tuple();
1038 let host_tlib_path =
1040 Arc::new(SearchPath::from_sysroot_and_triple(sopts.sysroot.path(), host_triple));
1041 let target_tlib_path = if host_triple == target_triple {
1042 Arc::clone(&host_tlib_path)
1045 } else {
1046 Arc::new(SearchPath::from_sysroot_and_triple(sopts.sysroot.path(), target_triple))
1047 };
1048
1049 let prof = SelfProfilerRef::new(
1050 self_profiler,
1051 sopts.unstable_opts.time_passes.then(|| sopts.unstable_opts.time_passes_format),
1052 );
1053
1054 let ctfe_backtrace = Lock::new(match env::var("RUSTC_CTFE_BACKTRACE") {
1055 Ok(ref val) if val == "immediate" => CtfeBacktrace::Immediate,
1056 Ok(ref val) if val != "0" => CtfeBacktrace::Capture,
1057 _ => CtfeBacktrace::Disabled,
1058 });
1059
1060 let asm_arch = if target.allow_asm { InlineAsmArch::from_arch(&target.arch) } else { None };
1061 let target_filesearch =
1062 filesearch::FileSearch::new(&sopts.search_paths, &target_tlib_path, &target);
1063 let host_filesearch = filesearch::FileSearch::new(&sopts.search_paths, &host_tlib_path, &host);
1064
1065 let invocation_temp = sopts
1066 .incremental
1067 .as_ref()
1068 .map(|_| rng().next_u32().to_base_fixed_len(CASE_INSENSITIVE).to_string());
1069
1070 let timings = TimingSectionHandler::new(sopts.json_timings);
1071
1072 let sess = Session {
1073 target,
1074 host,
1075 opts: sopts,
1076 target_tlib_path,
1077 psess,
1078 io,
1079 incr_comp_session: RwLock::new(IncrCompSession::NotInitialized),
1080 prof,
1081 timings,
1082 code_stats: Default::default(),
1083 lint_store: None,
1084 driver_lint_caps,
1085 ctfe_backtrace,
1086 miri_unleashed_features: Lock::new(Default::default()),
1087 asm_arch,
1088 target_features: Default::default(),
1089 unstable_target_features: Default::default(),
1090 cfg_version,
1091 using_internal_features,
1092 target_filesearch,
1093 host_filesearch,
1094 invocation_temp,
1095 };
1096
1097 validate_commandline_args_with_session_available(&sess);
1098
1099 sess
1100}
1101
1102#[allow(rustc::bad_opt_access)]
1108fn validate_commandline_args_with_session_available(sess: &Session) {
1109 if sess.opts.cg.linker_plugin_lto.enabled()
1117 && sess.opts.cg.prefer_dynamic
1118 && sess.target.is_like_windows
1119 {
1120 sess.dcx().emit_err(errors::LinkerPluginToWindowsNotSupported);
1121 }
1122
1123 if let Some(ref path) = sess.opts.cg.profile_use {
1126 if !path.exists() {
1127 sess.dcx().emit_err(errors::ProfileUseFileDoesNotExist { path });
1128 }
1129 }
1130
1131 if let Some(ref path) = sess.opts.unstable_opts.profile_sample_use {
1133 if !path.exists() {
1134 sess.dcx().emit_err(errors::ProfileSampleUseFileDoesNotExist { path });
1135 }
1136 }
1137
1138 if let Some(include_uwtables) = sess.opts.cg.force_unwind_tables {
1140 if sess.target.requires_uwtable && !include_uwtables {
1141 sess.dcx().emit_err(errors::TargetRequiresUnwindTables);
1142 }
1143 }
1144
1145 let supported_sanitizers = sess.target.options.supported_sanitizers;
1147 let mut unsupported_sanitizers = sess.opts.unstable_opts.sanitizer - supported_sanitizers;
1148 if sess.opts.unstable_opts.fixed_x18 && sess.target.arch == Arch::AArch64 {
1151 unsupported_sanitizers -= SanitizerSet::SHADOWCALLSTACK;
1152 }
1153 match unsupported_sanitizers.into_iter().count() {
1154 0 => {}
1155 1 => {
1156 sess.dcx()
1157 .emit_err(errors::SanitizerNotSupported { us: unsupported_sanitizers.to_string() });
1158 }
1159 _ => {
1160 sess.dcx().emit_err(errors::SanitizersNotSupported {
1161 us: unsupported_sanitizers.to_string(),
1162 });
1163 }
1164 }
1165
1166 if let Some((first, second)) = sess.opts.unstable_opts.sanitizer.mutually_exclusive() {
1168 sess.dcx().emit_err(errors::CannotMixAndMatchSanitizers {
1169 first: first.to_string(),
1170 second: second.to_string(),
1171 });
1172 }
1173
1174 if sess.crt_static(None)
1176 && !sess.opts.unstable_opts.sanitizer.is_empty()
1177 && !sess.target.is_like_msvc
1178 {
1179 sess.dcx().emit_err(errors::CannotEnableCrtStaticLinux);
1180 }
1181
1182 if sess.is_sanitizer_cfi_enabled()
1184 && !(sess.lto() == config::Lto::Fat || sess.opts.cg.linker_plugin_lto.enabled())
1185 {
1186 sess.dcx().emit_err(errors::SanitizerCfiRequiresLto);
1187 }
1188
1189 if sess.is_sanitizer_kcfi_enabled() && sess.panic_strategy().unwinds() {
1191 sess.dcx().emit_err(errors::SanitizerKcfiRequiresPanicAbort);
1192 }
1193
1194 if sess.is_sanitizer_cfi_enabled()
1196 && sess.lto() == config::Lto::Fat
1197 && (sess.codegen_units().as_usize() != 1)
1198 {
1199 sess.dcx().emit_err(errors::SanitizerCfiRequiresSingleCodegenUnit);
1200 }
1201
1202 if sess.is_sanitizer_cfi_canonical_jump_tables_disabled() {
1204 if !sess.is_sanitizer_cfi_enabled() {
1205 sess.dcx().emit_err(errors::SanitizerCfiCanonicalJumpTablesRequiresCfi);
1206 }
1207 }
1208
1209 if sess.is_sanitizer_kcfi_arity_enabled() && !sess.is_sanitizer_kcfi_enabled() {
1211 sess.dcx().emit_err(errors::SanitizerKcfiArityRequiresKcfi);
1212 }
1213
1214 if sess.is_sanitizer_cfi_generalize_pointers_enabled() {
1216 if !(sess.is_sanitizer_cfi_enabled() || sess.is_sanitizer_kcfi_enabled()) {
1217 sess.dcx().emit_err(errors::SanitizerCfiGeneralizePointersRequiresCfi);
1218 }
1219 }
1220
1221 if sess.is_sanitizer_cfi_normalize_integers_enabled() {
1223 if !(sess.is_sanitizer_cfi_enabled() || sess.is_sanitizer_kcfi_enabled()) {
1224 sess.dcx().emit_err(errors::SanitizerCfiNormalizeIntegersRequiresCfi);
1225 }
1226 }
1227
1228 if sess.is_split_lto_unit_enabled()
1230 && !(sess.lto() == config::Lto::Fat
1231 || sess.lto() == config::Lto::Thin
1232 || sess.opts.cg.linker_plugin_lto.enabled())
1233 {
1234 sess.dcx().emit_err(errors::SplitLtoUnitRequiresLto);
1235 }
1236
1237 if sess.lto() != config::Lto::Fat {
1239 if sess.opts.unstable_opts.virtual_function_elimination {
1240 sess.dcx().emit_err(errors::UnstableVirtualFunctionElimination);
1241 }
1242 }
1243
1244 if sess.opts.unstable_opts.stack_protector != StackProtector::None {
1245 if !sess.target.options.supports_stack_protector {
1246 sess.dcx().emit_warn(errors::StackProtectorNotSupportedForTarget {
1247 stack_protector: sess.opts.unstable_opts.stack_protector,
1248 target_triple: &sess.opts.target_triple,
1249 });
1250 }
1251 }
1252
1253 if sess.opts.unstable_opts.small_data_threshold.is_some() {
1254 if sess.target.small_data_threshold_support() == SmallDataThresholdSupport::None {
1255 sess.dcx().emit_warn(errors::SmallDataThresholdNotSupportedForTarget {
1256 target_triple: &sess.opts.target_triple,
1257 })
1258 }
1259 }
1260
1261 if sess.opts.unstable_opts.branch_protection.is_some() && sess.target.arch != Arch::AArch64 {
1262 sess.dcx().emit_err(errors::BranchProtectionRequiresAArch64);
1263 }
1264
1265 if let Some(dwarf_version) =
1266 sess.opts.cg.dwarf_version.or(sess.opts.unstable_opts.dwarf_version)
1267 {
1268 if dwarf_version < 2 || dwarf_version > 5 {
1270 sess.dcx().emit_err(errors::UnsupportedDwarfVersion { dwarf_version });
1271 }
1272 }
1273
1274 if !sess.target.options.supported_split_debuginfo.contains(&sess.split_debuginfo())
1275 && !sess.opts.unstable_opts.unstable_options
1276 {
1277 sess.dcx()
1278 .emit_err(errors::SplitDebugInfoUnstablePlatform { debuginfo: sess.split_debuginfo() });
1279 }
1280
1281 if sess.opts.unstable_opts.embed_source {
1282 let dwarf_version = sess.dwarf_version();
1283
1284 if dwarf_version < 5 {
1285 sess.dcx().emit_warn(errors::EmbedSourceInsufficientDwarfVersion { dwarf_version });
1286 }
1287
1288 if sess.opts.debuginfo == DebugInfo::None {
1289 sess.dcx().emit_warn(errors::EmbedSourceRequiresDebugInfo);
1290 }
1291 }
1292
1293 if sess.opts.unstable_opts.instrument_xray.is_some() && !sess.target.options.supports_xray {
1294 sess.dcx().emit_err(errors::InstrumentationNotSupported { us: "XRay".to_string() });
1295 }
1296
1297 if let Some(flavor) = sess.opts.cg.linker_flavor
1298 && let Some(compatible_list) = sess.target.linker_flavor.check_compatibility(flavor)
1299 {
1300 let flavor = flavor.desc();
1301 sess.dcx().emit_err(errors::IncompatibleLinkerFlavor { flavor, compatible_list });
1302 }
1303
1304 if sess.opts.unstable_opts.function_return != FunctionReturn::default() {
1305 if !#[allow(non_exhaustive_omitted_patterns)] match sess.target.arch {
Arch::X86 | Arch::X86_64 => true,
_ => false,
}matches!(sess.target.arch, Arch::X86 | Arch::X86_64) {
1306 sess.dcx().emit_err(errors::FunctionReturnRequiresX86OrX8664);
1307 }
1308 }
1309
1310 if sess.opts.unstable_opts.indirect_branch_cs_prefix {
1311 if !#[allow(non_exhaustive_omitted_patterns)] match sess.target.arch {
Arch::X86 | Arch::X86_64 => true,
_ => false,
}matches!(sess.target.arch, Arch::X86 | Arch::X86_64) {
1312 sess.dcx().emit_err(errors::IndirectBranchCsPrefixRequiresX86OrX8664);
1313 }
1314 }
1315
1316 if let Some(regparm) = sess.opts.unstable_opts.regparm {
1317 if regparm > 3 {
1318 sess.dcx().emit_err(errors::UnsupportedRegparm { regparm });
1319 }
1320 if sess.target.arch != Arch::X86 {
1321 sess.dcx().emit_err(errors::UnsupportedRegparmArch);
1322 }
1323 }
1324 if sess.opts.unstable_opts.reg_struct_return {
1325 if sess.target.arch != Arch::X86 {
1326 sess.dcx().emit_err(errors::UnsupportedRegStructReturnArch);
1327 }
1328 }
1329
1330 match sess.opts.unstable_opts.function_return {
1334 FunctionReturn::Keep => (),
1335 FunctionReturn::ThunkExtern => {
1336 if let Some(code_model) = sess.code_model()
1339 && code_model == CodeModel::Large
1340 {
1341 sess.dcx().emit_err(errors::FunctionReturnThunkExternRequiresNonLargeCodeModel);
1342 }
1343 }
1344 }
1345
1346 if sess.opts.cg.soft_float {
1347 if sess.target.arch == Arch::Arm {
1348 sess.dcx().emit_warn(errors::SoftFloatDeprecated);
1349 } else {
1350 sess.dcx().emit_warn(errors::SoftFloatIgnored);
1353 }
1354 }
1355}
1356
1357#[derive(#[automatically_derived]
impl ::core::fmt::Debug for IncrCompSession {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
IncrCompSession::NotInitialized =>
::core::fmt::Formatter::write_str(f, "NotInitialized"),
IncrCompSession::Active {
session_directory: __self_0, _lock_file: __self_1 } =>
::core::fmt::Formatter::debug_struct_field2_finish(f,
"Active", "session_directory", __self_0, "_lock_file",
&__self_1),
IncrCompSession::Finalized { session_directory: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"Finalized", "session_directory", &__self_0),
IncrCompSession::InvalidBecauseOfErrors {
session_directory: __self_0 } =>
::core::fmt::Formatter::debug_struct_field1_finish(f,
"InvalidBecauseOfErrors", "session_directory", &__self_0),
}
}
}Debug)]
1359enum IncrCompSession {
1360 NotInitialized,
1363 Active { session_directory: PathBuf, _lock_file: flock::Lock },
1368 Finalized { session_directory: PathBuf },
1371 InvalidBecauseOfErrors { session_directory: PathBuf },
1375}
1376
1377pub struct EarlyDiagCtxt {
1379 dcx: DiagCtxt,
1380}
1381
1382impl EarlyDiagCtxt {
1383 pub fn new(output: ErrorOutputType) -> Self {
1384 let emitter = mk_emitter(output);
1385 Self { dcx: DiagCtxt::new(emitter) }
1386 }
1387
1388 pub fn set_error_format(&mut self, output: ErrorOutputType) {
1391 if !self.dcx.handle().has_errors().is_none() {
::core::panicking::panic("assertion failed: self.dcx.handle().has_errors().is_none()")
};assert!(self.dcx.handle().has_errors().is_none());
1392
1393 let emitter = mk_emitter(output);
1394 self.dcx = DiagCtxt::new(emitter);
1395 }
1396
1397 pub fn early_note(&self, msg: impl Into<DiagMessage>) {
1398 self.dcx.handle().note(msg)
1399 }
1400
1401 pub fn early_help(&self, msg: impl Into<DiagMessage>) {
1402 self.dcx.handle().struct_help(msg).emit()
1403 }
1404
1405 #[must_use = "raise_fatal must be called on the returned ErrorGuaranteed in order to exit with a non-zero status code"]
1406 pub fn early_err(&self, msg: impl Into<DiagMessage>) -> ErrorGuaranteed {
1407 self.dcx.handle().err(msg)
1408 }
1409
1410 pub fn early_fatal(&self, msg: impl Into<DiagMessage>) -> ! {
1411 self.dcx.handle().fatal(msg)
1412 }
1413
1414 pub fn early_struct_fatal(&self, msg: impl Into<DiagMessage>) -> Diag<'_, FatalAbort> {
1415 self.dcx.handle().struct_fatal(msg)
1416 }
1417
1418 pub fn early_warn(&self, msg: impl Into<DiagMessage>) {
1419 self.dcx.handle().warn(msg)
1420 }
1421
1422 pub fn early_struct_warn(&self, msg: impl Into<DiagMessage>) -> Diag<'_, ()> {
1423 self.dcx.handle().struct_warn(msg)
1424 }
1425}
1426
1427fn mk_emitter(output: ErrorOutputType) -> Box<DynEmitter> {
1428 let translator =
1431 Translator::with_fallback_bundle(<[_]>::into_vec(::alloc::boxed::box_new([rustc_errors::DEFAULT_LOCALE_RESOURCE]))vec![rustc_errors::DEFAULT_LOCALE_RESOURCE], false);
1432 let emitter: Box<DynEmitter> = match output {
1433 config::ErrorOutputType::HumanReadable { kind, color_config } => match kind {
1434 HumanReadableErrorType { short, unicode } => Box::new(
1435 AnnotateSnippetEmitter::new(stderr_destination(color_config), translator)
1436 .theme(if unicode { OutputTheme::Unicode } else { OutputTheme::Ascii })
1437 .short_message(short),
1438 ),
1439 },
1440 config::ErrorOutputType::Json { pretty, json_rendered, color_config } => {
1441 Box::new(JsonEmitter::new(
1442 Box::new(io::BufWriter::new(io::stderr())),
1443 Some(Arc::new(SourceMap::new(FilePathMapping::empty()))),
1444 translator,
1445 pretty,
1446 json_rendered,
1447 color_config,
1448 ))
1449 }
1450 };
1451 emitter
1452}