Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type_length_limit example. #1026

Merged
merged 1 commit into from
May 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/attributes/limits.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,14 @@ to set the limit based on the number of type substitutions.

> Note: The default in `rustc` is 1048576.

<!-- This code should fail to compile. Unfortunately rustdoc's `compile_fail`
stops after analysis phase, and this error is generated after that. So
this needs to be `ignore` for now. -->

```rust,compile_fail,ignore
#![type_length_limit = "8"]
```rust,compile_fail
#![type_length_limit = "4"]

fn f<T>(x: T) {}

// This fails to compile because monomorphizing to
// `f::<(i32, i32, i32, i32, i32, i32, i32, i32, i32)>>` requires more
// than 8 type elements.
f((1, 2, 3, 4, 5, 6, 7, 8, 9));
// `f::<((((i32,), i32), i32), i32)>` requires more than 4 type elements.
f(((((1,), 2), 3), 4));
```

[_MetaNameValueStr_]: ../attributes.md#meta-item-attribute-syntax
Expand Down