Skip to content

Commit 02110e7

Browse files
committed
Fix compilation for nightly
1 parent e65f243 commit 02110e7

2 files changed

Lines changed: 14 additions & 45 deletions

File tree

src/monomorphize_collector.rs

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_middle::mir::visit::Visitor as MirVisitor;
2222
use rustc_middle::mir::{self, Local, Location};
2323
use rustc_middle::query::TyCtxtAt;
2424
use rustc_middle::ty::adjustment::{CustomCoerceUnsized, PointerCoercion};
25-
use rustc_middle::ty::print::with_no_trimmed_paths;
25+
use rustc_middle::ty::print::{shrunk_instance_name, with_no_trimmed_paths};
2626
use rustc_middle::ty::{
2727
self, GenericArgKind, GenericArgs, GenericParamDefKind, Instance, Ty, TyCtxt, TypeFoldable,
2828
TypeVisitableExt, VtblEntry,
@@ -34,7 +34,6 @@ use rustc_span::source_map::{dummy_spanned, respan, Spanned};
3434
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
3535
use rustc_trait_selection::traits;
3636
use std::ops::Range;
37-
use std::path::PathBuf;
3837

3938
// From rustc_monomorphize/lib.rs
4039
fn custom_coerce_unsize_info<'tcx>(
@@ -126,7 +125,7 @@ pub fn collect_crate_mono_items(
126125
tcx.sess.time("monomorphization_collector_graph_walk", || {
127126
par_for_each_in(roots, |root| {
128127
let mut recursion_depths = DefIdMap::default();
129-
let should_gen = match root {
128+
let should_gen = match *root {
130129
MonoItem::Static(def_id) => {
131130
let instance = Instance::mono(tcx, def_id);
132131
should_codegen_locally(tcx, &instance)
@@ -137,7 +136,7 @@ pub fn collect_crate_mono_items(
137136
if should_gen {
138137
collect_items_rec(
139138
tcx,
140-
dummy_spanned(root),
139+
dummy_spanned(*root),
141140
&visited,
142141
&mut recursion_depths,
143142
recursion_limit,
@@ -358,36 +357,6 @@ fn collect_items_rec<'tcx>(
358357
}
359358
}
360359

361-
/// Format instance name that is already known to be too long for rustc.
362-
/// Show only the first 2 types if it is longer than 32 characters to avoid blasting
363-
/// the user's terminal with thousands of lines of type-name.
364-
///
365-
/// If the type name is longer than before+after, it will be written to a file.
366-
fn shrunk_instance_name<'tcx>(
367-
tcx: TyCtxt<'tcx>,
368-
instance: Instance<'tcx>,
369-
) -> (String, Option<PathBuf>) {
370-
let s = instance.to_string();
371-
372-
// Only use the shrunk version if it's really shorter.
373-
// This also avoids the case where before and after slices overlap.
374-
if s.chars().nth(33).is_some() {
375-
let shrunk = format!("{}", ty::ShortInstance(instance, 4));
376-
if shrunk == s {
377-
return (s, None);
378-
}
379-
380-
let path = tcx
381-
.output_filenames(())
382-
.temp_path_ext("long-type.txt", None);
383-
let written_to_path = std::fs::write(&path, s).ok().map(|_| path);
384-
385-
(shrunk, written_to_path)
386-
} else {
387-
(s, None)
388-
}
389-
}
390-
391360
fn check_recursion_limit<'tcx>(
392361
tcx: TyCtxt<'tcx>,
393362
instance: Instance<'tcx>,

src/preempt_count/annotation.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ impl<'tcx> AnalysisCtxt<'tcx> {
4040
if let Some(adt_def) = self_ty.skip_binder().ty_adt_def()
4141
&& let data = self.def_path(adt_def.did()).data
4242
&& data.len() == 3
43-
&& let DefPathData::TypeNs(Some(task)) = data[0].data
43+
&& let DefPathData::TypeNs(task) = data[0].data
4444
&& task == *crate::symbol::task
45-
&& let DefPathData::TypeNs(Some(wake)) = data[1].data
45+
&& let DefPathData::TypeNs(wake) = data[1].data
4646
&& wake == *crate::symbol::wake
47-
&& let DefPathData::TypeNs(Some(waker)) = data[2].data
47+
&& let DefPathData::TypeNs(waker) = data[2].data
4848
&& waker == *crate::symbol::Waker
4949
{
5050
if fn_name == sym::clone
@@ -65,9 +65,9 @@ impl<'tcx> AnalysisCtxt<'tcx> {
6565
let data = self.def_path(def_id).data;
6666

6767
if data.len() == 3
68-
&& let DefPathData::TypeNs(Some(any)) = data[0].data
68+
&& let DefPathData::TypeNs(any) = data[0].data
6969
&& any == sym::any
70-
&& let DefPathData::TypeNs(Some(any_trait)) = data[1].data
70+
&& let DefPathData::TypeNs(any_trait) = data[1].data
7171
&& any_trait == sym::Any
7272
&& let DefPathData::ValueNs(_any_fn) = data[2].data
7373
{
@@ -80,9 +80,9 @@ impl<'tcx> AnalysisCtxt<'tcx> {
8080
}
8181

8282
if data.len() == 3
83-
&& let DefPathData::TypeNs(Some(error)) = data[0].data
83+
&& let DefPathData::TypeNs(error) = data[0].data
8484
&& error == *crate::symbol::error
85-
&& let DefPathData::TypeNs(Some(error_trait)) = data[1].data
85+
&& let DefPathData::TypeNs(error_trait) = data[1].data
8686
&& error_trait == sym::Error
8787
&& let DefPathData::ValueNs(_any_fn) = data[2].data
8888
{
@@ -95,7 +95,7 @@ impl<'tcx> AnalysisCtxt<'tcx> {
9595
}
9696

9797
if data.len() == 3
98-
&& let DefPathData::TypeNs(Some(fmt)) = data[0].data
98+
&& let DefPathData::TypeNs(fmt) = data[0].data
9999
&& fmt == sym::fmt
100100
&& let DefPathData::TypeNs(_fmt_trait) = data[1].data
101101
&& let DefPathData::ValueNs(fmt_fn) = data[2].data
@@ -109,9 +109,9 @@ impl<'tcx> AnalysisCtxt<'tcx> {
109109
};
110110
}
111111
if data.len() == 3
112-
&& let DefPathData::TypeNs(Some(fmt)) = data[0].data
112+
&& let DefPathData::TypeNs(fmt) = data[0].data
113113
&& fmt == sym::fmt
114-
&& let DefPathData::TypeNs(Some(write)) = data[1].data
114+
&& let DefPathData::TypeNs(write) = data[1].data
115115
&& write == *crate::symbol::Write
116116
&& let DefPathData::ValueNs(_write_fn) = data[2].data
117117
{
@@ -123,7 +123,7 @@ impl<'tcx> AnalysisCtxt<'tcx> {
123123
};
124124
}
125125
if data.len() == 2
126-
&& let DefPathData::TypeNs(Some(fmt)) = data[0].data
126+
&& let DefPathData::TypeNs(fmt) = data[0].data
127127
&& fmt == sym::fmt
128128
&& let DefPathData::ValueNs(write) = data[1].data
129129
&& write == *crate::symbol::write

0 commit comments

Comments
 (0)