Rollup merge of #139200 - xizheyin:issue-139174, r=compiler-errors
Skip suggest impl or dyn when poly trait is not a real trait
Fixes #139174
When `poly_trait_ref` is not a real trait, we should stop suggesting `impl` and `dyn` to avoid false positives. 3 cases were added to the ui test.
0b45675cfc/compiler/rustc_hir_analysis/src/hir_ty_lowering/lint.rs (L88-L93)
In the first commit, I submitted the test and passed it. In the second commit, I modified the code and we can see the changes in the test.
r? compiler
This commit is contained in:
commit
2d43a8b20d
3 changed files with 65 additions and 0 deletions
|
@ -86,6 +86,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
"expected a type, found a trait"
|
||||
);
|
||||
if self_ty.span.can_be_used_for_suggestions()
|
||||
&& poly_trait_ref.trait_ref.trait_def_id().is_some()
|
||||
&& !self.maybe_suggest_impl_trait(self_ty, &mut diag)
|
||||
&& !self.maybe_suggest_dyn_trait(self_ty, sugg, &mut diag)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue