Skip to content

Commit

Permalink
Auto merge of rust-lang#62253 - Centril:rollup-115uuuq, r=Centril
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - rust-lang#62062 (Use a more efficient iteration order for forward dataflow)
 - rust-lang#62063 (Use a more efficient iteration order for backward dataflow)
 - rust-lang#62224 (rustdoc: remove unused derives and variants)
 - rust-lang#62228 (Extend the #[must_use] lint to boxed types)
 - rust-lang#62235 (Extend the `#[must_use]` lint to arrays)
 - rust-lang#62239 (Fix a typo)
 - rust-lang#62241 (Always parse 'async unsafe fn' + properly ban in 2015)
 - rust-lang#62248 (before_exec actually will only get deprecated with 1.37)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jul 1, 2019
2 parents 5748825 + 1abbf4b commit 765eebf
Show file tree
Hide file tree
Showing 27 changed files with 359 additions and 119 deletions.
6 changes: 3 additions & 3 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ Misc

Compatibility Notes
-------------------
- [`Command::before_exec` is now deprecated in favor of the
unsafe method `Command::pre_exec`.][58059]
- [Use of `ATOMIC_{BOOL, ISIZE, USIZE}_INIT` is now deprecated.][57425] As you
- [`Command::before_exec` is being replaced by the unsafe method
`Command::pre_exec`][58059] and will be deprecated with Rust 1.37.0.
- [Use of `ATOMIC_{BOOL, ISIZE, USIZE}_INIT` is now deprecated][57425] as you
can now use `const` functions in `static` variables.

[58370]: https://github.com/rust-lang/rust/pull/58370/
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,16 +337,16 @@ impl char {
/// ```
/// // as chars
/// let eastern = '東';
/// let capitol = '京';
/// let capital = '京';
///
/// // both can be represented as three bytes
/// assert_eq!(3, eastern.len_utf8());
/// assert_eq!(3, capitol.len_utf8());
/// assert_eq!(3, capital.len_utf8());
///
/// // as a &str, these two are encoded in UTF-8
/// let tokyo = "東京";
///
/// let len = eastern.len_utf8() + capitol.len_utf8();
/// let len = eastern.len_utf8() + capital.len_utf8();
///
/// // we can see that they take six bytes total...
/// assert_eq!(6, tokyo.len());
Expand Down
48 changes: 41 additions & 7 deletions src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
}

let ty = cx.tables.expr_ty(&expr);
let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "");
let type_permits_lack_of_use = check_must_use_ty(cx, ty, &expr, s.span, "", "", false);

let mut fn_warned = false;
let mut op_warned = false;
Expand Down Expand Up @@ -133,23 +133,39 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
ty: Ty<'tcx>,
expr: &hir::Expr,
span: Span,
descr_post_path: &str,
descr_pre: &str,
descr_post: &str,
plural: bool,
) -> bool {
if ty.is_unit() || cx.tcx.is_ty_uninhabited_from(
cx.tcx.hir().get_module_parent(expr.hir_id), ty)
{
return true;
}

let plural_suffix = if plural { "s" } else { "" };

match ty.sty {
ty::Adt(def, _) => check_must_use_def(cx, def.did, span, "", descr_post_path),
ty::Adt(..) if ty.is_box() => {
let boxed_ty = ty.boxed_ty();
let descr_pre = &format!("{}boxed ", descr_pre);
check_must_use_ty(cx, boxed_ty, expr, span, descr_pre, descr_post, plural)
}
ty::Adt(def, _) => {
check_must_use_def(cx, def.did, span, descr_pre, descr_post)
}
ty::Opaque(def, _) => {
let mut has_emitted = false;
for (predicate, _) in &cx.tcx.predicates_of(def).predicates {
if let ty::Predicate::Trait(ref poly_trait_predicate) = predicate {
let trait_ref = poly_trait_predicate.skip_binder().trait_ref;
let def_id = trait_ref.def_id;
if check_must_use_def(cx, def_id, span, "implementer of ", "") {
let descr_pre = &format!(
"{}implementer{} of ",
descr_pre,
plural_suffix,
);
if check_must_use_def(cx, def_id, span, descr_pre, descr_post) {
has_emitted = true;
break;
}
Expand All @@ -162,7 +178,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
for predicate in binder.skip_binder().iter() {
if let ty::ExistentialPredicate::Trait(ref trait_ref) = predicate {
let def_id = trait_ref.def_id;
if check_must_use_def(cx, def_id, span, "", " trait object") {
let descr_post = &format!(
" trait object{}{}",
plural_suffix,
descr_post,
);
if check_must_use_def(cx, def_id, span, descr_pre, descr_post) {
has_emitted = true;
break;
}
Expand All @@ -179,14 +200,27 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
vec![]
};
for (i, ty) in tys.iter().map(|k| k.expect_ty()).enumerate() {
let descr_post_path = &format!(" in tuple element {}", i);
let descr_post = &format!(" in tuple element {}", i);
let span = *spans.get(i).unwrap_or(&span);
if check_must_use_ty(cx, ty, expr, span, descr_post_path) {
if check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, plural) {
has_emitted = true;
}
}
has_emitted
}
ty::Array(ty, len) => match len.assert_usize(cx.tcx) {
// If the array is definitely non-empty, we can do `#[must_use]` checking.
Some(n) if n != 0 => {
let descr_pre = &format!(
"{}array{} of ",
descr_pre,
plural_suffix,
);
check_must_use_ty(cx, ty, expr, span, descr_pre, descr_post, true)
}
// Otherwise, we don't lint, to avoid false positives.
_ => false,
}
_ => false,
}
}
Expand Down
20 changes: 18 additions & 2 deletions src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,25 @@ where
BD: BitDenotation<'tcx>,
{
fn walk_cfg(&mut self, in_out: &mut BitSet<BD::Idx>) {
let mut dirty_queue: WorkQueue<mir::BasicBlock> =
WorkQueue::with_all(self.builder.body.basic_blocks().len());
let body = self.builder.body;

// Initialize the dirty queue in reverse post-order. This makes it more likely that the
// entry state for each basic block will have the effects of its predecessors applied
// before it is processed. In fact, for CFGs without back edges, this guarantees that
// dataflow will converge in exactly `N` iterations, where `N` is the number of basic
// blocks.
let mut dirty_queue: WorkQueue<mir::BasicBlock> =
WorkQueue::with_none(body.basic_blocks().len());
for (bb, _) in traversal::reverse_postorder(body) {
dirty_queue.insert(bb);
}

// Add blocks which are not reachable from START_BLOCK to the work queue. These blocks will
// be processed after the ones added above.
for bb in body.basic_blocks().indices() {
dirty_queue.insert(bb);
}

while let Some(bb) = dirty_queue.pop() {
let (on_entry, trans) = self.builder.flow_state.sets.get_mut(bb.index());
debug_assert!(in_out.words().len() == on_entry.words().len());
Expand Down
21 changes: 18 additions & 3 deletions src/librustc_mir/util/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,24 @@ pub fn liveness_of_locals<'tcx>(

let mut bits = LiveVarSet::new_empty(num_live_vars);

// queue of things that need to be re-processed, and a set containing
// the things currently in the queue
let mut dirty_queue: WorkQueue<BasicBlock> = WorkQueue::with_all(body.basic_blocks().len());
// The dirty queue contains the set of basic blocks whose entry sets have changed since they
// were last processed. At the start of the analysis, we initialize the queue in post-order to
// make it more likely that the entry set for a given basic block will have the effects of all
// its successors in the CFG applied before it is processed.
//
// FIXME(ecstaticmorse): Reverse post-order on the reverse CFG may generate a better iteration
// order when cycles are present, but the overhead of computing the reverse CFG may outweigh
// any benefits. Benchmark this and find out.
let mut dirty_queue: WorkQueue<BasicBlock> = WorkQueue::with_none(body.basic_blocks().len());
for (bb, _) in traversal::postorder(body) {
dirty_queue.insert(bb);
}

// Add blocks which are not reachable from START_BLOCK to the work queue. These blocks will
// be processed after the ones added above.
for bb in body.basic_blocks().indices() {
dirty_queue.insert(bb);
}

let predecessors = body.predecessors();

Expand Down
7 changes: 0 additions & 7 deletions src/librustc_passes/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,13 +837,6 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
the relevant `fold_*()` method in `PlaceholderExpander`?");
}

fn visit_fn_header(&mut self, header: &'a FnHeader) {
if header.asyncness.node.is_async() && self.session.rust_2015() {
struct_span_err!(self.session, header.asyncness.span, E0670,
"`async fn` is not permitted in the 2015 edition").emit();
}
}

fn visit_impl_item(&mut self, ii: &'a ImplItem) {
match ii.node {
ImplItemKind::Method(ref sig, _) => {
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use syntax_pos::Span;

use crate::html::escape::Escape;

#[derive(Clone, RustcEncodable, RustcDecodable, Debug, PartialEq, Eq, Hash)]
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Cfg {
/// Accepts all configurations.
True,
Expand Down
Loading

0 comments on commit 765eebf

Please sign in to comment.