Skip to content

Commit 5d2abbb

Browse files
add test of the new attr and fix the breaking test
Signed-off-by: Vincenzo Palazzo <[email protected]>
1 parent 469c641 commit 5d2abbb

File tree

6 files changed

+51
-3
lines changed

6 files changed

+51
-3
lines changed

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2040,7 +2040,7 @@ impl ExpansionConfig<'_> {
20402040
crate_name,
20412041
features,
20422042
recursion_limit: Limit::new(1024),
2043-
expansion_growth_limit: Limit::new(1500),
2043+
expansion_growth_limit: Limit::new(6000),
20442044
trace_mac: false,
20452045
should_test: false,
20462046
span_debug: false,

compiler/rustc_middle/src/middle/limits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn get_recursion_limit(krate_attrs: &[Attribute], sess: &Session) -> Limit {
4242
}
4343

4444
pub fn get_expansion_growth_limit(krate_attrs: &[Attribute], sess: &Session) -> Limit {
45-
get_limit(krate_attrs, sess, sym::expansion_growth_limit, 1500)
45+
get_limit(krate_attrs, sess, sym::expansion_growth_limit, 6000)
4646
}
4747

4848
fn get_limit(krate_attrs: &[Attribute], sess: &Session, name: Symbol, default: usize) -> Limit {

compiler/rustc_session/src/session.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ pub struct Limits {
130130
pub move_size_limit: Limit,
131131
/// The maximum length of types during monomorphization.
132132
pub type_length_limit: Limit,
133-
/// FIXME(vincenzopalazzo) add docs
133+
/// The maximum blocks a const expression can evaluate.
134+
pub const_eval_limit: Limit,
135+
/// The maximum tokens limit for potentially infinitely resolving
136+
/// a macros that add infinite tokens inside the buffer.
134137
pub expansion_growth_limit: Limit,
135138
}
136139

tests/ui/limits/issue-95698.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// check-fail
2+
3+
/// issue #95698
4+
macro_rules! from_cow_impls {
5+
($( $from: ty ),+ $(,)? ) => {
6+
// recursion call
7+
from_cow_impls!(
8+
$( $from, Cow::from ),+
9+
);
10+
//~^^^ ERROR expansion grow limit reached while expanding `from_cow_impls!`
11+
};
12+
13+
($( $from: ty, $normalizer: expr ),+ $(,)? ) => {
14+
$( impl<'a> From<$from> for LhsValue<'a> {
15+
fn from(val: $from) -> Self {
16+
LhsValue::Bytes($normalizer(val))
17+
}
18+
} )+
19+
};
20+
}
21+
22+
from_cow_impls!(
23+
&'a [u8], /*callback,*/
24+
Vec<u8>, /*callback,*/
25+
);

tests/ui/limits/issue-95698.stderr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error: expansion grow limit reached while expanding `from_cow_impls!`
2+
--> $DIR/issue-95698.rs:7:9
3+
|
4+
LL | / from_cow_impls!(
5+
LL | | $( $from, Cow::from ),+
6+
LL | | );
7+
| |_________^
8+
...
9+
LL | / from_cow_impls!(
10+
LL | | &'a [u8], /*callback,*/
11+
LL | | Vec<u8>, /*callback,*/
12+
LL | | );
13+
| |_- in this macro invocation
14+
|
15+
= help: consider increasing the expansion grow limit by adding a `#![expansion_growth_limit = "12000"]` attribute to your crate (`issue_95698`)
16+
= note: this error originates in the macro `from_cow_impls` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error: aborting due to previous error
19+

tests/ui/mir/issue-29227.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![expansion_growth_limit = "16000"]
12
// run-pass
23
// ignore-tidy-linelength
34

0 commit comments

Comments
 (0)