Navigation Menu

Skip to content

Commit

Permalink
don't convert types into identical types
Browse files Browse the repository at this point in the history
example: let x: String = String::new().into();
  • Loading branch information
matthiaskrgr committed Sep 11, 2021
1 parent 22719ef commit 545d8d6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Expand Up @@ -1036,7 +1036,7 @@ impl<'a> State<'a> {
self.maybe_print_comment(st.span.lo());
match st.kind {
hir::StmtKind::Local(ref loc) => {
self.print_local(loc.init.as_deref(), |this| this.print_local_decl(&loc));
self.print_local(loc.init, |this| this.print_local_decl(&loc));
}
hir::StmtKind::Item(item) => self.ann.nested(self, Nested::Item(item)),
hir::StmtKind::Expr(ref expr) => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/error_reporting/mod.rs
Expand Up @@ -2345,7 +2345,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
);
err.span_suggestion(
generics.where_clause.tail_span_for_suggestion(),
"consider adding a where clause".into(),
"consider adding a where clause",
suggestion,
Applicability::MaybeIncorrect,
);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_passes/src/liveness.rs
Expand Up @@ -775,7 +775,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
if blk.targeted_by_break {
self.break_ln.insert(blk.hir_id, succ);
}
let succ = self.propagate_through_opt_expr(blk.expr.as_deref(), succ);
let succ = self.propagate_through_opt_expr(blk.expr, succ);
blk.stmts.iter().rev().fold(succ, |succ, stmt| self.propagate_through_stmt(stmt, succ))
}

Expand All @@ -796,7 +796,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
// initialization, which is mildly more complex than checking
// once at the func header but otherwise equivalent.

let succ = self.propagate_through_opt_expr(local.init.as_deref(), succ);
let succ = self.propagate_through_opt_expr(local.init, succ);
self.define_bindings_in_pat(&local.pat, succ)
}
hir::StmtKind::Item(..) => succ,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/region.rs
Expand Up @@ -812,7 +812,7 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
resolve_expr(self, ex);
}
fn visit_local(&mut self, l: &'tcx Local<'tcx>) {
resolve_local(self, Some(&l.pat), l.init.as_deref());
resolve_local(self, Some(&l.pat), l.init);
}
}

Expand Down

0 comments on commit 545d8d6

Please sign in to comment.