Commit a9ac706
committed
Auto merge of #149535 - Jamesbarford:chore/refactor-struct-placeholder, r=lcnr
Move `struct Placeholder<T>`
r? ghost
Couple of issues I've encountered;
- `compiler/rustc_infer/src/infer/region_constraints/mod.rs` `GenericKind` I can't call `write!(f, "{p}")` due to error 1. Which looks like I may need to implement `Lift` for `Placeholder`?
- Using the `define_print_and_forward_display!` for `ty::PlaceholderType` caused error 2, as I've moved the struct it no longer exists in the crate. I suspect because I'm not using that macro it causes the error for `GenericKind`
<details>
<summary>Error 1</summary>
```
error: lifetime may not live long enough
--> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:38
|
668 | impl<'tcx> fmt::Display for GenericKind<'tcx> {
| ---- lifetime `'tcx` defined here
...
672 | GenericKind::Placeholder(ref p) => write!(f, "{p}"),
| ^^^^^ assignment requires that `'tcx` must outlive `'static`
|
= note: requirement occurs because of the type `rustc_middle::ty::TyCtxt<'_>`, which makes the generic argument `'_` invariant
= note: the struct `rustc_middle::ty::TyCtxt<'tcx>` is invariant over the parameter `'tcx`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: implementation of `Lift` is not general enough
--> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:38
|
672 | GenericKind::Placeholder(ref p) => write!(f, "{p}"),
| ^^^^^ implementation of `Lift` is not general enough
|
= note: `Lift<rustc_middle::ty::TyCtxt<'0>>` would have to be implemented for the type `rustc_type_ir::Placeholder<rustc_middle::ty::TyCtxt<'_>, BoundTy>`, for any lifetime `'0`...
= note: ...but `Lift<rustc_middle::ty::TyCtxt<'1>>` is actually implemented for the type `rustc_type_ir::Placeholder<rustc_middle::ty::TyCtxt<'1>, BoundTy>`, for some specific lifetime `'1`
error: implementation of `Print` is not general enough
--> compiler/rustc_infer/src/infer/region_constraints/mod.rs:672:38
|
672 | GenericKind::Placeholder(ref p) => write!(f, "{p}"),
| ^^^^^ implementation of `Print` is not general enough
```
</details>
<details>
<summary>Error 2</summary>
```
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
|
3057 | / macro_rules! forward_display_to_print {
3058 | | ($($ty:ty),+) => {
3059 | | // Some of the $ty arguments may not actually use 'tcx
3060 | | $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... |
3072 | | };
3073 | | }
| |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | | ty::Region<'tcx>,
3095 | | Ty<'tcx>,
3096 | | &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | | ty::Const<'tcx>,
3098 | | &'tcx ty::PlaceholderType<'tcx>
| | ------------------------------- `rustc_type_ir::Placeholder` is not defined in the current crate
3099 | | }
| |_- in this macro invocation
|
= note: impl doesn't have any local type before any uncovered type parameters
= note: for more information see https://doc.rust-lang.org/reference/items/implementations.html#orphan-rules
= note: define and implement a trait or new type instead
error: implementation of `Lift` is not general enough
--> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
|
3057 | / macro_rules! forward_display_to_print {
3058 | | ($($ty:ty),+) => {
3059 | | // Some of the $ty arguments may not actually use 'tcx
3060 | | $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Lift` is not general enough
... |
3072 | | };
3073 | | }
| |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | | ty::Region<'tcx>,
3095 | | Ty<'tcx>,
3096 | | &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | | ty::Const<'tcx>,
3098 | | &'tcx ty::PlaceholderType<'tcx>
3099 | | }
| |_- in this macro invocation
|
= note: `Lift<context::TyCtxt<'0>>` would have to be implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'tcx>, BoundTy>`, for any lifetime `'0`...
= note: ...but `Lift<context::TyCtxt<'1>>` is actually implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'1>, BoundTy>`, for some specific lifetime `'1`
error: implementation of `print::Print` is not general enough
--> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
|
3057 | / macro_rules! forward_display_to_print {
3058 | | ($($ty:ty),+) => {
3059 | | // Some of the $ty arguments may not actually use 'tcx
3060 | | $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `print::Print` is not general enough
... |
3072 | | };
3073 | | }
| |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | | ty::Region<'tcx>,
3095 | | Ty<'tcx>,
3096 | | &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | | ty::Const<'tcx>,
3098 | | &'tcx ty::PlaceholderType<'tcx>
3099 | | }
| |_- in this macro invocation
|
= note: `print::Print<'0, print::pretty::FmtPrinter<'a, '0>>` would have to be implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'tcx>, BoundTy>`, for any lifetime `'0`...
= note: ...but `print::Print<'1, print::pretty::FmtPrinter<'a, 'tcx>>` is actually implemented for the type `rustc_type_ir::Placeholder<context::TyCtxt<'1>, BoundTy>`, for some specific lifetime `'1`
error: specializing impl repeats parameter `'tcx`
--> compiler/rustc_middle/src/ty/print/pretty.rs:3060:38
|
3057 | / macro_rules! forward_display_to_print {
3058 | | ($($ty:ty),+) => {
3059 | | // Some of the $ty arguments may not actually use 'tcx
3060 | | $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
... |
3072 | | };
3073 | | }
| |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | | ty::Region<'tcx>,
3095 | | Ty<'tcx>,
3096 | | &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | | ty::Const<'tcx>,
3098 | | &'tcx ty::PlaceholderType<'tcx>
3099 | | }
| |_- in this macro invocation
error[E0277]: the trait bound `&Placeholder<TyCtxt<'tcx>, BoundTy>: Lift<...>` is not satisfied
--> compiler/rustc_middle/src/ty/print/pretty.rs:3064:30
|
3057 | / macro_rules! forward_display_to_print {
3058 | | ($($ty:ty),+) => {
3059 | | // Some of the $ty arguments may not actually use 'tcx
3060 | | $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
... |
3064 | | tcx.lift(*self)
| | ---- ^^^^^ unsatisfied trait bound
| | |
| | required by a bound introduced by this call
... |
3072 | | };
3073 | | }
| |_- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | | ty::Region<'tcx>,
3095 | | Ty<'tcx>,
3096 | | &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | | ty::Const<'tcx>,
3098 | | &'tcx ty::PlaceholderType<'tcx>
3099 | | }
| |_- in this macro invocation
|
= help: the trait `Lift<context::TyCtxt<'_>>` is not implemented for `&rustc_type_ir::Placeholder<context::TyCtxt<'tcx>, BoundTy>`
note: required by a bound in `context::TyCtxt::<'tcx>::lift`
--> compiler/rustc_middle/src/ty/context.rs:1807:20
|
1807 | pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
| ^^^^^^^^^^^^^^^^^^ required by this bound in `TyCtxt::<'tcx>::lift`
= note: the full name for the type has been written to '/home/jambar02/Documents/arm/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/deps/rustc_middle-16e5c44041028d8b.long-type-3843651570422266958.txt'
= note: consider using `--verbose` to print the full type name to the console
help: consider dereferencing here
|
3064 | tcx.lift(**self)
| +
error[E0282]: type annotations needed
--> compiler/rustc_middle/src/ty/print/pretty.rs:3064:21
|
3057 | / macro_rules! forward_display_to_print {
3058 | | ($($ty:ty),+) => {
3059 | | // Some of the $ty arguments may not actually use 'tcx
3060 | | $(#[allow(unused_lifetimes)] impl<'tcx> fmt::Display for $ty {
... |
3064 | |/ tcx.lift(*self)
3065 | || .expect("could not lift for printing")
| ||______________________________________________________________^ cannot infer type
... |
3072 | | };
3073 | | }
| |__- in this expansion of `forward_display_to_print!`
...
3093 | / forward_display_to_print! {
3094 | | ty::Region<'tcx>,
3095 | | Ty<'tcx>,
3096 | | &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
3097 | | ty::Const<'tcx>,
3098 | | &'tcx ty::PlaceholderType<'tcx>
3099 | | }
| |_- in this macro invocation
```
</details>File tree
34 files changed
+326
-251
lines changed- compiler
- rustc_borrowck/src
- diagnostics
- region_infer
- opaque_types
- type_check
- rustc_hir_analysis/src/check
- rustc_infer/src/infer
- canonical
- lexical_region_resolve
- outlives
- region_constraints
- relate
- snapshot
- rustc_middle/src/ty
- print
- rustc_trait_selection/src
- error_reporting/infer
- traits
- rustc_type_ir/src
34 files changed
+326
-251
lines changedLines changed: 19 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
| 155 | + | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
| 172 | + | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
189 | 188 | | |
190 | 189 | | |
191 | 190 | | |
| |||
440 | 439 | | |
441 | 440 | | |
442 | 441 | | |
443 | | - | |
| 442 | + | |
444 | 443 | | |
445 | 444 | | |
446 | 445 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
| 430 | + | |
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
| 664 | + | |
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
686 | | - | |
| 686 | + | |
687 | 687 | | |
688 | 688 | | |
689 | 689 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
453 | 453 | | |
454 | 454 | | |
455 | 455 | | |
456 | | - | |
| 456 | + | |
457 | 457 | | |
458 | 458 | | |
459 | 459 | | |
| |||
481 | 481 | | |
482 | 482 | | |
483 | 483 | | |
484 | | - | |
| 484 | + | |
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
| |||
1311 | 1311 | | |
1312 | 1312 | | |
1313 | 1313 | | |
1314 | | - | |
| 1314 | + | |
1315 | 1315 | | |
1316 | 1316 | | |
1317 | 1317 | | |
| |||
1523 | 1523 | | |
1524 | 1524 | | |
1525 | 1525 | | |
1526 | | - | |
| 1526 | + | |
1527 | 1527 | | |
1528 | 1528 | | |
1529 | 1529 | | |
| |||
1564 | 1564 | | |
1565 | 1565 | | |
1566 | 1566 | | |
1567 | | - | |
| 1567 | + | |
1568 | 1568 | | |
1569 | 1569 | | |
1570 | 1570 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
| 199 | + | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | | - | |
| 205 | + | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
210 | | - | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
211 | 214 | | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
217 | | - | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
| |||
241 | 244 | | |
242 | 245 | | |
243 | 246 | | |
244 | | - | |
| 247 | + | |
245 | 248 | | |
246 | | - | |
| 249 | + | |
247 | 250 | | |
248 | 251 | | |
249 | 252 | | |
| |||
252 | 255 | | |
253 | 256 | | |
254 | 257 | | |
255 | | - | |
| 258 | + | |
256 | 259 | | |
257 | 260 | | |
258 | 261 | | |
259 | 262 | | |
260 | 263 | | |
261 | 264 | | |
262 | | - | |
| 265 | + | |
263 | 266 | | |
264 | 267 | | |
265 | 268 | | |
| |||
274 | 277 | | |
275 | 278 | | |
276 | 279 | | |
277 | | - | |
| 280 | + | |
278 | 281 | | |
279 | 282 | | |
280 | 283 | | |
| |||
293 | 296 | | |
294 | 297 | | |
295 | 298 | | |
296 | | - | |
| 299 | + | |
297 | 300 | | |
298 | 301 | | |
299 | 302 | | |
| |||
359 | 362 | | |
360 | 363 | | |
361 | 364 | | |
362 | | - | |
| 365 | + | |
363 | 366 | | |
364 | 367 | | |
365 | 368 | | |
| |||
368 | 371 | | |
369 | 372 | | |
370 | 373 | | |
371 | | - | |
| 374 | + | |
372 | 375 | | |
373 | 376 | | |
374 | 377 | | |
| |||
386 | 389 | | |
387 | 390 | | |
388 | 391 | | |
389 | | - | |
390 | | - | |
| 392 | + | |
| 393 | + | |
391 | 394 | | |
392 | | - | |
| 395 | + | |
393 | 396 | | |
394 | 397 | | |
395 | | - | |
396 | | - | |
| 398 | + | |
| 399 | + | |
397 | 400 | | |
398 | 401 | | |
399 | 402 | | |
400 | 403 | | |
401 | | - | |
| 404 | + | |
402 | 405 | | |
403 | 406 | | |
404 | 407 | | |
405 | 408 | | |
406 | 409 | | |
407 | | - | |
408 | | - | |
| 410 | + | |
| 411 | + | |
409 | 412 | | |
410 | 413 | | |
411 | 414 | | |
412 | | - | |
| 415 | + | |
413 | 416 | | |
414 | 417 | | |
415 | 418 | | |
416 | 419 | | |
417 | | - | |
418 | | - | |
419 | | - | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
420 | 427 | | |
421 | 428 | | |
422 | 429 | | |
423 | | - | |
424 | | - | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
425 | 436 | | |
426 | 437 | | |
427 | 438 | | |
| |||
441 | 452 | | |
442 | 453 | | |
443 | 454 | | |
444 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
445 | 458 | | |
446 | 459 | | |
447 | 460 | | |
| |||
0 commit comments