Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto traits in dyn Trait + Auto are suggestable #105627

Merged
merged 1 commit into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions compiler/rustc_middle/src/ty/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::ops::ControlFlow;

use crate::ty::{
visit::TypeVisitable, AliasTy, Const, ConstKind, DefIdTree, ExistentialPredicate, InferConst,
InferTy, Opaque, PolyTraitPredicate, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
visit::TypeVisitable, AliasTy, Const, ConstKind, DefIdTree, InferConst, InferTy, Opaque,
PolyTraitPredicate, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor,
};

use rustc_data_structures::fx::FxHashMap;
Expand Down Expand Up @@ -469,17 +469,6 @@ impl<'tcx> TypeVisitor<'tcx> for IsSuggestableVisitor<'tcx> {
}
}

Dynamic(dty, _, _) => {
for pred in *dty {
match pred.skip_binder() {
ExistentialPredicate::Trait(_) | ExistentialPredicate::Projection(_) => {
// Okay
}
_ => return ControlFlow::Break(()),
}
}
}

Param(param) => {
// FIXME: It would be nice to make this not use string manipulation,
// but it's pretty hard to do this, since `ty::ParamTy` is missing
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/argument-suggestions/display-is-suggestable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use std::fmt::Display;

fn foo(x: &(dyn Display + Send)) {}

fn main() {
foo();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied
}
19 changes: 19 additions & 0 deletions src/test/ui/argument-suggestions/display-is-suggestable.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error[E0061]: this function takes 1 argument but 0 arguments were supplied
--> $DIR/display-is-suggestable.rs:6:5
|
LL | foo();
| ^^^-- an argument of type `&dyn std::fmt::Display + Send` is missing
|
note: function defined here
--> $DIR/display-is-suggestable.rs:3:4
|
LL | fn foo(x: &(dyn Display + Send)) {}
| ^^^ ------------------------
help: provide the argument
|
LL | foo(/* &dyn std::fmt::Display + Send */);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error: aborting due to previous error

For more information about this error, try `rustc --explain E0061`.