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

new solver: handle edge case of a recursion limit of 0 #115355

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl<'tcx> SearchGraph<'tcx> {
pub(super) fn new(tcx: TyCtxt<'tcx>, mode: SolverMode) -> SearchGraph<'tcx> {
Self {
mode,
local_overflow_limit: tcx.recursion_limit().0.ilog2() as usize,
local_overflow_limit: tcx.recursion_limit().0.checked_ilog2().unwrap_or(0) as usize,
stack: Default::default(),
provisional_cache: ProvisionalCache::empty(),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//~ ERROR overflow evaluating the requirement `Self well-formed`
//~| ERROR overflow evaluating the requirement `Self: Trait`

// This is a non-regression test for issue #115351, where a recursion limit of 0 caused an ICE.
// compile-flags: -Ztrait-solver=next --crate-type=lib
// check-fail

#![recursion_limit = "0"]
trait Trait {}
impl Trait for u32 {}
//~^ ERROR overflow evaluating the requirement `u32: Trait`
//~| ERROR overflow evaluating the requirement `u32 well-formed`
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0275]: overflow evaluating the requirement `Self: Trait`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)

error[E0275]: overflow evaluating the requirement `Self well-formed`
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)

error[E0275]: overflow evaluating the requirement `u32: Trait`
--> $DIR/recursion-limit-zero-issue-115351.rs:10:16
|
LL | impl Trait for u32 {}
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)

error[E0275]: overflow evaluating the requirement `u32 well-formed`
--> $DIR/recursion-limit-zero-issue-115351.rs:10:16
|
LL | impl Trait for u32 {}
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`recursion_limit_zero_issue_115351`)

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0275`.