diff options
| author | bors <bors@rust-lang.org> | 2023-06-25 14:08:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-06-25 14:08:04 +0000 |
| commit | db3c3942ea846c541dd6c34c80fe8470b8a228b1 (patch) | |
| tree | 7d65f4414b6eb6fda0a234bb5692385d86a77712 | |
| parent | c51fbb3dd3a75fd43d51c0c29ca645c3dac99aae (diff) | |
| parent | d2f82a00d00ab2f76a0a24bb24fffbe9af770b29 (diff) | |
| download | rust-db3c3942ea846c541dd6c34c80fe8470b8a228b1.tar.gz rust-db3c3942ea846c541dd6c34c80fe8470b8a228b1.zip | |
Auto merge of #113027 - matthiaskrgr:rollup-mpes684, r=matthiaskrgr
Rollup of 2 pull requests Successful merges: - #113007 (Revert "Structurally resolve correctly in check_pat_lit") - #113023 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
| -rw-r--r-- | compiler/rustc_hir_typeck/src/pat.rs | 5 | ||||
| -rw-r--r-- | tests/rustdoc-gui/docblock-code-block-line-number.goml | 6 | ||||
| -rw-r--r-- | tests/ui/pattern/byte-string-inference.rs | 15 | ||||
| -rw-r--r-- | tests/ui/traits/new-solver/slice-match-byte-lit.rs | 2 | ||||
| -rw-r--r-- | tests/ui/traits/new-solver/slice-match-byte-lit.stderr | 11 |
5 files changed, 33 insertions, 6 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 2f9871a103a..5af955d3134 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -393,8 +393,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // They can denote both statically and dynamically-sized byte arrays. let mut pat_ty = ty; if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind { - if let ty::Ref(_, inner_ty, _) = *self.structurally_resolved_type(span, expected).kind() - && self.structurally_resolved_type(span, inner_ty).is_slice() + let expected = self.structurally_resolved_type(span, expected); + if let ty::Ref(_, inner_ty, _) = expected.kind() + && matches!(inner_ty.kind(), ty::Slice(_)) { let tcx = self.tcx; trace!(?lt.hir_id.local_id, "polymorphic byte string lit"); diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml index 4c36394a30c..a50449e1701 100644 --- a/tests/rustdoc-gui/docblock-code-block-line-number.goml +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -37,15 +37,15 @@ define-function: ( ) call-function: ("check-colors", { "theme": "ayu", - "color": "rgb(92, 103, 115)", + "color": "#5c6773", }) call-function: ("check-colors", { "theme": "dark", - "color": "rgb(59, 145, 226)", + "color": "#3b91e2", }) call-function: ("check-colors", { "theme": "light", - "color": "rgb(198, 126, 45)", + "color": "#c67e2d", }) // The first code block has two lines so let's check its `<pre>` elements lists both of them. diff --git a/tests/ui/pattern/byte-string-inference.rs b/tests/ui/pattern/byte-string-inference.rs new file mode 100644 index 00000000000..b1517de6b67 --- /dev/null +++ b/tests/ui/pattern/byte-string-inference.rs @@ -0,0 +1,15 @@ +// check-pass + +fn load<L>() -> Option<L> { + todo!() +} + +fn main() { + while let Some(tag) = load() { + match &tag { + b"NAME" => {} + b"DATA" => {} + _ => {} + } + } +} diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.rs b/tests/ui/traits/new-solver/slice-match-byte-lit.rs index 4f848062595..5f9c0df6450 100644 --- a/tests/ui/traits/new-solver/slice-match-byte-lit.rs +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.rs @@ -1,5 +1,5 @@ // compile-flags: -Ztrait-solver=next -// check-pass +// known-bug: rust-lang/trait-system-refactor-initiative#38 fn test(s: &[u8]) { match &s[0..3] { diff --git a/tests/ui/traits/new-solver/slice-match-byte-lit.stderr b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr new file mode 100644 index 00000000000..294e8bc94be --- /dev/null +++ b/tests/ui/traits/new-solver/slice-match-byte-lit.stderr @@ -0,0 +1,11 @@ +error[E0271]: type mismatch resolving `[u8; 3] <: <Range<usize> as SliceIndex<[u8]>>::Output` + --> $DIR/slice-match-byte-lit.rs:6:9 + | +LL | match &s[0..3] { + | -------- this expression has type `&<std::ops::Range<usize> as SliceIndex<[u8]>>::Output` +LL | b"uwu" => {} + | ^^^^^^ types differ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. |
