diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2018-12-12 17:19:11 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-01-01 20:05:02 +0100 |
| commit | 135132891d69dde7ff4a2a6356f9fb92b004c1f7 (patch) | |
| tree | f31ecf2ccee87797db02feb3f8d60a1c74cb098d | |
| parent | 88df3a2c970a8de576b31ae1ae089f6e99374484 (diff) | |
| download | rust-135132891d69dde7ff4a2a6356f9fb92b004c1f7.tar.gz rust-135132891d69dde7ff4a2a6356f9fb92b004c1f7.zip | |
Simplify and fix some diagnostics around arrays
| -rw-r--r-- | src/librustc/traits/error_reporting.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f66dcb8dffd..bac22510135 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -418,20 +418,16 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(format!("[{}]", self.tcx.type_of(def.did).to_string())), )); let tcx = self.tcx; - if let ty::LazyConst::Evaluated(len) = len { - if let Some(len) = len.val.try_to_scalar().and_then(|scalar| { - scalar.to_usize(&tcx).ok() - }) { - flags.push(( - "_Self".to_owned(), - Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), - )); - } else { - flags.push(( - "_Self".to_owned(), - Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), - )); - } + if let Some(len) = len.assert_usize(tcx) { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; {}]", self.tcx.type_of(def.did).to_string(), len)), + )); + } else { + flags.push(( + "_Self".to_owned(), + Some(format!("[{}; _]", self.tcx.type_of(def.did).to_string())), + )); } } } |
