Skip to content

Commit 71a7b66

Browse files
committed
Auto merge of rust-lang#121790 - jhpratt:rollup-yocg203, r=jhpratt
Rollup of 10 pull requests Successful merges: - rust-lang#119748 (Increase visibility of `join_path` and `split_paths`) - rust-lang#120291 (Have `String` use `SliceIndex` impls from `str`) - rust-lang#121723 (Two diagnostic things) - rust-lang#121740 (Changing some attributes to only_local.) - rust-lang#121745 (Deeply normalize obligations in `refining_impl_trait`) - rust-lang#121748 (Restore the standard library review rotation to its former glory) - rust-lang#121768 (Implement unwind safety for Condvar on all platforms ) - rust-lang#121777 (Fix typo in `rustc_passes/messages.ftl`) - rust-lang#121778 (Document potential memory leak in unbounded channel) - rust-lang#121779 (Remove unused diagnostic struct) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d3d145e + 698cec8 commit 71a7b66

File tree

18 files changed

+173
-213
lines changed

18 files changed

+173
-213
lines changed

compiler/rustc_builtin_macros/src/errors.rs

-21
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,6 @@ pub(crate) struct BenchSig {
136136
pub(crate) span: Span,
137137
}
138138

139-
#[derive(Diagnostic)]
140-
#[diag(builtin_macros_test_arg_non_lifetime)]
141-
pub(crate) struct TestArgNonLifetime {
142-
#[primary_span]
143-
pub(crate) span: Span,
144-
}
145-
146-
#[derive(Diagnostic)]
147-
#[diag(builtin_macros_should_panic)]
148-
pub(crate) struct ShouldPanic {
149-
#[primary_span]
150-
pub(crate) span: Span,
151-
}
152-
153-
#[derive(Diagnostic)]
154-
#[diag(builtin_macros_test_args)]
155-
pub(crate) struct TestArgs {
156-
#[primary_span]
157-
pub(crate) span: Span,
158-
}
159-
160139
#[derive(Diagnostic)]
161140
#[diag(builtin_macros_alloc_must_statics)]
162141
pub(crate) struct AllocMustStatics {

compiler/rustc_errors/src/diagnostic.rs

+19
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,25 @@ impl EmissionGuarantee for rustc_span::fatal_error::FatalError {
108108

109109
/// Trait implemented by error types. This is rarely implemented manually. Instead, use
110110
/// `#[derive(Diagnostic)]` -- see [rustc_macros::Diagnostic].
111+
///
112+
/// When implemented manually, it should be generic over the emission
113+
/// guarantee, i.e.:
114+
/// ```ignore (fragment)
115+
/// impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for Foo { ... }
116+
/// ```
117+
/// rather than being specific:
118+
/// ```ignore (fragment)
119+
/// impl<'a> IntoDiagnostic<'a> for Bar { ... } // the default type param is `ErrorGuaranteed`
120+
/// impl<'a> IntoDiagnostic<'a, ()> for Baz { ... }
121+
/// ```
122+
/// There are two reasons for this.
123+
/// - A diagnostic like `Foo` *could* be emitted at any level -- `level` is
124+
/// passed in to `into_diagnostic` from outside. Even if in practice it is
125+
/// always emitted at a single level, we let the diagnostic creation/emission
126+
/// site determine the level (by using `create_err`, `emit_warn`, etc.)
127+
/// rather than the `IntoDiagnostic` impl.
128+
/// - Derived impls are always generic, and it's good for the hand-written
129+
/// impls to be consistent with them.
111130
#[rustc_diagnostic_item = "IntoDiagnostic"]
112131
pub trait IntoDiagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
113132
/// Write out as a diagnostic out of `DiagCtxt`.

compiler/rustc_errors/src/lib.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -1498,14 +1498,26 @@ impl DiagCtxtInner {
14981498
let bugs: Vec<_> =
14991499
std::mem::take(&mut self.delayed_bugs).into_iter().map(|(b, _)| b).collect();
15001500

1501-
// If backtraces are enabled, also print the query stack
15021501
let backtrace = std::env::var_os("RUST_BACKTRACE").map_or(true, |x| &x != "0");
1503-
for (i, bug) in bugs.into_iter().enumerate() {
1504-
if let Some(file) = self.ice_file.as_ref()
1505-
&& let Ok(mut out) = std::fs::File::options().create(true).append(true).open(file)
1506-
{
1507-
let _ = write!(
1508-
&mut out,
1502+
let decorate = backtrace || self.ice_file.is_none();
1503+
let mut out = self
1504+
.ice_file
1505+
.as_ref()
1506+
.and_then(|file| std::fs::File::options().create(true).append(true).open(file).ok());
1507+
1508+
// Put the overall explanation before the `DelayedBug`s, to frame them
1509+
// better (e.g. separate warnings from them). Also, use notes, which
1510+
// don't count as errors, to avoid possibly triggering
1511+
// `-Ztreat-err-as-bug`, which we don't want.
1512+
let note1 = "no errors encountered even though delayed bugs were created";
1513+
let note2 = "those delayed bugs will now be shown as internal compiler errors";
1514+
self.emit_diagnostic(DiagInner::new(Note, note1));
1515+
self.emit_diagnostic(DiagInner::new(Note, note2));
1516+
1517+
for bug in bugs {
1518+
if let Some(out) = &mut out {
1519+
_ = write!(
1520+
out,
15091521
"delayed bug: {}\n{}\n",
15101522
bug.inner
15111523
.messages
@@ -1516,21 +1528,9 @@ impl DiagCtxtInner {
15161528
);
15171529
}
15181530

1519-
if i == 0 {
1520-
// Put the overall explanation before the `DelayedBug`s, to
1521-
// frame them better (e.g. separate warnings from them). Also,
1522-
// make it a note so it doesn't count as an error, because that
1523-
// could trigger `-Ztreat-err-as-bug`, which we don't want.
1524-
let note1 = "no errors encountered even though delayed bugs were created";
1525-
let note2 = "those delayed bugs will now be shown as internal compiler errors";
1526-
self.emit_diagnostic(DiagInner::new(Note, note1));
1527-
self.emit_diagnostic(DiagInner::new(Note, note2));
1528-
}
1529-
1530-
let mut bug =
1531-
if backtrace || self.ice_file.is_none() { bug.decorate(self) } else { bug.inner };
1531+
let mut bug = if decorate { bug.decorate(self) } else { bug.inner };
15321532

1533-
// "Undelay" the delayed bugs (into plain `Bug`s).
1533+
// "Undelay" the delayed bugs into plain bugs.
15341534
if bug.level != DelayedBug {
15351535
// NOTE(eddyb) not panicking here because we're already producing
15361536
// an ICE, and the more information the merrier.

compiler/rustc_feature/src/builtin_attrs.rs

+45-18
Original file line numberDiff line numberDiff line change
@@ -555,56 +555,80 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
555555
),
556556
gated!(
557557
rustc_allow_const_fn_unstable, Normal,
558-
template!(Word, List: "feat1, feat2, ..."), DuplicatesOk,
558+
template!(Word, List: "feat1, feat2, ..."), DuplicatesOk, @only_local: true,
559559
"rustc_allow_const_fn_unstable side-steps feature gating and stability checks"
560560
),
561561
gated!(
562562
allow_internal_unsafe, Normal, template!(Word), WarnFollowing,
563-
"allow_internal_unsafe side-steps the unsafe_code lint",
563+
@only_local: true, "allow_internal_unsafe side-steps the unsafe_code lint",
564+
),
565+
rustc_attr!(
566+
rustc_allowed_through_unstable_modules, Normal, template!(Word),
567+
WarnFollowing, @only_local: true,
568+
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
569+
through unstable paths"
564570
),
565-
rustc_attr!(rustc_allowed_through_unstable_modules, Normal, template!(Word), WarnFollowing,
566-
"rustc_allowed_through_unstable_modules special cases accidental stabilizations of stable items \
567-
through unstable paths"),
568571

569572
// ==========================================================================
570573
// Internal attributes: Type system related:
571574
// ==========================================================================
572575

573576
gated!(fundamental, Normal, template!(Word), WarnFollowing, experimental!(fundamental)),
574577
gated!(
575-
may_dangle, Normal, template!(Word), WarnFollowing, dropck_eyepatch,
578+
may_dangle, Normal, template!(Word), WarnFollowing,
579+
@only_local: true, dropck_eyepatch,
576580
"`may_dangle` has unstable semantics and may be removed in the future",
577581
),
578582

579583
// ==========================================================================
580584
// Internal attributes: Runtime related:
581585
// ==========================================================================
582586

583-
rustc_attr!(rustc_allocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
584-
rustc_attr!(rustc_nounwind, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
585-
rustc_attr!(rustc_reallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
586-
rustc_attr!(rustc_deallocator, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
587-
rustc_attr!(rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing, IMPL_DETAIL),
587+
rustc_attr!(
588+
rustc_allocator, Normal, template!(Word), WarnFollowing,
589+
@only_local: true, IMPL_DETAIL
590+
),
591+
rustc_attr!(
592+
rustc_nounwind, Normal, template!(Word), WarnFollowing,
593+
@only_local: true, IMPL_DETAIL
594+
),
595+
rustc_attr!(
596+
rustc_reallocator, Normal, template!(Word), WarnFollowing,
597+
@only_local: true, IMPL_DETAIL
598+
),
599+
rustc_attr!(
600+
rustc_deallocator, Normal, template!(Word), WarnFollowing,
601+
@only_local: true, IMPL_DETAIL
602+
),
603+
rustc_attr!(
604+
rustc_allocator_zeroed, Normal, template!(Word), WarnFollowing,
605+
@only_local: true, IMPL_DETAIL
606+
),
607+
gated!(
608+
default_lib_allocator, Normal, template!(Word), WarnFollowing,
609+
@only_local: true, allocator_internals, experimental!(default_lib_allocator),
610+
),
588611
gated!(
589-
default_lib_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
590-
experimental!(default_lib_allocator),
612+
needs_allocator, Normal, template!(Word), WarnFollowing,
613+
@only_local: true, allocator_internals, experimental!(needs_allocator),
591614
),
592615
gated!(
593-
needs_allocator, Normal, template!(Word), WarnFollowing, allocator_internals,
594-
experimental!(needs_allocator),
616+
panic_runtime, Normal, template!(Word), WarnFollowing,
617+
@only_local: true, experimental!(panic_runtime)
595618
),
596-
gated!(panic_runtime, Normal, template!(Word), WarnFollowing, experimental!(panic_runtime)),
597619
gated!(
598620
needs_panic_runtime, Normal, template!(Word), WarnFollowing,
599-
experimental!(needs_panic_runtime)
621+
@only_local: true, experimental!(needs_panic_runtime)
600622
),
601623
gated!(
602624
compiler_builtins, Normal, template!(Word), WarnFollowing,
625+
@only_local: true,
603626
"the `#[compiler_builtins]` attribute is used to identify the `compiler_builtins` crate \
604627
which contains compiler-rt intrinsics and will never be stable",
605628
),
606629
gated!(
607630
profiler_runtime, Normal, template!(Word), WarnFollowing,
631+
@only_local: true,
608632
"the `#[profiler_runtime]` attribute is used to identify the `profiler_builtins` crate \
609633
which contains the profiler runtime and will never be stable",
610634
),
@@ -630,7 +654,10 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
630654
template!(Word, List: "name, /*opt*/ attributes(name1, name2, ...)"), ErrorFollowing,
631655
IMPL_DETAIL,
632656
),
633-
rustc_attr!(rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing, INTERNAL_UNSTABLE),
657+
rustc_attr!(
658+
rustc_proc_macro_decls, Normal, template!(Word), WarnFollowing,
659+
@only_local: true, INTERNAL_UNSTABLE
660+
),
634661
rustc_attr!(
635662
rustc_macro_transparency, Normal,
636663
template!(NameValueStr: "transparent|semitransparent|opaque"), ErrorFollowing,

compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,15 @@ pub(super) fn check_refining_return_position_impl_trait_in_trait<'tcx>(
136136
// 1. Project the RPITIT projections from the trait to the opaques on the impl,
137137
// which means that they don't need to be mapped manually.
138138
//
139-
// 2. Project any other projections that show up in the bound. That makes sure that
140-
// we don't consider `tests/ui/async-await/in-trait/async-associated-types.rs`
141-
// to be refining.
142-
let (trait_bounds, impl_bounds) =
143-
ocx.normalize(&ObligationCause::dummy(), param_env, (trait_bounds, impl_bounds));
139+
// 2. Deeply normalize any other projections that show up in the bound. That makes sure
140+
// that we don't consider `tests/ui/async-await/in-trait/async-associated-types.rs`
141+
// or `tests/ui/impl-trait/in-trait/refine-normalize.rs` to be refining.
142+
let Ok((trait_bounds, impl_bounds)) =
143+
ocx.deeply_normalize(&ObligationCause::dummy(), param_env, (trait_bounds, impl_bounds))
144+
else {
145+
tcx.dcx().delayed_bug("encountered errors when checking RPITIT refinement (selection)");
146+
return;
147+
};
144148

145149
// Since we've normalized things, we need to resolve regions, since we'll
146150
// possibly have introduced region vars during projection. We don't expect

compiler/rustc_hir_analysis/src/errors.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1004,13 +1004,6 @@ pub(crate) struct StaticSpecialize {
10041004
pub span: Span,
10051005
}
10061006

1007-
#[derive(Diagnostic)]
1008-
#[diag(hir_analysis_missing_tilde_const)]
1009-
pub(crate) struct MissingTildeConst {
1010-
#[primary_span]
1011-
pub span: Span,
1012-
}
1013-
10141007
#[derive(Diagnostic)]
10151008
pub(crate) enum DropImplPolarity {
10161009
#[diag(hir_analysis_drop_impl_negative)]

compiler/rustc_parse/src/errors.rs

-8
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,6 @@ pub(crate) struct CatchAfterTry {
557557
pub span: Span,
558558
}
559559

560-
#[derive(Diagnostic)]
561-
#[diag(parse_gen_fn)]
562-
#[help]
563-
pub(crate) struct GenFn {
564-
#[primary_span]
565-
pub span: Span,
566-
}
567-
568560
#[derive(Diagnostic)]
569561
#[diag(parse_comma_after_base_struct)]
570562
#[note]

compiler/rustc_passes/messages.ftl

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ passes_doc_attr_not_crate_level =
187187
`#![doc({$attr_name} = "...")]` isn't allowed as a crate-level attribute
188188
189189
passes_doc_cfg_hide_takes_list =
190-
`#[doc(cfg_hide(...)]` takes a list of attributes
190+
`#[doc(cfg_hide(...))]` takes a list of attributes
191191
192192
passes_doc_expect_str =
193193
doc {$attr_name} attribute expects a string: #[doc({$attr_name} = "a")]

compiler/rustc_resolve/src/errors.rs

-39
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,6 @@ use rustc_span::{
77

88
use crate::{late::PatternSource, Res};
99

10-
#[derive(Diagnostic)]
11-
#[diag(resolve_parent_module_reset_for_binding, code = E0637)]
12-
pub(crate) struct ParentModuleResetForBinding;
13-
14-
#[derive(Diagnostic)]
15-
#[diag(resolve_ampersand_used_without_explicit_lifetime_name, code = E0637)]
16-
#[note]
17-
pub(crate) struct AmpersandUsedWithoutExplicitLifetimeName(#[primary_span] pub(crate) Span);
18-
19-
#[derive(Diagnostic)]
20-
#[diag(resolve_underscore_lifetime_name_cannot_be_used_here, code = E0637)]
21-
#[note]
22-
pub(crate) struct UnderscoreLifetimeNameCannotBeUsedHere(#[primary_span] pub(crate) Span);
23-
24-
#[derive(Diagnostic)]
25-
#[diag(resolve_crate_may_not_be_imported)]
26-
pub(crate) struct CrateMayNotBeImported(#[primary_span] pub(crate) Span);
27-
28-
#[derive(Diagnostic)]
29-
#[diag(resolve_crate_root_imports_must_be_named_explicitly)]
30-
pub(crate) struct CrateRootNamesMustBeNamedExplicitly(#[primary_span] pub(crate) Span);
31-
32-
#[derive(Diagnostic)]
33-
#[diag(resolve_crate_root_imports_must_be_named_explicitly)]
34-
pub(crate) struct ResolutionError(#[primary_span] pub(crate) Span);
35-
3610
#[derive(Diagnostic)]
3711
#[diag(resolve_generic_params_from_outer_item, code = E0401)]
3812
pub(crate) struct GenericParamsFromOuterItem {
@@ -467,19 +441,6 @@ pub(crate) struct UnreachableLabelSubLabelUnreachable {
467441
pub(crate) ident_span: Span,
468442
}
469443

470-
#[derive(Diagnostic)]
471-
#[diag(resolve_trait_impl_mismatch)]
472-
pub(crate) struct TraitImplMismatch {
473-
#[primary_span]
474-
#[label]
475-
pub(crate) span: Span,
476-
pub(crate) name: Symbol,
477-
pub(crate) kind: String,
478-
#[label(resolve_label_trait_item)]
479-
pub(crate) trait_item_span: Span,
480-
pub(crate) trait_path: String,
481-
}
482-
483444
#[derive(Diagnostic)]
484445
#[diag(resolve_invalid_asm_sym)]
485446
#[help]

compiler/rustc_trait_selection/src/traits/engine.rs

+9
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
107107
self.register_infer_ok_obligations(infer_ok)
108108
}
109109

110+
pub fn deeply_normalize<T: TypeFoldable<TyCtxt<'tcx>>>(
111+
&self,
112+
cause: &ObligationCause<'tcx>,
113+
param_env: ty::ParamEnv<'tcx>,
114+
value: T,
115+
) -> Result<T, Vec<FulfillmentError<'tcx>>> {
116+
self.infcx.at(cause, param_env).deeply_normalize(value, &mut **self.engine.borrow_mut())
117+
}
118+
110119
/// Makes `expected <: actual`.
111120
pub fn eq_exp<T>(
112121
&self,

library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
#![feature(set_ptr_value)]
153153
#![feature(sized_type_properties)]
154154
#![feature(slice_from_ptr_range)]
155+
#![feature(slice_index_methods)]
155156
#![feature(slice_ptr_get)]
156157
#![feature(slice_ptr_len)]
157158
#![feature(slice_range)]

0 commit comments

Comments
 (0)