Skip to content

Commit d3eb9d8

Browse files
Merge #4376
4376: Fix type of byte literals r=matklad a=flodiebold They're `&[u8; N]`, not `&[u8]` (see #4374). Co-authored-by: Florian Diebold <[email protected]>
2 parents 51e4b92 + f5177f9 commit d3eb9d8

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

crates/ra_hir_ty/src/infer/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,8 @@ impl<'a> InferenceContext<'a> {
501501
}
502502
Literal::ByteString(..) => {
503503
let byte_type = Ty::simple(TypeCtor::Int(Uncertain::Known(IntTy::u8())));
504-
let slice_type = Ty::apply_one(TypeCtor::Slice, byte_type);
505-
Ty::apply_one(TypeCtor::Ref(Mutability::Shared), slice_type)
504+
let array_type = Ty::apply_one(TypeCtor::Array, byte_type);
505+
Ty::apply_one(TypeCtor::Ref(Mutability::Shared), array_type)
506506
}
507507
Literal::Char(..) => Ty::simple(TypeCtor::Char),
508508
Literal::Int(_v, ty) => Ty::simple(TypeCtor::Int((*ty).into())),

crates/ra_hir_ty/src/tests/method_resolution.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ impl<T> [T] {
1717
#[lang = "slice_alloc"]
1818
impl<T> [T] {}
1919
20-
fn test() {
21-
<[_]>::foo(b"foo");
20+
fn test(x: &[u8]) {
21+
<[_]>::foo(x);
2222
}
2323
"#),
2424
@r###"
2525
45..49 'self': &[T]
2626
56..79 '{ ... }': T
2727
66..73 'loop {}': !
2828
71..73 '{}': ()
29-
133..160 '{ ...o"); }': ()
30-
139..149 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8
31-
139..157 '<[_]>:..."foo")': u8
32-
150..156 'b"foo"': &[u8]
29+
131..132 'x': &[u8]
30+
141..163 '{ ...(x); }': ()
31+
147..157 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8
32+
147..160 '<[_]>::foo(x)': u8
33+
158..159 'x': &[u8]
3334
"###
3435
);
3536
}

crates/ra_hir_ty/src/tests/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,15 +414,15 @@ fn test() {
414414
27..31 '5f32': f32
415415
37..41 '5f64': f64
416416
47..54 '"hello"': &str
417-
60..68 'b"bytes"': &[u8]
417+
60..68 'b"bytes"': &[u8; _]
418418
74..77 ''c'': char
419419
83..87 'b'b'': u8
420420
93..97 '3.14': f64
421421
103..107 '5000': i32
422422
113..118 'false': bool
423423
124..128 'true': bool
424424
134..202 'r#" ... "#': &str
425-
208..218 'br#"yolo"#': &[u8]
425+
208..218 'br#"yolo"#': &[u8; _]
426426
"###
427427
);
428428
}

0 commit comments

Comments
 (0)