Skip to content

Commit 3cee020

Browse files
authored
Merge pull request #19702 from lnicola/sync-from-rust
internal: Sync from downstream
2 parents d8887c0 + bf61680 commit 3cee020

File tree

16 files changed

+73
-220
lines changed

16 files changed

+73
-220
lines changed

Cargo.lock

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

Cargo.toml

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

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

9494
# local crates that aren't published to crates.io. These should not have versions.
9595

@@ -132,11 +132,12 @@ pulldown-cmark-to-cmark = "10.0.4"
132132
pulldown-cmark = { version = "0.9.6", default-features = false }
133133
rayon = "1.10.0"
134134
salsa = "0.20.0"
135-
rustc-hash = "2.1.1"
136135
semver = "1.0.26"
137136
serde = { version = "1.0.219" }
138137
serde_derive = { version = "1.0.219" }
139138
serde_json = "1.0.140"
139+
rustc-hash = "2.1.1"
140+
rustc-literal-escaper = "0.0.2"
140141
smallvec = { version = "1.14.0", features = [
141142
"const_new",
142143
"union",
@@ -171,6 +172,7 @@ hashbrown = { version = "0.14.0", features = [
171172
elided_lifetimes_in_paths = "warn"
172173
explicit_outlives_requirements = "warn"
173174
unsafe_op_in_unsafe_fn = "warn"
175+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)'] }
174176
unused_extern_crates = "warn"
175177
unused_lifetimes = "warn"
176178
unreachable_pub = "warn"

crates/hir-def/src/hir/format_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub enum FormatAlignment {
137137
#[derive(Clone, Debug, PartialEq, Eq)]
138138
pub enum FormatCount {
139139
/// `{:5}` or `{:.5}`
140-
Literal(usize),
140+
Literal(u16),
141141
/// `{:.*}`, `{:.5$}`, or `{:a$}`, etc.
142142
Argument(FormatArgPosition),
143143
}

crates/hir-expand/src/inert_attr_macro.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,6 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
665665
rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
666666
rustc_attr!(TEST, rustc_abi, Normal, template!(List: "field1, field2, ..."), WarnFollowing),
667667
rustc_attr!(TEST, rustc_regions, Normal, template!(Word), WarnFollowing),
668-
rustc_attr!(
669-
TEST, rustc_error, Normal,
670-
template!(Word, List: "delayed_bug_from_inside_query"), WarnFollowingWordOnly
671-
),
672668
rustc_attr!(TEST, rustc_dump_user_args, Normal, template!(Word), WarnFollowing),
673669
rustc_attr!(TEST, rustc_evaluate_where_clauses, Normal, template!(Word), WarnFollowing),
674670
rustc_attr!(

crates/ide-db/src/generated/lints.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,35 +3789,6 @@ The tracking issue for this feature is: [#64797]
37893789
[#64797]: https://github.com/rust-lang/rust/issues/64797
37903790

37913791
------------------------
3792-
"##,
3793-
default_severity: Severity::Allow,
3794-
warn_since: None,
3795-
deny_since: None,
3796-
},
3797-
Lint {
3798-
label: "cfg_boolean_literals",
3799-
description: r##"# `cfg_boolean_literals`
3800-
3801-
The tracking issue for this feature is: [#131204]
3802-
3803-
[#131204]: https://github.com/rust-lang/rust/issues/131204
3804-
3805-
------------------------
3806-
3807-
The `cfg_boolean_literals` feature makes it possible to use the `true`/`false`
3808-
literal as cfg predicate. They always evaluate to true/false respectively.
3809-
3810-
## Examples
3811-
3812-
```rust
3813-
#![feature(cfg_boolean_literals)]
3814-
3815-
#[cfg(true)]
3816-
const A: i32 = 5;
3817-
3818-
#[cfg(all(false))]
3819-
const A: i32 = 58 * 89;
3820-
```
38213792
"##,
38223793
default_severity: Severity::Allow,
38233794
warn_since: None,

crates/ide/src/hover/tests.rs

Lines changed: 8 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -6704,109 +6704,14 @@ pub fn foo() {}
67046704

67056705
#[test]
67066706
fn hover_feature() {
6707-
check(
6708-
r#"#![feature(intrinsics$0)]"#,
6709-
expect![[r#"
6710-
*intrinsics*
6711-
```
6712-
intrinsics
6713-
```
6714-
___
6715-
6716-
# `intrinsics`
6717-
6718-
The tracking issue for this feature is: None.
6719-
6720-
Intrinsics are rarely intended to be stable directly, but are usually
6721-
exported in some sort of stable manner. Prefer using the stable interfaces to
6722-
the intrinsic directly when you can.
6723-
6724-
------------------------
6725-
6726-
6727-
## Intrinsics with fallback logic
6728-
6729-
Many intrinsics can be written in pure rust, albeit inefficiently or without supporting
6730-
some features that only exist on some backends. Backends can simply not implement those
6731-
intrinsics without causing any code miscompilations or failures to compile.
6732-
All intrinsic fallback bodies are automatically made cross-crate inlineable (like `#[inline]`)
6733-
by the codegen backend, but not the MIR inliner.
6734-
6735-
```rust
6736-
#![feature(intrinsics)]
6737-
#![allow(internal_features)]
6738-
6739-
#[rustc_intrinsic]
6740-
const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
6741-
```
6742-
6743-
Since these are just regular functions, it is perfectly ok to create the intrinsic twice:
6744-
6745-
```rust
6746-
#![feature(intrinsics)]
6747-
#![allow(internal_features)]
6748-
6749-
#[rustc_intrinsic]
6750-
const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {}
6751-
6752-
mod foo {
6753-
#[rustc_intrinsic]
6754-
const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {
6755-
panic!("noisy const dealloc")
6756-
}
6757-
}
6758-
6759-
```
6760-
6761-
The behaviour on backends that override the intrinsic is exactly the same. On other
6762-
backends, the intrinsic behaviour depends on which implementation is called, just like
6763-
with any regular function.
6764-
6765-
## Intrinsics lowered to MIR instructions
6766-
6767-
Various intrinsics have native MIR operations that they correspond to. Instead of requiring
6768-
backends to implement both the intrinsic and the MIR operation, the `lower_intrinsics` pass
6769-
will convert the calls to the MIR operation. Backends do not need to know about these intrinsics
6770-
at all. These intrinsics only make sense without a body, and can either be declared as a "rust-intrinsic"
6771-
or as a `#[rustc_intrinsic]`. The body is never used, as calls to the intrinsic do not exist
6772-
anymore after MIR analyses.
6773-
6774-
## Intrinsics without fallback logic
6775-
6776-
These must be implemented by all backends.
6777-
6778-
### `#[rustc_intrinsic]` declarations
6779-
6780-
These are written like intrinsics with fallback bodies, but the body is irrelevant.
6781-
Use `loop {}` for the body or call the intrinsic recursively and add
6782-
`#[rustc_intrinsic_must_be_overridden]` to the function to ensure that backends don't
6783-
invoke the body.
6784-
6785-
### Legacy extern ABI based intrinsics
6786-
6787-
These are imported as if they were FFI functions, with the special
6788-
`rust-intrinsic` ABI. For example, if one was in a freestanding
6789-
context, but wished to be able to `transmute` between types, and
6790-
perform efficient pointer arithmetic, one would import those functions
6791-
via a declaration like
6792-
6793-
```rust
6794-
#![feature(intrinsics)]
6795-
#![allow(internal_features)]
6796-
# fn main() {}
6797-
6798-
extern "rust-intrinsic" {
6799-
fn transmute<T, U>(x: T) -> U;
6800-
6801-
fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
6802-
}
6803-
```
6804-
6805-
As with any other FFI functions, these are by default always `unsafe` to call.
6806-
You can add `#[rustc_safe_intrinsic]` to the intrinsic to make it safe to call.
6807-
6808-
"#]],
6809-
)
6707+
let (analysis, position) = fixture::position(r#"#![feature(intrinsics$0)]"#);
6708+
analysis
6709+
.hover(
6710+
&HoverConfig { links_in_hover: true, ..HOVER_BASE_CONFIG },
6711+
FileRange { file_id: position.file_id, range: TextRange::empty(position.offset) },
6712+
)
6713+
.unwrap()
6714+
.unwrap();
68106715
}
68116716

68126717
#[test]

crates/parser/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ rust-version.workspace = true
1414
[dependencies]
1515
drop_bomb = "0.1.5"
1616
ra-ap-rustc_lexer.workspace = true
17+
rustc-literal-escaper.workspace = true
1718
tracing = { workspace = true, optional = true }
1819

1920
edition.workspace = true

crates/parser/src/lexed_str.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
1111
use std::ops;
1212

13-
use rustc_lexer::unescape::{EscapeError, Mode};
13+
use rustc_literal_escaper::{
14+
EscapeError, Mode, unescape_byte, unescape_char, unescape_mixed, unescape_unicode,
15+
};
1416

1517
use crate::{
1618
Edition,
@@ -282,7 +284,7 @@ impl<'a> Converter<'a> {
282284
let text = &self.res.text[self.offset + 1..][..len - 1];
283285
let i = text.rfind('\'').unwrap();
284286
let text = &text[..i];
285-
if let Err(e) = rustc_lexer::unescape::unescape_char(text) {
287+
if let Err(e) = unescape_char(text) {
286288
err = error_to_diagnostic_message(e, Mode::Char);
287289
}
288290
}
@@ -295,7 +297,7 @@ impl<'a> Converter<'a> {
295297
let text = &self.res.text[self.offset + 2..][..len - 2];
296298
let i = text.rfind('\'').unwrap();
297299
let text = &text[..i];
298-
if let Err(e) = rustc_lexer::unescape::unescape_byte(text) {
300+
if let Err(e) = unescape_byte(text) {
299301
err = error_to_diagnostic_message(e, Mode::Byte);
300302
}
301303
}
@@ -402,14 +404,14 @@ fn unescape_string_error_message(text: &str, mode: Mode) -> &'static str {
402404
let mut error_message = "";
403405
match mode {
404406
Mode::CStr => {
405-
rustc_lexer::unescape::unescape_mixed(text, mode, &mut |_, res| {
407+
unescape_mixed(text, mode, &mut |_, res| {
406408
if let Err(e) = res {
407409
error_message = error_to_diagnostic_message(e, mode);
408410
}
409411
});
410412
}
411413
Mode::ByteStr | Mode::Str => {
412-
rustc_lexer::unescape::unescape_unicode(text, mode, &mut |_, res| {
414+
unescape_unicode(text, mode, &mut |_, res| {
413415
if let Err(e) = res {
414416
error_message = error_to_diagnostic_message(e, mode);
415417
}

0 commit comments

Comments
 (0)