|
12 | 12 | //!
|
13 | 13 | //! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/mir/index.html
|
14 | 14 |
|
15 |
| -use graphviz::IntoCow; |
16 | 15 | use hir::def::CtorKind;
|
17 | 16 | use hir::def_id::DefId;
|
18 | 17 | use hir::{self, HirId, InlineAsm};
|
@@ -327,22 +326,20 @@ impl<'tcx> Mir<'tcx> {
|
327 | 326 | if idx < stmts.len() {
|
328 | 327 | &stmts[idx].source_info
|
329 | 328 | } else {
|
330 |
| - assert!(idx == stmts.len()); |
| 329 | + assert_eq!(idx, stmts.len()); |
331 | 330 | &block.terminator().source_info
|
332 | 331 | }
|
333 | 332 | }
|
334 | 333 |
|
335 | 334 | /// Check if `sub` is a sub scope of `sup`
|
336 | 335 | pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool {
|
337 |
| - loop { |
338 |
| - if sub == sup { |
339 |
| - return true; |
340 |
| - } |
| 336 | + while sub != sup { |
341 | 337 | match self.source_scopes[sub].parent_scope {
|
342 | 338 | None => return false,
|
343 | 339 | Some(p) => sub = p,
|
344 | 340 | }
|
345 | 341 | }
|
| 342 | + true |
346 | 343 | }
|
347 | 344 |
|
348 | 345 | /// Return the return type, it always return first element from `local_decls` array
|
@@ -526,9 +523,7 @@ impl BorrowKind {
|
526 | 523 | pub fn allows_two_phase_borrow(&self) -> bool {
|
527 | 524 | match *self {
|
528 | 525 | BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => false,
|
529 |
| - BorrowKind::Mut { |
530 |
| - allow_two_phase_borrow, |
531 |
| - } => allow_two_phase_borrow, |
| 526 | + BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow, |
532 | 527 | }
|
533 | 528 | }
|
534 | 529 | }
|
@@ -1551,42 +1546,42 @@ impl<'tcx> TerminatorKind<'tcx> {
|
1551 | 1546 | };
|
1552 | 1547 | fmt_const_val(&mut s, &c).unwrap();
|
1553 | 1548 | s.into()
|
1554 |
| - }).chain(iter::once(String::from("otherwise").into())) |
| 1549 | + }).chain(iter::once("otherwise".into())) |
1555 | 1550 | .collect()
|
1556 | 1551 | }
|
1557 | 1552 | Call {
|
1558 | 1553 | destination: Some(_),
|
1559 | 1554 | cleanup: Some(_),
|
1560 | 1555 | ..
|
1561 |
| - } => vec!["return".into_cow(), "unwind".into_cow()], |
| 1556 | + } => vec!["return".into(), "unwind".into()], |
1562 | 1557 | Call {
|
1563 | 1558 | destination: Some(_),
|
1564 | 1559 | cleanup: None,
|
1565 | 1560 | ..
|
1566 |
| - } => vec!["return".into_cow()], |
| 1561 | + } => vec!["return".into()], |
1567 | 1562 | Call {
|
1568 | 1563 | destination: None,
|
1569 | 1564 | cleanup: Some(_),
|
1570 | 1565 | ..
|
1571 |
| - } => vec!["unwind".into_cow()], |
| 1566 | + } => vec!["unwind".into()], |
1572 | 1567 | Call {
|
1573 | 1568 | destination: None,
|
1574 | 1569 | cleanup: None,
|
1575 | 1570 | ..
|
1576 | 1571 | } => vec![],
|
1577 |
| - Yield { drop: Some(_), .. } => vec!["resume".into_cow(), "drop".into_cow()], |
1578 |
| - Yield { drop: None, .. } => vec!["resume".into_cow()], |
| 1572 | + Yield { drop: Some(_), .. } => vec!["resume".into(), "drop".into()], |
| 1573 | + Yield { drop: None, .. } => vec!["resume".into()], |
1579 | 1574 | DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => {
|
1580 |
| - vec!["return".into_cow()] |
| 1575 | + vec!["return".into()] |
1581 | 1576 | }
|
1582 | 1577 | DropAndReplace {
|
1583 | 1578 | unwind: Some(_), ..
|
1584 | 1579 | }
|
1585 | 1580 | | Drop {
|
1586 | 1581 | unwind: Some(_), ..
|
1587 |
| - } => vec!["return".into_cow(), "unwind".into_cow()], |
| 1582 | + } => vec!["return".into(), "unwind".into()], |
1588 | 1583 | Assert { cleanup: None, .. } => vec!["".into()],
|
1589 |
| - Assert { .. } => vec!["success".into_cow(), "unwind".into_cow()], |
| 1584 | + Assert { .. } => vec!["success".into(), "unwind".into()], |
1590 | 1585 | FalseEdges {
|
1591 | 1586 | ref imaginary_targets,
|
1592 | 1587 | ..
|
|
0 commit comments