Skip to content

Commit df31872

Browse files
committed
Remove one lifetime from QueryKeyStringBuilder
1 parent 88935e0 commit df31872

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

compiler/rustc_query_impl/src/profiling_support.rs

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ impl QueryKeyStringCache {
1919
}
2020
}
2121

22-
struct QueryKeyStringBuilder<'p, 'c, 'tcx> {
22+
struct QueryKeyStringBuilder<'p, 'tcx> {
2323
profiler: &'p SelfProfiler,
2424
tcx: TyCtxt<'tcx>,
25-
string_cache: &'c mut QueryKeyStringCache,
25+
string_cache: &'p mut QueryKeyStringCache,
2626
}
2727

28-
impl<'p, 'c, 'tcx> QueryKeyStringBuilder<'p, 'c, 'tcx> {
28+
impl<'p, 'tcx> QueryKeyStringBuilder<'p, 'tcx> {
2929
fn new(
3030
profiler: &'p SelfProfiler,
3131
tcx: TyCtxt<'tcx>,
32-
string_cache: &'c mut QueryKeyStringCache,
33-
) -> QueryKeyStringBuilder<'p, 'c, 'tcx> {
32+
string_cache: &'p mut QueryKeyStringCache,
33+
) -> QueryKeyStringBuilder<'p, 'tcx> {
3434
QueryKeyStringBuilder { profiler, tcx, string_cache }
3535
}
3636

@@ -99,7 +99,7 @@ impl<'p, 'c, 'tcx> QueryKeyStringBuilder<'p, 'c, 'tcx> {
9999
}
100100

101101
trait IntoSelfProfilingString {
102-
fn to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_, '_>) -> StringId;
102+
fn to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId;
103103
}
104104

105105
// The default implementation of `IntoSelfProfilingString` just uses `Debug`
@@ -109,68 +109,50 @@ trait IntoSelfProfilingString {
109109
impl<T: Debug> IntoSelfProfilingString for T {
110110
default fn to_self_profile_string(
111111
&self,
112-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
112+
builder: &mut QueryKeyStringBuilder<'_, '_>,
113113
) -> StringId {
114114
let s = format!("{:?}", self);
115115
builder.profiler.alloc_string(&s[..])
116116
}
117117
}
118118

119119
impl<T: SpecIntoSelfProfilingString> IntoSelfProfilingString for T {
120-
fn to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_, '_>) -> StringId {
120+
fn to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
121121
self.spec_to_self_profile_string(builder)
122122
}
123123
}
124124

125125
#[rustc_specialization_trait]
126126
trait SpecIntoSelfProfilingString: Debug {
127-
fn spec_to_self_profile_string(
128-
&self,
129-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
130-
) -> StringId;
127+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId;
131128
}
132129

133130
impl SpecIntoSelfProfilingString for DefId {
134-
fn spec_to_self_profile_string(
135-
&self,
136-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
137-
) -> StringId {
131+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
138132
builder.def_id_to_string_id(*self)
139133
}
140134
}
141135

142136
impl SpecIntoSelfProfilingString for CrateNum {
143-
fn spec_to_self_profile_string(
144-
&self,
145-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
146-
) -> StringId {
137+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
147138
builder.def_id_to_string_id(self.as_def_id())
148139
}
149140
}
150141

151142
impl SpecIntoSelfProfilingString for DefIndex {
152-
fn spec_to_self_profile_string(
153-
&self,
154-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
155-
) -> StringId {
143+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
156144
builder.def_id_to_string_id(DefId { krate: LOCAL_CRATE, index: *self })
157145
}
158146
}
159147

160148
impl SpecIntoSelfProfilingString for LocalDefId {
161-
fn spec_to_self_profile_string(
162-
&self,
163-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
164-
) -> StringId {
149+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
165150
builder.def_id_to_string_id(DefId { krate: LOCAL_CRATE, index: self.local_def_index })
166151
}
167152
}
168153

169154
impl<T: SpecIntoSelfProfilingString> SpecIntoSelfProfilingString for WithOptConstParam<T> {
170-
fn spec_to_self_profile_string(
171-
&self,
172-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
173-
) -> StringId {
155+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
174156
// We print `WithOptConstParam` values as tuples to make them shorter
175157
// and more readable, without losing information:
176158
//
@@ -205,10 +187,7 @@ where
205187
T0: SpecIntoSelfProfilingString,
206188
T1: SpecIntoSelfProfilingString,
207189
{
208-
fn spec_to_self_profile_string(
209-
&self,
210-
builder: &mut QueryKeyStringBuilder<'_, '_, '_>,
211-
) -> StringId {
190+
fn spec_to_self_profile_string(&self, builder: &mut QueryKeyStringBuilder<'_, '_>) -> StringId {
212191
let val0 = self.0.to_self_profile_string(builder);
213192
let val1 = self.1.to_self_profile_string(builder);
214193

0 commit comments

Comments
 (0)