Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 18a029c

Browse files
committed
Auto merge of #139657 - Zalathar:rollup-6oh6f9q, r=Zalathar
Rollup of 12 pull requests Successful merges: - #137447 (add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`) - #138182 (rustc_target: update x86_win64 to match the documented calling convention for f128) - #138682 (Allow drivers to supply a list of extra symbols to intern) - #138904 (Test linking and running `no_std` binaries) - #138998 (Don't suggest the use of `impl Trait` in closure parameter) - #139447 (doc changes: debug assertions -> overflow checks) - #139469 (Introduce a `//@ needs-crate-type` compiletest directive) - #139564 (Deeply normalize obligations in `BestObligation` folder) - #139574 (bootstrap: improve `channel` handling) - #139600 (Update `compiler-builtins` to 0.1.153) - #139641 (Allow parenthesis around inferred array lengths) - #139654 (Improve `AssocItem::descr`.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e62d47d + 96d282c commit 18a029c

File tree

91 files changed

+899
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+899
-313
lines changed

‎compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
20342034
}
20352035

20362036
fn lower_array_length_to_const_arg(&mut self, c: &AnonConst) -> &'hir hir::ConstArg<'hir> {
2037-
match c.value.kind {
2037+
// We cannot just match on `ExprKind::Underscore` as `(_)` is represented as
2038+
// `ExprKind::Paren(ExprKind::Underscore)` and should also be lowered to `GenericArg::Infer`
2039+
match c.value.peel_parens().kind {
20382040
ExprKind::Underscore => {
20392041
if !self.tcx.features().generic_arg_infer() {
20402042
feature_err(

‎compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14211421
return Ok(bx.shuffle_vector(args[0].immediate(), args[1].immediate(), indices));
14221422
}
14231423

1424-
if name == sym::simd_insert {
1424+
if name == sym::simd_insert || name == sym::simd_insert_dyn {
14251425
require!(
14261426
in_elem == arg_tys[2],
14271427
InvalidMonomorphization::InsertedType {
@@ -1432,40 +1432,49 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
14321432
out_ty: arg_tys[2]
14331433
}
14341434
);
1435-
let idx = bx
1436-
.const_to_opt_u128(args[1].immediate(), false)
1437-
.expect("typeck should have ensure that this is a const");
1438-
if idx >= in_len.into() {
1439-
return_error!(InvalidMonomorphization::SimdIndexOutOfBounds {
1440-
span,
1441-
name,
1442-
arg_idx: 1,
1443-
total_len: in_len.into(),
1444-
});
1445-
}
1446-
return Ok(bx.insert_element(
1447-
args[0].immediate(),
1448-
args[2].immediate(),
1449-
bx.const_i32(idx as i32),
1450-
));
1435+
1436+
let index_imm = if name == sym::simd_insert {
1437+
let idx = bx
1438+
.const_to_opt_u128(args[1].immediate(), false)
1439+
.expect("typeck should have ensure that this is a const");
1440+
if idx >= in_len.into() {
1441+
return_error!(InvalidMonomorphization::SimdIndexOutOfBounds {
1442+
span,
1443+
name,
1444+
arg_idx: 1,
1445+
total_len: in_len.into(),
1446+
});
1447+
}
1448+
bx.const_i32(idx as i32)
1449+
} else {
1450+
args[1].immediate()
1451+
};
1452+
1453+
return Ok(bx.insert_element(args[0].immediate(), args[2].immediate(), index_imm));
14511454
}
1452-
if name == sym::simd_extract {
1455+
if name == sym::simd_extract || name == sym::simd_extract_dyn {
14531456
require!(
14541457
ret_ty == in_elem,
14551458
InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty }
14561459
);
1457-
let idx = bx
1458-
.const_to_opt_u128(args[1].immediate(), false)
1459-
.expect("typeck should have ensure that this is a const");
1460-
if idx >= in_len.into() {
1461-
return_error!(InvalidMonomorphization::SimdIndexOutOfBounds {
1462-
span,
1463-
name,
1464-
arg_idx: 1,
1465-
total_len: in_len.into(),
1466-
});
1467-
}
1468-
return Ok(bx.extract_element(args[0].immediate(), bx.const_i32(idx as i32)));
1460+
let index_imm = if name == sym::simd_extract {
1461+
let idx = bx
1462+
.const_to_opt_u128(args[1].immediate(), false)
1463+
.expect("typeck should have ensure that this is a const");
1464+
if idx >= in_len.into() {
1465+
return_error!(InvalidMonomorphization::SimdIndexOutOfBounds {
1466+
span,
1467+
name,
1468+
arg_idx: 1,
1469+
total_len: in_len.into(),
1470+
});
1471+
}
1472+
bx.const_i32(idx as i32)
1473+
} else {
1474+
args[1].immediate()
1475+
};
1476+
1477+
return Ok(bx.extract_element(args[0].immediate(), index_imm));
14691478
}
14701479

14711480
if name == sym::simd_select {

‎compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ pub fn run_compiler(at_args: &[String], callbacks: &mut (dyn Callbacks + Send))
264264
hash_untracked_state: None,
265265
register_lints: None,
266266
override_queries: None,
267+
extra_symbols: Vec::new(),
267268
make_codegen_backend: None,
268269
registry: diagnostics_registry(),
269270
using_internal_features: &USING_INTERNAL_FEATURES,

‎compiler/rustc_hir/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn def_path_hash_depends_on_crate_id() {
1717
// the crate by changing the crate disambiguator (e.g. via bumping the
1818
// crate's version number).
1919

20-
create_session_globals_then(Edition::Edition2024, None, || {
20+
create_session_globals_then(Edition::Edition2024, &[],None, || {
2121
let id0 = StableCrateId::new(Symbol::intern("foo"), false, vec!["1".to_string()], "");
2222
let id1 = StableCrateId::new(Symbol::intern("foo"), false, vec!["2".to_string()], "");
2323

‎compiler/rustc_hir_analysis/src/check/intrinsic.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,12 @@ pub(crate) fn check_intrinsic_type(
659659
sym::simd_masked_load => (3, 0, vec![param(0), param(1), param(2)], param(2)),
660660
sym::simd_masked_store => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
661661
sym::simd_scatter => (3, 0, vec![param(0), param(1), param(2)], tcx.types.unit),
662-
sym::simd_insert => (2, 0, vec![param(0), tcx.types.u32, param(1)], param(0)),
663-
sym::simd_extract => (2, 0, vec![param(0), tcx.types.u32], param(1)),
662+
sym::simd_insert | sym::simd_insert_dyn => {
663+
(2, 0, vec![param(0), tcx.types.u32, param(1)], param(0))
664+
}
665+
sym::simd_extract | sym::simd_extract_dyn => {
666+
(2, 0, vec![param(0), tcx.types.u32], param(1))
667+
}
664668
sym::simd_cast
665669
| sym::simd_as
666670
| sym::simd_cast_ptr

‎compiler/rustc_interface/src/interface.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,10 @@ pub struct Config {
348348
/// the list of queries.
349349
pub override_queries: Option<fn(&Session, &mut Providers)>,
350350

351+
/// An extra set of symbols to add to the symbol interner, the symbol indices
352+
/// will start at [`PREDEFINED_SYMBOLS_COUNT`](rustc_span::symbol::PREDEFINED_SYMBOLS_COUNT)
353+
pub extra_symbols: Vec<&'static str>,
354+
351355
/// This is a callback from the driver that is called to create a codegen backend.
352356
///
353357
/// Has no uses within this repository, but is used by bjorn3 for "the
@@ -409,6 +413,7 @@ pub fn run_compiler<R: Send>(config: Config, f: impl FnOnce(&Compiler) -> R + Se
409413
&early_dcx,
410414
config.opts.edition,
411415
config.opts.unstable_opts.threads,
416+
&config.extra_symbols,
412417
SourceMapInputs { file_loader, path_mapping, hash_kind, checksum_hash_kind },
413418
|current_gcx| {
414419
// The previous `early_dcx` can't be reused here because it doesn't

‎compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ where
5353
checksum_hash_kind,
5454
});
5555

56-
rustc_span::create_session_globals_then(DEFAULT_EDITION, sm_inputs, || {
56+
rustc_span::create_session_globals_then(DEFAULT_EDITION, &[],sm_inputs, || {
5757
let temps_dir = sessopts.unstable_opts.temps_dir.as_deref().map(PathBuf::from);
5858
let io = CompilerIO {
5959
input: Input::Str { name: FileName::Custom(String::new()), input: String::new() },

‎compiler/rustc_interface/src/util.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ fn run_in_thread_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
117117
thread_stack_size: usize,
118118
edition: Edition,
119119
sm_inputs: SourceMapInputs,
120+
extra_symbols: &[&'static str],
120121
f: F,
121122
) -> R {
122123
// The "thread pool" is a single spawned thread in the non-parallel
@@ -134,9 +135,12 @@ fn run_in_thread_with_globals<F: FnOnce(CurrentGcx) -> R + Send, R: Send>(
134135
// name contains null bytes.
135136
let r = builder
136137
.spawn_scoped(s, move || {
137-
rustc_span::create_session_globals_then(edition, Some(sm_inputs), || {
138-
f(CurrentGcx::new())
139-
})
138+
rustc_span::create_session_globals_then(
139+
edition,
140+
extra_symbols,
141+
Some(sm_inputs),
142+
|| f(CurrentGcx::new()),
143+
)
140144
})
141145
.unwrap()
142146
.join();
@@ -152,6 +156,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
152156
thread_builder_diag: &EarlyDiagCtxt,
153157
edition: Edition,
154158
threads: usize,
159+
extra_symbols: &[&'static str],
155160
sm_inputs: SourceMapInputs,
156161
f: F,
157162
) -> R {
@@ -168,12 +173,18 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
168173
let registry = sync::Registry::new(std::num::NonZero::new(threads).unwrap());
169174

170175
if !sync::is_dyn_thread_safe() {
171-
return run_in_thread_with_globals(thread_stack_size, edition, sm_inputs, |current_gcx| {
172-
// Register the thread for use with the `WorkerLocal` type.
173-
registry.register();
174-
175-
f(current_gcx)
176-
});
176+
return run_in_thread_with_globals(
177+
thread_stack_size,
178+
edition,
179+
sm_inputs,
180+
extra_symbols,
181+
|current_gcx| {
182+
// Register the thread for use with the `WorkerLocal` type.
183+
registry.register();
184+
185+
f(current_gcx)
186+
},
187+
);
177188
}
178189

179190
let current_gcx = FromDyn::from(CurrentGcx::new());
@@ -230,7 +241,7 @@ pub(crate) fn run_in_thread_pool_with_globals<F: FnOnce(CurrentGcx) -> R + Send,
230241
// pool. Upon creation, each worker thread created gets a copy of the
231242
// session globals in TLS. This is possible because `SessionGlobals` impls
232243
// `Send` in the parallel compiler.
233-
rustc_span::create_session_globals_then(edition, Some(sm_inputs), || {
244+
rustc_span::create_session_globals_then(edition, extra_symbols,Some(sm_inputs), || {
234245
rustc_span::with_session_globals(|session_globals| {
235246
let session_globals = FromDyn::from(session_globals);
236247
builder

‎compiler/rustc_macros/src/symbols.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ pub(super) fn symbols(input: TokenStream) -> TokenStream {
142142
output
143143
}
144144

145-
struct Preinterned {
145+
struct Predefined {
146146
idx: u32,
147147
span_of_name: Span,
148148
}
149149

150150
struct Entries {
151-
map: HashMap<String, Preinterned>,
151+
map: HashMap<String, Predefined>,
152152
}
153153

154154
impl Entries {
@@ -163,7 +163,7 @@ impl Entries {
163163
prev.idx
164164
} else {
165165
let idx = self.len();
166-
self.map.insert(s.to_string(), Preinterned { idx, span_of_name: span });
166+
self.map.insert(s.to_string(), Predefined { idx, span_of_name: span });
167167
idx
168168
}
169169
}
@@ -295,10 +295,14 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
295295
}
296296

297297
let symbol_digits_base = entries.map["0"].idx;
298-
let preinterned_symbols_count = entries.len();
298+
let predefined_symbols_count = entries.len();
299299
let output = quote! {
300300
const SYMBOL_DIGITS_BASE: u32 = #symbol_digits_base;
301-
const PREINTERNED_SYMBOLS_COUNT: u32 = #preinterned_symbols_count;
301+
302+
/// The number of predefined symbols; this is the the first index for
303+
/// extra pre-interned symbols in an Interner created via
304+
/// [`Interner::with_extra_symbols`].
305+
pub const PREDEFINED_SYMBOLS_COUNT: u32 = #predefined_symbols_count;
302306

303307
#[doc(hidden)]
304308
#[allow(non_upper_case_globals)]
@@ -315,10 +319,13 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
315319
}
316320

317321
impl Interner {
318-
pub(crate) fn fresh() -> Self {
319-
Interner::prefill(&[
320-
#prefill_stream
321-
])
322+
/// Creates an `Interner` with the predefined symbols from the `symbols!` macro and
323+
/// any extra symbols provided by external drivers such as Clippy
324+
pub(crate) fn with_extra_symbols(extra_symbols: &[&'static str]) -> Self {
325+
Interner::prefill(
326+
&[#prefill_stream],
327+
extra_symbols,
328+
)
322329
}
323330
}
324331
};

‎compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,9 +562,9 @@ impl<'a, 'tcx> SpanDecoder for DecodeContext<'a, 'tcx> {
562562
Symbol::intern(s)
563563
})
564564
}
565-
SYMBOL_PREINTERNED => {
565+
SYMBOL_PREDEFINED => {
566566
let symbol_index = self.read_u32();
567-
Symbol::new_from_decoded(symbol_index)
567+
Symbol::new(symbol_index)
568568
}
569569
_ => unreachable!(),
570570
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /