mirror of
https://github.com/rust-lang/rust.git
synced 2025-09-28 21:55:31 +00:00

`TyCtxt::short_string` ensures that user visible type paths aren't overwhelming on the terminal output, and properly saves the long name to disk as a side-channel. We already use these throughout the compiler and have been using them as needed when users find cases where the output is verbose. This is a proactive search of some cases to use `short_string`. We add support for shortening the path of "trait path only". Every manual use of `short_string` is a bright marker that that error should be using structured diagnostics instead (as they have proper handling of long types without the maintainer having to think abou tthem). When we don't actually print out a shortened type we don't need the "use `--verbose`" note. On E0599 show type identity to avoid expanding the receiver's generic parameters. Unify wording on `long_ty_path` everywhere.
28 lines
655 B
Rust
28 lines
655 B
Rust
// Issue 22443: Reject code using non-regular types that would
|
|
// otherwise cause dropck to loop infinitely.
|
|
//@ compile-flags: -Zwrite-long-types-to-disk=yes
|
|
|
|
use std::marker::PhantomData;
|
|
|
|
struct Digit<T> {
|
|
elem: T
|
|
}
|
|
|
|
struct Node<T:'static> { m: PhantomData<&'static T> }
|
|
|
|
|
|
enum FingerTree<T:'static> {
|
|
Single(T),
|
|
// Bug report said Digit after Box would stack overflow (versus
|
|
// Digit before Box; see dropck_no_diverge_on_nonregular_2).
|
|
Deep(
|
|
Box<FingerTree<Node<T>>>,
|
|
Digit<T>,
|
|
)
|
|
}
|
|
|
|
fn main() {
|
|
let ft = //~ ERROR overflow while adding drop-check rules for `FingerTree
|
|
FingerTree::Single(1);
|
|
}
|