Skip to content

Commit d4ba274

Browse files
committed
Auto merge of rust-lang#117459 - matthiaskrgr:rollup-t3osb3c, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - rust-lang#113241 (rustdoc: Document lack of object safety on affected traits) - rust-lang#117388 (Turn const_caller_location from a query to a hook) - rust-lang#117417 (Add a stable MIR visitor) - rust-lang#117439 (prepopulate opaque ty storage before using it) - rust-lang#117451 (Add support for pre-unix-epoch file dates on Apple platforms (rust-lang#108277)) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 50be229 + d06200b commit d4ba274

File tree

22 files changed

+811
-103
lines changed

22 files changed

+811
-103
lines changed

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,7 @@ pub(crate) fn type_check<'mir, 'tcx>(
188188
&mut borrowck_context,
189189
);
190190

191-
// FIXME(-Ztrait-solver=next): A bit dubious that we're only registering
192-
// predefined opaques in the typeck root.
193-
if infcx.next_trait_solver() && !infcx.tcx.is_typeck_child(body.source.def_id()) {
194-
checker.register_predefined_opaques_in_new_solver();
195-
}
191+
checker.check_user_type_annotations();
196192

197193
let mut verifier = TypeVerifier::new(&mut checker, promoted);
198194
verifier.visit_body(&body);
@@ -1021,7 +1017,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
10211017
borrowck_context,
10221018
reported_errors: Default::default(),
10231019
};
1024-
checker.check_user_type_annotations();
1020+
1021+
// FIXME(-Ztrait-solver=next): A bit dubious that we're only registering
1022+
// predefined opaques in the typeck root.
1023+
if infcx.next_trait_solver() && !infcx.tcx.is_typeck_child(body.source.def_id()) {
1024+
checker.register_predefined_opaques_in_new_solver();
1025+
}
1026+
10251027
checker
10261028
}
10271029

Diff for: compiler/rustc_const_eval/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn provide(providers: &mut Providers) {
4949
const_eval::provide(providers);
5050
providers.eval_to_const_value_raw = const_eval::eval_to_const_value_raw_provider;
5151
providers.eval_to_allocation_raw = const_eval::eval_to_allocation_raw_provider;
52-
providers.const_caller_location = util::caller_location::const_caller_location_provider;
52+
providers.hooks.const_caller_location = util::caller_location::const_caller_location_provider;
5353
providers.eval_to_valtree = |tcx, param_env_and_value| {
5454
let (param_env, raw) = param_env_and_value.into_parts();
5555
const_eval::eval_to_valtree(tcx, param_env, raw)

Diff for: compiler/rustc_const_eval/src/util/caller_location.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use rustc_hir::LangItem;
22
use rustc_middle::mir;
3+
use rustc_middle::query::TyCtxtAt;
4+
use rustc_middle::ty;
35
use rustc_middle::ty::layout::LayoutOf;
4-
use rustc_middle::ty::{self, TyCtxt};
5-
use rustc_span::{source_map::DUMMY_SP, symbol::Symbol};
6+
use rustc_span::symbol::Symbol;
67
use rustc_type_ir::Mutability;
78

89
use crate::const_eval::{mk_eval_cx, CanAccessStatics, CompileTimeEvalContext};
@@ -49,11 +50,13 @@ fn alloc_caller_location<'mir, 'tcx>(
4950
}
5051

5152
pub(crate) fn const_caller_location_provider(
52-
tcx: TyCtxt<'_>,
53-
(file, line, col): (Symbol, u32, u32),
53+
tcx: TyCtxtAt<'_>,
54+
file: Symbol,
55+
line: u32,
56+
col: u32,
5457
) -> mir::ConstValue<'_> {
5558
trace!("const_caller_location: {}:{}:{}", file, line, col);
56-
let mut ecx = mk_eval_cx(tcx, DUMMY_SP, ty::ParamEnv::reveal_all(), CanAccessStatics::No);
59+
let mut ecx = mk_eval_cx(tcx.tcx, tcx.span, ty::ParamEnv::reveal_all(), CanAccessStatics::No);
5760

5861
let loc_place = alloc_caller_location(&mut ecx, file, line, col);
5962
if intern_const_alloc_recursive(&mut ecx, InternKind::Constant, &loc_place).is_err() {

Diff for: compiler/rustc_middle/src/hooks/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,7 @@ declare_hooks! {
6767
/// Tries to destructure an `mir::Const` ADT or array into its variant index
6868
/// and its field values. This should only be used for pretty printing.
6969
hook try_destructure_mir_constant_for_diagnostics(val: mir::ConstValue<'tcx>, ty: Ty<'tcx>) -> Option<mir::DestructuredConstant<'tcx>>;
70+
71+
/// Getting a &core::panic::Location referring to a span.
72+
hook const_caller_location(file: rustc_span::Symbol, line: u32, col: u32) -> mir::ConstValue<'tcx>;
7073
}

Diff for: compiler/rustc_middle/src/mir/consts.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -590,12 +590,12 @@ impl<'tcx> TyCtxt<'tcx> {
590590
pub fn span_as_caller_location(self, span: Span) -> ConstValue<'tcx> {
591591
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
592592
let caller = self.sess.source_map().lookup_char_pos(topmost.lo());
593-
self.const_caller_location((
593+
self.const_caller_location(
594594
rustc_span::symbol::Symbol::intern(
595595
&caller.file.name.for_codegen(&self.sess).to_string_lossy(),
596596
),
597597
caller.line as u32,
598598
caller.col_display as u32 + 1,
599-
))
599+
)
600600
}
601601
}

Diff for: compiler/rustc_middle/src/query/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1101,10 +1101,6 @@ rustc_queries! {
11011101
desc { "destructuring type level constant"}
11021102
}
11031103

1104-
query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> mir::ConstValue<'tcx> {
1105-
desc { "getting a &core::panic::Location referring to a span" }
1106-
}
1107-
11081104
// FIXME get rid of this with valtrees
11091105
query lit_to_const(
11101106
key: LitToConstInput<'tcx>

Diff for: compiler/rustc_smir/src/rustc_smir/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
216216
tables.create_def_id(def_id)
217217
}
218218

219+
fn instance_mangled_name(&self, def: InstanceDef) -> String {
220+
let tables = self.0.borrow_mut();
221+
let instance = tables.instances[def];
222+
tables.tcx.symbol_name(instance).name.to_string()
223+
}
224+
219225
fn mono_instance(&self, item: stable_mir::CrateItem) -> stable_mir::mir::mono::Instance {
220226
let mut tables = self.0.borrow_mut();
221227
let def_id = tables[item.0];

Diff for: compiler/stable_mir/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ pub type DefKind = Opaque;
103103
pub type Filename = Opaque;
104104

105105
/// Holds information about an item in the crate.
106-
/// For now, it only stores the item DefId. Use functions inside `rustc_internal` module to
107-
/// use this item.
108106
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
109107
pub struct CrateItem(pub DefId);
110108

@@ -224,6 +222,9 @@ pub trait Context {
224222
/// Get the instance.
225223
fn instance_def_id(&self, instance: InstanceDef) -> DefId;
226224

225+
/// Get the instance mangled name.
226+
fn instance_mangled_name(&self, instance: InstanceDef) -> String;
227+
227228
/// Convert a non-generic crate item into an instance.
228229
/// This function will panic if the item is generic.
229230
fn mono_instance(&self, item: CrateItem) -> Instance;
@@ -259,7 +260,7 @@ pub fn with<R>(f: impl FnOnce(&dyn Context) -> R) -> R {
259260
}
260261

261262
/// A type that provides internal information but that can still be used for debug purpose.
262-
#[derive(Clone)]
263+
#[derive(Clone, Eq, PartialEq)]
263264
pub struct Opaque(String);
264265

265266
impl std::fmt::Display for Opaque {

Diff for: compiler/stable_mir/src/mir.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
mod body;
22
pub mod mono;
3+
pub mod visit;
34

45
pub use body::*;
6+
pub use visit::MirVisitor;

0 commit comments

Comments
 (0)