Skip to content

Commit db3c394

Browse files
committed
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
2 parents c51fbb3 + d2f82a0 commit db3c394

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

compiler/rustc_hir_typeck/src/pat.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
393393
// They can denote both statically and dynamically-sized byte arrays.
394394
let mut pat_ty = ty;
395395
if let hir::ExprKind::Lit(Spanned { node: ast::LitKind::ByteStr(..), .. }) = lt.kind {
396-
if let ty::Ref(_, inner_ty, _) = *self.structurally_resolved_type(span, expected).kind()
397-
&& self.structurally_resolved_type(span, inner_ty).is_slice()
396+
let expected = self.structurally_resolved_type(span, expected);
397+
if let ty::Ref(_, inner_ty, _) = expected.kind()
398+
&& matches!(inner_ty.kind(), ty::Slice(_))
398399
{
399400
let tcx = self.tcx;
400401
trace!(?lt.hir_id.local_id, "polymorphic byte string lit");

tests/rustdoc-gui/docblock-code-block-line-number.goml

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ define-function: (
3737
)
3838
call-function: ("check-colors", {
3939
"theme": "ayu",
40-
"color": "rgb(92, 103, 115)",
40+
"color": "#5c6773",
4141
})
4242
call-function: ("check-colors", {
4343
"theme": "dark",
44-
"color": "rgb(59, 145, 226)",
44+
"color": "#3b91e2",
4545
})
4646
call-function: ("check-colors", {
4747
"theme": "light",
48-
"color": "rgb(198, 126, 45)",
48+
"color": "#c67e2d",
4949
})
5050

5151
// The first code block has two lines so let's check its `<pre>` elements lists both of them.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// check-pass
2+
3+
fn load<L>() -> Option<L> {
4+
todo!()
5+
}
6+
7+
fn main() {
8+
while let Some(tag) = load() {
9+
match &tag {
10+
b"NAME" => {}
11+
b"DATA" => {}
12+
_ => {}
13+
}
14+
}
15+
}

tests/ui/traits/new-solver/slice-match-byte-lit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// compile-flags: -Ztrait-solver=next
2-
// check-pass
2+
// known-bug: rust-lang/trait-system-refactor-initiative#38
33

44
fn test(s: &[u8]) {
55
match &s[0..3] {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0271]: type mismatch resolving `[u8; 3] <: <Range<usize> as SliceIndex<[u8]>>::Output`
2+
--> $DIR/slice-match-byte-lit.rs:6:9
3+
|
4+
LL | match &s[0..3] {
5+
| -------- this expression has type `&<std::ops::Range<usize> as SliceIndex<[u8]>>::Output`
6+
LL | b"uwu" => {}
7+
| ^^^^^^ types differ
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0271`.

0 commit comments

Comments
 (0)