mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
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 <florian.diebold@freiheit.com>
This commit is contained in:
commit
d3eb9d8eaf
3 changed files with 11 additions and 10 deletions
|
@ -501,8 +501,8 @@ impl<'a> InferenceContext<'a> {
|
||||||
}
|
}
|
||||||
Literal::ByteString(..) => {
|
Literal::ByteString(..) => {
|
||||||
let byte_type = Ty::simple(TypeCtor::Int(Uncertain::Known(IntTy::u8())));
|
let byte_type = Ty::simple(TypeCtor::Int(Uncertain::Known(IntTy::u8())));
|
||||||
let slice_type = Ty::apply_one(TypeCtor::Slice, byte_type);
|
let array_type = Ty::apply_one(TypeCtor::Array, byte_type);
|
||||||
Ty::apply_one(TypeCtor::Ref(Mutability::Shared), slice_type)
|
Ty::apply_one(TypeCtor::Ref(Mutability::Shared), array_type)
|
||||||
}
|
}
|
||||||
Literal::Char(..) => Ty::simple(TypeCtor::Char),
|
Literal::Char(..) => Ty::simple(TypeCtor::Char),
|
||||||
Literal::Int(_v, ty) => Ty::simple(TypeCtor::Int((*ty).into())),
|
Literal::Int(_v, ty) => Ty::simple(TypeCtor::Int((*ty).into())),
|
||||||
|
|
|
@ -17,8 +17,8 @@ impl<T> [T] {
|
||||||
#[lang = "slice_alloc"]
|
#[lang = "slice_alloc"]
|
||||||
impl<T> [T] {}
|
impl<T> [T] {}
|
||||||
|
|
||||||
fn test() {
|
fn test(x: &[u8]) {
|
||||||
<[_]>::foo(b"foo");
|
<[_]>::foo(x);
|
||||||
}
|
}
|
||||||
"#),
|
"#),
|
||||||
@r###"
|
@r###"
|
||||||
|
@ -26,10 +26,11 @@ fn test() {
|
||||||
56..79 '{ ... }': T
|
56..79 '{ ... }': T
|
||||||
66..73 'loop {}': !
|
66..73 'loop {}': !
|
||||||
71..73 '{}': ()
|
71..73 '{}': ()
|
||||||
133..160 '{ ...o"); }': ()
|
131..132 'x': &[u8]
|
||||||
139..149 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8
|
141..163 '{ ...(x); }': ()
|
||||||
139..157 '<[_]>:..."foo")': u8
|
147..157 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8
|
||||||
150..156 'b"foo"': &[u8]
|
147..160 '<[_]>::foo(x)': u8
|
||||||
|
158..159 'x': &[u8]
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,7 +414,7 @@ fn test() {
|
||||||
27..31 '5f32': f32
|
27..31 '5f32': f32
|
||||||
37..41 '5f64': f64
|
37..41 '5f64': f64
|
||||||
47..54 '"hello"': &str
|
47..54 '"hello"': &str
|
||||||
60..68 'b"bytes"': &[u8]
|
60..68 'b"bytes"': &[u8; _]
|
||||||
74..77 ''c'': char
|
74..77 ''c'': char
|
||||||
83..87 'b'b'': u8
|
83..87 'b'b'': u8
|
||||||
93..97 '3.14': f64
|
93..97 '3.14': f64
|
||||||
|
@ -422,7 +422,7 @@ fn test() {
|
||||||
113..118 'false': bool
|
113..118 'false': bool
|
||||||
124..128 'true': bool
|
124..128 'true': bool
|
||||||
134..202 'r#" ... "#': &str
|
134..202 'r#" ... "#': &str
|
||||||
208..218 'br#"yolo"#': &[u8]
|
208..218 'br#"yolo"#': &[u8; _]
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue