mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Merge commit 'a911652360
' into sync-from-ra
This commit is contained in:
parent
0661390ad4
commit
e4866b6ddb
315 changed files with 7088 additions and 4415 deletions
|
@ -6,9 +6,8 @@ use base_db::salsa::Cycle;
|
|||
use hir_def::{
|
||||
data::adt::VariantData,
|
||||
layout::{Integer, LayoutCalculator, ReprOptions, TargetDataLayout},
|
||||
AdtId, EnumVariantId, LocalEnumVariantId, VariantId,
|
||||
AdtId, VariantId,
|
||||
};
|
||||
use la_arena::RawIdx;
|
||||
use rustc_index::IndexVec;
|
||||
use smallvec::SmallVec;
|
||||
use triomphe::Arc;
|
||||
|
@ -22,8 +21,8 @@ use crate::{
|
|||
|
||||
use super::LayoutCx;
|
||||
|
||||
pub(crate) const fn struct_variant_idx() -> RustcEnumVariantIdx {
|
||||
RustcEnumVariantIdx(LocalEnumVariantId::from_raw(RawIdx::from_u32(0)))
|
||||
pub(crate) fn struct_variant_idx() -> RustcEnumVariantIdx {
|
||||
RustcEnumVariantIdx(0)
|
||||
}
|
||||
|
||||
pub fn layout_of_adt_query(
|
||||
|
@ -62,12 +61,7 @@ pub fn layout_of_adt_query(
|
|||
let r = data
|
||||
.variants
|
||||
.iter()
|
||||
.map(|(idx, v)| {
|
||||
handle_variant(
|
||||
EnumVariantId { parent: e, local_id: idx }.into(),
|
||||
&v.variant_data,
|
||||
)
|
||||
})
|
||||
.map(|&(v, _)| handle_variant(v.into(), &db.enum_variant_data(v).variant_data))
|
||||
.collect::<Result<SmallVec<_>, _>>()?;
|
||||
(r, data.repr.unwrap_or_default())
|
||||
}
|
||||
|
@ -86,11 +80,10 @@ pub fn layout_of_adt_query(
|
|||
matches!(def, AdtId::EnumId(..)),
|
||||
is_unsafe_cell(db, def),
|
||||
layout_scalar_valid_range(db, def),
|
||||
|min, max| repr_discr(&dl, &repr, min, max).unwrap_or((Integer::I8, false)),
|
||||
|min, max| repr_discr(dl, &repr, min, max).unwrap_or((Integer::I8, false)),
|
||||
variants.iter_enumerated().filter_map(|(id, _)| {
|
||||
let AdtId::EnumId(e) = def else { return None };
|
||||
let d =
|
||||
db.const_eval_discriminant(EnumVariantId { parent: e, local_id: id.0 }).ok()?;
|
||||
let d = db.const_eval_discriminant(db.enum_data(e).variants[id.0].0).ok()?;
|
||||
Some((id, d))
|
||||
}),
|
||||
// FIXME: The current code for niche-filling relies on variant indices
|
||||
|
|
|
@ -12,7 +12,7 @@ pub fn target_data_layout_query(
|
|||
) -> Option<Arc<TargetDataLayout>> {
|
||||
let crate_graph = db.crate_graph();
|
||||
let target_layout = crate_graph[krate].target_layout.as_ref().ok()?;
|
||||
let res = TargetDataLayout::parse_from_llvm_datalayout_string(&target_layout);
|
||||
let res = TargetDataLayout::parse_from_llvm_datalayout_string(target_layout);
|
||||
if let Err(_e) = &res {
|
||||
// FIXME: Print the error here once it implements debug/display
|
||||
// also logging here is somewhat wrong, but unfortunately this is the earliest place we can
|
||||
|
|
|
@ -366,11 +366,11 @@ fn return_position_impl_trait() {
|
|||
}
|
||||
let waker = Arc::new(EmptyWaker).into();
|
||||
let mut context = Context::from_waker(&waker);
|
||||
let x = pinned.poll(&mut context);
|
||||
x
|
||||
|
||||
pinned.poll(&mut context)
|
||||
}
|
||||
let x = unwrap_fut(f());
|
||||
x
|
||||
|
||||
unwrap_fut(f())
|
||||
}
|
||||
size_and_align_expr! {
|
||||
struct Foo<T>(T, T, (T, T));
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#![allow(clippy::match_single_binding)]
|
||||
#![allow(clippy::no_effect)]
|
||||
|
||||
use crate::size_and_align_expr;
|
||||
|
||||
#[test]
|
||||
|
@ -36,7 +39,7 @@ fn ref_simple() {
|
|||
let mut y: i32 = 5;
|
||||
]
|
||||
|x: i32| {
|
||||
y = y + x;
|
||||
y += x;
|
||||
y
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +69,7 @@ fn ref_simple() {
|
|||
let x: &mut X = &mut X(2, 6);
|
||||
]
|
||||
|| {
|
||||
(*x).0 as i64 + x.1
|
||||
x.0 as i64 + x.1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,9 +191,7 @@ fn match_pattern() {
|
|||
struct X(i64, i32, (u8, i128));
|
||||
let _y: X = X(2, 5, (7, 3));
|
||||
move |x: i64| {
|
||||
match _y {
|
||||
_ => x,
|
||||
}
|
||||
x
|
||||
}
|
||||
}
|
||||
size_and_align_expr! {
|
||||
|
@ -264,8 +265,8 @@ fn regression_15623() {
|
|||
let c = 5;
|
||||
move || {
|
||||
let 0 = a else { return b; };
|
||||
let y = c;
|
||||
y
|
||||
|
||||
c
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue