about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-11-02 01:37:26 -0500
committerAaron Hill <aa1ronham@gmail.com>2020-11-02 01:43:25 -0500
commit6c1f15fa81be5f89cd7af7f7e73012967b4e673a (patch)
tree255f70d53542ab18d9f63633b8c9f7b8f57a21a4 /src
parentd8ef0d7757742862116c455345120dcbfb7e74e0 (diff)
downloadrust-6c1f15fa81be5f89cd7af7f7e73012967b4e673a.tar.gz
rust-6c1f15fa81be5f89cd7af7f7e73012967b4e673a.zip
Fix ICE when a future-incompat-report has its command-line level capped
Fixes #78660

With PR https://github.com/rust-lang/rust/pull/75534 merged, we now run
more lint-related code for future-incompat-report, even when their final
level is Allow. Some lint-related code was not expecting `Level::Allow`,
and had an explicit panic.

This PR explicitly tracks the lint level set on the command line before
`--cap-lints` is applied. This is used to emit a more precise error
note (e.g. we don't say that `-W lint-name` was specified on the
command line just because a lint was capped to Warn). As a result, we
can now correctly emit a note that `-A` was used if we got
`Level::Allow` from the command line (before the cap is applied).
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/lint/issue-78660-cap-lints-future-compat.rs10
-rw-r--r--src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr11
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs b/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs
new file mode 100644
index 00000000000..4d98f0ad62d
--- /dev/null
+++ b/src/test/ui/lint/issue-78660-cap-lints-future-compat.rs
@@ -0,0 +1,10 @@
+// compile-flags: -D warnings --cap-lints allow
+// check-pass
+
+// Regression test for issue #78660
+// Tests that we don't ICE when a future-incompat-report lint has
+// has a command-line source, but is capped to allow
+
+fn main() {
+    ["hi"].into_iter();
+}
diff --git a/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr b/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr
new file mode 100644
index 00000000000..79958ba90d4
--- /dev/null
+++ b/src/test/ui/lint/issue-78660-cap-lints-future-compat.stderr
@@ -0,0 +1,11 @@
+Future incompatibility report: Future breakage date: None, diagnostic:
+warning: this method call currently resolves to `<&[T; N] as IntoIterator>::into_iter` (due to autoref coercions), but that might change in the future when `IntoIterator` impls for arrays are added.
+  --> $DIR/issue-78660-cap-lints-future-compat.rs:9:12
+   |
+LL |     ["hi"].into_iter();
+   |            ^^^^^^^^^ help: use `.iter()` instead of `.into_iter()` to avoid ambiguity: `iter`
+   |
+   = note: `-D array-into-iter` implied by `-D warnings`
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #66145 <https://github.com/rust-lang/rust/issues/66145>
+