File tree 4 files changed +6
-11
lines changed
4 files changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -156,9 +156,6 @@ pub struct Session {
156
156
/// Metadata about the allocators for the current crate being compiled.
157
157
pub has_global_allocator : Once < bool > ,
158
158
159
- /// Metadata about the panic handlers for the current crate being compiled.
160
- pub has_panic_handler : Once < bool > ,
161
-
162
159
/// Cap lint level specified by a driver specifically.
163
160
pub driver_lint_caps : FxHashMap < lint:: LintId , lint:: Level > ,
164
161
@@ -1249,7 +1246,6 @@ fn build_session_(
1249
1246
print_fuel,
1250
1247
jobserver : jobserver:: client ( ) ,
1251
1248
has_global_allocator : Once :: new ( ) ,
1252
- has_panic_handler : Once :: new ( ) ,
1253
1249
driver_lint_caps,
1254
1250
trait_methods_not_found : Lock :: new ( Default :: default ( ) ) ,
1255
1251
confused_type_with_std_module : Lock :: new ( Default :: default ( ) ) ,
Original file line number Diff line number Diff line change @@ -3045,4 +3045,9 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
3045
3045
assert_eq ! ( cnum, LOCAL_CRATE ) ;
3046
3046
attr:: contains_name ( tcx. hir ( ) . krate_attrs ( ) , sym:: compiler_builtins)
3047
3047
} ;
3048
+ providers. has_panic_handler = |tcx, cnum| {
3049
+ assert_eq ! ( cnum, LOCAL_CRATE ) ;
3050
+ // We want to check if the panic handler was defined in this crate
3051
+ tcx. lang_items ( ) . panic_impl ( ) . map_or ( false , |did| did. is_local ( ) )
3052
+ } ;
3048
3053
}
Original file line number Diff line number Diff line change @@ -542,7 +542,6 @@ impl<'tcx> EncodeContext<'tcx> {
542
542
let attrs = tcx. hir ( ) . krate_attrs ( ) ;
543
543
let has_default_lib_allocator = attr:: contains_name ( & attrs, sym:: default_lib_allocator) ;
544
544
let has_global_allocator = * tcx. sess . has_global_allocator . get ( ) ;
545
- let has_panic_handler = * tcx. sess . has_panic_handler . try_get ( ) . unwrap_or ( & false ) ;
546
545
547
546
let root = self . lazy ( CrateRoot {
548
547
name : tcx. crate_name ( LOCAL_CRATE ) ,
@@ -553,7 +552,7 @@ impl<'tcx> EncodeContext<'tcx> {
553
552
panic_strategy : tcx. sess . panic_strategy ( ) ,
554
553
edition : tcx. sess . edition ( ) ,
555
554
has_global_allocator : has_global_allocator,
556
- has_panic_handler : has_panic_handler,
555
+ has_panic_handler : tcx . has_panic_handler ( LOCAL_CRATE ) ,
557
556
has_default_lib_allocator : has_default_lib_allocator,
558
557
plugin_registrar_fn : tcx. plugin_registrar_fn ( LOCAL_CRATE ) . map ( |id| id. index ) ,
559
558
proc_macro_decls_static : if is_proc_macro {
Original file line number Diff line number Diff line change @@ -1267,11 +1267,6 @@ fn check_fn<'a, 'tcx>(
1267
1267
if let Some ( panic_impl_did) = fcx. tcx . lang_items ( ) . panic_impl ( ) {
1268
1268
if panic_impl_did == fcx. tcx . hir ( ) . local_def_id ( fn_id) {
1269
1269
if let Some ( panic_info_did) = fcx. tcx . lang_items ( ) . panic_info ( ) {
1270
- // at this point we don't care if there are duplicate handlers or if the handler has
1271
- // the wrong signature as this value we'll be used when writing metadata and that
1272
- // only happens if compilation succeeded
1273
- fcx. tcx . sess . has_panic_handler . try_set_same ( true ) ;
1274
-
1275
1270
if declared_ret_ty. kind != ty:: Never {
1276
1271
fcx. tcx . sess . span_err (
1277
1272
decl. output . span ( ) ,
You can’t perform that action at this time.
0 commit comments