Skip to content

Commit

Permalink
Update rustc to nightly-2023-05-01
Browse files Browse the repository at this point in the history
  • Loading branch information
vakaras committed May 4, 2023
1 parent f175873 commit 9fb5479
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 43 deletions.
8 changes: 4 additions & 4 deletions extractor/src/hir_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_hir::{
};
use rustc_middle::hir::map::Map as HirMap;
use rustc_middle::mir::{self, HasLocalDecls};
use rustc_middle::ty::{TyCtxt, WithOptConstParam};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_span::source_map::Span;
use std::mem;
Expand Down Expand Up @@ -429,16 +429,16 @@ impl<'a, 'tcx> Visitor<'tcx> for HirVisitor<'a, 'tcx> {
intravisit::walk_body(self, body);
let id = body.id();
let def_id = self.hir_map.body_owner_def_id(id);
let def = WithOptConstParam::unknown(def_id.to_def_id());
// let def = WithOptConstParam::unknown(def_id.to_def_id());
let def_kind = self.tcx.def_kind(def_id);
let mir_body = match def_kind {
DefKind::Const
| DefKind::Static(_)
| DefKind::AssocConst
| DefKind::Ctor(..)
| DefKind::AnonConst
| DefKind::InlineConst => self.tcx.mir_for_ctfe_opt_const_arg(def),
_ => self.tcx.optimized_mir(def.did),
| DefKind::InlineConst => self.tcx.mir_for_ctfe(def_id.to_def_id()),
_ => self.tcx.optimized_mir(def_id),
};

self.visit_mir(def_id, mir_body);
Expand Down
73 changes: 36 additions & 37 deletions extractor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use rustc_hir::def_id::DefId;
use rustc_interface::interface::Compiler;
use rustc_interface::Queries;
use rustc_middle::ty::{
self,
query::{ExternProviders, Providers},
TyCtxt,
};
Expand Down Expand Up @@ -195,7 +194,7 @@ pub fn override_queries(
_providers_extern: &mut ExternProviders,
) {
providers.unsafety_check_result = unsafety_check_result;
providers.unsafety_check_result_for_const_arg = unsafety_check_result_for_const_arg;
// providers.unsafety_check_result_for_const_arg = unsafety_check_result_for_const_arg;
}

fn unsafety_check_result<'tcx>(
Expand All @@ -205,44 +204,44 @@ fn unsafety_check_result<'tcx>(
let mut providers = Providers::default();
rustc_mir_transform::provide(&mut providers);
let original_unsafety_check_result = providers.unsafety_check_result;
if let None = ty::WithOptConstParam::try_lookup(local_def_id, tcx) {
// FIXME: check_unsafety changed too much and needs to be written from scratch.
// let (result, reasons) = check_unsafety::unsafety_check_result(
// tcx,
// ty::WithOptConstParam::unknown(local_def_id),
// );
// let def_id = local_def_id.to_def_id();
// let mut state = SHARED_STATE.lock().unwrap();
// state.function_unsafe_use.insert(def_id, result);
// state.function_unsafe_reasons.insert(def_id, reasons);
}
// if let None = ty::WithOptConstParam::try_lookup(local_def_id, tcx) {
// FIXME: check_unsafety changed too much and needs to be written from scratch.
// let (result, reasons) = check_unsafety::unsafety_check_result(
// tcx,
// ty::WithOptConstParam::unknown(local_def_id),
// );
// let def_id = local_def_id.to_def_id();
// let mut state = SHARED_STATE.lock().unwrap();
// state.function_unsafe_use.insert(def_id, result);
// state.function_unsafe_reasons.insert(def_id, reasons);
// }
original_unsafety_check_result(tcx, local_def_id)
}

fn unsafety_check_result_for_const_arg<'tcx>(
tcx: TyCtxt<'tcx>,
(local_def_id, param_did): (LocalDefId, DefId),
) -> &'tcx rustc_middle::mir::UnsafetyCheckResult {
let mut providers = Providers::default();
rustc_mir_transform::provide(&mut providers);
let original_unsafety_check_result_for_const_arg =
providers.unsafety_check_result_for_const_arg;
{
// FIXME: check_unsafety changed too much and needs to be written from scratch.
// let (result, reasons) = check_unsafety::unsafety_check_result(
// tcx,
// ty::WithOptConstParam {
// did: local_def_id,
// const_param_did: Some(param_did),
// },
// );
// let def_id = local_def_id.to_def_id();
// let mut state = SHARED_STATE.lock().unwrap();
// state.function_unsafe_use.insert(def_id, result);
// state.function_unsafe_reasons.insert(def_id, reasons);
}
original_unsafety_check_result_for_const_arg(tcx, (local_def_id, param_did))
}
// fn unsafety_check_result_for_const_arg<'tcx>(
// tcx: TyCtxt<'tcx>,
// (local_def_id, param_did): (LocalDefId, DefId),
// ) -> &'tcx rustc_middle::mir::UnsafetyCheckResult {
// let mut providers = Providers::default();
// rustc_mir_transform::provide(&mut providers);
// let original_unsafety_check_result_for_const_arg =
// providers.unsafety_check_result_for_const_arg;
// {
// // FIXME: check_unsafety changed too much and needs to be written from scratch.
// // let (result, reasons) = check_unsafety::unsafety_check_result(
// // tcx,
// // ty::WithOptConstParam {
// // did: local_def_id,
// // const_param_did: Some(param_did),
// // },
// // );
// // let def_id = local_def_id.to_def_id();
// // let mut state = SHARED_STATE.lock().unwrap();
// // state.function_unsafe_use.insert(def_id, result);
// // state.function_unsafe_reasons.insert(def_id, reasons);
// }
// original_unsafety_check_result_for_const_arg(tcx, (local_def_id, param_did))
// }

/// Save `cfg!` configuration.
pub fn save_cfg_configuration(set: &FxHashSet<(String, Option<String>)>) {
Expand Down
5 changes: 4 additions & 1 deletion extractor/src/table_filler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ impl<'a, 'tcx> TableFiller<'a, 'tcx> {
let crate_name = self.tcx.crate_name(crate_num).as_str().to_string();
let crate_hash = self.tcx.crate_hash(crate_num).as_u64().into();
let def_path_str = self.tcx.def_path_debug_str(def_id);
let def_path_hash = self.tcx.def_path_hash(def_id).0.as_value().into();
let def_path_hash = {
let (f, s) = self.tcx.def_path_hash(def_id).0.split();
(f.as_u64(), s.as_u64()).into()
};
let summary_key_str = mirai_utils::summary_key_str(self.tcx, def_id);
let summary_key_str_value = std::rc::Rc::try_unwrap(summary_key_str).unwrap();
let def_path = self.tables.register_def_paths(
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-04-15"
channel = "nightly-2023-05-01"
components = [ "rustfmt", "rustc-dev", "llvm-tools-preview", "rust-src" ]

0 comments on commit 9fb5479

Please sign in to comment.