Skip to content

Commit 4586fdc

Browse files
committed
Taint _ placeholder types
1 parent 174e73a commit 4586fdc

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

compiler/rustc_hir_analysis/src/astconv/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25432543
self.suggest_trait_fn_ty_for_impl_fn_infer(hir_id, Some(i))
25442544
{
25452545
infer_replacements.push((a.span, suggested_ty.to_string()));
2546-
return suggested_ty;
2546+
return Ty::new_error_with_message(
2547+
self.tcx(),
2548+
a.span,
2549+
suggested_ty.to_string(),
2550+
);
25472551
}
25482552
}
25492553

@@ -2561,7 +2565,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
25612565
self.suggest_trait_fn_ty_for_impl_fn_infer(hir_id, None)
25622566
{
25632567
infer_replacements.push((output.span, suggested_ty.to_string()));
2564-
suggested_ty
2568+
Ty::new_error_with_message(self.tcx(), output.span, suggested_ty.to_string())
25652569
} else {
25662570
visitor.visit_ty(output);
25672571
self.ast_ty_to_ty(output)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
trait Deserialize {
2+
fn deserialize(&self);
3+
}
4+
5+
struct ArchivedVec<T>(T);
6+
7+
impl<T> Deserialize for ArchivedVec<T> {
8+
fn deserialize(s: _) {}
9+
//~^ ERROR: `_` is not allowed within types on item signatures
10+
//~| ERROR: has a `&self` declaration in the trait, but not in the impl
11+
}
12+
13+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
2+
--> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:23
3+
|
4+
LL | fn deserialize(s: _) {}
5+
| ^ not allowed in type signatures
6+
|
7+
help: try replacing `_` with the type in the corresponding trait method signature
8+
|
9+
LL | fn deserialize(s: &ArchivedVec<T>) {}
10+
| ~~~~~~~~~~~~~~~
11+
12+
error[E0186]: method `deserialize` has a `&self` declaration in the trait, but not in the impl
13+
--> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:5
14+
|
15+
LL | fn deserialize(&self);
16+
| ---------------------- `&self` used in trait
17+
...
18+
LL | fn deserialize(s: _) {}
19+
| ^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl
20+
21+
error: aborting due to 2 previous errors
22+
23+
Some errors have detailed explanations: E0121, E0186.
24+
For more information about an error, try `rustc --explain E0121`.

0 commit comments

Comments
 (0)