File tree 3 files changed +44
-1
lines changed
compiler/rustc_trait_selection/src/solve/search_graph
tests/ui/traits/new-solver/overflow
3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -51,9 +51,13 @@ pub(super) struct SearchGraph<'tcx> {
51
51
52
52
impl < ' tcx > SearchGraph < ' tcx > {
53
53
pub ( super ) fn new ( tcx : TyCtxt < ' tcx > , mode : SolverMode ) -> SearchGraph < ' tcx > {
54
+ let local_overflow_limit = {
55
+ let recursion_limit = tcx. recursion_limit ( ) . 0 ;
56
+ if recursion_limit == 0 { 0 } else { recursion_limit. ilog2 ( ) as usize }
57
+ } ;
54
58
Self {
55
59
mode,
56
- local_overflow_limit : tcx . recursion_limit ( ) . 0 . ilog2 ( ) as usize ,
60
+ local_overflow_limit,
57
61
stack : Default :: default ( ) ,
58
62
provisional_cache : ProvisionalCache :: empty ( ) ,
59
63
}
Original file line number Diff line number Diff line change
1
+ //~ ERROR overflow evaluating the requirement `Self well-formed`
2
+ //~| ERROR overflow evaluating the requirement `Self: Trait`
3
+
4
+ // This is a non-regression test for issue #115351, where a recursion limit of 0 caused an ICE.
5
+ // compile-flags: -Ztrait-solver=next --crate-type=lib
6
+ // check-fail
7
+
8
+ #![ recursion_limit = "0" ]
9
+ trait Trait { }
10
+ impl Trait for u32 { }
11
+ //~^ ERROR overflow evaluating the requirement `u32: Trait`
12
+ //~| ERROR overflow evaluating the requirement `u32 well-formed`
Original file line number Diff line number Diff line change
1
+ error[E0275]: overflow evaluating the requirement `Self: Trait`
2
+ |
3
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)
4
+
5
+ error[E0275]: overflow evaluating the requirement `Self well-formed`
6
+ |
7
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)
8
+
9
+ error[E0275]: overflow evaluating the requirement `u32: Trait`
10
+ --> $DIR/recursion-limit-zero-issue-115351.rs:10:16
11
+ |
12
+ LL | impl Trait for u32 {}
13
+ | ^^^
14
+ |
15
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)
16
+
17
+ error[E0275]: overflow evaluating the requirement `u32 well-formed`
18
+ --> $DIR/recursion-limit-zero-issue-115351.rs:10:16
19
+ |
20
+ LL | impl Trait for u32 {}
21
+ | ^^^
22
+ |
23
+ = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)
24
+
25
+ error: aborting due to 4 previous errors
26
+
27
+ For more information about this error, try `rustc --explain E0275`.
You can’t perform that action at this time.
0 commit comments