Rollup merge of #100155 - compiler-errors:issue-100154, r=jackh726
Use `node_type_opt` to skip over generics that were not expected Fixes #100154
This commit is contained in:
commit
721af40dcb
4 changed files with 51 additions and 9 deletions
|
@ -1761,13 +1761,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
.filter_map(|seg| seg.args.as_ref())
|
.filter_map(|seg| seg.args.as_ref())
|
||||||
.flat_map(|a| a.args.iter())
|
.flat_map(|a| a.args.iter())
|
||||||
{
|
{
|
||||||
if let hir::GenericArg::Type(hir_ty) = &arg {
|
if let hir::GenericArg::Type(hir_ty) = &arg
|
||||||
let ty = self.resolve_vars_if_possible(
|
&& let Some(ty) =
|
||||||
self.typeck_results.borrow().node_type(hir_ty.hir_id),
|
self.typeck_results.borrow().node_type_opt(hir_ty.hir_id)
|
||||||
);
|
&& self.resolve_vars_if_possible(ty) == predicate.self_ty()
|
||||||
if ty == predicate.self_ty() {
|
{
|
||||||
error.obligation.cause.span = hir_ty.span;
|
error.obligation.cause.span = hir_ty.span;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
src/test/ui/argument-suggestions/issue-100154.rs
Normal file
7
src/test/ui/argument-suggestions/issue-100154.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
fn foo(i: impl std::fmt::Display) {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo::<()>(());
|
||||||
|
//~^ ERROR this function takes 0 generic arguments but 1 generic argument was supplied
|
||||||
|
//~| ERROR `()` doesn't implement `std::fmt::Display`
|
||||||
|
}
|
35
src/test/ui/argument-suggestions/issue-100154.stderr
Normal file
35
src/test/ui/argument-suggestions/issue-100154.stderr
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
error[E0107]: this function takes 0 generic arguments but 1 generic argument was supplied
|
||||||
|
--> $DIR/issue-100154.rs:4:5
|
||||||
|
|
|
||||||
|
LL | foo::<()>(());
|
||||||
|
| ^^^------ help: remove these generics
|
||||||
|
| |
|
||||||
|
| expected 0 generic arguments
|
||||||
|
|
|
||||||
|
note: function defined here, with 0 generic parameters
|
||||||
|
--> $DIR/issue-100154.rs:1:4
|
||||||
|
|
|
||||||
|
LL | fn foo(i: impl std::fmt::Display) {}
|
||||||
|
| ^^^
|
||||||
|
= note: `impl Trait` cannot be explicitly specified as a generic argument
|
||||||
|
|
||||||
|
error[E0277]: `()` doesn't implement `std::fmt::Display`
|
||||||
|
--> $DIR/issue-100154.rs:4:15
|
||||||
|
|
|
||||||
|
LL | foo::<()>(());
|
||||||
|
| --------- ^^ `()` cannot be formatted with the default formatter
|
||||||
|
| |
|
||||||
|
| required by a bound introduced by this call
|
||||||
|
|
|
||||||
|
= help: the trait `std::fmt::Display` is not implemented for `()`
|
||||||
|
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
|
||||||
|
note: required by a bound in `foo`
|
||||||
|
--> $DIR/issue-100154.rs:1:16
|
||||||
|
|
|
||||||
|
LL | fn foo(i: impl std::fmt::Display) {}
|
||||||
|
| ^^^^^^^^^^^^^^^^^ required by this bound in `foo`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0107, E0277.
|
||||||
|
For more information about an error, try `rustc --explain E0107`.
|
|
@ -1,8 +1,8 @@
|
||||||
error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
|
error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
|
||||||
--> $DIR/references.rs:19:52
|
--> $DIR/references.rs:19:37
|
||||||
|
|
|
|
||||||
LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>();
|
LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>();
|
||||||
| ^^^^^^^^^^^^^ `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
|
| ^^^^^^^^^^^^^ `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`.
|
||||||
|
|
|
|
||||||
= help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, true, true, true, true>` is not implemented for `&'static Unit`
|
= help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, true, true, true, true>` is not implemented for `&'static Unit`
|
||||||
note: required by a bound in `is_maybe_transmutable`
|
note: required by a bound in `is_maybe_transmutable`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue