about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-04-13 14:37:36 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2022-05-24 15:37:33 +0000
commit31e0bf7891ca688bd550753f749e1f03db597675 (patch)
tree631669b938da30947b1cf245f702f68040432bb0
parentb2eba058e6e1c698723e47074561a30b50b5fa7a (diff)
downloadrust-31e0bf7891ca688bd550753f749e1f03db597675.tar.gz
rust-31e0bf7891ca688bd550753f749e1f03db597675.zip
trait selection errors should poison the typeck results, too, so that const eval can avoid running at all
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs1
-rw-r--r--src/test/ui/consts/issue-91434.rs1
-rw-r--r--src/test/ui/consts/issue-91434.stderr10
-rw-r--r--src/test/ui/consts/nested_erroneous_ctfe.rs4
-rw-r--r--src/test/ui/consts/nested_erroneous_ctfe.stderr12
5 files changed, 18 insertions, 10 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 266fcc777ef..0cefa802c85 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -273,6 +273,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
         error: &SelectionError<'tcx>,
         fallback_has_occurred: bool,
     ) {
+        self.set_tainted_by_errors();
         let tcx = self.tcx;
         let mut span = obligation.cause.span;
 
diff --git a/src/test/ui/consts/issue-91434.rs b/src/test/ui/consts/issue-91434.rs
index fc7731291b3..001dc708f89 100644
--- a/src/test/ui/consts/issue-91434.rs
+++ b/src/test/ui/consts/issue-91434.rs
@@ -2,5 +2,4 @@ fn main() {
     [9; [[9E; h]]];
     //~^ ERROR: expected at least one digit in exponent
     //~| ERROR: cannot find value `h` in this scope [E0425]
-    //~| ERROR: constant expression depends on a generic parameter
 }
diff --git a/src/test/ui/consts/issue-91434.stderr b/src/test/ui/consts/issue-91434.stderr
index 9d3fe5f2016..08d3ad77053 100644
--- a/src/test/ui/consts/issue-91434.stderr
+++ b/src/test/ui/consts/issue-91434.stderr
@@ -10,14 +10,6 @@ error[E0425]: cannot find value `h` in this scope
 LL |     [9; [[9E; h]]];
    |               ^ not found in this scope
 
-error: constant expression depends on a generic parameter
-  --> $DIR/issue-91434.rs:2:9
-   |
-LL |     [9; [[9E; h]]];
-   |         ^^^^^^^^^
-   |
-   = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/consts/nested_erroneous_ctfe.rs b/src/test/ui/consts/nested_erroneous_ctfe.rs
new file mode 100644
index 00000000000..1ec271401fb
--- /dev/null
+++ b/src/test/ui/consts/nested_erroneous_ctfe.rs
@@ -0,0 +1,4 @@
+fn main() {
+    [9; || [9; []]];
+    //~^ ERROR: mismatched types
+}
diff --git a/src/test/ui/consts/nested_erroneous_ctfe.stderr b/src/test/ui/consts/nested_erroneous_ctfe.stderr
new file mode 100644
index 00000000000..d579a54e983
--- /dev/null
+++ b/src/test/ui/consts/nested_erroneous_ctfe.stderr
@@ -0,0 +1,12 @@
+error[E0308]: mismatched types
+  --> $DIR/nested_erroneous_ctfe.rs:2:16
+   |
+LL |     [9; || [9; []]];
+   |                ^^ expected `usize`, found array of 0 elements
+   |
+   = note: expected type `usize`
+             found array `[_; 0]`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.