More Typefoldable/TypeVisitable cleanups#110838
Conversation
Because the derived versions are good enough.
Typefoldable/TypeVisitable cleanups
There was a problem hiding this comment.
could make this a negative impl 🤔
There was a problem hiding this comment.
It doesn't work because we actually have two impls:
error[E0751]: found both positive and negative implementation of trait `rustc_type_ir::fold::TypeFoldable<context::TyCtxt<'_>>` for type `&[InlineAsmTemplatePiece]`:
--> compiler/rustc_middle/src/mir/type_foldable.rs:31:1
|
31 | impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [InlineAsmTemplatePiece] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ positive implementation here
|
= note: negative implementation in crate `rustc_type_ir`
error[E0751]: found both positive and negative implementation of trait `rustc_type_ir::fold::TypeFoldable<context::TyCtxt<'_>>` for type `&[rustc_span::Span]`:
--> compiler/rustc_middle/src/mir/type_foldable.rs:40:1
|
40 | impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for &'tcx [Span] {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ positive implementation here
|
= note: negative implementation in crate `rustc_type_ir`
It was these two impls that triggered me to write this commit, because I wondered why there weren't corresponding TypeVisitable impls.
There was a problem hiding this comment.
that's unfortunate 😅 these impls should be unnecessary with #108214 which I am really looking forward to, but until then I guess this is fine.
There was a problem hiding this comment.
Now I realize there is a better way to do this. I have changed the third commit, please take a look :)
|
@bors r+ rollup |
|
📌 Commit 69cbe914f8e6080bba536a7bae3025955c759a7e has been approved by It is now in the queue for this repository. |
69cbe91 to
a9f6cde
Compare
There was a problem hiding this comment.
isn't that dangerous because we just ignore T here? I would have expected the impl to require T: !TypeFoldable<I> to check that it is trivial.
There was a problem hiding this comment.
Yeah, what is this impl used for? This is certainly not the right implementation (but arguably there should not be one).
There was a problem hiding this comment.
It is used for the impls that the third commit removes: &'tcx [InlineAsmTemplatePiece] and &'tcx [Span]. These are things carried over from HIR, and treated as constants.
The negative bounds suggestion is a good one, except that they're not supported?
error: negative bounds are not supported
--> compiler/rustc_type_ir/src/structural_impls.rs:146:20
|
146 | impl<I: Interner, T: !TypeFoldable<I>> TypeFoldable<I> for &[T] {
| ^^^^^^^^^^^^^^^^^^ negative bounds are not supported
At this point I think I'll go back to the original commit which just added a comment explaining why TypeFoldable isn't impl'd for &[T].
a9f6cde to
4b85aa9
Compare
…cleanups, r=lcnr More `Typefoldable`/`TypeVisitable` cleanups r? `@lcnr`
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#105745 (docs(std): clarify remove_dir_all errors) - rust-lang#106456 (Correct `std::prelude` comment) - rust-lang#106599 (Change memory ordering in System wrapper example) - rust-lang#110838 (More `Typefoldable`/`TypeVisitable` cleanups) - rust-lang#110851 (compiletest: emit assembly-output header in error) - rust-lang#110853 (compiletest: add bpf-linker assembly support) - rust-lang#110878 (Add `known-bug` tests for 4 unsound issues) - rust-lang#110886 (`DepGraph` cleanups) - rust-lang#110905 (Remove invalid value from scraped-examples.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
r? @lcnr