about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_metadata/src/rmeta/encoder.rs6
-rw-r--r--tests/ui/consts/auxiliary/foreign-generic-mismatch-with-const-arg.rs1
-rw-r--r--tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs8
-rw-r--r--tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr21
-rw-r--r--tests/ui/generics/auxiliary/foreign-generic-mismatch.rs3
-rw-r--r--tests/ui/generics/foreign-generic-mismatch.rs10
-rw-r--r--tests/ui/generics/foreign-generic-mismatch.stderr35
7 files changed, 50 insertions, 34 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 14c1b9d5589..17a9daee7d0 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -824,6 +824,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
         | DefKind::AssocTy
         | DefKind::TyParam
         | DefKind::ConstParam
+        | DefKind::LifetimeParam
         | DefKind::Fn
         | DefKind::Const
         | DefKind::Static(_)
@@ -840,10 +841,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
         | DefKind::Impl { .. }
         | DefKind::Closure
         | DefKind::Generator => true,
-        DefKind::ForeignMod
-        | DefKind::ImplTraitPlaceholder
-        | DefKind::LifetimeParam
-        | DefKind::GlobalAsm => false,
+        DefKind::ForeignMod | DefKind::ImplTraitPlaceholder | DefKind::GlobalAsm => false,
     }
 }
 
diff --git a/tests/ui/consts/auxiliary/foreign-generic-mismatch-with-const-arg.rs b/tests/ui/consts/auxiliary/foreign-generic-mismatch-with-const-arg.rs
deleted file mode 100644
index 85b0c6c9df8..00000000000
--- a/tests/ui/consts/auxiliary/foreign-generic-mismatch-with-const-arg.rs
+++ /dev/null
@@ -1 +0,0 @@
-pub fn test<const N: usize, T>() {}
diff --git a/tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs b/tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs
deleted file mode 100644
index 7590abbd827..00000000000
--- a/tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-// aux-build: foreign-generic-mismatch-with-const-arg.rs
-
-extern crate foreign_generic_mismatch_with_const_arg;
-
-fn main() {
-    foreign_generic_mismatch_with_const_arg::test::<1>();
-    //~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied
-}
diff --git a/tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr b/tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr
deleted file mode 100644
index 4cc03a20514..00000000000
--- a/tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
-  --> $DIR/foreign-generic-mismatch-with-const-arg.rs:6:46
-   |
-LL |     foreign_generic_mismatch_with_const_arg::test::<1>();
-   |                                              ^^^^   - supplied 1 generic argument
-   |                                              |
-   |                                              expected 2 generic arguments
-   |
-note: function defined here, with 2 generic parameters: `N`, `T`
-  --> $DIR/auxiliary/foreign-generic-mismatch-with-const-arg.rs:1:8
-   |
-LL | pub fn test<const N: usize, T>() {}
-   |        ^^^^ --------------  -
-help: add missing generic argument
-   |
-LL |     foreign_generic_mismatch_with_const_arg::test::<1, T>();
-   |                                                      +++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0107`.
diff --git a/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs b/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs
new file mode 100644
index 00000000000..d89c1e03688
--- /dev/null
+++ b/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs
@@ -0,0 +1,3 @@
+pub fn const_arg<const N: usize, T>() {}
+
+pub fn lt_arg<'a: 'a>() {}
diff --git a/tests/ui/generics/foreign-generic-mismatch.rs b/tests/ui/generics/foreign-generic-mismatch.rs
new file mode 100644
index 00000000000..403fd73d7df
--- /dev/null
+++ b/tests/ui/generics/foreign-generic-mismatch.rs
@@ -0,0 +1,10 @@
+// aux-build: foreign-generic-mismatch.rs
+
+extern crate foreign_generic_mismatch;
+
+fn main() {
+    foreign_generic_mismatch::const_arg::<()>();
+    //~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied
+    foreign_generic_mismatch::lt_arg::<'static, 'static>();
+    //~^ ERROR function takes 1 lifetime argument but 2 lifetime arguments were supplied
+}
diff --git a/tests/ui/generics/foreign-generic-mismatch.stderr b/tests/ui/generics/foreign-generic-mismatch.stderr
new file mode 100644
index 00000000000..5322b3f919d
--- /dev/null
+++ b/tests/ui/generics/foreign-generic-mismatch.stderr
@@ -0,0 +1,35 @@
+error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
+  --> $DIR/foreign-generic-mismatch.rs:6:31
+   |
+LL |     foreign_generic_mismatch::const_arg::<()>();
+   |                               ^^^^^^^^^   -- supplied 1 generic argument
+   |                               |
+   |                               expected 2 generic arguments
+   |
+note: function defined here, with 2 generic parameters: `N`, `T`
+  --> $DIR/auxiliary/foreign-generic-mismatch.rs:1:8
+   |
+LL | pub fn const_arg<const N: usize, T>() {}
+   |        ^^^^^^^^^ --------------  -
+help: add missing generic argument
+   |
+LL |     foreign_generic_mismatch::const_arg::<(), T>();
+   |                                             +++
+
+error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were supplied
+  --> $DIR/foreign-generic-mismatch.rs:8:31
+   |
+LL |     foreign_generic_mismatch::lt_arg::<'static, 'static>();
+   |                               ^^^^^^            ------- help: remove this lifetime argument
+   |                               |
+   |                               expected 1 lifetime argument
+   |
+note: function defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/auxiliary/foreign-generic-mismatch.rs:3:8
+   |
+LL | pub fn lt_arg<'a: 'a>() {}
+   |        ^^^^^^ --
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0107`.