Auto merge of #84410 - BoxyUwU:blue, r=varkor
Fix generic arg mismatch errors being ignored with explicit late bound lifetimes Fixes #83466 r? `@varkor`
This commit is contained in:
commit
4de7572097
@ -278,9 +278,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
// another. This is an error. However, if we already know that
|
// another. This is an error. However, if we already know that
|
||||||
// the arguments don't match up with the parameters, we won't issue
|
// the arguments don't match up with the parameters, we won't issue
|
||||||
// an additional error, as the user already knows what's wrong.
|
// an additional error, as the user already knows what's wrong.
|
||||||
if arg_count.correct.is_ok()
|
if arg_count.correct.is_ok() {
|
||||||
&& arg_count.explicit_late_bound == ExplicitLateBound::No
|
|
||||||
{
|
|
||||||
// We're going to iterate over the parameters to sort them out, and
|
// We're going to iterate over the parameters to sort them out, and
|
||||||
// show that order to the user as a possible order for the parameters
|
// show that order to the user as a possible order for the parameters
|
||||||
let mut param_types_present = defs
|
let mut param_types_present = defs
|
||||||
@ -462,7 +460,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if silent {
|
if silent {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if provided > expected_max {
|
if provided > expected_max {
|
||||||
|
@ -1282,6 +1282,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
|
|
||||||
let mut infer_args_for_err = FxHashSet::default();
|
let mut infer_args_for_err = FxHashSet::default();
|
||||||
|
|
||||||
|
let mut explicit_late_bound = ExplicitLateBound::No;
|
||||||
for &PathSeg(def_id, index) in &path_segs {
|
for &PathSeg(def_id, index) in &path_segs {
|
||||||
let seg = &segments[index];
|
let seg = &segments[index];
|
||||||
let generics = tcx.generics_of(def_id);
|
let generics = tcx.generics_of(def_id);
|
||||||
@ -1290,17 +1291,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
// parameter internally, but we don't allow users to specify the
|
// parameter internally, but we don't allow users to specify the
|
||||||
// parameter's value explicitly, so we have to do some error-
|
// parameter's value explicitly, so we have to do some error-
|
||||||
// checking here.
|
// checking here.
|
||||||
if let GenericArgCountResult {
|
let arg_count = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
|
||||||
correct: Err(GenericArgCountMismatch { reported: Some(_), .. }),
|
|
||||||
..
|
|
||||||
} = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
|
|
||||||
tcx,
|
tcx,
|
||||||
span,
|
span,
|
||||||
def_id,
|
def_id,
|
||||||
&generics,
|
&generics,
|
||||||
seg,
|
seg,
|
||||||
IsMethodCall::No,
|
IsMethodCall::No,
|
||||||
) {
|
);
|
||||||
|
|
||||||
|
if let ExplicitLateBound::Yes = arg_count.explicit_late_bound {
|
||||||
|
explicit_late_bound = ExplicitLateBound::Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(GenericArgCountMismatch { reported: Some(_), .. }) = arg_count.correct {
|
||||||
infer_args_for_err.insert(index);
|
infer_args_for_err.insert(index);
|
||||||
self.set_tainted_by_errors(); // See issue #53251.
|
self.set_tainted_by_errors(); // See issue #53251.
|
||||||
}
|
}
|
||||||
@ -1357,7 +1361,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
let ty = tcx.type_of(def_id);
|
let ty = tcx.type_of(def_id);
|
||||||
|
|
||||||
let arg_count = GenericArgCountResult {
|
let arg_count = GenericArgCountResult {
|
||||||
explicit_late_bound: ExplicitLateBound::No,
|
explicit_late_bound,
|
||||||
correct: if infer_args_for_err.is_empty() {
|
correct: if infer_args_for_err.is_empty() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
17
src/test/ui/const-generics/issues/issue-83466.rs
Normal file
17
src/test/ui/const-generics/issues/issue-83466.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// regression test for #83466- tests that generic arg mismatch errors between
|
||||||
|
// consts and types are not supressed when there are explicit late bound lifetimes
|
||||||
|
|
||||||
|
struct S;
|
||||||
|
impl S {
|
||||||
|
fn func<'a, U>(self) -> U {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn dont_crash<'a, U>() {
|
||||||
|
S.func::<'a, 10_u32>()
|
||||||
|
//~^ WARNING cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||||
|
//~^^ WARNING this was previously accepted by
|
||||||
|
//~^^^ ERROR constant provided when a type was expected [E0747]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
22
src/test/ui/const-generics/issues/issue-83466.stderr
Normal file
22
src/test/ui/const-generics/issues/issue-83466.stderr
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
|
||||||
|
--> $DIR/issue-83466.rs:11:14
|
||||||
|
|
|
||||||
|
LL | fn func<'a, U>(self) -> U {
|
||||||
|
| -- the late bound lifetime parameter is introduced here
|
||||||
|
...
|
||||||
|
LL | S.func::<'a, 10_u32>()
|
||||||
|
| ^^
|
||||||
|
|
|
||||||
|
= note: `#[warn(late_bound_lifetime_arguments)]` on by default
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
= note: for more information, see issue #42868 <https://github.com/rust-lang/rust/issues/42868>
|
||||||
|
|
||||||
|
error[E0747]: constant provided when a type was expected
|
||||||
|
--> $DIR/issue-83466.rs:11:18
|
||||||
|
|
|
||||||
|
LL | S.func::<'a, 10_u32>()
|
||||||
|
| ^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error; 1 warning emitted
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0747`.
|
Loading…
x
Reference in New Issue
Block a user