Don't print newlines in APITs
This commit is contained in:
parent
096309e6dc
commit
4692375389
3 changed files with 54 additions and 1 deletions
|
@ -1425,7 +1425,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
DefPathData::ImplTrait,
|
DefPathData::ImplTrait,
|
||||||
span,
|
span,
|
||||||
);
|
);
|
||||||
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
|
|
||||||
|
// HACK: pprust breaks strings with newlines when the type
|
||||||
|
// gets too long. We don't want these to show up in compiler
|
||||||
|
// output or built artifacts, so replace them here...
|
||||||
|
// Perhaps we should instead format APITs more robustly.
|
||||||
|
let ident = Ident::from_str_and_span(
|
||||||
|
&pprust::ty_to_string(t).replace('\n', " "),
|
||||||
|
span,
|
||||||
|
);
|
||||||
|
|
||||||
let (param, bounds, path) = self.lower_universal_param_and_bounds(
|
let (param, bounds, path) = self.lower_universal_param_and_bounds(
|
||||||
*def_node_id,
|
*def_node_id,
|
||||||
span,
|
span,
|
||||||
|
|
22
tests/ui/impl-trait/arg-position-impl-trait-too-long.rs
Normal file
22
tests/ui/impl-trait/arg-position-impl-trait-too-long.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
struct Header;
|
||||||
|
struct EntryMetadata;
|
||||||
|
struct Entry<A, B>(A, B);
|
||||||
|
|
||||||
|
trait Tr {
|
||||||
|
type EncodedKey;
|
||||||
|
type EncodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test<C: Tr, R>(
|
||||||
|
// This APIT is long, however we shouldn't render the type name with a newline in it.
|
||||||
|
y: impl FnOnce(
|
||||||
|
&mut Header,
|
||||||
|
&mut [EntryMetadata],
|
||||||
|
&mut [Entry<C::EncodedKey, C::EncodedValue>]
|
||||||
|
) -> R,
|
||||||
|
) {
|
||||||
|
let () = y;
|
||||||
|
//~^ ERROR mismatched types
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
22
tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
Normal file
22
tests/ui/impl-trait/arg-position-impl-trait-too-long.stderr
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/arg-position-impl-trait-too-long.rs:18:9
|
||||||
|
|
|
||||||
|
LL | y: impl FnOnce(
|
||||||
|
| ________-
|
||||||
|
LL | | &mut Header,
|
||||||
|
LL | | &mut [EntryMetadata],
|
||||||
|
LL | | &mut [Entry<C::EncodedKey, C::EncodedValue>]
|
||||||
|
LL | | ) -> R,
|
||||||
|
| |__________- this type parameter
|
||||||
|
LL | ) {
|
||||||
|
LL | let () = y;
|
||||||
|
| ^^ - this expression has type `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`
|
||||||
|
| |
|
||||||
|
| expected type parameter `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`, found `()`
|
||||||
|
|
|
||||||
|
= note: expected type parameter `impl FnOnce(&mut Header, &mut [EntryMetadata], &mut [Entry<C::EncodedKey, C::EncodedValue>]) -> R`
|
||||||
|
found unit type `()`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Add table
Add a link
Reference in a new issue