Skip to content

Commit

Permalink
Auto merge of #110469 - compiler-errors:encode-lt-param-span, r=oli-obk
Browse files Browse the repository at this point in the history
Encode lifetime param spans too

Fixes #110464
Fixes #110591
  • Loading branch information
bors committed Apr 22, 2023
2 parents 80a2ec4 + 24c2c07 commit 37b22cf
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 34 deletions.
6 changes: 2 additions & 4 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)
Expand All @@ -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,
}
}

Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions tests/ui/consts/foreign-generic-mismatch-with-const-arg.rs

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ui/consts/foreign-generic-mismatch-with-const-arg.stderr

This file was deleted.

3 changes: 3 additions & 0 deletions tests/ui/generics/auxiliary/foreign-generic-mismatch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn const_arg<const N: usize, T>() {}

pub fn lt_arg<'a: 'a>() {}
10 changes: 10 additions & 0 deletions tests/ui/generics/foreign-generic-mismatch.rs
Original file line number Diff line number Diff line change
@@ -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
}
35 changes: 35 additions & 0 deletions tests/ui/generics/foreign-generic-mismatch.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 37b22cf

Please sign in to comment.