Skip to content

Commit ca855e6

Browse files
committed
Auto merge of rust-lang#106708 - JohnTitor:rollup-xcmg5yv, r=JohnTitor
Rollup of 14 pull requests Successful merges: - rust-lang#105194 (Add comment to cleanup_kinds) - rust-lang#106521 (remove E0280) - rust-lang#106628 (Remove unneeded ItemId::Primitive variant) - rust-lang#106635 (std sync tests: better type name, clarifying comment) - rust-lang#106642 (Add test for rust-lang#106062) - rust-lang#106645 ([RFC 2397] Initial implementation) - rust-lang#106653 (Fix help docs for -Zallow-features) - rust-lang#106657 (Remove myself from rust-lang/rust reviewers) - rust-lang#106662 (specialize impl of `ToString` on `bool`) - rust-lang#106669 (create helper function for `rustc_lint_defs::Level` and remove it's duplicated code) - rust-lang#106671 (Change flags with a fixed default value from Option<bool> to bool) - rust-lang#106689 (Fix invalid files array re-creation in rustdoc-gui tester) - rust-lang#106690 (Fix scrolling for item declaration block) - rust-lang#106698 (Add compiler-errors to some trait system notification groups) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents bf7ea0d + a804980 commit ca855e6

File tree

34 files changed

+455
-134
lines changed

34 files changed

+455
-134
lines changed

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+3
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ impl CleanupKind {
261261
}
262262
}
263263

264+
/// MSVC requires unwinding code to be split to a tree of *funclets*, where each funclet can only
265+
/// branch to itself or to its parent. Luckily, the code we generates matches this pattern.
266+
/// Recover that structure in an analyze pass.
264267
pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
265268
fn discover_masters<'tcx>(
266269
result: &mut IndexVec<mir::BasicBlock, CleanupKind>,

compiler/rustc_error_codes/src/error_codes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ E0791: include_str!("./error_codes/E0791.md"),
574574
// E0274, // on_unimplemented #2
575575
// E0278, // requirement is not satisfied
576576
// E0279,
577-
E0280, // requirement is not satisfied
577+
// E0280, // changed to ICE
578578
// E0285, // overflow evaluation builtin bounds
579579
// E0296, // replaced with a generic attribute input check
580580
// E0298, // cannot compare constants

compiler/rustc_errors/src/diagnostic_impls.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,7 @@ impl IntoDiagnosticArg for type_ir::FloatTy {
179179

180180
impl IntoDiagnosticArg for Level {
181181
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
182-
DiagnosticArgValue::Str(Cow::Borrowed(match self {
183-
Level::Allow => "-A",
184-
Level::Warn => "-W",
185-
Level::ForceWarn(_) => "--force-warn",
186-
Level::Deny => "-D",
187-
Level::Forbid => "-F",
188-
Level::Expect(_) => {
189-
unreachable!("lints with the level of `expect` should not run this code");
190-
}
191-
}))
182+
DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
192183
}
193184
}
194185

compiler/rustc_feature/src/active.rs

+2
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ declare_features! (
374374
(active, deprecated_safe, "1.61.0", Some(94978), None),
375375
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
376376
(active, deprecated_suggestion, "1.61.0", Some(94785), None),
377+
/// Controls errors in trait implementations.
378+
(active, do_not_recommend, "1.67.0", Some(51992), None),
377379
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
378380
(active, doc_auto_cfg, "1.58.0", Some(43781), None),
379381
/// Allows `#[doc(cfg(...))]`.

compiler/rustc_feature/src/builtin_attrs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,9 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
487487
experimental!(collapse_debuginfo)
488488
),
489489

490+
// RFC 2397
491+
gated!(do_not_recommend, Normal, template!(Word), WarnFollowing, experimental!(do_not_recommend)),
492+
490493
// ==========================================================================
491494
// Internal attributes: Stability, deprecation, and unsafe:
492495
// ==========================================================================

compiler/rustc_interface/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ fn test_unstable_options_tracking_hash() {
715715
tracked!(asm_comments, true);
716716
tracked!(assume_incomplete_release, true);
717717
tracked!(binary_dep_depinfo, true);
718-
tracked!(box_noalias, Some(false));
718+
tracked!(box_noalias, false);
719719
tracked!(
720720
branch_protection,
721721
Some(BranchProtection {
@@ -754,7 +754,7 @@ fn test_unstable_options_tracking_hash() {
754754
tracked!(mir_enable_passes, vec![("DestProp".to_string(), false)]);
755755
tracked!(mir_opt_level, Some(4));
756756
tracked!(move_size_limit, Some(4096));
757-
tracked!(mutable_noalias, Some(true));
757+
tracked!(mutable_noalias, false);
758758
tracked!(no_generate_arange_section, true);
759759
tracked!(no_jump_tables, true);
760760
tracked!(no_link, true);

compiler/rustc_lint_defs/src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,19 @@ impl Level {
253253
}
254254
}
255255

256+
pub fn to_cmd_flag(self) -> &'static str {
257+
match self {
258+
Level::Warn => "-W",
259+
Level::Deny => "-D",
260+
Level::Forbid => "-F",
261+
Level::Allow => "-A",
262+
Level::ForceWarn(_) => "--force-warn",
263+
Level::Expect(_) => {
264+
unreachable!("the expect level does not have a commandline flag")
265+
}
266+
}
267+
}
268+
256269
pub fn is_error(self) -> bool {
257270
match self {
258271
Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn(_) => false,

compiler/rustc_middle/src/lint.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,7 @@ pub fn explain_lint_level_source(
234234
err.note_once(&format!("`#[{}({})]` on by default", level.as_str(), name));
235235
}
236236
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
237-
let flag = match orig_level {
238-
Level::Warn => "-W",
239-
Level::Deny => "-D",
240-
Level::Forbid => "-F",
241-
Level::Allow => "-A",
242-
Level::ForceWarn(_) => "--force-warn",
243-
Level::Expect(_) => {
244-
unreachable!("the expect level does not have a commandline flag")
245-
}
246-
};
237+
let flag = orig_level.to_cmd_flag();
247238
let hyphen_case_lint_name = name.replace('_', "-");
248239
if lint_flag_val.as_str() == name {
249240
err.note_once(&format!(

compiler/rustc_session/src/options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ options! {
12411241

12421242
// tidy-alphabetical-start
12431243
allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
1244-
"only allow the listed language features to be enabled in code (space separated)"),
1244+
"only allow the listed language features to be enabled in code (comma separated)"),
12451245
always_encode_mir: bool = (false, parse_bool, [TRACKED],
12461246
"encode MIR of all functions into the crate metadata (default: no)"),
12471247
asm_comments: bool = (false, parse_bool, [TRACKED],
@@ -1255,7 +1255,7 @@ options! {
12551255
binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
12561256
"include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
12571257
(default: no)"),
1258-
box_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1258+
box_noalias: bool = (true, parse_bool, [TRACKED],
12591259
"emit noalias metadata for box (default: yes)"),
12601260
branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED],
12611261
"set options for branch target identification and pointer authentication on AArch64"),
@@ -1437,7 +1437,7 @@ options! {
14371437
"use line numbers relative to the function in mir pretty printing"),
14381438
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
14391439
"the size at which the `large_assignments` lint starts to be emitted"),
1440-
mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
1440+
mutable_noalias: bool = (true, parse_bool, [TRACKED],
14411441
"emit noalias metadata for mutable references (default: yes)"),
14421442
nll_facts: bool = (false, parse_bool, [UNTRACKED],
14431443
"dump facts from NLL analysis into side files (default: no)"),

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ symbols! {
613613
dispatch_from_dyn,
614614
div,
615615
div_assign,
616+
do_not_recommend,
616617
doc,
617618
doc_alias,
618619
doc_auto_cfg,

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

+11-7
Original file line numberDiff line numberDiff line change
@@ -1102,15 +1102,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
11021102
}
11031103

11041104
ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
1105-
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
11061105
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) => {
1107-
let predicate = self.resolve_vars_if_possible(obligation.predicate);
1108-
struct_span_err!(
1109-
self.tcx.sess,
1106+
span_bug!(
11101107
span,
1111-
E0280,
1112-
"the requirement `{}` is not satisfied",
1113-
predicate
1108+
"outlives clauses should not error outside borrowck. obligation: `{:?}`",
1109+
obligation
1110+
)
1111+
}
1112+
1113+
ty::PredicateKind::Clause(ty::Clause::Projection(..)) => {
1114+
span_bug!(
1115+
span,
1116+
"projection clauses should be implied from elsewhere. obligation: `{:?}`",
1117+
obligation
11141118
)
11151119
}
11161120

compiler/rustc_ty_utils/src/abi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ fn adjust_for_rust_scalar<'tcx>(
254254
// The aliasing rules for `Box<T>` are still not decided, but currently we emit
255255
// `noalias` for it. This can be turned off using an unstable flag.
256256
// See https://github.com/rust-lang/unsafe-code-guidelines/issues/326
257-
let noalias_for_box = cx.tcx.sess.opts.unstable_opts.box_noalias.unwrap_or(true);
257+
let noalias_for_box = cx.tcx.sess.opts.unstable_opts.box_noalias;
258258

259259
// LLVM prior to version 12 had known miscompiles in the presence of noalias attributes
260260
// (see #54878), so it was conditionally disabled, but we don't support earlier
261261
// versions at all anymore. We still support turning it off using -Zmutable-noalias.
262-
let noalias_mut_ref = cx.tcx.sess.opts.unstable_opts.mutable_noalias.unwrap_or(true);
262+
let noalias_mut_ref = cx.tcx.sess.opts.unstable_opts.mutable_noalias;
263263

264264
// `&mut` pointer parameters never alias other parameters,
265265
// or mutable global data

library/alloc/src/string.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2548,6 +2548,15 @@ impl ToString for char {
25482548
}
25492549
}
25502550

2551+
#[cfg(not(no_global_oom_handling))]
2552+
#[stable(feature = "bool_to_string_specialization", since = "CURRENT_RUSTC_VERSION")]
2553+
impl ToString for bool {
2554+
#[inline]
2555+
fn to_string(&self) -> String {
2556+
String::from(if *self { "true" } else { "false" })
2557+
}
2558+
}
2559+
25512560
#[cfg(not(no_global_oom_handling))]
25522561
#[stable(feature = "u8_to_string_specialization", since = "1.54.0")]
25532562
impl ToString for u8 {

library/std/src/sync/mutex/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn test_mutex_arc_poison() {
181181
let arc2 = arc.clone();
182182
let _ = thread::spawn(move || {
183183
let lock = arc2.lock().unwrap();
184-
assert_eq!(*lock, 2);
184+
assert_eq!(*lock, 2); // deliberate assertion failure to poison the mutex
185185
})
186186
.join();
187187
assert!(arc.lock().is_err());

library/std/src/thread/local/tests.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ impl Signal {
2323
}
2424
}
2525

26-
struct Foo(Signal);
26+
struct NotifyOnDrop(Signal);
2727

28-
impl Drop for Foo {
28+
impl Drop for NotifyOnDrop {
2929
fn drop(&mut self) {
30-
let Foo(ref f) = *self;
30+
let NotifyOnDrop(ref f) = *self;
3131
f.notify();
3232
}
3333
}
@@ -82,18 +82,18 @@ fn states() {
8282

8383
#[test]
8484
fn smoke_dtor() {
85-
thread_local!(static FOO: UnsafeCell<Option<Foo>> = UnsafeCell::new(None));
85+
thread_local!(static FOO: UnsafeCell<Option<NotifyOnDrop>> = UnsafeCell::new(None));
8686
run(&FOO);
87-
thread_local!(static FOO2: UnsafeCell<Option<Foo>> = const { UnsafeCell::new(None) });
87+
thread_local!(static FOO2: UnsafeCell<Option<NotifyOnDrop>> = const { UnsafeCell::new(None) });
8888
run(&FOO2);
8989

90-
fn run(key: &'static LocalKey<UnsafeCell<Option<Foo>>>) {
90+
fn run(key: &'static LocalKey<UnsafeCell<Option<NotifyOnDrop>>>) {
9191
let signal = Signal::default();
9292
let signal2 = signal.clone();
9393
let t = thread::spawn(move || unsafe {
9494
let mut signal = Some(signal2);
9595
key.with(|f| {
96-
*f.get() = Some(Foo(signal.take().unwrap()));
96+
*f.get() = Some(NotifyOnDrop(signal.take().unwrap()));
9797
});
9898
});
9999
signal.wait();
@@ -187,13 +187,13 @@ fn self_referential() {
187187
fn dtors_in_dtors_in_dtors() {
188188
struct S1(Signal);
189189
thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell::new(None));
190-
thread_local!(static K2: UnsafeCell<Option<Foo>> = UnsafeCell::new(None));
190+
thread_local!(static K2: UnsafeCell<Option<NotifyOnDrop>> = UnsafeCell::new(None));
191191

192192
impl Drop for S1 {
193193
fn drop(&mut self) {
194194
let S1(ref signal) = *self;
195195
unsafe {
196-
let _ = K2.try_with(|s| *s.get() = Some(Foo(signal.clone())));
196+
let _ = K2.try_with(|s| *s.get() = Some(NotifyOnDrop(signal.clone())));
197197
}
198198
}
199199
}
@@ -211,13 +211,13 @@ fn dtors_in_dtors_in_dtors() {
211211
fn dtors_in_dtors_in_dtors_const_init() {
212212
struct S1(Signal);
213213
thread_local!(static K1: UnsafeCell<Option<S1>> = const { UnsafeCell::new(None) });
214-
thread_local!(static K2: UnsafeCell<Option<Foo>> = const { UnsafeCell::new(None) });
214+
thread_local!(static K2: UnsafeCell<Option<NotifyOnDrop>> = const { UnsafeCell::new(None) });
215215

216216
impl Drop for S1 {
217217
fn drop(&mut self) {
218218
let S1(ref signal) = *self;
219219
unsafe {
220-
let _ = K2.try_with(|s| *s.get() = Some(Foo(signal.clone())));
220+
let _ = K2.try_with(|s| *s.get() = Some(NotifyOnDrop(signal.clone())));
221221
}
222222
}
223223
}

src/librustdoc/clean/inline.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,9 @@ fn build_module_items(
600600
items.push(clean::Item {
601601
name: None,
602602
attrs: Box::new(clean::Attributes::default()),
603-
item_id: ItemId::Primitive(prim_ty, did.krate),
603+
// We can use the item's `DefId` directly since the only information ever used
604+
// from it is `DefId.krate`.
605+
item_id: ItemId::DefId(did),
604606
kind: Box::new(clean::ImportItem(clean::Import::new_simple(
605607
item.ident.name,
606608
clean::ImportSource {

src/librustdoc/clean/types.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ pub(crate) enum ItemId {
6262
Auto { trait_: DefId, for_: DefId },
6363
/// Identifier that is used for blanket implementations.
6464
Blanket { impl_id: DefId, for_: DefId },
65-
/// Identifier for primitive types.
66-
Primitive(PrimitiveType, CrateNum),
6765
}
6866

6967
impl ItemId {
@@ -73,7 +71,6 @@ impl ItemId {
7371
ItemId::Auto { for_: id, .. }
7472
| ItemId::Blanket { for_: id, .. }
7573
| ItemId::DefId(id) => id.is_local(),
76-
ItemId::Primitive(_, krate) => krate == LOCAL_CRATE,
7774
}
7875
}
7976

@@ -98,7 +95,6 @@ impl ItemId {
9895
ItemId::Auto { for_: id, .. }
9996
| ItemId::Blanket { for_: id, .. }
10097
| ItemId::DefId(id) => id.krate,
101-
ItemId::Primitive(_, krate) => krate,
10298
}
10399
}
104100
}
@@ -707,15 +703,13 @@ impl Item {
707703
let def_id = match self.item_id {
708704
// Anything but DefId *shouldn't* matter, but return a reasonable value anyway.
709705
ItemId::Auto { .. } | ItemId::Blanket { .. } => return None,
710-
// Primitives and Keywords are written in the source code as private modules.
711-
// The modules need to be private so that nobody actually uses them, but the
712-
// keywords and primitives that they are documenting are public.
713-
ItemId::Primitive(..) => return Some(Visibility::Public),
714706
ItemId::DefId(def_id) => def_id,
715707
};
716708

717709
match *self.kind {
718-
// Explication on `ItemId::Primitive` just above.
710+
// Primitives and Keywords are written in the source code as private modules.
711+
// The modules need to be private so that nobody actually uses them, but the
712+
// keywords and primitives that they are documenting are public.
719713
ItemKind::KeywordItem | ItemKind::PrimitiveItem(_) => return Some(Visibility::Public),
720714
// Variant fields inherit their enum's visibility.
721715
StructFieldItem(..) if is_field_vis_inherited(tcx, def_id) => {

src/librustdoc/formats/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ impl Impl {
5353
ItemId::Blanket { impl_id, .. } => impl_id,
5454
ItemId::Auto { trait_, .. } => trait_,
5555
ItemId::DefId(def_id) => def_id,
56-
ItemId::Primitive(_, _) => {
57-
panic!(
58-
"Unexpected ItemId::Primitive in expect_def_id: {:?}",
59-
self.impl_item.item_id
60-
)
61-
}
6256
}
6357
}
6458

0 commit comments

Comments
 (0)