Skip to content

Rollup of 5 pull requests #71549

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

Merged
merged 13 commits into from
Apr 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 7 additions & 10 deletions src/liballoc/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,9 +1034,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
R: RangeBounds<T>,
{
if let Some(root) = &self.root {
let root1 = root.as_ref();
let root2 = root.as_ref();
let (f, b) = range_search(root1, root2, range);
let (f, b) = range_search(root.as_ref(), range);

Range { front: Some(f), back: Some(b) }
} else {
Expand Down Expand Up @@ -1082,9 +1080,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
R: RangeBounds<T>,
{
if let Some(root) = &mut self.root {
let root1 = root.as_mut();
let root2 = unsafe { ptr::read(&root1) };
let (f, b) = range_search(root1, root2, range);
let (f, b) = range_search(root.as_mut(), range);

RangeMut { front: Some(f), back: Some(b), _marker: PhantomData }
} else {
Expand Down Expand Up @@ -2043,8 +2039,7 @@ where
}

fn range_search<BorrowType, K, V, Q: ?Sized, R: RangeBounds<Q>>(
root1: NodeRef<BorrowType, K, V, marker::LeafOrInternal>,
root2: NodeRef<BorrowType, K, V, marker::LeafOrInternal>,
root: NodeRef<BorrowType, K, V, marker::LeafOrInternal>,
range: R,
) -> (
Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::Edge>,
Expand All @@ -2064,8 +2059,10 @@ where
_ => {}
};

let mut min_node = root1;
let mut max_node = root2;
// We duplicate the root NodeRef here -- we will never access it in a way
// that overlaps references obtained from the root.
let mut min_node = unsafe { ptr::read(&root) };
let mut max_node = root;
let mut min_found = false;
let mut max_found = false;

Expand Down
8 changes: 2 additions & 6 deletions src/librustc_ast_lowering/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
let then_arm = self.arm(then_pat, self.arena.alloc(then_expr));

// `match <scrutinee> { ... }`
let match_expr = self.expr_match(
scrutinee.span,
scrutinee,
arena_vec![self; then_arm, else_arm],
desugar,
);
let match_expr =
self.expr_match(span, scrutinee, arena_vec![self; then_arm, else_arm], desugar);

// `[opt_ident]: loop { ... }`
hir::ExprKind::Loop(self.block_expr(self.arena.alloc(match_expr)), opt_label, source)
Expand Down
23 changes: 18 additions & 5 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ pub struct ModuleConfig {
}

impl ModuleConfig {
fn new(kind: ModuleKind, sess: &Session, no_builtins: bool) -> ModuleConfig {
fn new(
kind: ModuleKind,
sess: &Session,
no_builtins: bool,
is_compiler_builtins: bool,
) -> ModuleConfig {
// If it's a regular module, use `$regular`, otherwise use `$other`.
// `$regular` and `$other` are evaluated lazily.
macro_rules! if_regular {
Expand Down Expand Up @@ -160,7 +165,10 @@ impl ModuleConfig {
passes: if_regular!(
{
let mut passes = sess.opts.cg.passes.clone();
if sess.opts.debugging_opts.profile {
// compiler_builtins overrides the codegen-units settings,
// which is incompatible with -Zprofile which requires that
// only a single codegen unit is used per crate.
if sess.opts.debugging_opts.profile && !is_compiler_builtins {
passes.push("insert-gcov-profiling".to_owned());
}
passes
Expand Down Expand Up @@ -406,6 +414,8 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
let crate_name = tcx.crate_name(LOCAL_CRATE);
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
let no_builtins = attr::contains_name(&tcx.hir().krate().item.attrs, sym::no_builtins);
let is_compiler_builtins =
attr::contains_name(&tcx.hir().krate().item.attrs, sym::compiler_builtins);
let subsystem =
attr::first_attr_value_str_by_name(&tcx.hir().krate().item.attrs, sym::windows_subsystem);
let windows_subsystem = subsystem.map(|subsystem| {
Expand All @@ -422,9 +432,12 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
let linker_info = LinkerInfo::new(tcx);
let crate_info = CrateInfo::new(tcx);

let regular_config = ModuleConfig::new(ModuleKind::Regular, sess, no_builtins);
let metadata_config = ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins);
let allocator_config = ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins);
let regular_config =
ModuleConfig::new(ModuleKind::Regular, sess, no_builtins, is_compiler_builtins);
let metadata_config =
ModuleConfig::new(ModuleKind::Metadata, sess, no_builtins, is_compiler_builtins);
let allocator_config =
ModuleConfig::new(ModuleKind::Allocator, sess, no_builtins, is_compiler_builtins);

let (shared_emitter, shared_emitter_main) = SharedEmitter::new();
let (codegen_worker_send, codegen_worker_receive) = channel();
Expand Down
8 changes: 7 additions & 1 deletion src/librustc_lint/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_middle::ty::{self, Ty};
use rustc_session::lint::builtin::UNUSED_ATTRIBUTES;
use rustc_span::symbol::Symbol;
use rustc_span::symbol::{kw, sym};
use rustc_span::{BytePos, Span};
use rustc_span::{BytePos, Span, DUMMY_SP};

use log::debug;

Expand Down Expand Up @@ -415,6 +415,12 @@ trait UnusedDelimLint {
msg: &str,
keep_space: (bool, bool),
) {
// FIXME(flip1995): Quick and dirty fix for #70814. This should be fixed in rustdoc
// properly.
if span == DUMMY_SP {
return;
}

cx.struct_span_lint(self.lint(), span, |lint| {
let span_msg = format!("unnecessary {} around {}", Self::DELIM_STR, msg);
let mut err = lint.build(&span_msg);
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
return None;
}

// FIXME we need to revisit this for #67176
if rvalue.needs_subst() {
return None;
}

// Perform any special handling for specific Rvalue types.
// Generally, checks here fall into one of two categories:
// 1. Additional checking to provide useful lints to the user
Expand Down Expand Up @@ -636,11 +641,6 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
_ => {}
}

// FIXME we need to revisit this for #67176
if rvalue.needs_subst() {
return None;
}

self.use_ecx(|this| {
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
this.ecx.eval_rvalue_into_place(rvalue, place)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn while_loop(_1: bool) -> () {

bb5: {
StorageDead(_4); // bb5[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
StorageDead(_2); // bb5[1]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
StorageDead(_2); // bb5[1]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
goto -> bb0; // bb5[2]: scope 0 at $DIR/while-storage.rs:10:5: 14:6
}

Expand All @@ -74,7 +74,7 @@ fn while_loop(_1: bool) -> () {
}

bb7: {
StorageDead(_2); // bb7[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22
StorageDead(_2); // bb7[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6
return; // bb7[1]: scope 0 at $DIR/while-storage.rs:15:2: 15:2
}
}
14 changes: 14 additions & 0 deletions src/test/rustdoc-ui/unused-braces-lint.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// check-pass

// This tests the bug in #70814, where the unused_braces lint triggered on the following code
// without providing a span.

#![deny(unused_braces)]

fn main() {
{
{
use std;
}
}
}
10 changes: 8 additions & 2 deletions src/test/ui/block-result/block-must-not-have-result-while.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ LL | while true {
error[E0308]: mismatched types
--> $DIR/block-must-not-have-result-while.rs:3:9
|
LL | true
| ^^^^ expected `()`, found `bool`
LL | / while true {
LL | | true
| | ^^^^ expected `()`, found `bool`
LL | |
LL | | }
| | -- help: consider using a semicolon here
| |_____|
| expected this to be `()`

error: aborting due to previous error; 1 warning emitted

Expand Down
6 changes: 2 additions & 4 deletions src/test/ui/consts/const-eval/ice-generic-assoc-const.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-pass
// build-pass (tests post-monomorphisation failure)
#![crate_type = "lib"]

pub trait Nullable {
const NULL: Self;
Expand All @@ -13,6 +14,3 @@ impl<T> Nullable for *const T {
*self == Self::NULL
}
}

fn main() {
}
Loading