Skip to content

Commit b0afdd1

Browse files
authored
Merge branch 'master' into graceful_error
2 parents 78e17e7 + 69b3959 commit b0afdd1

File tree

151 files changed

+2124
-1355
lines changed

Some content is hidden

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

151 files changed

+2124
-1355
lines changed

.github/ISSUE_TEMPLATE/tracking_issue.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ for larger features an implementation could be broken up into multiple PRs.
4141
- [ ] Implement the RFC (cc @rust-lang/XXX -- can anyone write up mentoring
4242
instructions?)
4343
- [ ] Adjust documentation ([see instructions on rustc-dev-guide][doc-guide])
44-
- [ ] Formatting for new syntax has been added to the [Style Guide] ([nightly-style-procedure])
44+
- [ ] Style updates for any new syntax ([nightly-style-procedure])
45+
- [ ] Style team decision on new formatting
46+
- [ ] Formatting for new syntax has been added to the [Style Guide]
47+
- [ ] (non-blocking) Formatting has been implemented in `rustfmt`
4548
- [ ] Stabilization PR ([see instructions on rustc-dev-guide][stabilization-guide])
4649

4750
[stabilization-guide]: https://rustc-dev-guide.rust-lang.org/stabilization_guide.html#stabilization-pr

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1829,7 +1829,7 @@ pub struct PointeeInfo {
18291829
pub safe: Option<PointerKind>,
18301830
/// If `safe` is `Some`, then the pointer is either null or dereferenceable for this many bytes.
18311831
/// On a function argument, "dereferenceable" here means "dereferenceable for the entire duration
1832-
/// of this function call", i.e. it is UB for the memory that this pointer points to to be freed
1832+
/// of this function call", i.e. it is UB for the memory that this pointer points to be freed
18331833
/// while this function is still running.
18341834
/// The size can be zero if the pointer is not dereferenceable.
18351835
pub size: Size,

compiler/rustc_builtin_macros/src/autodiff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ mod llvm_enzyme {
234234
let meta_item_vec: ThinVec<MetaItemInner> = match meta_item.kind {
235235
ast::MetaItemKind::List(ref vec) => vec.clone(),
236236
_ => {
237-
dcx.emit_err(errors::AutoDiffInvalidApplication { span: item.span() });
237+
dcx.emit_err(errors::AutoDiffMissingConfig { span: item.span() });
238238
return vec![item];
239239
}
240240
};

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 72 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::iter;
33
use rustc_index::IndexVec;
44
use rustc_index::bit_set::DenseBitSet;
55
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
6-
use rustc_middle::mir::{Local, UnwindTerminateReason, traversal};
6+
use rustc_middle::mir::{Body, Local, UnwindTerminateReason, traversal};
77
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, TyAndLayout};
88
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeFoldable, TypeVisitableExt};
99
use rustc_middle::{bug, mir, span_bug};
@@ -170,19 +170,29 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
170170
) {
171171
assert!(!instance.args.has_infer());
172172

173+
let tcx = cx.tcx();
173174
let llfn = cx.get_fn(instance);
174175

175-
let mir = cx.tcx().instance_mir(instance.def);
176+
let mut mir = tcx.instance_mir(instance.def);
176177

177178
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
178179
debug!("fn_abi: {:?}", fn_abi);
179180

180-
if cx.tcx().codegen_fn_attrs(instance.def_id()).flags.contains(CodegenFnAttrFlags::NAKED) {
181+
if tcx.codegen_fn_attrs(instance.def_id()).flags.contains(CodegenFnAttrFlags::NAKED) {
181182
crate::mir::naked_asm::codegen_naked_asm::<Bx>(cx, &mir, instance);
182183
return;
183184
}
184185

185-
let debug_context = cx.create_function_debug_context(instance, fn_abi, llfn, mir);
186+
if tcx.features().ergonomic_clones() {
187+
let monomorphized_mir = instance.instantiate_mir_and_normalize_erasing_regions(
188+
tcx,
189+
ty::TypingEnv::fully_monomorphized(),
190+
ty::EarlyBinder::bind(mir.clone()),
191+
);
192+
mir = tcx.arena.alloc(optimize_use_clone::<Bx>(cx, monomorphized_mir));
193+
}
194+
195+
let debug_context = cx.create_function_debug_context(instance, fn_abi, llfn, &mir);
186196

187197
let start_llbb = Bx::append_block(cx, llfn, "start");
188198
let mut start_bx = Bx::build(cx, start_llbb);
@@ -194,7 +204,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
194204
}
195205

196206
let cleanup_kinds =
197-
base::wants_new_eh_instructions(cx.tcx().sess).then(|| analyze::cleanup_kinds(mir));
207+
base::wants_new_eh_instructions(tcx.sess).then(|| analyze::cleanup_kinds(&mir));
198208

199209
let cached_llbbs: IndexVec<mir::BasicBlock, CachedLlbb<Bx::BasicBlock>> =
200210
mir.basic_blocks
@@ -217,7 +227,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
217227
cleanup_kinds,
218228
landing_pads: IndexVec::from_elem(None, &mir.basic_blocks),
219229
funclets: IndexVec::from_fn_n(|_| None, mir.basic_blocks.len()),
220-
cold_blocks: find_cold_blocks(cx.tcx(), mir),
230+
cold_blocks: find_cold_blocks(tcx, mir),
221231
locals: locals::Locals::empty(),
222232
debug_context,
223233
per_local_var_debug_info: None,
@@ -233,7 +243,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
233243
fx.compute_per_local_var_debug_info(&mut start_bx).unzip();
234244
fx.per_local_var_debug_info = per_local_var_debug_info;
235245

236-
let traversal_order = traversal::mono_reachable_reverse_postorder(mir, cx.tcx(), instance);
246+
let traversal_order = traversal::mono_reachable_reverse_postorder(mir, tcx, instance);
237247
let memory_locals = analyze::non_ssa_locals(&fx, &traversal_order);
238248

239249
// Allocate variable and temp allocas
@@ -310,6 +320,61 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
310320
}
311321
}
312322

323+
// FIXME: Move this function to mir::transform when post-mono MIR passes land.
324+
fn optimize_use_clone<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
325+
cx: &'a Bx::CodegenCx,
326+
mut mir: Body<'tcx>,
327+
) -> Body<'tcx> {
328+
let tcx = cx.tcx();
329+
330+
if tcx.features().ergonomic_clones() {
331+
for bb in mir.basic_blocks.as_mut() {
332+
let mir::TerminatorKind::Call {
333+
args,
334+
destination,
335+
target,
336+
call_source: mir::CallSource::Use,
337+
..
338+
} = &bb.terminator().kind
339+
else {
340+
continue;
341+
};
342+
343+
// CallSource::Use calls always use 1 argument.
344+
assert_eq!(args.len(), 1);
345+
let arg = &args[0];
346+
347+
// These types are easily available from locals, so check that before
348+
// doing DefId lookups to figure out what we're actually calling.
349+
let arg_ty = arg.node.ty(&mir.local_decls, tcx);
350+
351+
let ty::Ref(_region, inner_ty, mir::Mutability::Not) = *arg_ty.kind() else { continue };
352+
353+
if !tcx.type_is_copy_modulo_regions(cx.typing_env(), inner_ty) {
354+
continue;
355+
}
356+
357+
let Some(arg_place) = arg.node.place() else { continue };
358+
359+
let destination_block = target.unwrap();
360+
361+
bb.statements.push(mir::Statement {
362+
source_info: bb.terminator().source_info,
363+
kind: mir::StatementKind::Assign(Box::new((
364+
*destination,
365+
mir::Rvalue::Use(mir::Operand::Copy(
366+
arg_place.project_deeper(&[mir::ProjectionElem::Deref], tcx),
367+
)),
368+
))),
369+
});
370+
371+
bb.terminator_mut().kind = mir::TerminatorKind::Goto { target: destination_block };
372+
}
373+
}
374+
375+
mir
376+
}
377+
313378
/// Produces, for each argument, a `Value` pointing at the
314379
/// argument's value. As arguments are places, these are always
315380
/// indirect.

compiler/rustc_data_structures/src/obligation_forest/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ mod helper {
315315
use super::*;
316316
pub(super) type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>;
317317
impl<O: ForestObligation> ObligationForest<O> {
318-
#[cfg_attr(not(bootstrap), define_opaque(ObligationTreeIdGenerator))]
318+
#[define_opaque(ObligationTreeIdGenerator)]
319319
pub fn new() -> ObligationForest<O> {
320320
ObligationForest {
321321
nodes: vec![],

compiler/rustc_error_codes/src/error_codes/E0622.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#### Note: this error code is no longer emitted by the compiler.
2+
13
An intrinsic was declared without being a function.
24

35
Erroneous code example:
46

5-
```compile_fail,E0622
7+
```no_run
68
#![feature(intrinsics)]
79
#![allow(internal_features)]
810

compiler/rustc_error_codes/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ E0618: 0618,
397397
E0619: 0619,
398398
E0620: 0620,
399399
E0621: 0621,
400-
E0622: 0622,
400+
E0622: 0622, // REMOVED: rustc-intrinsic ABI was removed
401401
E0623: 0623,
402402
E0624: 0624,
403403
E0625: 0625,

compiler/rustc_error_messages/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ pub type LazyFallbackBundle = Arc<LazyLock<FluentBundle, impl FnOnce() -> Fluent
208208

209209
/// Return the default `FluentBundle` with standard "en-US" diagnostic messages.
210210
#[instrument(level = "trace", skip(resources))]
211-
#[cfg_attr(not(bootstrap), define_opaque(LazyFallbackBundle))]
211+
#[define_opaque(LazyFallbackBundle)]
212212
pub fn fallback_fluent_bundle(
213213
resources: Vec<&'static str>,
214214
with_directionality_markers: bool,

compiler/rustc_feature/src/accepted.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ declare_features! (
6363
/// Allows using `const` operands in inline assembly.
6464
(accepted, asm_const, "1.82.0", Some(93332)),
6565
/// Allows using `label` operands in inline assembly.
66-
(accepted, asm_goto, "CURRENT_RUSTC_VERSION", Some(119364)),
66+
(accepted, asm_goto, "1.87.0", Some(119364)),
6767
/// Allows using `sym` operands in inline assembly.
6868
(accepted, asm_sym, "1.66.0", Some(93333)),
6969
/// Allows the definition of associated constants in `trait` or `impl` blocks.
@@ -332,7 +332,7 @@ declare_features! (
332332
/// Allows `use<'a, 'b, A, B>` in `impl Trait + use<...>` for precise capture of generic args.
333333
(accepted, precise_capturing, "1.82.0", Some(123432)),
334334
/// Allows `use<..>` precise capturign on impl Trait in traits.
335-
(accepted, precise_capturing_in_traits, "CURRENT_RUSTC_VERSION", Some(130044)),
335+
(accepted, precise_capturing_in_traits, "1.87.0", Some(130044)),
336336
/// Allows procedural macros in `proc-macro` crates.
337337
(accepted, proc_macro, "1.29.0", Some(38356)),
338338
/// Allows multi-segment paths in attributes and derives.

compiler/rustc_feature/src/removed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ declare_features! (
247247
/// Allows unnamed fields of struct and union type
248248
(removed, unnamed_fields, "1.83.0", Some(49804), Some("feature needs redesign")),
249249
(removed, unsafe_no_drop_flag, "1.0.0", None, None),
250-
(removed, unsized_tuple_coercion, "CURRENT_RUSTC_VERSION", Some(42877),
250+
(removed, unsized_tuple_coercion, "1.87.0", Some(42877),
251251
Some("The feature restricts possible layouts for tuples, and this restriction is not worth it.")),
252252
/// Allows `union` fields that don't implement `Copy` as long as they don't have any drop glue.
253253
(removed, untagged_unions, "1.13.0", Some(55149),

0 commit comments

Comments
 (0)