Skip to content

Commit 7ab2c17

Browse files
committed
Auto merge of #18183 - lnicola:sync-from-rust, r=lnicola
internal: Sync from downstream
2 parents 82b2d07 + f4bcae3 commit 7ab2c17

File tree

10 files changed

+76
-56
lines changed

10 files changed

+76
-56
lines changed

Cargo.lock

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ tt = { path = "./crates/tt", version = "0.0.0" }
8585
vfs-notify = { path = "./crates/vfs-notify", version = "0.0.0" }
8686
vfs = { path = "./crates/vfs", version = "0.0.0" }
8787

88-
ra-ap-rustc_lexer = { version = "0.63.0", default-features = false }
89-
ra-ap-rustc_parse_format = { version = "0.63.0", default-features = false }
90-
ra-ap-rustc_index = { version = "0.63.0", default-features = false }
91-
ra-ap-rustc_abi = { version = "0.63.0", default-features = false }
92-
ra-ap-rustc_pattern_analysis = { version = "0.63.0", default-features = false }
88+
ra-ap-rustc_lexer = { version = "0.68.0", default-features = false }
89+
ra-ap-rustc_parse_format = { version = "0.68.0", default-features = false }
90+
ra-ap-rustc_index = { version = "0.68.0", default-features = false }
91+
ra-ap-rustc_abi = { version = "0.68.0", default-features = false }
92+
ra-ap-rustc_pattern_analysis = { version = "0.68.0", default-features = false }
9393

9494
# local crates that aren't published to crates.io. These should not have versions.
9595
test-fixture = { path = "./crates/test-fixture" }

crates/hir-expand/src/inert_attr_macro.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
464464
// Used by the `rustc::potential_query_instability` lint to warn methods which
465465
// might not be stable during incremental compilation.
466466
rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
467+
// Used by the `rustc::untracked_query_information` lint to warn methods which
468+
// might break incremental compilation.
469+
rustc_attr!(rustc_lint_untracked_query_information, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
467470
// Used by the `rustc::untranslatable_diagnostic` and `rustc::diagnostic_outside_of_impl` lints
468471
// to assist in changes to diagnostic APIs.
469472
rustc_attr!(rustc_lint_diagnostics, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),

crates/hir-ty/src/layout.rs

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
//! Compute the binary representation of a type
22
3-
use std::{borrow::Cow, fmt};
3+
use std::fmt;
44

55
use base_db::salsa::Cycle;
66
use chalk_ir::{AdtId, FloatTy, IntTy, TyKind, UintTy};
77
use hir_def::{
88
layout::{
9-
Abi, FieldsShape, Float, Integer, LayoutCalculator, LayoutS, Primitive, ReprOptions,
10-
Scalar, Size, StructKind, TargetDataLayout, WrappingRange,
9+
Abi, FieldsShape, Float, Integer, LayoutCalculator, LayoutCalculatorError, LayoutS,
10+
Primitive, ReprOptions, Scalar, Size, StructKind, TargetDataLayout, WrappingRange,
1111
},
1212
LocalFieldId, StructId,
1313
};
1414
use la_arena::{Idx, RawIdx};
1515
use rustc_abi::AddressSpace;
1616
use rustc_index::{IndexSlice, IndexVec};
1717

18-
use stdx::never;
1918
use triomphe::Arc;
2019

2120
use crate::{
@@ -73,6 +72,7 @@ pub type Variants = hir_def::layout::Variants<RustcFieldIdx, RustcEnumVariantIdx
7372

7473
#[derive(Debug, PartialEq, Eq, Clone)]
7574
pub enum LayoutError {
75+
EmptyUnion,
7676
HasErrorConst,
7777
HasErrorType,
7878
HasPlaceholder,
@@ -81,6 +81,7 @@ pub enum LayoutError {
8181
RecursiveTypeWithoutIndirection,
8282
SizeOverflow,
8383
TargetLayoutNotAvailable,
84+
UnexpectedUnsized,
8485
Unknown,
8586
UserReprTooSmall,
8687
}
@@ -89,6 +90,7 @@ impl std::error::Error for LayoutError {}
8990
impl fmt::Display for LayoutError {
9091
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9192
match self {
93+
LayoutError::EmptyUnion => write!(f, "type is an union with no fields"),
9294
LayoutError::HasErrorConst => write!(f, "type contains an unevaluatable const"),
9395
LayoutError::HasErrorType => write!(f, "type contains an error"),
9496
LayoutError::HasPlaceholder => write!(f, "type contains placeholders"),
@@ -99,6 +101,9 @@ impl fmt::Display for LayoutError {
99101
}
100102
LayoutError::SizeOverflow => write!(f, "size overflow"),
101103
LayoutError::TargetLayoutNotAvailable => write!(f, "target layout not available"),
104+
LayoutError::UnexpectedUnsized => {
105+
write!(f, "an unsized type was found where a sized type was expected")
106+
}
102107
LayoutError::Unknown => write!(f, "unknown"),
103108
LayoutError::UserReprTooSmall => {
104109
write!(f, "the `#[repr]` hint is too small to hold the discriminants of the enum")
@@ -107,19 +112,23 @@ impl fmt::Display for LayoutError {
107112
}
108113
}
109114

110-
struct LayoutCx<'a> {
111-
target: &'a TargetDataLayout,
115+
impl<F> From<LayoutCalculatorError<F>> for LayoutError {
116+
fn from(err: LayoutCalculatorError<F>) -> Self {
117+
match err {
118+
LayoutCalculatorError::EmptyUnion => LayoutError::EmptyUnion,
119+
LayoutCalculatorError::UnexpectedUnsized(_) => LayoutError::UnexpectedUnsized,
120+
LayoutCalculatorError::SizeOverflow => LayoutError::SizeOverflow,
121+
}
122+
}
112123
}
113124

114-
impl<'a> LayoutCalculator for LayoutCx<'a> {
115-
type TargetDataLayoutRef = &'a TargetDataLayout;
116-
117-
fn delayed_bug(&self, txt: impl Into<Cow<'static, str>>) {
118-
never!("{}", txt.into());
119-
}
125+
struct LayoutCx<'a> {
126+
calc: LayoutCalculator<&'a TargetDataLayout>,
127+
}
120128

121-
fn current_data_layout(&self) -> &'a TargetDataLayout {
122-
self.target
129+
impl<'a> LayoutCx<'a> {
130+
fn new(target: &'a TargetDataLayout) -> Self {
131+
Self { calc: LayoutCalculator::new(target) }
123132
}
124133
}
125134

@@ -205,8 +214,8 @@ pub fn layout_of_ty_query(
205214
let Ok(target) = db.target_data_layout(krate) else {
206215
return Err(LayoutError::TargetLayoutNotAvailable);
207216
};
208-
let cx = LayoutCx { target: &target };
209-
let dl = cx.current_data_layout();
217+
let dl = &*target;
218+
let cx = LayoutCx::new(dl);
210219
let ty = normalize(db, trait_env.clone(), ty);
211220
let result = match ty.kind(Interner) {
212221
TyKind::Adt(AdtId(def), subst) => {
@@ -281,7 +290,7 @@ pub fn layout_of_ty_query(
281290
.collect::<Result<Vec<_>, _>>()?;
282291
let fields = fields.iter().map(|it| &**it).collect::<Vec<_>>();
283292
let fields = fields.iter().collect::<IndexVec<_, _>>();
284-
cx.univariant(dl, &fields, &ReprOptions::default(), kind).ok_or(LayoutError::Unknown)?
293+
cx.calc.univariant(&fields, &ReprOptions::default(), kind)?
285294
}
286295
TyKind::Array(element, count) => {
287296
let count = try_const_usize(db, count).ok_or(LayoutError::HasErrorConst)? as u64;
@@ -367,12 +376,12 @@ pub fn layout_of_ty_query(
367376
};
368377

369378
// Effectively a (ptr, meta) tuple.
370-
cx.scalar_pair(data_ptr, metadata)
379+
cx.calc.scalar_pair(data_ptr, metadata)
371380
}
372-
TyKind::FnDef(_, _) => layout_of_unit(&cx, dl)?,
373-
TyKind::Never => cx.layout_of_never_type(),
381+
TyKind::FnDef(_, _) => layout_of_unit(&cx)?,
382+
TyKind::Never => cx.calc.layout_of_never_type(),
374383
TyKind::Dyn(_) | TyKind::Foreign(_) => {
375-
let mut unit = layout_of_unit(&cx, dl)?;
384+
let mut unit = layout_of_unit(&cx)?;
376385
match &mut unit.abi {
377386
Abi::Aggregate { sized } => *sized = false,
378387
_ => return Err(LayoutError::Unknown),
@@ -414,8 +423,7 @@ pub fn layout_of_ty_query(
414423
.collect::<Result<Vec<_>, _>>()?;
415424
let fields = fields.iter().map(|it| &**it).collect::<Vec<_>>();
416425
let fields = fields.iter().collect::<IndexVec<_, _>>();
417-
cx.univariant(dl, &fields, &ReprOptions::default(), StructKind::AlwaysSized)
418-
.ok_or(LayoutError::Unknown)?
426+
cx.calc.univariant(&fields, &ReprOptions::default(), StructKind::AlwaysSized)?
419427
}
420428
TyKind::Coroutine(_, _) | TyKind::CoroutineWitness(_, _) => {
421429
return Err(LayoutError::NotImplemented)
@@ -447,14 +455,14 @@ pub fn layout_of_ty_recover(
447455
Err(LayoutError::RecursiveTypeWithoutIndirection)
448456
}
449457

450-
fn layout_of_unit(cx: &LayoutCx<'_>, dl: &TargetDataLayout) -> Result<Layout, LayoutError> {
451-
cx.univariant::<RustcFieldIdx, RustcEnumVariantIdx, &&Layout>(
452-
dl,
453-
IndexSlice::empty(),
454-
&ReprOptions::default(),
455-
StructKind::AlwaysSized,
456-
)
457-
.ok_or(LayoutError::Unknown)
458+
fn layout_of_unit(cx: &LayoutCx<'_>) -> Result<Layout, LayoutError> {
459+
cx.calc
460+
.univariant::<RustcFieldIdx, RustcEnumVariantIdx, &&Layout>(
461+
IndexSlice::empty(),
462+
&ReprOptions::default(),
463+
StructKind::AlwaysSized,
464+
)
465+
.map_err(Into::into)
458466
}
459467

460468
fn struct_tail_erasing_lifetimes(db: &dyn HirDatabase, pointee: Ty) -> Ty {

crates/hir-ty/src/layout/adt.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{cmp, ops::Bound};
55
use base_db::salsa::Cycle;
66
use hir_def::{
77
data::adt::VariantData,
8-
layout::{Integer, LayoutCalculator, ReprOptions, TargetDataLayout},
8+
layout::{Integer, ReprOptions, TargetDataLayout},
99
AdtId, VariantId,
1010
};
1111
use intern::sym;
@@ -36,8 +36,8 @@ pub fn layout_of_adt_query(
3636
let Ok(target) = db.target_data_layout(krate) else {
3737
return Err(LayoutError::TargetLayoutNotAvailable);
3838
};
39-
let cx = LayoutCx { target: &target };
40-
let dl = cx.current_data_layout();
39+
let dl = &*target;
40+
let cx = LayoutCx::new(dl);
4141
let handle_variant = |def: VariantId, var: &VariantData| {
4242
var.fields()
4343
.iter()
@@ -73,9 +73,9 @@ pub fn layout_of_adt_query(
7373
.collect::<SmallVec<[_; 1]>>();
7474
let variants = variants.iter().map(|it| it.iter().collect()).collect::<IndexVec<_, _>>();
7575
let result = if matches!(def, AdtId::UnionId(..)) {
76-
cx.layout_of_union(&repr, &variants).ok_or(LayoutError::Unknown)?
76+
cx.calc.layout_of_union(&repr, &variants)?
7777
} else {
78-
cx.layout_of_struct_or_enum(
78+
cx.calc.layout_of_struct_or_enum(
7979
&repr,
8080
&variants,
8181
matches!(def, AdtId::EnumId(..)),
@@ -103,8 +103,7 @@ pub fn layout_of_adt_query(
103103
.next()
104104
.and_then(|it| it.iter().last().map(|it| !it.is_unsized()))
105105
.unwrap_or(true),
106-
)
107-
.ok_or(LayoutError::SizeOverflow)?
106+
)?
108107
};
109108
Ok(Arc::new(result))
110109
}

crates/hir-ty/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ pub enum FnAbi {
379379
AvrNonBlockingInterrupt,
380380
C,
381381
CCmseNonsecureCall,
382+
CCmseNonsecureEntry,
382383
CDecl,
383384
CDeclUnwind,
384385
CUnwind,
@@ -436,6 +437,7 @@ impl FnAbi {
436437
s if *s == sym::avr_dash_interrupt => FnAbi::AvrInterrupt,
437438
s if *s == sym::avr_dash_non_dash_blocking_dash_interrupt => FnAbi::AvrNonBlockingInterrupt,
438439
s if *s == sym::C_dash_cmse_dash_nonsecure_dash_call => FnAbi::CCmseNonsecureCall,
440+
s if *s == sym::C_dash_cmse_dash_nonsecure_dash_entry => FnAbi::CCmseNonsecureEntry,
439441
s if *s == sym::C_dash_unwind => FnAbi::CUnwind,
440442
s if *s == sym::C => FnAbi::C,
441443
s if *s == sym::cdecl_dash_unwind => FnAbi::CDeclUnwind,
@@ -479,6 +481,7 @@ impl FnAbi {
479481
FnAbi::AvrNonBlockingInterrupt => "avr-non-blocking-interrupt",
480482
FnAbi::C => "C",
481483
FnAbi::CCmseNonsecureCall => "C-cmse-nonsecure-call",
484+
FnAbi::CCmseNonsecureEntry => "C-cmse-nonsecure-entry",
482485
FnAbi::CDecl => "C-decl",
483486
FnAbi::CDeclUnwind => "cdecl-unwind",
484487
FnAbi::CUnwind => "C-unwind",

crates/ide-completion/src/completions/extern_abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const SUPPORTED_CALLING_CONVENTIONS: &[&str] = &[
3232
"riscv-interrupt-m",
3333
"riscv-interrupt-s",
3434
"C-cmse-nonsecure-call",
35+
"C-cmse-nonsecure-entry",
3536
"wasm",
3637
"system",
3738
"system-unwind",

crates/intern/src/symbol/symbols.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ define_symbols! {
9494
avr_dash_interrupt = "avr-interrupt",
9595
avr_dash_non_dash_blocking_dash_interrupt = "avr-non-blocking-interrupt",
9696
C_dash_cmse_dash_nonsecure_dash_call = "C-cmse-nonsecure-call",
97+
C_dash_cmse_dash_nonsecure_dash_entry = "C-cmse-nonsecure-entry",
9798
C_dash_unwind = "C-unwind",
9899
cdecl_dash_unwind = "cdecl-unwind",
99100
fastcall_dash_unwind = "fastcall-unwind",

crates/parser/src/lexed_str.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ impl<'a> Converter<'a> {
198198
}
199199
LIFETIME_IDENT
200200
}
201+
rustc_lexer::TokenKind::UnknownPrefixLifetime => {
202+
err = "Unknown lifetime prefix";
203+
LIFETIME_IDENT
204+
}
205+
rustc_lexer::TokenKind::RawLifetime => LIFETIME_IDENT,
201206

202207
rustc_lexer::TokenKind::Semi => T![;],
203208
rustc_lexer::TokenKind::Comma => T![,],

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6cf068db566de080dfa7ed24a216ea3aed2b98ce
1+
1b5aa96d6016bafe50e071b45d4d2e3c90fd766f

0 commit comments

Comments
 (0)