Skip to content

Commit 24c2c07

Browse files
Encode lifetime param spans too
1 parent 0fd50f3 commit 24c2c07

7 files changed

+50
-34
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
824824
| DefKind::AssocTy
825825
| DefKind::TyParam
826826
| DefKind::ConstParam
827+
| DefKind::LifetimeParam
827828
| DefKind::Fn
828829
| DefKind::Const
829830
| DefKind::Static(_)
@@ -840,10 +841,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
840841
| DefKind::Impl { .. }
841842
| DefKind::Closure
842843
| DefKind::Generator => true,
843-
DefKind::ForeignMod
844-
| DefKind::ImplTraitPlaceholder
845-
| DefKind::LifetimeParam
846-
| DefKind::GlobalAsm => false,
844+
DefKind::ForeignMod | DefKind::ImplTraitPlaceholder | DefKind::GlobalAsm => false,
847845
}
848846
}
849847

tests/ui/consts/auxiliary/foreign-generic-mismatch-with-const-arg.rs

-1
This file was deleted.

tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs

-8
This file was deleted.

tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pub fn const_arg<const N: usize, T>() {}
2+
3+
pub fn lt_arg<'a: 'a>() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// aux-build: foreign-generic-mismatch.rs
2+
3+
extern crate foreign_generic_mismatch;
4+
5+
fn main() {
6+
foreign_generic_mismatch::const_arg::<()>();
7+
//~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied
8+
foreign_generic_mismatch::lt_arg::<'static, 'static>();
9+
//~^ ERROR function takes 1 lifetime argument but 2 lifetime arguments were supplied
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
2+
--> $DIR/foreign-generic-mismatch.rs:6:31
3+
|
4+
LL | foreign_generic_mismatch::const_arg::<()>();
5+
| ^^^^^^^^^ -- supplied 1 generic argument
6+
| |
7+
| expected 2 generic arguments
8+
|
9+
note: function defined here, with 2 generic parameters: `N`, `T`
10+
--> $DIR/auxiliary/foreign-generic-mismatch.rs:1:8
11+
|
12+
LL | pub fn const_arg<const N: usize, T>() {}
13+
| ^^^^^^^^^ -------------- -
14+
help: add missing generic argument
15+
|
16+
LL | foreign_generic_mismatch::const_arg::<(), T>();
17+
| +++
18+
19+
error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were supplied
20+
--> $DIR/foreign-generic-mismatch.rs:8:31
21+
|
22+
LL | foreign_generic_mismatch::lt_arg::<'static, 'static>();
23+
| ^^^^^^ ------- help: remove this lifetime argument
24+
| |
25+
| expected 1 lifetime argument
26+
|
27+
note: function defined here, with 1 lifetime parameter: `'a`
28+
--> $DIR/auxiliary/foreign-generic-mismatch.rs:3:8
29+
|
30+
LL | pub fn lt_arg<'a: 'a>() {}
31+
| ^^^^^^ --
32+
33+
error: aborting due to 2 previous errors
34+
35+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)