Skip to content

Commit 5891a01

Browse files
committed
Auto merge of #119755 - matthiaskrgr:rollup-0tn7ybr, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #117744 (Add -Zuse-sync-unwind) - #118649 (Make inductive cycles in coherence ambiguous always) - #118979 (Use `assert_unsafe_precondition` for `char::from_u32_unchecked`) - #119562 (Rename `pointer` field on `Pin`) - #119619 (mir-opt and custom target fixes) - #119632 (Fix broken build for ESP IDF due to #119026) - #119712 (Adding alignment to the cases to test for specific error messages.) - #119734 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d6affcf + 201173f commit 5891a01

File tree

44 files changed

+1034
-763
lines changed

Some content is hidden

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

44 files changed

+1034
-763
lines changed

Cargo.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -2465,6 +2465,7 @@ dependencies = [
24652465
"ctrlc",
24662466
"env_logger",
24672467
"getrandom",
2468+
"jemalloc-sys",
24682469
"lazy_static",
24692470
"libc",
24702471
"libffi",
@@ -2474,7 +2475,6 @@ dependencies = [
24742475
"rand",
24752476
"regex",
24762477
"rustc_version",
2477-
"serde",
24782478
"smallvec",
24792479
"ui_test",
24802480
]
@@ -3280,9 +3280,9 @@ dependencies = [
32803280

32813281
[[package]]
32823282
name = "rustc-build-sysroot"
3283-
version = "0.4.2"
3283+
version = "0.4.4"
32843284
source = "registry+https://github.com/rust-lang/crates.io-index"
3285-
checksum = "8ed2a90dfa5232ed5ff21d53d4df655f315ab316ea06fc508f1c74bcedb1ce6c"
3285+
checksum = "39dcf8d82b1f79a179bdb284dc44db440a9666eefa5a6df5ef282d6db930d544"
32863286
dependencies = [
32873287
"anyhow",
32883288
"rustc_version",

compiler/rustc_codegen_llvm/src/allocator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ fn create_wrapper_function(
134134
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
135135
}
136136
if tcx.sess.must_emit_unwind_tables() {
137-
let uwtable = attributes::uwtable_attr(llcx);
137+
let uwtable =
138+
attributes::uwtable_attr(llcx, tcx.sess.opts.unstable_opts.use_sync_unwind);
138139
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Function, &[uwtable]);
139140
}
140141

compiler/rustc_codegen_llvm/src/attributes.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ pub fn sanitize_attrs<'ll>(
9595

9696
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
9797
#[inline]
98-
pub fn uwtable_attr(llcx: &llvm::Context) -> &Attribute {
98+
pub fn uwtable_attr(llcx: &llvm::Context, use_sync_unwind: Option<bool>) -> &Attribute {
9999
// NOTE: We should determine if we even need async unwind tables, as they
100100
// take have more overhead and if we can use sync unwind tables we
101101
// probably should.
102-
llvm::CreateUWTableAttr(llcx, true)
102+
let async_unwind = !use_sync_unwind.unwrap_or(false);
103+
llvm::CreateUWTableAttr(llcx, async_unwind)
103104
}
104105

105106
pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
@@ -333,7 +334,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
333334
// You can also find more info on why Windows always requires uwtables here:
334335
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
335336
if cx.sess().must_emit_unwind_tables() {
336-
to_add.push(uwtable_attr(cx.llcx));
337+
to_add.push(uwtable_attr(cx.llcx, cx.sess().opts.unstable_opts.use_sync_unwind));
337338
}
338339

339340
if cx.sess().opts.unstable_opts.profile_sample_use.is_some() {

compiler/rustc_lint/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,11 @@ fn register_builtins(store: &mut LintStore) {
513513
"converted into hard error, see PR #117984 \
514514
<https://github.com/rust-lang/rust/pull/117984> for more information",
515515
);
516+
store.register_removed(
517+
"coinductive_overlap_in_coherence",
518+
"converted into hard error, see PR #118649 \
519+
<https://github.com/rust-lang/rust/pull/118649> for more information",
520+
);
516521
}
517522

518523
fn register_internals(store: &mut LintStore) {

compiler/rustc_lint_defs/src/builtin.rs

-40
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ declare_lint_pass! {
2626
BYTE_SLICE_IN_PACKED_STRUCT_WITH_DERIVE,
2727
CENUM_IMPL_DROP_CAST,
2828
COHERENCE_LEAK_CHECK,
29-
COINDUCTIVE_OVERLAP_IN_COHERENCE,
3029
CONFLICTING_REPR_HINTS,
3130
CONST_EVALUATABLE_UNCHECKED,
3231
CONST_ITEM_MUTATION,
@@ -4367,45 +4366,6 @@ declare_lint! {
43674366
@feature_gate = sym::type_privacy_lints;
43684367
}
43694368

4370-
declare_lint! {
4371-
/// The `coinductive_overlap_in_coherence` lint detects impls which are currently
4372-
/// considered not overlapping, but may be considered to overlap if support for
4373-
/// coinduction is added to the trait solver.
4374-
///
4375-
/// ### Example
4376-
///
4377-
/// ```rust,compile_fail
4378-
/// #![deny(coinductive_overlap_in_coherence)]
4379-
///
4380-
/// trait CyclicTrait {}
4381-
/// impl<T: CyclicTrait> CyclicTrait for T {}
4382-
///
4383-
/// trait Trait {}
4384-
/// impl<T: CyclicTrait> Trait for T {}
4385-
/// // conflicting impl with the above
4386-
/// impl Trait for u8 {}
4387-
/// ```
4388-
///
4389-
/// {{produces}}
4390-
///
4391-
/// ### Explanation
4392-
///
4393-
/// We have two choices for impl which satisfy `u8: Trait`: the blanket impl
4394-
/// for generic `T`, and the direct impl for `u8`. These two impls nominally
4395-
/// overlap, since we can infer `T = u8` in the former impl, but since the where
4396-
/// clause `u8: CyclicTrait` would end up resulting in a cycle (since it depends
4397-
/// on itself), the blanket impl is not considered to hold for `u8`. This will
4398-
/// change in a future release.
4399-
pub COINDUCTIVE_OVERLAP_IN_COHERENCE,
4400-
Deny,
4401-
"impls that are not considered to overlap may be considered to \
4402-
overlap in the future",
4403-
@future_incompatible = FutureIncompatibleInfo {
4404-
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
4405-
reference: "issue #114040 <https://github.com/rust-lang/rust/issues/114040>",
4406-
};
4407-
}
4408-
44094369
declare_lint! {
44104370
/// The `unknown_or_malformed_diagnostic_attributes` lint detects unrecognized or otherwise malformed
44114371
/// diagnostic attributes.

compiler/rustc_parse_format/src/lib.rs

+22-6
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ impl<'a> Iterator for Parser<'a> {
289289
}
290290
} else {
291291
if let Some(&(_, maybe)) = self.cur.peek() {
292-
if maybe == '?' {
293-
self.suggest_format();
294-
} else {
295-
self.suggest_positional_arg_instead_of_captured_arg(arg);
292+
match maybe {
293+
'?' => self.suggest_format_debug(),
294+
'<' | '^' | '>' => self.suggest_format_align(maybe),
295+
_ => self.suggest_positional_arg_instead_of_captured_arg(arg),
296296
}
297297
}
298298
}
@@ -868,10 +868,9 @@ impl<'a> Parser<'a> {
868868
found.then_some(cur)
869869
}
870870

871-
fn suggest_format(&mut self) {
871+
fn suggest_format_debug(&mut self) {
872872
if let (Some(pos), Some(_)) = (self.consume_pos('?'), self.consume_pos(':')) {
873873
let word = self.word();
874-
let _end = self.current_pos();
875874
let pos = self.to_span_index(pos);
876875
self.errors.insert(
877876
0,
@@ -887,6 +886,23 @@ impl<'a> Parser<'a> {
887886
}
888887
}
889888

889+
fn suggest_format_align(&mut self, alignment: char) {
890+
if let Some(pos) = self.consume_pos(alignment) {
891+
let pos = self.to_span_index(pos);
892+
self.errors.insert(
893+
0,
894+
ParseError {
895+
description: "expected format parameter to occur after `:`".to_owned(),
896+
note: None,
897+
label: format!("expected `{}` to occur after `:`", alignment).to_owned(),
898+
span: pos.to(pos),
899+
secondary_label: None,
900+
suggestion: Suggestion::None,
901+
},
902+
);
903+
}
904+
}
905+
890906
fn suggest_positional_arg_instead_of_captured_arg(&mut self, arg: Argument<'a>) {
891907
if let Some(end) = self.consume_pos('.') {
892908
let byte_pos = self.to_span_index(end);

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1960,6 +1960,8 @@ written to standard error output)"),
19601960
"adds unstable command line options to rustc interface (default: no)"),
19611961
use_ctors_section: Option<bool> = (None, parse_opt_bool, [TRACKED],
19621962
"use legacy .ctors section for initializers rather than .init_array"),
1963+
use_sync_unwind: Option<bool> = (None, parse_opt_bool, [TRACKED],
1964+
"Generate sync unwind tables instead of async unwind tables (default: no)"),
19631965
validate_mir: bool = (false, parse_bool, [UNTRACKED],
19641966
"validate MIR after each transformation"),
19651967
#[rustc_lint_opt_deny_field_access("use `Session::verbose_internals` instead of this field")]

compiler/rustc_trait_selection/src/traits/coherence.rs

+6-58
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor
1010
use crate::solve::{deeply_normalize_for_diagnostics, inspect};
1111
use crate::traits::engine::TraitEngineExt;
1212
use crate::traits::query::evaluate_obligation::InferCtxtExt;
13-
use crate::traits::select::{IntercrateAmbiguityCause, TreatInductiveCycleAs};
13+
use crate::traits::select::IntercrateAmbiguityCause;
1414
use crate::traits::structural_normalize::StructurallyNormalizeExt;
1515
use crate::traits::NormalizeExt;
1616
use crate::traits::SkipLeakCheck;
@@ -31,7 +31,6 @@ use rustc_middle::traits::DefiningAnchor;
3131
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
3232
use rustc_middle::ty::visit::{TypeVisitable, TypeVisitableExt};
3333
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitor};
34-
use rustc_session::lint::builtin::COINDUCTIVE_OVERLAP_IN_COHERENCE;
3534
use rustc_span::symbol::sym;
3635
use rustc_span::DUMMY_SP;
3736
use std::fmt::Debug;
@@ -197,7 +196,7 @@ fn overlap<'tcx>(
197196
.intercrate(true)
198197
.with_next_trait_solver(tcx.next_trait_solver_in_coherence())
199198
.build();
200-
let selcx = &mut SelectionContext::new(&infcx);
199+
let selcx = &mut SelectionContext::with_treat_inductive_cycle_as_ambig(&infcx);
201200
if track_ambiguity_causes.is_yes() {
202201
selcx.enable_tracking_intercrate_ambiguity_causes();
203202
}
@@ -224,61 +223,10 @@ fn overlap<'tcx>(
224223
);
225224

226225
if overlap_mode.use_implicit_negative() {
227-
for mode in [TreatInductiveCycleAs::Ambig, TreatInductiveCycleAs::Recur] {
228-
if let Some(failing_obligation) = selcx.with_treat_inductive_cycle_as(mode, |selcx| {
229-
impl_intersection_has_impossible_obligation(selcx, &obligations)
230-
}) {
231-
if matches!(mode, TreatInductiveCycleAs::Recur) {
232-
let first_local_impl = impl1_header
233-
.impl_def_id
234-
.as_local()
235-
.or(impl2_header.impl_def_id.as_local())
236-
.expect("expected one of the impls to be local");
237-
infcx.tcx.struct_span_lint_hir(
238-
COINDUCTIVE_OVERLAP_IN_COHERENCE,
239-
infcx.tcx.local_def_id_to_hir_id(first_local_impl),
240-
infcx.tcx.def_span(first_local_impl),
241-
format!(
242-
"implementations {} will conflict in the future",
243-
match impl1_header.trait_ref {
244-
Some(trait_ref) => {
245-
let trait_ref = infcx.resolve_vars_if_possible(trait_ref);
246-
format!(
247-
"of `{}` for `{}`",
248-
trait_ref.print_trait_sugared(),
249-
trait_ref.self_ty()
250-
)
251-
}
252-
None => format!(
253-
"for `{}`",
254-
infcx.resolve_vars_if_possible(impl1_header.self_ty)
255-
),
256-
},
257-
),
258-
|lint| {
259-
lint.note(
260-
"impls that are not considered to overlap may be considered to \
261-
overlap in the future",
262-
)
263-
.span_label(
264-
infcx.tcx.def_span(impl1_header.impl_def_id),
265-
"the first impl is here",
266-
)
267-
.span_label(
268-
infcx.tcx.def_span(impl2_header.impl_def_id),
269-
"the second impl is here",
270-
);
271-
lint.note(format!(
272-
"`{}` may be considered to hold in future releases, \
273-
causing the impls to overlap",
274-
infcx.resolve_vars_if_possible(failing_obligation.predicate)
275-
));
276-
},
277-
);
278-
}
279-
280-
return None;
281-
}
226+
if let Some(_failing_obligation) =
227+
impl_intersection_has_impossible_obligation(selcx, &obligations)
228+
{
229+
return None;
282230
}
283231
}
284232

compiler/rustc_trait_selection/src/traits/select/mod.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,16 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
239239
}
240240
}
241241

242-
// Sets the `TreatInductiveCycleAs` mode temporarily in the selection context
243-
pub fn with_treat_inductive_cycle_as<T>(
244-
&mut self,
245-
treat_inductive_cycle: TreatInductiveCycleAs,
246-
f: impl FnOnce(&mut Self) -> T,
247-
) -> T {
242+
pub fn with_treat_inductive_cycle_as_ambig(
243+
infcx: &'cx InferCtxt<'tcx>,
244+
) -> SelectionContext<'cx, 'tcx> {
248245
// Should be executed in a context where caching is disabled,
249246
// otherwise the cache is poisoned with the temporary result.
250-
assert!(self.is_intercrate());
251-
let treat_inductive_cycle =
252-
std::mem::replace(&mut self.treat_inductive_cycle, treat_inductive_cycle);
253-
let value = f(self);
254-
self.treat_inductive_cycle = treat_inductive_cycle;
255-
value
247+
assert!(infcx.intercrate);
248+
SelectionContext {
249+
treat_inductive_cycle: TreatInductiveCycleAs::Ambig,
250+
..SelectionContext::new(infcx)
251+
}
256252
}
257253

258254
pub fn with_query_mode(

library/core/src/char/convert.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::char::TryFromCharError;
44
use crate::convert::TryFrom;
55
use crate::error::Error;
66
use crate::fmt;
7+
use crate::intrinsics::assert_unsafe_precondition;
78
use crate::mem::transmute;
89
use crate::str::FromStr;
910

@@ -23,7 +24,13 @@ pub(super) const fn from_u32(i: u32) -> Option<char> {
2324
#[must_use]
2425
pub(super) const unsafe fn from_u32_unchecked(i: u32) -> char {
2526
// SAFETY: the caller must guarantee that `i` is a valid char value.
26-
if cfg!(debug_assertions) { char::from_u32(i).unwrap() } else { unsafe { transmute(i) } }
27+
unsafe {
28+
assert_unsafe_precondition!(
29+
"invalid value for `char`",
30+
(i: u32) => char_try_from_u32(i).is_ok()
31+
);
32+
transmute(i)
33+
}
2734
}
2835

2936
#[stable(feature = "char_convert", since = "1.13.0")]

0 commit comments

Comments
 (0)