mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-04 03:07:25 +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.
49 lines
1.0 KiB
Rust
49 lines
1.0 KiB
Rust
//@ compile-flags: -Zwrite-long-types-to-disk=yes
|
|
// Fixes #110131
|
|
//
|
|
// The issue is that we were constructing an `ImplDerived` cause code for the
|
|
// `&'a T: IntoIterator<Item = &'a u8>` obligation for `Helper::new`, which is
|
|
// incorrect because derived obligations are only expected to come from *traits*.
|
|
|
|
struct SeqBuffer<'a, T>
|
|
where
|
|
&'a T: IntoIterator<Item = &'a u8>,
|
|
{
|
|
iter: <&'a T as IntoIterator>::IntoIter,
|
|
}
|
|
|
|
struct Helper<'a, T>
|
|
where
|
|
&'a T: IntoIterator<Item = &'a u8>,
|
|
{
|
|
buf: SeqBuffer<'a, T>,
|
|
}
|
|
|
|
impl<'a, T> Helper<'a, T>
|
|
where
|
|
&'a T: IntoIterator<Item = &'a u8>,
|
|
{
|
|
fn new(sq: &'a T) -> Self {
|
|
loop {}
|
|
}
|
|
}
|
|
|
|
struct BitReaderWrapper<T>(T);
|
|
|
|
impl<'a, T> IntoIterator for &'a BitReaderWrapper<T>
|
|
where
|
|
&'a T: IntoIterator<Item = &'a u8>,
|
|
{
|
|
type Item = u32;
|
|
|
|
type IntoIter = Helper<'a, T>;
|
|
//~^ ERROR `Helper<'a, T>` is not an iterator
|
|
|
|
fn into_iter(self) -> Self::IntoIter {
|
|
Helper::new(&self.0)
|
|
//~^ ERROR overflow evaluating the requirement `&_: IntoIterator`
|
|
}
|
|
}
|
|
|
|
fn main() {}
|