Skip to content

Commit d01c62b

Browse files
authored
Rollup merge of #110425 - compiler-errors:def-span-for-ct-param, r=petrochenkov
Encode def span for `ConstParam` Fixes #110206 r? ``@petrochenkov``
2 parents 0790996 + 1ee189c commit d01c62b

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

Diff for: compiler/rustc_metadata/src/rmeta/encoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
823823
| DefKind::TraitAlias
824824
| DefKind::AssocTy
825825
| DefKind::TyParam
826+
| DefKind::ConstParam
826827
| DefKind::Fn
827828
| DefKind::Const
828829
| DefKind::Static(_)
@@ -837,8 +838,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
837838
| DefKind::Impl { .. }
838839
| DefKind::Closure
839840
| DefKind::Generator => true,
840-
DefKind::ConstParam
841-
| DefKind::ExternCrate
841+
DefKind::ExternCrate
842842
| DefKind::Use
843843
| DefKind::ForeignMod
844844
| DefKind::ImplTraitPlaceholder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn test<const N: usize, T>() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// aux-build: foreign-generic-mismatch-with-const-arg.rs
2+
3+
extern crate foreign_generic_mismatch_with_const_arg;
4+
5+
fn main() {
6+
foreign_generic_mismatch_with_const_arg::test::<1>();
7+
//~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied
2+
--> $DIR/foreign-generic-mismatch-with-const-arg.rs:6:46
3+
|
4+
LL | foreign_generic_mismatch_with_const_arg::test::<1>();
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-with-const-arg.rs:1:8
11+
|
12+
LL | pub fn test<const N: usize, T>() {}
13+
| ^^^^ -------------- -
14+
help: add missing generic argument
15+
|
16+
LL | foreign_generic_mismatch_with_const_arg::test::<1, T>();
17+
| +++
18+
19+
error: aborting due to previous error
20+
21+
For more information about this error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)