Skip to content

Commit 3b3c706

Browse files
Point at type parameter in plain path expr
1 parent a2cdcb3 commit 3b3c706

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

compiler/rustc_typeck/src/check/fn_ctxt/checks.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1780,16 +1780,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
17801780
return true;
17811781
}
17821782
}
1783-
// Notably, we only point to params that are local to the
1784-
// item we're checking, since those are the ones we are able
1785-
// to look in the final `hir::PathSegment` for. Everything else
1786-
// would require a deeper search into the `qpath` than I think
1787-
// is worthwhile.
1788-
if let Some(param_to_point_at) = param_to_point_at
1789-
&& self.point_at_path_if_possible(error, def_id, param_to_point_at, qpath)
1790-
{
1791-
return true;
1792-
}
1783+
}
1784+
// Notably, we only point to params that are local to the
1785+
// item we're checking, since those are the ones we are able
1786+
// to look in the final `hir::PathSegment` for. Everything else
1787+
// would require a deeper search into the `qpath` than I think
1788+
// is worthwhile.
1789+
if let Some(param_to_point_at) = param_to_point_at
1790+
&& self.point_at_path_if_possible(error, def_id, param_to_point_at, qpath)
1791+
{
1792+
return true;
17931793
}
17941794
}
17951795
hir::ExprKind::MethodCall(segment, args, ..) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn foo<T: std::fmt::Display>() {}
2+
3+
fn main() {
4+
let x = foo::<()>;
5+
//~^ ERROR `()` doesn't implement `std::fmt::Display`
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0277]: `()` doesn't implement `std::fmt::Display`
2+
--> $DIR/point-at-type-param-in-path-expr.rs:4:19
3+
|
4+
LL | let x = foo::<()>;
5+
| ^^ `()` cannot be formatted with the default formatter
6+
|
7+
= help: the trait `std::fmt::Display` is not implemented for `()`
8+
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
9+
note: required by a bound in `foo`
10+
--> $DIR/point-at-type-param-in-path-expr.rs:1:11
11+
|
12+
LL | fn foo<T: std::fmt::Display>() {}
13+
| ^^^^^^^^^^^^^^^^^ required by this bound in `foo`
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0277`.

0 commit comments

Comments
 (0)