X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_session%2Fsrc%2Fsession.rs;h=103521983578bc4d8670429afd93e6c3dde5cb6e;hb=408b8cf7c4890ec2de3b3edb6c383886a241bdd0;hp=100c66f63641c6cda1174344062cb72b6d557f2a;hpb=790a71642019ebab8801e3237d3f8ff0472dc764;p=rust.git diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 100c66f6364..10352198357 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -286,6 +286,7 @@ pub fn init_crate_types(&self, crate_types: Vec) { } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn>( &self, sp: S, @@ -294,6 +295,7 @@ pub fn struct_span_warn>( self.diagnostic().struct_span_warn(sp, msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn_with_expectation>( &self, sp: S, @@ -303,6 +305,7 @@ pub fn struct_span_warn_with_expectation>( self.diagnostic().struct_span_warn_with_expectation(sp, msg, id) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_warn_with_code>( &self, sp: S, @@ -312,10 +315,12 @@ pub fn struct_span_warn_with_code>( self.diagnostic().struct_span_warn_with_code(sp, msg, code) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { self.diagnostic().struct_warn(msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn_with_expectation( &self, msg: impl Into, @@ -324,6 +329,7 @@ pub fn struct_warn_with_expectation( self.diagnostic().struct_warn_with_expectation(msg, id) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_allow>( &self, sp: S, @@ -332,10 +338,12 @@ pub fn struct_span_allow>( self.diagnostic().struct_span_allow(sp, msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_allow(&self, msg: impl Into) -> DiagnosticBuilder<'_, ()> { self.diagnostic().struct_allow(msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_expect( &self, msg: impl Into, @@ -344,6 +352,7 @@ pub fn struct_expect( self.diagnostic().struct_expect(msg, id) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err>( &self, sp: S, @@ -352,6 +361,7 @@ pub fn struct_span_err>( self.diagnostic().struct_span_err(sp, msg) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_err_with_code>( &self, sp: S, @@ -362,12 +372,14 @@ pub fn struct_span_err_with_code>( } // FIXME: This method should be removed (every error should have an associated error code). #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_err( &self, msg: impl Into, ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { self.parse_sess.struct_err(msg) } + #[track_caller] #[rustc_lint_diagnostics] pub fn struct_err_with_code( &self, @@ -377,6 +389,7 @@ pub fn struct_err_with_code( self.diagnostic().struct_err_with_code(msg, code) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_warn_with_code( &self, msg: impl Into, @@ -385,6 +398,7 @@ pub fn struct_warn_with_code( self.diagnostic().struct_warn_with_code(msg, code) } #[rustc_lint_diagnostics] + #[track_caller] pub fn struct_span_fatal>( &self, sp: S, @@ -407,6 +421,7 @@ pub fn struct_fatal(&self, msg: impl Into) -> DiagnosticBuild } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_fatal>(&self, sp: S, msg: impl Into) -> ! { self.diagnostic().span_fatal(sp, msg) } @@ -424,6 +439,7 @@ pub fn fatal(&self, msg: impl Into) -> ! { self.diagnostic().fatal(msg).raise() } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_err_or_warn>( &self, is_warning: bool, @@ -437,6 +453,7 @@ pub fn span_err_or_warn>( } } #[rustc_lint_diagnostics] + #[track_caller] pub fn span_err>( &self, sp: S, @@ -457,12 +474,14 @@ pub fn span_err_with_code>( pub fn err(&self, msg: impl Into) -> ErrorGuaranteed { self.diagnostic().err(msg) } + #[track_caller] pub fn create_err<'a>( &'a self, err: impl IntoDiagnostic<'a>, ) -> DiagnosticBuilder<'a, ErrorGuaranteed> { self.parse_sess.create_err(err) } + #[track_caller] pub fn create_feature_err<'a>( &'a self, err: impl IntoDiagnostic<'a>, @@ -475,33 +494,40 @@ pub fn create_feature_err<'a>( add_feature_diagnostics(&mut err, &self.parse_sess, feature); err } + #[track_caller] pub fn emit_err<'a>(&'a self, err: impl IntoDiagnostic<'a>) -> ErrorGuaranteed { self.parse_sess.emit_err(err) } + #[track_caller] pub fn create_warning<'a>( &'a self, err: impl IntoDiagnostic<'a, ()>, ) -> DiagnosticBuilder<'a, ()> { self.parse_sess.create_warning(err) } + #[track_caller] pub fn emit_warning<'a>(&'a self, warning: impl IntoDiagnostic<'a, ()>) { self.parse_sess.emit_warning(warning) } + #[track_caller] pub fn create_note<'a>( &'a self, note: impl IntoDiagnostic<'a, Noted>, ) -> DiagnosticBuilder<'a, Noted> { self.parse_sess.create_note(note) } + #[track_caller] pub fn emit_note<'a>(&'a self, note: impl IntoDiagnostic<'a, Noted>) -> Noted { self.parse_sess.emit_note(note) } + #[track_caller] pub fn create_fatal<'a>( &'a self, fatal: impl IntoDiagnostic<'a, !>, ) -> DiagnosticBuilder<'a, !> { self.parse_sess.create_fatal(fatal) } + #[track_caller] pub fn emit_fatal<'a>(&'a self, fatal: impl IntoDiagnostic<'a, !>) -> ! { self.parse_sess.emit_fatal(fatal) } @@ -541,6 +567,7 @@ pub fn track_errors(&self, f: F) -> Result } #[allow(rustc::untranslatable_diagnostic)] #[allow(rustc::diagnostic_outside_of_impl)] + #[track_caller] pub fn span_warn>(&self, sp: S, msg: impl Into) { self.diagnostic().span_warn(sp, msg) } @@ -587,6 +614,8 @@ pub fn delay_good_path_bug(&self, msg: impl Into) { pub fn note_without_error(&self, msg: impl Into) { self.diagnostic().note_without_error(msg) } + + #[track_caller] pub fn span_note_without_error>( &self, sp: S, @@ -989,11 +1018,8 @@ pub fn lto(&self) -> config::Lto { return config::Lto::Fat; } config::LtoCli::Thin => { - return if self.opts.cli_forced_thinlto_off { - config::Lto::Fat - } else { - config::Lto::Thin - }; + // The user explicitly asked for ThinLTO + return config::Lto::Thin; } } @@ -1005,7 +1031,7 @@ pub fn lto(&self) -> config::Lto { // If processing command line options determined that we're incompatible // with ThinLTO (e.g., `-C lto --emit llvm-ir`) then return that option. - if self.opts.cli_forced_thinlto_off { + if self.opts.cli_forced_local_thinlto_off { return config::Lto::No; } @@ -1213,6 +1239,7 @@ fn default_emitter( fallback_bundle: LazyFallbackBundle, ) -> Box { let macro_backtrace = sopts.unstable_opts.macro_backtrace; + let track_diagnostics = sopts.unstable_opts.track_diagnostics; match sopts.error_format { config::ErrorOutputType::HumanReadable(kind) => { let (short, color_config) = kind.unzip(); @@ -1236,6 +1263,7 @@ fn default_emitter( sopts.unstable_opts.teach, sopts.diagnostic_width, macro_backtrace, + track_diagnostics, ); Box::new(emitter.ui_testing(sopts.unstable_opts.ui_testing)) } @@ -1250,6 +1278,7 @@ fn default_emitter( json_rendered, sopts.diagnostic_width, macro_backtrace, + track_diagnostics, ) .ui_testing(sopts.unstable_opts.ui_testing), ), @@ -1280,7 +1309,7 @@ pub fn build_session( let sysroot = match &sopts.maybe_sysroot { Some(sysroot) => sysroot.clone(), - None => filesearch::get_or_default_sysroot(), + None => filesearch::get_or_default_sysroot().expect("Failed finding sysroot"), }; let target_cfg = config::build_target_config(&sopts, target_override, &sysroot); @@ -1552,11 +1581,18 @@ fn early_error_handler(output: config::ErrorOutputType) -> rustc_errors::Handler false, None, false, + false, )) } - config::ErrorOutputType::Json { pretty, json_rendered } => { - Box::new(JsonEmitter::basic(pretty, json_rendered, None, fallback_bundle, None, false)) - } + config::ErrorOutputType::Json { pretty, json_rendered } => Box::new(JsonEmitter::basic( + pretty, + json_rendered, + None, + fallback_bundle, + None, + false, + false, + )), }; rustc_errors::Handler::with_emitter(true, None, emitter) }