about summary refs log tree commit diff
path: root/tests/ui/error-codes
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-05-09 20:49:32 +0200
committerGitHub <noreply@github.com>2023-05-09 20:49:32 +0200
commit363d158cd88b9e01bf92c98176e472b13ecf6bd8 (patch)
treef788ec0c4e448bf91654fb2486f2368c15d31ee2 /tests/ui/error-codes
parent985ea2248977f90df2dcfbaef8281273ccb46fe7 (diff)
parent73b3ce26ecf580aec44e45308e952753f5218e07 (diff)
downloadrust-363d158cd88b9e01bf92c98176e472b13ecf6bd8.tar.gz
rust-363d158cd88b9e01bf92c98176e472b13ecf6bd8.zip
Rollup merge of #111215 - BoxyUwU:resolve_anon_consts_differently, r=cjgillot
Various changes to name resolution of anon consts

Sorry this PR is kind of all over the place ^^'

Fixes #111012

- Rewrites anon const nameres to all go through `fn resolve_anon_const` explicitly instead of `visit_anon_const` to ensure that we do not accidentally resolve anon consts as if they are allowed to use generics when they aren't. Also means that we dont have bits of code for resolving anon consts that will get out of sync (i.e. legacy const generics and resolving path consts that were parsed as type arguments)
- Renames two of the `LifetimeRibKind`, `AnonConst -> ConcreteAnonConst` and `ConstGeneric -> ConstParamTy`
- Noticed while doing this that under `generic_const_exprs` all lifetimes currently get resolved to errors without any error being emitted which was causing a bunch of tests to pass without their bugs having been fixed, incidentally fixed that in this PR and marked those tests as `// known-bug:`. I'm fine to break those since `generic_const_exprs` is a very unstable incomplete feature and this PR _does_ make generic_const_exprs "less broken" as a whole, also I can't be assed to figure out what the underlying causes of all of them are. This PR reopens #77357 #83993
- Changed `generics_of` to stop providing generics and predicates to enum variant discriminant anon consts since those are not allowed to use generic parameters
- Updated the error for non 'static lifetime in const arguments and the error for non 'static lifetime in const param tys to use `derive(Diagnostic)`

I have a vague idea why const-arg-in-const-arg.rs, in-closure.rs and simple.rs have started failing which is unfortunate since these were deliberately made to work, I think lifetime resolution being broken just means this regressed at some point and nobody noticed because the tests were not testing anything :( I'm fine breaking these too for the same reason as the tests for #77357 #83993. I couldn't get `// known-bug` to work for these ICEs and just kept getting different stderr between CI and local `--bless` so I just removed them and will create an issue to track re-adding (and fixing) the bugs if this PR lands.

r? `@cjgillot` cc `@compiler-errors`
Diffstat (limited to 'tests/ui/error-codes')
-rw-r--r--tests/ui/error-codes/E0771.rs2
-rw-r--r--tests/ui/error-codes/E0771.stderr8
2 files changed, 5 insertions, 5 deletions
diff --git a/tests/ui/error-codes/E0771.rs b/tests/ui/error-codes/E0771.rs
index 67e7d106a1f..c0a2e98a7df 100644
--- a/tests/ui/error-codes/E0771.rs
+++ b/tests/ui/error-codes/E0771.rs
@@ -1,7 +1,7 @@
 #![feature(adt_const_params)]
 //~^ WARN the feature `adt_const_params` is incomplete
 
-fn function_with_str<'a, const STRING: &'a str>() {} //~ ERROR E0771
+fn function_with_str<'a, const STRING: &'a str>() {} //~ ERROR E0770
 
 fn main() {
     function_with_str::<"Hello, world!">()
diff --git a/tests/ui/error-codes/E0771.stderr b/tests/ui/error-codes/E0771.stderr
index b759399a940..9450c61c27b 100644
--- a/tests/ui/error-codes/E0771.stderr
+++ b/tests/ui/error-codes/E0771.stderr
@@ -1,10 +1,10 @@
-error[E0771]: use of non-static lifetime `'a` in const generic
+error[E0770]: the type of const parameters must not depend on other generic parameters
   --> $DIR/E0771.rs:4:41
    |
 LL | fn function_with_str<'a, const STRING: &'a str>() {}
-   |                                         ^^
+   |                                         ^^ the type must not depend on the parameter `'a`
    |
-   = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
+   = note: lifetime parameters may not be used in the type of const parameters
 
 warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
   --> $DIR/E0771.rs:1:12
@@ -17,4 +17,4 @@ LL | #![feature(adt_const_params)]
 
 error: aborting due to previous error; 1 warning emitted
 
-For more information about this error, try `rustc --explain E0771`.
+For more information about this error, try `rustc --explain E0770`.