diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-12-11 23:36:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-11 23:36:45 +0100 |
| commit | aa7b5b32e3463fc21468073ca3a75e2c3617b179 (patch) | |
| tree | 435f1c886c4dc21d452bc02de355c3abd5f1e939 | |
| parent | 668976b80ad6ca3bfbc0cddf9e676b289c07fc49 (diff) | |
| parent | 64ad337a3bc50f7381f1afc1a0fc7006a8ad7f53 (diff) | |
| download | rust-aa7b5b32e3463fc21468073ca3a75e2c3617b179.tar.gz rust-aa7b5b32e3463fc21468073ca3a75e2c3617b179.zip | |
Rollup merge of #105283 - compiler-errors:ty-var-in-hir-wfcheck, r=nagisa
Don't call `diagnostic_hir_wf_check` query if we have infer variables Fixes #105260
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs | 1 | ||||
| -rw-r--r-- | src/test/ui/wf/hir-wf-canonicalized.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/wf/hir-wf-canonicalized.stderr | 32 |
3 files changed, 51 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index dda7b2b2fa5..82449a36b1d 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -597,6 +597,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { // can get a better error message by performing HIR-based well-formedness checking. if let ObligationCauseCode::WellFormed(Some(wf_loc)) = root_obligation.cause.code().peel_derives() + && !obligation.predicate.has_non_region_infer() { if let Some(cause) = self .tcx diff --git a/src/test/ui/wf/hir-wf-canonicalized.rs b/src/test/ui/wf/hir-wf-canonicalized.rs new file mode 100644 index 00000000000..bdb84409d00 --- /dev/null +++ b/src/test/ui/wf/hir-wf-canonicalized.rs @@ -0,0 +1,18 @@ +// incremental + +trait Foo { + type V; +} + +trait Callback<T: Foo>: Fn(&Bar<'_, T>, &T::V) {} + +struct Bar<'a, T> { + callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>, + //~^ ERROR the trait bound `Bar<'a, T>: Foo` is not satisfied + //~| ERROR the trait bound `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static): Foo` is not satisfied + //~| ERROR the size for values of type `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)` cannot be known at compilation time +} + +impl<T: Foo> Bar<'_, Bar<'_, T>> {} + +fn main() {} diff --git a/src/test/ui/wf/hir-wf-canonicalized.stderr b/src/test/ui/wf/hir-wf-canonicalized.stderr new file mode 100644 index 00000000000..9fd0f9c81eb --- /dev/null +++ b/src/test/ui/wf/hir-wf-canonicalized.stderr @@ -0,0 +1,32 @@ +error[E0277]: the trait bound `Bar<'a, T>: Foo` is not satisfied + --> $DIR/hir-wf-canonicalized.rs:10:15 + | +LL | callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bar<'a, T>` + +error[E0277]: the trait bound `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static): Foo` is not satisfied + --> $DIR/hir-wf-canonicalized.rs:10:15 + | +LL | callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)` + +error[E0277]: the size for values of type `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)` cannot be known at compilation time + --> $DIR/hir-wf-canonicalized.rs:10:15 + | +LL | callback: Box<dyn Callback<dyn Callback<Bar<'a, T>>>>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Callback<Bar<'a, T>, for<'b, 'c, 'd> Output = ()> + 'static)` +note: required by a bound in `Bar` + --> $DIR/hir-wf-canonicalized.rs:9:16 + | +LL | struct Bar<'a, T> { + | ^ required by this bound in `Bar` +help: consider relaxing the implicit `Sized` restriction + | +LL | struct Bar<'a, T: ?Sized> { + | ++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. |
