Skip to content

Commit 41c22ae

Browse files
authored
Unrolled build for rust-lang#132941
Rollup merge of rust-lang#132941 - lnicola:sync-from-ra2, r=lnicola Subtree update of `rust-analyzer` r? `@ghost`
2 parents 9a9dadd + 61dba02 commit 41c22ae

File tree

26 files changed

+294
-249
lines changed

26 files changed

+294
-249
lines changed

src/tools/rust-analyzer/.github/workflows/autopublish.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ jobs:
5353
cargo workspaces rename --from project-model project_model
5454
cargo workspaces rename --from test-fixture test_fixture
5555
cargo workspaces rename --from test-utils test_utils
56-
cargo workspaces rename --from text-edit text_edit
5756
# Remove library crates from the workspaces so we don't auto-publish them as well
5857
sed -i 's/ "lib\/\*",//' ./Cargo.toml
5958
cargo workspaces rename ra_ap_%n

src/tools/rust-analyzer/crates/hir-def/src/data.rs

-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use syntax::{ast, Parse};
1313
use triomphe::Arc;
1414

1515
use crate::{
16-
attr::Attrs,
1716
db::DefDatabase,
1817
expander::{Expander, Mark},
1918
item_tree::{self, AssocItem, FnFlags, ItemTree, ItemTreeId, MacroCall, ModItem, TreeId},
@@ -37,8 +36,6 @@ pub struct FunctionData {
3736
pub name: Name,
3837
pub params: Box<[TypeRefId]>,
3938
pub ret_type: TypeRefId,
40-
// FIXME: why are these stored here? They should be accessed via the query
41-
pub attrs: Attrs,
4239
pub visibility: RawVisibility,
4340
pub abi: Option<Symbol>,
4441
pub legacy_const_generics_indices: Option<Box<Box<[u32]>>>,
@@ -115,7 +112,6 @@ impl FunctionData {
115112
.filter_map(|(_, param)| param.type_ref)
116113
.collect(),
117114
ret_type: func.ret_type,
118-
attrs: item_tree.attrs(db, krate, ModItem::from(loc.id.value).into()),
119115
visibility,
120116
abi: func.abi.clone(),
121117
legacy_const_generics_indices,

src/tools/rust-analyzer/crates/hir-expand/src/inert_attr_macro.rs

+13
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,19 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
632632
rustc_safe_intrinsic, Normal, template!(Word), WarnFollowing,
633633
"the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe"
634634
),
635+
rustc_attr!(
636+
rustc_intrinsic, Normal, template!(Word), ErrorFollowing,
637+
"the `#[rustc_intrinsic]` attribute is used to declare intrinsics with function bodies",
638+
),
639+
rustc_attr!(
640+
rustc_no_mir_inline, Normal, template!(Word), WarnFollowing,
641+
"#[rustc_no_mir_inline] prevents the MIR inliner from inlining a function while not affecting codegen"
642+
),
643+
rustc_attr!(
644+
rustc_intrinsic_must_be_overridden, Normal, template!(Word), ErrorFollowing,
645+
"the `#[rustc_intrinsic_must_be_overridden]` attribute is used to declare intrinsics without real bodies",
646+
),
647+
635648
rustc_attr!(
636649
rustc_deprecated_safe_2024, Normal, template!(Word), WarnFollowing,
637650
"the `#[rustc_safe_intrinsic]` marks functions as unsafe in Rust 2024",

src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,9 @@ impl chalk_solve::RustIrDatabase<Interner> for ChalkContext<'_> {
381381
TyKind::Error.intern(Interner)
382382
}
383383

384+
// object safety was renamed to dyn-compatibility but still remains here in chalk.
385+
// This will be removed since we are going to migrate to next-gen trait solver.
384386
fn is_object_safe(&self, trait_id: chalk_ir::TraitId<Interner>) -> bool {
385-
// FIXME: When cargo is updated, change to dyn_compatibility
386387
let trait_ = from_chalk_trait_id(trait_id);
387388
crate::dyn_compatibility::dyn_compatibility(self.db, trait_).is_none()
388389
}

src/tools/rust-analyzer/crates/hir-ty/src/consteval/tests/intrinsics.rs

+44-53
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use super::*;
44
fn size_of() {
55
check_number(
66
r#"
7-
extern "rust-intrinsic" {
8-
pub fn size_of<T>() -> usize;
9-
}
7+
#[rustc_intrinsic]
8+
pub fn size_of<T>() -> usize;
109
1110
const GOAL: usize = size_of::<i32>();
1211
"#,
@@ -19,9 +18,8 @@ fn size_of_val() {
1918
check_number(
2019
r#"
2120
//- minicore: coerce_unsized
22-
extern "rust-intrinsic" {
23-
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
24-
}
21+
#[rustc_intrinsic]
22+
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
2523
2624
struct X(i32, u8);
2725
@@ -32,9 +30,8 @@ fn size_of_val() {
3230
check_number(
3331
r#"
3432
//- minicore: coerce_unsized
35-
extern "rust-intrinsic" {
36-
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
37-
}
33+
#[rustc_intrinsic]
34+
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
3835
3936
const GOAL: usize = {
4037
let it: &[i32] = &[1, 2, 3];
@@ -48,9 +45,8 @@ fn size_of_val() {
4845
//- minicore: coerce_unsized, transmute
4946
use core::mem::transmute;
5047
51-
extern "rust-intrinsic" {
52-
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
53-
}
48+
#[rustc_intrinsic]
49+
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
5450
5551
struct X {
5652
x: i64,
@@ -70,9 +66,8 @@ fn size_of_val() {
7066
//- minicore: coerce_unsized, transmute
7167
use core::mem::transmute;
7268
73-
extern "rust-intrinsic" {
74-
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
75-
}
69+
#[rustc_intrinsic]
70+
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
7671
7772
struct X {
7873
x: i32,
@@ -90,9 +85,8 @@ fn size_of_val() {
9085
check_number(
9186
r#"
9287
//- minicore: coerce_unsized, fmt, builtin_impls, dispatch_from_dyn
93-
extern "rust-intrinsic" {
94-
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
95-
}
88+
#[rustc_intrinsic]
89+
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
9690
9791
const GOAL: usize = {
9892
let x: &i16 = &5;
@@ -106,9 +100,8 @@ fn size_of_val() {
106100
check_number(
107101
r#"
108102
//- minicore: coerce_unsized
109-
extern "rust-intrinsic" {
110-
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
111-
}
103+
#[rustc_intrinsic]
104+
pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
112105
113106
const GOAL: usize = {
114107
size_of_val("salam")
@@ -123,9 +116,8 @@ fn min_align_of_val() {
123116
check_number(
124117
r#"
125118
//- minicore: coerce_unsized
126-
extern "rust-intrinsic" {
127-
pub fn min_align_of_val<T: ?Sized>(_: *const T) -> usize;
128-
}
119+
#[rustc_intrinsic]
120+
pub fn min_align_of_val<T: ?Sized>(_: *const T) -> usize;
129121
130122
struct X(i32, u8);
131123
@@ -136,9 +128,8 @@ fn min_align_of_val() {
136128
check_number(
137129
r#"
138130
//- minicore: coerce_unsized
139-
extern "rust-intrinsic" {
140-
pub fn min_align_of_val<T: ?Sized>(_: *const T) -> usize;
141-
}
131+
#[rustc_intrinsic]
132+
pub fn min_align_of_val<T: ?Sized>(_: *const T) -> usize;
142133
143134
const GOAL: usize = {
144135
let x: &[i32] = &[1, 2, 3];
@@ -153,19 +144,17 @@ fn min_align_of_val() {
153144
fn type_name() {
154145
check_str(
155146
r#"
156-
extern "rust-intrinsic" {
157-
pub fn type_name<T: ?Sized>() -> &'static str;
158-
}
147+
#[rustc_intrinsic]
148+
pub fn type_name<T: ?Sized>() -> &'static str;
159149
160150
const GOAL: &str = type_name::<i32>();
161151
"#,
162152
"i32",
163153
);
164154
check_str(
165155
r#"
166-
extern "rust-intrinsic" {
167-
pub fn type_name<T: ?Sized>() -> &'static str;
168-
}
156+
#[rustc_intrinsic]
157+
pub fn type_name<T: ?Sized>() -> &'static str;
169158
170159
mod mod1 {
171160
pub mod mod2 {
@@ -183,9 +172,8 @@ fn type_name() {
183172
fn transmute() {
184173
check_number(
185174
r#"
186-
extern "rust-intrinsic" {
187-
pub fn transmute<T, U>(e: T) -> U;
188-
}
175+
#[rustc_intrinsic]
176+
pub fn transmute<T, U>(e: T) -> U;
189177
190178
const GOAL: i32 = transmute((1i16, 1i16));
191179
"#,
@@ -197,10 +185,10 @@ fn transmute() {
197185
fn read_via_copy() {
198186
check_number(
199187
r#"
200-
extern "rust-intrinsic" {
201-
pub fn read_via_copy<T>(e: *const T) -> T;
202-
pub fn volatile_load<T>(e: *const T) -> T;
203-
}
188+
#[rustc_intrinsic]
189+
pub fn read_via_copy<T>(e: *const T) -> T;
190+
#[rustc_intrinsic]
191+
pub fn volatile_load<T>(e: *const T) -> T;
204192
205193
const GOAL: i32 = {
206194
let x = 2;
@@ -399,9 +387,14 @@ fn discriminant_value() {
399387
fn likely() {
400388
check_number(
401389
r#"
402-
extern "rust-intrinsic" {
403-
pub fn likely(b: bool) -> bool;
404-
pub fn unlikely(b: bool) -> bool;
390+
#[rustc_intrinsic]
391+
pub const fn likely(b: bool) -> bool {
392+
b
393+
}
394+
395+
#[rustc_intrinsic]
396+
pub const fn unlikely(b: bool) -> bool {
397+
b
405398
}
406399
407400
const GOAL: bool = likely(true) && unlikely(true) && !likely(false) && !unlikely(false);
@@ -704,9 +697,8 @@ fn rotate() {
704697
);
705698
check_number(
706699
r#"
707-
extern "rust-intrinsic" {
708-
pub fn rotate_right<T: Copy>(x: T, y: T) -> T;
709-
}
700+
#[rustc_intrinsic]
701+
pub fn rotate_right<T: Copy>(x: T, y: T) -> T;
710702
711703
const GOAL: i32 = rotate_right(10006016, 1020315);
712704
"#,
@@ -721,9 +713,8 @@ fn simd() {
721713
pub struct i8x16(
722714
i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,
723715
);
724-
extern "platform-intrinsic" {
725-
pub fn simd_bitmask<T, U>(x: T) -> U;
726-
}
716+
#[rustc_intrinsic]
717+
pub fn simd_bitmask<T, U>(x: T) -> U;
727718
const GOAL: u16 = simd_bitmask(i8x16(
728719
0, 1, 0, 0, 2, 255, 100, 0, 50, 0, 1, 1, 0, 0, 0, 0
729720
));
@@ -735,10 +726,10 @@ fn simd() {
735726
pub struct i8x16(
736727
i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,i8,
737728
);
738-
extern "platform-intrinsic" {
739-
pub fn simd_lt<T, U>(x: T, y: T) -> U;
740-
pub fn simd_bitmask<T, U>(x: T) -> U;
741-
}
729+
#[rustc_intrinsic]
730+
pub fn simd_lt<T, U>(x: T, y: T) -> U;
731+
#[rustc_intrinsic]
732+
pub fn simd_bitmask<T, U>(x: T) -> U;
742733
const GOAL: u16 = simd_bitmask(simd_lt::<i8x16, i8x16>(
743734
i8x16(
744735
-105, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

src/tools/rust-analyzer/crates/hir-ty/src/diagnostics/decl_check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'a> DeclValidator<'a> {
201201

202202
// Don't run the lint on extern "[not Rust]" fn items with the
203203
// #[no_mangle] attribute.
204-
let no_mangle = data.attrs.by_key(&sym::no_mangle).exists();
204+
let no_mangle = self.db.attrs(func.into()).by_key(&sym::no_mangle).exists();
205205
if no_mangle && data.abi.as_ref().is_some_and(|abi| *abi != sym::Rust) {
206206
cov_mark::hit!(extern_func_no_mangle_ignored);
207207
} else {

src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ fn receiver_is_dispatchable(
472472
return false;
473473
};
474474

475-
// `self: Self` can't be dispatched on, but this is already considered dyn compatible
475+
// `self: Self` can't be dispatched on, but this is already considered dyn-compatible
476476
// See rustc's comment on https://github.com/rust-lang/rust/blob/3f121b9461cce02a703a0e7e450568849dfaa074/compiler/rustc_trait_selection/src/traits/object_safety.rs#L433-L437
477477
if sig
478478
.skip_binders()

src/tools/rust-analyzer/crates/hir-ty/src/dyn_compatibility/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn check_dyn_compatibility<'a>(
6666
});
6767
ControlFlow::Continue(())
6868
});
69-
assert_eq!(osvs, expected, "Dyn Compatibility violations for `{name}` do not match;");
69+
assert_eq!(osvs, expected, "dyn-compatibility violations for `{name}` do not match;");
7070
}
7171

7272
let remains: Vec<_> = expected.keys().collect();

src/tools/rust-analyzer/crates/hir-ty/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ pub use mapping::{
9898
};
9999
pub use method_resolution::check_orphan_rules;
100100
pub use traits::TraitEnvironment;
101-
pub use utils::{all_super_traits, is_fn_unsafe_to_call};
101+
pub use utils::{all_super_traits, direct_super_traits, is_fn_unsafe_to_call};
102102

103103
pub use chalk_ir::{
104104
cast::Cast,

0 commit comments

Comments
 (0)