Skip to content

Encode def span for ConstParam #110425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
| DefKind::TraitAlias
| DefKind::AssocTy
| DefKind::TyParam
| DefKind::ConstParam
| DefKind::Fn
| DefKind::Const
| DefKind::Static(_)
Expand All @@ -837,8 +838,7 @@ fn should_encode_span(def_kind: DefKind) -> bool {
| DefKind::Impl { .. }
| DefKind::Closure
| DefKind::Generator => true,
DefKind::ConstParam
| DefKind::ExternCrate
DefKind::ExternCrate
| DefKind::Use
| DefKind::ForeignMod
| DefKind::ImplTraitPlaceholder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub fn test<const N: usize, T>() {}
8 changes: 8 additions & 0 deletions tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// 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
}
21 changes: 21 additions & 0 deletions tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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`.