mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Auto merge of #110469 - compiler-errors:encode-lt-param-span, r=oli-obk
Encode lifetime param spans too Fixes #110464 Fixes #110591
This commit is contained in:
commit
37b22cf2d5
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
pub fn test<const N: usize, T>() {}
|
@ -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
|
||||
}
|
@ -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`.
|
3
tests/ui/generics/auxiliary/foreign-generic-mismatch.rs
Normal file
3
tests/ui/generics/auxiliary/foreign-generic-mismatch.rs
Normal file
@ -0,0 +1,3 @@
|
||||
pub fn const_arg<const N: usize, T>() {}
|
||||
|
||||
pub fn lt_arg<'a: 'a>() {}
|
10
tests/ui/generics/foreign-generic-mismatch.rs
Normal file
10
tests/ui/generics/foreign-generic-mismatch.rs
Normal file
@ -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
tests/ui/generics/foreign-generic-mismatch.stderr
Normal file
35
tests/ui/generics/foreign-generic-mismatch.stderr
Normal file
@ -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`.
|
Loading…
Reference in New Issue
Block a user