Skip to content

Commit

Permalink
Auto merge of rust-lang#106708 - JohnTitor:rollup-xcmg5yv, r=JohnTitor
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Jan 11, 2023
2 parents bf7ea0d + a804980 commit ca855e6
Show file tree
Hide file tree
Showing 34 changed files with 455 additions and 134 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_ssa/src/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ impl CleanupKind {
}
}

/// MSVC requires unwinding code to be split to a tree of *funclets*, where each funclet can only
/// branch to itself or to its parent. Luckily, the code we generates matches this pattern.
/// Recover that structure in an analyze pass.
pub fn cleanup_kinds(mir: &mir::Body<'_>) -> IndexVec<mir::BasicBlock, CleanupKind> {
fn discover_masters<'tcx>(
result: &mut IndexVec<mir::BasicBlock, CleanupKind>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ E0791: include_str!("./error_codes/E0791.md"),
// E0274, // on_unimplemented #2
// E0278, // requirement is not satisfied
// E0279,
E0280, // requirement is not satisfied
// E0280, // changed to ICE
// E0285, // overflow evaluation builtin bounds
// E0296, // replaced with a generic attribute input check
// E0298, // cannot compare constants
Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_errors/src/diagnostic_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,7 @@ impl IntoDiagnosticArg for type_ir::FloatTy {

impl IntoDiagnosticArg for Level {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
DiagnosticArgValue::Str(Cow::Borrowed(match self {
Level::Allow => "-A",
Level::Warn => "-W",
Level::ForceWarn(_) => "--force-warn",
Level::Deny => "-D",
Level::Forbid => "-F",
Level::Expect(_) => {
unreachable!("lints with the level of `expect` should not run this code");
}
}))
DiagnosticArgValue::Str(Cow::Borrowed(self.to_cmd_flag()))
}
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,8 @@ declare_features! (
(active, deprecated_safe, "1.61.0", Some(94978), None),
/// Allows having using `suggestion` in the `#[deprecated]` attribute.
(active, deprecated_suggestion, "1.61.0", Some(94785), None),
/// Controls errors in trait implementations.
(active, do_not_recommend, "1.67.0", Some(51992), None),
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
(active, doc_auto_cfg, "1.58.0", Some(43781), None),
/// Allows `#[doc(cfg(...))]`.
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
experimental!(collapse_debuginfo)
),

// RFC 2397
gated!(do_not_recommend, Normal, template!(Word), WarnFollowing, experimental!(do_not_recommend)),

// ==========================================================================
// Internal attributes: Stability, deprecation, and unsafe:
// ==========================================================================
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(asm_comments, true);
tracked!(assume_incomplete_release, true);
tracked!(binary_dep_depinfo, true);
tracked!(box_noalias, Some(false));
tracked!(box_noalias, false);
tracked!(
branch_protection,
Some(BranchProtection {
Expand Down Expand Up @@ -754,7 +754,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(mir_enable_passes, vec![("DestProp".to_string(), false)]);
tracked!(mir_opt_level, Some(4));
tracked!(move_size_limit, Some(4096));
tracked!(mutable_noalias, Some(true));
tracked!(mutable_noalias, false);
tracked!(no_generate_arange_section, true);
tracked!(no_jump_tables, true);
tracked!(no_link, true);
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,19 @@ impl Level {
}
}

pub fn to_cmd_flag(self) -> &'static str {
match self {
Level::Warn => "-W",
Level::Deny => "-D",
Level::Forbid => "-F",
Level::Allow => "-A",
Level::ForceWarn(_) => "--force-warn",
Level::Expect(_) => {
unreachable!("the expect level does not have a commandline flag")
}
}
}

pub fn is_error(self) -> bool {
match self {
Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn(_) => false,
Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,7 @@ pub fn explain_lint_level_source(
err.note_once(&format!("`#[{}({})]` on by default", level.as_str(), name));
}
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
let flag = match orig_level {
Level::Warn => "-W",
Level::Deny => "-D",
Level::Forbid => "-F",
Level::Allow => "-A",
Level::ForceWarn(_) => "--force-warn",
Level::Expect(_) => {
unreachable!("the expect level does not have a commandline flag")
}
};
let flag = orig_level.to_cmd_flag();
let hyphen_case_lint_name = name.replace('_', "-");
if lint_flag_val.as_str() == name {
err.note_once(&format!(
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ options! {

// tidy-alphabetical-start
allow_features: Option<Vec<String>> = (None, parse_opt_comma_list, [TRACKED],
"only allow the listed language features to be enabled in code (space separated)"),
"only allow the listed language features to be enabled in code (comma separated)"),
always_encode_mir: bool = (false, parse_bool, [TRACKED],
"encode MIR of all functions into the crate metadata (default: no)"),
asm_comments: bool = (false, parse_bool, [TRACKED],
Expand All @@ -1255,7 +1255,7 @@ options! {
binary_dep_depinfo: bool = (false, parse_bool, [TRACKED],
"include artifacts (sysroot, crate dependencies) used during compilation in dep-info \
(default: no)"),
box_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
box_noalias: bool = (true, parse_bool, [TRACKED],
"emit noalias metadata for box (default: yes)"),
branch_protection: Option<BranchProtection> = (None, parse_branch_protection, [TRACKED],
"set options for branch target identification and pointer authentication on AArch64"),
Expand Down Expand Up @@ -1437,7 +1437,7 @@ options! {
"use line numbers relative to the function in mir pretty printing"),
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
"the size at which the `large_assignments` lint starts to be emitted"),
mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
mutable_noalias: bool = (true, parse_bool, [TRACKED],
"emit noalias metadata for mutable references (default: yes)"),
nll_facts: bool = (false, parse_bool, [UNTRACKED],
"dump facts from NLL analysis into side files (default: no)"),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ symbols! {
dispatch_from_dyn,
div,
div_assign,
do_not_recommend,
doc,
doc_alias,
doc_auto_cfg,
Expand Down
18 changes: 11 additions & 7 deletions compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,15 +1102,19 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}

ty::PredicateKind::Clause(ty::Clause::RegionOutlives(..))
| ty::PredicateKind::Clause(ty::Clause::Projection(..))
| ty::PredicateKind::Clause(ty::Clause::TypeOutlives(..)) => {
let predicate = self.resolve_vars_if_possible(obligation.predicate);
struct_span_err!(
self.tcx.sess,
span_bug!(
span,
E0280,
"the requirement `{}` is not satisfied",
predicate
"outlives clauses should not error outside borrowck. obligation: `{:?}`",
obligation
)
}

ty::PredicateKind::Clause(ty::Clause::Projection(..)) => {
span_bug!(
span,
"projection clauses should be implied from elsewhere. obligation: `{:?}`",
obligation
)
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ty_utils/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ fn adjust_for_rust_scalar<'tcx>(
// The aliasing rules for `Box<T>` are still not decided, but currently we emit
// `noalias` for it. This can be turned off using an unstable flag.
// See https://github.com/rust-lang/unsafe-code-guidelines/issues/326
let noalias_for_box = cx.tcx.sess.opts.unstable_opts.box_noalias.unwrap_or(true);
let noalias_for_box = cx.tcx.sess.opts.unstable_opts.box_noalias;

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

// `&mut` pointer parameters never alias other parameters,
// or mutable global data
Expand Down
9 changes: 9 additions & 0 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2548,6 +2548,15 @@ impl ToString for char {
}
}

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "bool_to_string_specialization", since = "CURRENT_RUSTC_VERSION")]
impl ToString for bool {
#[inline]
fn to_string(&self) -> String {
String::from(if *self { "true" } else { "false" })
}
}

#[cfg(not(no_global_oom_handling))]
#[stable(feature = "u8_to_string_specialization", since = "1.54.0")]
impl ToString for u8 {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sync/mutex/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ fn test_mutex_arc_poison() {
let arc2 = arc.clone();
let _ = thread::spawn(move || {
let lock = arc2.lock().unwrap();
assert_eq!(*lock, 2);
assert_eq!(*lock, 2); // deliberate assertion failure to poison the mutex
})
.join();
assert!(arc.lock().is_err());
Expand Down
22 changes: 11 additions & 11 deletions library/std/src/thread/local/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ impl Signal {
}
}

struct Foo(Signal);
struct NotifyOnDrop(Signal);

impl Drop for Foo {
impl Drop for NotifyOnDrop {
fn drop(&mut self) {
let Foo(ref f) = *self;
let NotifyOnDrop(ref f) = *self;
f.notify();
}
}
Expand Down Expand Up @@ -82,18 +82,18 @@ fn states() {

#[test]
fn smoke_dtor() {
thread_local!(static FOO: UnsafeCell<Option<Foo>> = UnsafeCell::new(None));
thread_local!(static FOO: UnsafeCell<Option<NotifyOnDrop>> = UnsafeCell::new(None));
run(&FOO);
thread_local!(static FOO2: UnsafeCell<Option<Foo>> = const { UnsafeCell::new(None) });
thread_local!(static FOO2: UnsafeCell<Option<NotifyOnDrop>> = const { UnsafeCell::new(None) });
run(&FOO2);

fn run(key: &'static LocalKey<UnsafeCell<Option<Foo>>>) {
fn run(key: &'static LocalKey<UnsafeCell<Option<NotifyOnDrop>>>) {
let signal = Signal::default();
let signal2 = signal.clone();
let t = thread::spawn(move || unsafe {
let mut signal = Some(signal2);
key.with(|f| {
*f.get() = Some(Foo(signal.take().unwrap()));
*f.get() = Some(NotifyOnDrop(signal.take().unwrap()));
});
});
signal.wait();
Expand Down Expand Up @@ -187,13 +187,13 @@ fn self_referential() {
fn dtors_in_dtors_in_dtors() {
struct S1(Signal);
thread_local!(static K1: UnsafeCell<Option<S1>> = UnsafeCell::new(None));
thread_local!(static K2: UnsafeCell<Option<Foo>> = UnsafeCell::new(None));
thread_local!(static K2: UnsafeCell<Option<NotifyOnDrop>> = UnsafeCell::new(None));

impl Drop for S1 {
fn drop(&mut self) {
let S1(ref signal) = *self;
unsafe {
let _ = K2.try_with(|s| *s.get() = Some(Foo(signal.clone())));
let _ = K2.try_with(|s| *s.get() = Some(NotifyOnDrop(signal.clone())));
}
}
}
Expand All @@ -211,13 +211,13 @@ fn dtors_in_dtors_in_dtors() {
fn dtors_in_dtors_in_dtors_const_init() {
struct S1(Signal);
thread_local!(static K1: UnsafeCell<Option<S1>> = const { UnsafeCell::new(None) });
thread_local!(static K2: UnsafeCell<Option<Foo>> = const { UnsafeCell::new(None) });
thread_local!(static K2: UnsafeCell<Option<NotifyOnDrop>> = const { UnsafeCell::new(None) });

impl Drop for S1 {
fn drop(&mut self) {
let S1(ref signal) = *self;
unsafe {
let _ = K2.try_with(|s| *s.get() = Some(Foo(signal.clone())));
let _ = K2.try_with(|s| *s.get() = Some(NotifyOnDrop(signal.clone())));
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ fn build_module_items(
items.push(clean::Item {
name: None,
attrs: Box::new(clean::Attributes::default()),
item_id: ItemId::Primitive(prim_ty, did.krate),
// We can use the item's `DefId` directly since the only information ever used
// from it is `DefId.krate`.
item_id: ItemId::DefId(did),
kind: Box::new(clean::ImportItem(clean::Import::new_simple(
item.ident.name,
clean::ImportSource {
Expand Down
12 changes: 3 additions & 9 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ pub(crate) enum ItemId {
Auto { trait_: DefId, for_: DefId },
/// Identifier that is used for blanket implementations.
Blanket { impl_id: DefId, for_: DefId },
/// Identifier for primitive types.
Primitive(PrimitiveType, CrateNum),
}

impl ItemId {
Expand All @@ -73,7 +71,6 @@ impl ItemId {
ItemId::Auto { for_: id, .. }
| ItemId::Blanket { for_: id, .. }
| ItemId::DefId(id) => id.is_local(),
ItemId::Primitive(_, krate) => krate == LOCAL_CRATE,
}
}

Expand All @@ -98,7 +95,6 @@ impl ItemId {
ItemId::Auto { for_: id, .. }
| ItemId::Blanket { for_: id, .. }
| ItemId::DefId(id) => id.krate,
ItemId::Primitive(_, krate) => krate,
}
}
}
Expand Down Expand Up @@ -707,15 +703,13 @@ impl Item {
let def_id = match self.item_id {
// Anything but DefId *shouldn't* matter, but return a reasonable value anyway.
ItemId::Auto { .. } | ItemId::Blanket { .. } => return None,
// Primitives and Keywords are written in the source code as private modules.
// The modules need to be private so that nobody actually uses them, but the
// keywords and primitives that they are documenting are public.
ItemId::Primitive(..) => return Some(Visibility::Public),
ItemId::DefId(def_id) => def_id,
};

match *self.kind {
// Explication on `ItemId::Primitive` just above.
// Primitives and Keywords are written in the source code as private modules.
// The modules need to be private so that nobody actually uses them, but the
// keywords and primitives that they are documenting are public.
ItemKind::KeywordItem | ItemKind::PrimitiveItem(_) => return Some(Visibility::Public),
// Variant fields inherit their enum's visibility.
StructFieldItem(..) if is_field_vis_inherited(tcx, def_id) => {
Expand Down
6 changes: 0 additions & 6 deletions src/librustdoc/formats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ impl Impl {
ItemId::Blanket { impl_id, .. } => impl_id,
ItemId::Auto { trait_, .. } => trait_,
ItemId::DefId(def_id) => def_id,
ItemId::Primitive(_, _) => {
panic!(
"Unexpected ItemId::Primitive in expect_def_id: {:?}",
self.impl_item.item_id
)
}
}
}

Expand Down
Loading

0 comments on commit ca855e6

Please sign in to comment.