Skip to content

Commit cfa6a93

Browse files
Auto traits in dyn are suggestable
1 parent ba64ba8 commit cfa6a93

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

compiler/rustc_middle/src/ty/diagnostics.rs

+2-13
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use std::ops::ControlFlow;
44

55
use crate::ty::{
6-
visit::TypeVisitable, AliasTy, Const, ConstKind, DefIdTree, ExistentialPredicate, InferConst,
7-
InferTy, Opaque, PolyTraitPredicate, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
6+
visit::TypeVisitable, AliasTy, Const, ConstKind, DefIdTree, InferConst, InferTy, Opaque,
7+
PolyTraitPredicate, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
88
};
99

1010
use rustc_data_structures::fx::FxHashMap;
@@ -469,17 +469,6 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
469469
}
470470
}
471471

472-
Dynamic(dty, _, _) => {
473-
for pred in *dty {
474-
match pred.skip_binder() {
475-
ExistentialPredicate::Trait(_) | ExistentialPredicate::Projection(_) => {
476-
// Okay
477-
}
478-
_ => return ControlFlow::Break(()),
479-
}
480-
}
481-
}
482-
483472
Param(param) => {
484473
// FIXME: It would be nice to make this not use string manipulation,
485474
// but it's pretty hard to do this, since `ty::ParamTy` is missing
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use std::fmt::Display;
2+
3+
fn foo(x: &(dyn Display + Send)) {}
4+
5+
fn main() {
6+
foo();
7+
//~^ ERROR this function takes 1 argument but 0 arguments were supplied
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error[E0061]: this function takes 1 argument but 0 arguments were supplied
2+
--> $DIR/display-is-suggestable.rs:6:5
3+
|
4+
LL | foo();
5+
| ^^^-- an argument of type `&dyn std::fmt::Display + Send` is missing
6+
|
7+
note: function defined here
8+
--> $DIR/display-is-suggestable.rs:3:4
9+
|
10+
LL | fn foo(x: &(dyn Display + Send)) {}
11+
| ^^^ ------------------------
12+
help: provide the argument
13+
|
14+
LL | foo(/* &dyn std::fmt::Display + Send */);
15+
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
17+
error: aborting due to previous error
18+
19+
For more information about this error, try `rustc --explain E0061`.

0 commit comments

Comments
 (0)