Skip to content

Commit

Permalink
Rollup merge of #63612 - estebank:macro-sugg-try-into, r=Centril
Browse files Browse the repository at this point in the history
Do not suggest `try_into` for base types inside of macro expansions
  • Loading branch information
Centril committed Aug 16, 2019
2 parents 7dbd98f + fbf1efb commit 8958e50
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/librustc_typeck/check/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// FIXME(estebank): modify once we decide to suggest `as` casts
return false;
}
if !self.tcx.sess.source_map().span_to_filename(expr.span).is_real() {
// Ignore if span is from within a macro.
return false;
}

// If casting this expression to a given numeric type would be appropriate in case of a type
// mismatch.
Expand Down
3 changes: 3 additions & 0 deletions src/test/ui/suggestions/dont-suggest-try_into-in-macros.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
assert_eq!(10u64, 10usize); //~ ERROR mismatched types
}
11 changes: 11 additions & 0 deletions src/test/ui/suggestions/dont-suggest-try_into-in-macros.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0308]: mismatched types
--> $DIR/dont-suggest-try_into-in-macros.rs:2:5
|
LL | assert_eq!(10u64, 10usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected u64, found usize
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

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

0 comments on commit 8958e50

Please sign in to comment.