Skip to content

Commit

Permalink
Don't ICE when encountering unresolved regions in fully_resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Oct 12, 2023
1 parent 3d575a2 commit 5f1fd77
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
27 changes: 20 additions & 7 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtx
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
use rustc_span::symbol::Symbol;
use rustc_span::Span;
use rustc_span::{Span, DUMMY_SP};

use std::cell::{Cell, RefCell};
use std::fmt;
Expand Down Expand Up @@ -1422,12 +1422,25 @@ impl<'tcx> InferCtxt<'tcx> {
/// This method is idempotent, but it not typically not invoked
/// except during the writeback phase.
pub fn fully_resolve<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> FixupResult<'tcx, T> {
let value = resolve::fully_resolve(self, value);
assert!(
value.as_ref().map_or(true, |value| !value.has_infer()),
"`{value:?}` is not fully resolved"
);
value
match resolve::fully_resolve(self, value) {
Ok(value) => {
if value.has_non_region_infer() {
bug!("`{value:?}` is not fully resolved");
}
if value.has_infer_regions() {
let guar = self
.tcx
.sess
.delay_span_bug(DUMMY_SP, format!("`{value:?}` is not fully resolved"));
Ok(self.tcx.fold_regions(value, |re, _| {
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
}))
} else {
Ok(value)
}
}
Err(e) => Err(e),
}
}

// Instantiates the bound variables in a given binder with fresh inference
Expand Down
2 changes: 1 addition & 1 deletion src/doc/reference
2 changes: 1 addition & 1 deletion src/tools/cargo
Submodule cargo updated 70 files
+5 −35 .github/renovate.json5
+5 −5 .github/workflows/main.yml
+2 −213 CHANGELOG.md
+15 −28 Cargo.lock
+7 −8 Cargo.toml
+1 −2 crates/cargo-platform/Cargo.toml
+0 −1 crates/cargo-test-support/src/compare.rs
+0 −48 crates/cargo-test-support/src/lib.rs
+2 −2 crates/cargo-util/Cargo.toml
+1 −1 crates/crates-io/Cargo.toml
+0 −4 crates/crates-io/lib.rs
+0 −1 crates/home/Cargo.toml
+17 −4 crates/xtask-bump-check/src/xtask.rs
+1 −2 credential/cargo-credential-1password/Cargo.toml
+1 −2 credential/cargo-credential-libsecret/Cargo.toml
+1 −2 credential/cargo-credential-macos-keychain/Cargo.toml
+1 −2 credential/cargo-credential-wincred/Cargo.toml
+2 −2 credential/cargo-credential/Cargo.toml
+9 −23 src/bin/cargo/cli.rs
+8 −1 src/bin/cargo/commands/build.rs
+0 −8 src/cargo/core/compiler/context/mod.rs
+3 −7 src/cargo/core/compiler/future_incompat.rs
+1 −1 src/cargo/core/compiler/layout.rs
+6 −19 src/cargo/core/features.rs
+3 −8 src/cargo/core/package.rs
+15 −19 src/cargo/core/package_id.rs
+1 −4 src/cargo/ops/cargo_add/mod.rs
+1 −4 src/cargo/ops/cargo_generate_lockfile.rs
+3 −39 src/cargo/ops/cargo_install.rs
+2 −3 src/cargo/ops/cargo_package.rs
+0 −1 src/cargo/ops/cargo_uninstall.rs
+8 −60 src/cargo/ops/common_for_install_and_uninstall.rs
+3 −3 src/cargo/ops/lockfile.rs
+1 −2 src/cargo/ops/registry/mod.rs
+1 −2 src/cargo/ops/registry/publish.rs
+1 −4 src/cargo/ops/resolve.rs
+1 −4 src/cargo/sources/git/source.rs
+3 −4 src/cargo/sources/registry/download.rs
+1 −4 src/cargo/sources/registry/http_remote.rs
+1 −2 src/cargo/sources/registry/index.rs
+1 −4 src/cargo/sources/registry/mod.rs
+4 −11 src/cargo/sources/registry/remote.rs
+0 −549 src/cargo/util/cache_lock.rs
+0 −21 src/cargo/util/command_prelude.rs
+85 −36 src/cargo/util/config/mod.rs
+104 −183 src/cargo/util/flock.rs
+0 −1 src/cargo/util/mod.rs
+2,486 −2,488 src/cargo/util/toml/mod.rs
+1 −1 src/cargo/util/toml/targets.rs
+1 −1 src/doc/man/generated_txt/cargo-init.txt
+1 −1 src/doc/man/generated_txt/cargo-new.txt
+1 −1 src/doc/man/includes/options-new.md
+1 −1 src/doc/src/commands/cargo-init.md
+1 −1 src/doc/src/commands/cargo-new.md
+1 −1 src/doc/src/reference/publishing.md
+0 −27 src/doc/src/reference/unstable.md
+1 −1 src/etc/man/cargo-init.1
+1 −1 src/etc/man/cargo-new.1
+1 −51 tests/testsuite/build.rs
+0 −304 tests/testsuite/cache_lock.rs
+1 −1 tests/testsuite/cargo_init/help/stdout.log
+1 −1 tests/testsuite/cargo_new/help/stdout.log
+5 −28 tests/testsuite/config.rs
+2 −2 tests/testsuite/doc.rs
+0 −20 tests/testsuite/install.rs
+0 −1 tests/testsuite/main.rs
+0 −23 tests/testsuite/out_dir.rs
+2 −2 tests/testsuite/package.rs
+3 −5 tests/testsuite/rustdocflags.rs
+1 −4 tests/testsuite/search.rs
21 changes: 21 additions & 0 deletions tests/ui/async-await/in-trait/unconstrained-impl-region.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// edition: 2021

#![feature(async_fn_in_trait)]

pub(crate) trait Inbox<M> {
async fn next(self) -> M;
}

pub(crate) trait Actor: Sized {
type Message;

async fn on_mount(self, _: impl Inbox<Self::Message>);
}

impl<'a> Actor for () {
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
type Message = &'a ();
async fn on_mount(self, _: impl Inbox<&'a ()>) {}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> $DIR/unconstrained-impl-region.rs:15:6
|
LL | impl<'a> Actor for () {
| ^^ unconstrained lifetime parameter

error: aborting due to previous error

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

0 comments on commit 5f1fd77

Please sign in to comment.