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 8 pull requests #62253

Merged
merged 20 commits into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e991abd
remove unused derives and variants
euclio Jun 27, 2019
07c5e2b
Use a more efficient iteration order for forward dataflow
ecstatic-morse Jun 22, 2019
e2479e2
Use more efficient iteration order for backward dataflow
ecstatic-morse Jun 22, 2019
47551b1
Fix a typo
Jun 29, 2019
1fd64cf
fix the same typo in doctest
Jun 29, 2019
ce1d95a
Always parse 'async unsafe fn' + properly ban in 2015.
Centril Jun 29, 2019
c0fb347
before_exec actually will only get deprecated with 1.37
RalfJung Jun 30, 2019
b613ef1
Extend the #[must_use] lint to boxed types
varkor Jun 29, 2019
d066f19
Improve error messages for boxed trait objects in tuples
varkor Jun 29, 2019
75f31e7
Fix run-pass tests
varkor Jun 29, 2019
400fd60
Update miri
varkor Jun 30, 2019
76f5b50
Extend #[must_use] lint to arrays
varkor Jun 29, 2019
543c464
Rollup merge of #62062 - ecstatic-morse:dataflow-order, r=nagisa
Centril Jun 30, 2019
70ea57b
Rollup merge of #62063 - ecstatic-morse:dataflow-backward-order, r=na…
Centril Jun 30, 2019
1683bb7
Rollup merge of #62224 - euclio:remove-derives, r=GuillaumeGomez
Centril Jun 30, 2019
c779f4e
Rollup merge of #62228 - varkor:must_use-trait-in-box, r=Centril
Centril Jun 30, 2019
2b313b1
Rollup merge of #62235 - varkor:must_use-adt-components, r=Centril
Centril Jun 30, 2019
690f9e4
Rollup merge of #62239 - lcolaholicl:lcolaholicl-patch-1, r=kennytm
Centril Jun 30, 2019
43eba5f
Rollup merge of #62241 - Centril:fix-async-unsafe-order, r=petrochenkov
Centril Jun 30, 2019
1abbf4b
Rollup merge of #62248 - RalfJung:release-notes, r=Mark-Simulacrum
Centril Jun 30, 2019
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
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