Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #87806

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3171bd5
ignore comments in tidy-filelength
ibraheemdev Jul 25, 2021
a77d6ff
add long error explanation for E0625
bhgomes Aug 3, 2021
2fd874d
Fix overflow when calculating expected_min in generics diagnostics
SkiFire13 Aug 3, 2021
ae313da
Add regression tests
SkiFire13 Aug 3, 2021
e3389be
Bless test
SkiFire13 Aug 3, 2021
2f85aa6
remove trailing newline
bhgomes Aug 3, 2021
a96fd57
Validate FFI-safety warnings on naked functions
npmccallum Aug 3, 2021
1247f9b
Add back -Zno-profiler-runtime
Amanieu Aug 4, 2021
f280a12
Re-use std::sealed::Sealed in os/linux/process.
m-ou-se Aug 4, 2021
94ffa00
Promote `aarch64-apple-ios-sim` to Tier 2
badboy Aug 2, 2021
b1d14ef
dropck
BoxyUwU Aug 4, 2021
dc5f6d2
move full explanation to after erroneous example
bhgomes Aug 4, 2021
fa46715
remove tywf relation
BoxyUwU Aug 5, 2021
1db8737
alloc: Use intra doc links for the reserve function
est31 Aug 5, 2021
1a7e56c
Remove special case for statement `NodeId` assignment
Aaron1011 Aug 5, 2021
a633895
Rollup merge of #87462 - ibraheemdev:tidy-file-length-ignore-comment,…
JohnTitor Aug 6, 2021
f13c61d
Rollup merge of #87715 - bhgomes:long-explanation-E0625, r=GuillaumeG…
JohnTitor Aug 6, 2021
928c719
Rollup merge of #87727 - SkiFire13:fix-87718, r=jackh726
JohnTitor Aug 6, 2021
bd8858b
Rollup merge of #87742 - npmccallum:naked_ffi, r=Amanieu
JohnTitor Aug 6, 2021
0fc0614
Rollup merge of #87756 - Amanieu:no_profiler_runtime, r=jackh726
JohnTitor Aug 6, 2021
57ffa31
Rollup merge of #87759 - m-ou-se:linux-process-sealed, r=jyn514
JohnTitor Aug 6, 2021
f91d8d1
Rollup merge of #87760 - badboy:promote-ios-sim-target, r=Mark-Simula…
JohnTitor Aug 6, 2021
5f37944
Rollup merge of #87770 - BoxyUwU:cec-drop-impl, r=lcnr
JohnTitor Aug 6, 2021
7353e2f
Rollup merge of #87779 - Aaron1011:stmt-ast-id, r=petrochenkov
JohnTitor Aug 6, 2021
0b3a5b0
Rollup merge of #87780 - est31:intra_doc_links, r=jyn514
JohnTitor Aug 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -359,6 +359,7 @@ E0621: include_str!("./error_codes/E0621.md"),
E0622: include_str!("./error_codes/E0622.md"),
E0623: include_str!("./error_codes/E0623.md"),
E0624: include_str!("./error_codes/E0624.md"),
E0625: include_str!("./error_codes/E0625.md"),
E0626: include_str!("./error_codes/E0626.md"),
E0627: include_str!("./error_codes/E0627.md"),
E0628: include_str!("./error_codes/E0628.md"),
Expand Down Expand Up @@ -622,7 +623,6 @@ E0783: include_str!("./error_codes/E0783.md"),
// E0611, // merged into E0616
// E0612, // merged into E0609
// E0613, // Removed (merged with E0609)
E0625, // thread-local statics cannot be accessed at compile-time
// E0629, // missing 'feature' (rustc_const_unstable)
// E0630, // rustc_const_unstable attribute must be paired with stable/unstable
// attribute
Expand Down
28 changes: 28 additions & 0 deletions compiler/rustc_error_codes/src/error_codes/E0625.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
A compile-time const variable is referring to a thread-local static variable.

Erroneous code example:

```compile_fail,E0625
#![feature(thread_local)]

#[thread_local]
static X: usize = 12;

const Y: usize = 2 * X;
```

Static and const variables can refer to other const variables but a const
variable cannot refer to a thread-local static variable. In this example,
`Y` cannot refer to `X`. To fix this, the value can be extracted as a const
and then used:

```
#![feature(thread_local)]

const C: usize = 12;

#[thread_local]
static X: usize = C;

const Y: usize = 2 * C;
```
9 changes: 2 additions & 7 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
self.cx.force_mode = orig_force_mode;

// Finally incorporate all the expanded macros into the input AST fragment.
let mut placeholder_expander = PlaceholderExpander::new(self.cx, self.monotonic);
let mut placeholder_expander = PlaceholderExpander::default();
while let Some(expanded_fragments) = expanded_fragments.pop() {
for (expn_id, expanded_fragment) in expanded_fragments.into_iter().rev() {
placeholder_expander
Expand Down Expand Up @@ -1341,14 +1341,9 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
}
}

// The placeholder expander gives ids to statements, so we avoid folding the id here.
// We don't use `assign_id!` - it will be called when we visit statement's contents
// (e.g. an expression, item, or local)
let ast::Stmt { id, kind, span } = stmt;
let res = noop_flat_map_stmt_kind(kind, self)
.into_iter()
.map(|kind| ast::Stmt { id, kind, span })
.collect();
let res = noop_flat_map_stmt(stmt, self);

self.cx.current_expansion.is_trailing_mac = false;
res
Expand Down
25 changes: 4 additions & 21 deletions compiler/rustc_expand/src/placeholders.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::base::ExtCtxt;
use crate::expand::{AstFragment, AstFragmentKind};

use rustc_ast as ast;
Expand Down Expand Up @@ -175,17 +174,12 @@ pub fn placeholder(
}
}

pub struct PlaceholderExpander<'a, 'b> {
#[derive(Default)]
pub struct PlaceholderExpander {
expanded_fragments: FxHashMap<ast::NodeId, AstFragment>,
cx: &'a mut ExtCtxt<'b>,
monotonic: bool,
}

impl<'a, 'b> PlaceholderExpander<'a, 'b> {
pub fn new(cx: &'a mut ExtCtxt<'b>, monotonic: bool) -> Self {
PlaceholderExpander { cx, expanded_fragments: FxHashMap::default(), monotonic }
}

impl PlaceholderExpander {
pub fn add(&mut self, id: ast::NodeId, mut fragment: AstFragment) {
fragment.mut_visit_with(self);
self.expanded_fragments.insert(id, fragment);
Expand All @@ -196,7 +190,7 @@ impl<'a, 'b> PlaceholderExpander<'a, 'b> {
}
}

impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
impl MutVisitor for PlaceholderExpander {
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
if arm.is_placeholder {
self.remove(arm.id).make_arms()
Expand Down Expand Up @@ -360,15 +354,4 @@ impl<'a, 'b> MutVisitor for PlaceholderExpander<'a, 'b> {
_ => noop_visit_ty(ty, self),
}
}

fn visit_block(&mut self, block: &mut P<ast::Block>) {
noop_visit_block(block, self);

for stmt in block.stmts.iter_mut() {
if self.monotonic {
assert_eq!(stmt.id, ast::DUMMY_NODE_ID);
stmt.id = self.cx.resolver.next_node_id();
}
}
}
}
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-tidy-filelength
use crate::def::{CtorKind, DefKind, Res};
use crate::def_id::{DefId, CRATE_DEF_ID};
crate use crate::hir_id::{HirId, ItemLocalId};
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(new_llvm_pass_manager, Some(true));
tracked!(no_generate_arange_section, true);
tracked!(no_link, true);
tracked!(no_profiler_runtime, true);
tracked!(osx_rpath_install_name, true);
tracked!(panic_abort_tests, true);
tracked!(plt, Some(true));
Expand All @@ -748,7 +749,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(print_fuel, Some("abc".to_string()));
tracked!(profile, true);
tracked!(profile_emit, Some(PathBuf::from("abc")));
tracked!(profiler_runtime, None);
tracked!(profiler_runtime, "abc".to_string());
tracked!(relax_elf_relocations, Some(true));
tracked!(relro_level, Some(RelroLevel::Full));
tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore-tidy-filelength

//! Lints in the Rust compiler.
//!
//! This contains lints which can feasibly be implemented as their own
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore-tidy-filelength

//! Some lints that are built in to the compiler.
//!
//! These are the built-in lints that are emitted direct in the main
Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_metadata/src/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,19 +777,17 @@ impl<'a> CrateLoader<'a> {
}

fn inject_profiler_runtime(&mut self, krate: &ast::Crate) {
let profiler_runtime = &self.sess.opts.debugging_opts.profiler_runtime;

if !(profiler_runtime.is_some()
&& (self.sess.instrument_coverage()
if self.sess.opts.debugging_opts.no_profiler_runtime
|| !(self.sess.instrument_coverage()
|| self.sess.opts.debugging_opts.profile
|| self.sess.opts.cg.profile_generate.enabled()))
|| self.sess.opts.cg.profile_generate.enabled())
{
return;
}

info!("loading profiler");

let name = Symbol::intern(profiler_runtime.as_ref().unwrap());
let name = Symbol::intern(&self.sess.opts.debugging_opts.profiler_runtime);
if name == sym::profiler_builtins && self.sess.contains_name(&krate.attrs, sym::no_core) {
self.sess.err(
"`profiler_builtins` crate (required by compiler options) \
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/locator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,8 +1103,8 @@ impl CrateError {
if sess.is_nightly_build() {
err.help("consider building the standard library from source with `cargo build -Zbuild-std`");
}
} else if Some(crate_name)
== sess.opts.debugging_opts.profiler_runtime.as_deref().map(Symbol::intern)
} else if crate_name
== Symbol::intern(&sess.opts.debugging_opts.profiler_runtime)
{
err.note(&"the compiler may have been built without the profiler runtime");
}
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-tidy-filelength
use crate::ich::StableHashingContext;
use crate::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use crate::mir::{GeneratorLayout, GeneratorSavedLocal};
Expand Down
6 changes: 4 additions & 2 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,8 @@ options! {
"compile without linking"),
no_parallel_llvm: bool = (false, parse_no_flag, [UNTRACKED],
"run LLVM in non-parallel mode (while keeping codegen-units and ThinLTO)"),
no_profiler_runtime: bool = (false, parse_no_flag, [TRACKED],
"prevent automatic injection of the profiler_builtins crate"),
normalize_docs: bool = (false, parse_bool, [TRACKED],
"normalize associated items in rustdoc when generating documentation"),
osx_rpath_install_name: bool = (false, parse_bool, [TRACKED],
Expand Down Expand Up @@ -1217,8 +1219,8 @@ options! {
profile_emit: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
"file path to emit profiling data at runtime when using 'profile' \
(default based on relative source path)"),
profiler_runtime: Option<String> = (Some(String::from("profiler_builtins")), parse_opt_string, [TRACKED],
"name of the profiler runtime crate to automatically inject, or None to disable"),
profiler_runtime: String = (String::from("profiler_builtins"), parse_string, [TRACKED],
"name of the profiler runtime crate to automatically inject (default: `profiler_builtins`)"),
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
"enable queries of the dependency graph for regression testing (default: no)"),
query_stats: bool = (false, parse_bool, [UNTRACKED],
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_typeck/src/astconv/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
param_counts.consts + named_type_param_count
- default_counts.types
- default_counts.consts
- synth_type_param_count
};
debug!("expected_min: {:?}", expected_min);
debug!("arg_counts.lifetimes: {:?}", gen_args.num_lifetime_params());
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_typeck/src/check/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(

// This closure is a more robust way to check `Predicate` equality
// than simple `==` checks (which were the previous implementation).
// It relies on `ty::relate` for `TraitPredicate` and `ProjectionPredicate`
// (which implement the Relate trait), while delegating on simple equality
// for the other `Predicate`.
// It relies on `ty::relate` for `TraitPredicate`, `ProjectionPredicate`,
// `ConstEvaluatable` and `TypeOutlives` (which implement the Relate trait),
// while delegating on simple equality for the other `Predicate`.
// This implementation solves (Issue #59497) and (Issue #58311).
// It is unclear to me at the moment whether the approach based on `relate`
// could be extended easily also to the other `Predicate`.
Expand All @@ -235,6 +235,13 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
(ty::PredicateKind::Projection(a), ty::PredicateKind::Projection(b)) => {
relator.relate(predicate.rebind(a), p.rebind(b)).is_ok()
}
(
ty::PredicateKind::ConstEvaluatable(def_a, substs_a),
ty::PredicateKind::ConstEvaluatable(def_b, substs_b),
) => tcx.try_unify_abstract_consts(((def_a, substs_a), (def_b, substs_b))),
(ty::PredicateKind::TypeOutlives(a), ty::PredicateKind::TypeOutlives(b)) => {
relator.relate(predicate.rebind(a.0), p.rebind(b.0)).is_ok()
}
_ => predicate == p,
}
};
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_typeck/src/collect.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-tidy-filelength
//! "Collection" is the process of determining the type and other external
//! details of each item in Rust. Collection is specifically concerned
//! with *inter-procedural* things -- for example, for a function
Expand All @@ -15,8 +14,6 @@
//! At present, however, we do run collection across all items in the
//! crate as a kind of pass. This should eventually be factored away.

// ignore-tidy-filelength

use crate::astconv::{AstConv, SizedByDefault};
use crate::bounds::Bounds;
use crate::check::intrinsic::intrinsic_operation_unsafety;
Expand Down
4 changes: 3 additions & 1 deletion library/alloc/src/collections/vec_deque/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,9 @@ impl<T, A: Allocator> VecDeque<T, A> {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: VecDeque::reserve
///
/// # Errors
///
Expand Down
4 changes: 3 additions & 1 deletion library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,9 @@ impl String {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: String::reserve
///
/// # Errors
///
Expand Down
8 changes: 6 additions & 2 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,9 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: Vec::reserve
///
/// # Panics
///
Expand Down Expand Up @@ -875,7 +877,9 @@ impl<T, A: Allocator> Vec<T, A> {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer `reserve` if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: Vec::reserve
///
/// # Errors
///
Expand Down
4 changes: 0 additions & 4 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// ignore-tidy-filelength
// This file almost exclusively consists of the definition of `Iterator`. We
// can't split that into multiple files.

use crate::cmp::{self, Ordering};
use crate::ops::{ControlFlow, Try};

Expand Down
1 change: 0 additions & 1 deletion library/core/src/slice/iter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore-tidy-filelength
//! Definitions of a bunch of iterators for `[T]`.

#[macro_use] // import iterator! and forward_iterator!
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore-tidy-filelength

//! Slice management and manipulation.
//!
//! For more details see [`std::slice`].
Expand Down
2 changes: 0 additions & 2 deletions library/std/src/collections/hash/map.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// ignore-tidy-filelength

#[cfg(test)]
mod tests;

Expand Down
4 changes: 3 additions & 1 deletion library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ impl OsString {
///
/// Note that the allocator may give the collection more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer reserve if future insertions are expected.
/// minimal. Prefer [`reserve`] if future insertions are expected.
///
/// [`reserve`]: OsString::reserve
///
/// # Examples
///
Expand Down
15 changes: 3 additions & 12 deletions library/std/src/os/linux/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use crate::io::Result;
use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use crate::process;
use crate::sealed::Sealed;
#[cfg(not(doc))]
use crate::sys::fd::FileDesc;
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
Expand Down Expand Up @@ -84,15 +85,10 @@ impl IntoRawFd for PidFd {
}
}

mod private_child_ext {
pub trait Sealed {}
impl Sealed for crate::process::Child {}
}

/// Os-specific extensions for [`Child`]
///
/// [`Child`]: process::Child
pub trait ChildExt: private_child_ext::Sealed {
pub trait ChildExt: Sealed {
/// Obtains a reference to the [`PidFd`] created for this [`Child`], if available.
///
/// A pidfd will only be available if its creation was requested with
Expand Down Expand Up @@ -120,15 +116,10 @@ pub trait ChildExt: private_child_ext::Sealed {
fn take_pidfd(&mut self) -> Result<PidFd>;
}

mod private_command_ext {
pub trait Sealed {}
impl Sealed for crate::process::Command {}
}

/// Os-specific extensions for [`Command`]
///
/// [`Command`]: process::Command
pub trait CommandExt: private_command_ext::Sealed {
pub trait CommandExt: Sealed {
/// Sets whether a [`PidFd`](struct@PidFd) should be created for the [`Child`]
/// spawned by this [`Command`].
/// By default, no pidfd will be created.
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ pub struct Child {
pub stderr: Option<ChildStderr>,
}

/// Allows extension traits within `std`.
#[unstable(feature = "sealed", issue = "none")]
impl crate::sealed::Sealed for Child {}

impl AsInner<imp::Process> for Child {
fn as_inner(&self) -> &imp::Process {
&self.handle
Expand Down
Loading