Skip to content

Commit fd4dc18

Browse files
committed
Auto merge of rust-lang#139452 - GuillaumeGomez:rollup-u9edkjo, r=GuillaumeGomez
Rollup of 6 pull requests Successful merges: - rust-lang#138562 (Optimize slice {Chunks,Windows}::nth) - rust-lang#138876 (Trusty: Implement `write_vectored` for stdio ) - rust-lang#139072 (Add `slice::align_to_uninit_mut`) - rust-lang#139367 (Add `*_value` methods to proc_macro lib) - rust-lang#139391 (Check if merged attributes list is empty in expr) - rust-lang#139414 (Fix typo in `RawList`'s documentation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 175dcc7 + b3e051a commit fd4dc18

File tree

34 files changed

+349
-840
lines changed

34 files changed

+349
-840
lines changed

Cargo.lock

+9-1
Original file line numberDiff line numberDiff line change
@@ -3150,6 +3150,12 @@ version = "2.1.1"
31503150
source = "registry+https://github.com/rust-lang/crates.io-index"
31513151
checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d"
31523152

3153+
[[package]]
3154+
name = "rustc-literal-escaper"
3155+
version = "0.0.2"
3156+
source = "registry+https://github.com/rust-lang/crates.io-index"
3157+
checksum = "0041b6238913c41fe704213a4a9329e2f685a156d1781998128b4149c230ad04"
3158+
31533159
[[package]]
31543160
name = "rustc-main"
31553161
version = "0.0.0"
@@ -3242,10 +3248,10 @@ version = "0.0.0"
32423248
dependencies = [
32433249
"bitflags",
32443250
"memchr",
3251+
"rustc-literal-escaper",
32453252
"rustc_ast_ir",
32463253
"rustc_data_structures",
32473254
"rustc_index",
3248-
"rustc_lexer",
32493255
"rustc_macros",
32503256
"rustc_serialize",
32513257
"rustc_span",
@@ -4200,6 +4206,7 @@ name = "rustc_parse"
42004206
version = "0.0.0"
42014207
dependencies = [
42024208
"bitflags",
4209+
"rustc-literal-escaper",
42034210
"rustc_ast",
42044211
"rustc_ast_pretty",
42054212
"rustc_data_structures",
@@ -4222,6 +4229,7 @@ dependencies = [
42224229
name = "rustc_parse_format"
42234230
version = "0.0.0"
42244231
dependencies = [
4232+
"rustc-literal-escaper",
42254233
"rustc_index",
42264234
"rustc_lexer",
42274235
]

compiler/rustc_ast/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ edition = "2024"
77
# tidy-alphabetical-start
88
bitflags = "2.4.1"
99
memchr = "2.7.4"
10+
rustc-literal-escaper = "0.0.2"
1011
rustc_ast_ir = { path = "../rustc_ast_ir" }
1112
rustc_data_structures = { path = "../rustc_data_structures" }
1213
rustc_index = { path = "../rustc_index" }
13-
rustc_lexer = { path = "../rustc_lexer" }
1414
rustc_macros = { path = "../rustc_macros" }
1515
rustc_serialize = { path = "../rustc_serialize" }
1616
rustc_span = { path = "../rustc_span" }

compiler/rustc_ast/src/util/literal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::{ascii, fmt, str};
44

5-
use rustc_lexer::unescape::{
5+
use rustc_literal_escaper::{
66
MixedUnit, Mode, byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode,
77
};
88
use rustc_span::{Span, Symbol, kw, sym};

compiler/rustc_ast_lowering/src/expr.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
7474
// Merge attributes into the inner expression.
7575
if !e.attrs.is_empty() {
7676
let old_attrs = self.attrs.get(&ex.hir_id.local_id).copied().unwrap_or(&[]);
77-
self.attrs.insert(
78-
ex.hir_id.local_id,
79-
&*self.arena.alloc_from_iter(
80-
self.lower_attrs_vec(&e.attrs, e.span)
81-
.into_iter()
82-
.chain(old_attrs.iter().cloned()),
83-
),
77+
let attrs = &*self.arena.alloc_from_iter(
78+
self.lower_attrs_vec(&e.attrs, e.span)
79+
.into_iter()
80+
.chain(old_attrs.iter().cloned()),
8481
);
82+
if attrs.is_empty() {
83+
return ex;
84+
}
85+
86+
self.attrs.insert(ex.hir_id.local_id, attrs);
8587
}
8688
return ex;
8789
}

compiler/rustc_lexer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
// tidy-alphabetical-end
2727

2828
mod cursor;
29-
pub mod unescape;
3029

3130
#[cfg(test)]
3231
mod tests;

0 commit comments

Comments
 (0)