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 4 pull requests #74987

Closed
wants to merge 9 commits into from
9 changes: 9 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
Version 1.45.2 (2020-08-03)
==========================

* [Fix bindings in tuple struct patterns][74954]
* [Fix track_caller integration with trait objects][74784]

[74954]: https://github.com/rust-lang/rust/issues/74954
[74784]: https://github.com/rust-lang/rust/issues/74784

Version 1.45.1 (2020-07-30)
==========================

Expand Down
45 changes: 10 additions & 35 deletions library/alloc/src/collections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,32 +1110,17 @@ impl<T> IterMut<'_, T> {
/// Inserts the given element just after the element most recently returned by `.next()`.
/// The inserted element does not appear in the iteration.
///
/// # Examples
///
/// ```
/// #![feature(linked_list_extras)]
///
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect();
///
/// {
/// let mut it = list.iter_mut();
/// assert_eq!(it.next().unwrap(), &1);
/// // insert `2` after `1`
/// it.insert_next(2);
/// }
/// {
/// let vec: Vec<_> = list.into_iter().collect();
/// assert_eq!(vec, [1, 2, 3, 4]);
/// }
/// ```
/// This method will be removed soon.
#[inline]
#[unstable(
feature = "linked_list_extras",
reason = "this is probably better handled by a cursor type -- we'll see",
issue = "27794"
)]
#[rustc_deprecated(
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
since = "1.47.0"
)]
pub fn insert_next(&mut self, element: T) {
match self.head {
// `push_back` is okay with aliasing `element` references
Expand Down Expand Up @@ -1163,27 +1148,17 @@ impl<T> IterMut<'_, T> {

/// Provides a reference to the next element, without changing the iterator.
///
/// # Examples
///
/// ```
/// #![feature(linked_list_extras)]
///
/// use std::collections::LinkedList;
///
/// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect();
///
/// let mut it = list.iter_mut();
/// assert_eq!(it.next().unwrap(), &1);
/// assert_eq!(it.peek_next().unwrap(), &2);
/// // We just peeked at 2, so it was not consumed from the iterator.
/// assert_eq!(it.next().unwrap(), &2);
/// ```
/// This method will be removed soon.
#[inline]
#[unstable(
feature = "linked_list_extras",
reason = "this is probably better handled by a cursor type -- we'll see",
issue = "27794"
)]
#[rustc_deprecated(
reason = "Deprecated in favor of CursorMut methods. This method will be removed soon.",
since = "1.47.0"
)]
pub fn peek_next(&mut self) -> Option<&mut T> {
if self.len == 0 {
None
Expand Down
27 changes: 0 additions & 27 deletions library/alloc/src/collections/linked_list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,33 +153,6 @@ fn test_clone_from() {
}
}

#[test]
fn test_insert_prev() {
let mut m = list_from(&[0, 2, 4, 6, 8]);
let len = m.len();
{
let mut it = m.iter_mut();
it.insert_next(-2);
loop {
match it.next() {
None => break,
Some(elt) => {
it.insert_next(*elt + 1);
match it.peek_next() {
Some(x) => assert_eq!(*x, *elt + 2),
None => assert_eq!(8, *elt),
}
}
}
}
it.insert_next(0);
it.insert_next(1);
}
check_links(&m);
assert_eq!(m.len(), 3 + len * 2);
assert_eq!(m.into_iter().collect::<Vec<_>>(), [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]);
}

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
fn test_send() {
Expand Down
3 changes: 3 additions & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ fn main() {
} else if target.contains("freebsd") {
println!("cargo:rustc-link-lib=execinfo");
println!("cargo:rustc-link-lib=pthread");
if env::var("RUST_STD_FREEBSD_12_ABI").is_ok() {
println!("cargo:rustc-cfg=freebsd12");
}
} else if target.contains("netbsd") {
println!("cargo:rustc-link-lib=pthread");
println!("cargo:rustc-link-lib=rt");
Expand Down
8 changes: 8 additions & 0 deletions library/std/src/os/freebsd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ pub trait MetadataExt {
impl MetadataExt for Metadata {
#[allow(deprecated)]
fn as_raw_stat(&self) -> &raw::stat {
// The methods below use libc::stat, so they work fine when libc is built with FreeBSD 12 ABI.
// This method would just return nonsense.
#[cfg(freebsd12)]
panic!("as_raw_stat not supported with FreeBSD 12 ABI");
#[cfg(not(freebsd12))]
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
}
fn st_dev(&self) -> u64 {
Expand Down Expand Up @@ -137,6 +142,9 @@ impl MetadataExt for Metadata {
self.as_inner().as_inner().st_flags as u32
}
fn st_lspare(&self) -> u32 {
#[cfg(freebsd12)]
panic!("st_lspare not supported with FreeBSD 12 ABI");
#[cfg(not(freebsd12))]
self.as_inner().as_inner().st_lspare as u32
}
}
1 change: 1 addition & 0 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ fn supported_sanitizers(
}
"x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
"x86_64-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),
"x86_64-unknown-freebsd" => common_libs("freebsd", "x86_64", &["asan", "msan", "tsan"]),
"x86_64-unknown-linux-gnu" => {
common_libs("linux", "x86_64", &["asan", "lsan", "msan", "tsan"])
}
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ ENV \

ENV HOSTS=x86_64-unknown-freebsd

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --disable-docs
ENV RUST_CONFIGURE_ARGS --enable-extended --enable-profiler --enable-sanitizers --disable-docs
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS
1 change: 1 addition & 0 deletions src/librustc_codegen_ssa/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ fn link_sanitizer_runtime(sess: &Session, linker: &mut dyn Linker, name: &str) {
"aarch64-fuchsia"
| "aarch64-unknown-linux-gnu"
| "x86_64-fuchsia"
| "x86_64-unknown-freebsd"
| "x86_64-unknown-linux-gnu" => {
let filename = format!("librustc{}_rt.{}.a", channel, name);
let path = default_tlib.join(&filename);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ pub struct TypeckResults<'tcx> {
pat_binding_modes: ItemLocalMap<BindingMode>,

/// Stores the types which were implicitly dereferenced in pattern binding modes
/// for later usage in HAIR lowering. For example,
/// for later usage in THIR lowering. For example,
///
/// ```
/// match &&Some(5i32) {
Expand Down
10 changes: 3 additions & 7 deletions src/librustc_mir_build/build/block.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::build::matches::ArmHasGuard;
use crate::build::ForGuard::OutsideGuard;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_hir as hir;
use rustc_middle::mir::*;
use rustc_session::lint::builtin::UNSAFE_OP_IN_UNSAFE_FN;
Expand Down Expand Up @@ -176,7 +176,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let tail_result_is_ignored =
destination_ty.is_unit() || this.block_context.currently_ignores_tail_results();
let span = match expr {
ExprRef::Hair(expr) => expr.span,
ExprRef::Thir(expr) => expr.span,
ExprRef::Mirror(ref expr) => expr.span,
};
this.block_context.push(BlockFrame::TailExpr { tail_result_is_ignored, span });
Expand Down Expand Up @@ -235,11 +235,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.push_unsafe_count
.checked_sub(1)
.unwrap_or_else(|| span_bug!(span, "unsafe count underflow"));
if self.push_unsafe_count == 0 {
Some(self.unpushed_unsafe)
} else {
None
}
if self.push_unsafe_count == 0 { Some(self.unpushed_unsafe) } else { None }
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_constant.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! See docs in build/expr/mod.rs

use crate::build::Builder;
use crate::hair::*;
use crate::thir::*;
use rustc_middle::mir::*;
use rustc_middle::ty::CanonicalUserTypeAnnotation;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::build::expr::category::Category;
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::*;

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use crate::build::expr::category::Category;
use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::AssertKind::BoundsCheck;
use rustc_middle::mir::*;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/as_rvalue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_index::vec::Idx;

use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::AssertKind;
use rustc_middle::mir::*;
Expand Down
8 changes: 5 additions & 3 deletions src/librustc_mir_build/build/expr/as_temp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::build::scope::DropKind;
use crate::build::{BlockAnd, BlockAndExtension, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir as hir;
use rustc_middle::middle::region;
Expand Down Expand Up @@ -67,12 +67,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ExprKind::StaticRef { def_id, .. } => {
assert!(!this.hir.tcx().is_thread_local_static(def_id));
local_decl.internal = true;
local_decl.local_info = Some(box LocalInfo::StaticRef { def_id, is_thread_local: false });
local_decl.local_info =
Some(box LocalInfo::StaticRef { def_id, is_thread_local: false });
}
ExprKind::ThreadLocalRef(def_id) => {
assert!(this.hir.tcx().is_thread_local_static(def_id));
local_decl.internal = true;
local_decl.local_info = Some(box LocalInfo::StaticRef { def_id, is_thread_local: true });
local_decl.local_info =
Some(box LocalInfo::StaticRef { def_id, is_thread_local: true });
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/expr/category.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::hair::*;
use crate::thir::*;

#[derive(Debug, PartialEq)]
crate enum Category {
Expand Down
18 changes: 9 additions & 9 deletions src/librustc_mir_build/build/expr/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::build::expr::category::{Category, RvalueFunc};
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_ast::ast::InlineAsmOptions;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stack::ensure_sufficient_stack;
Expand Down Expand Up @@ -320,23 +320,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
block.unit()
}
ExprKind::InlineAsm { template, operands, options, line_spans } => {
use crate::hair;
use crate::thir;
use rustc_middle::mir;
let operands = operands
.into_iter()
.map(|op| match op {
hair::InlineAsmOperand::In { reg, expr } => mir::InlineAsmOperand::In {
thir::InlineAsmOperand::In { reg, expr } => mir::InlineAsmOperand::In {
reg,
value: unpack!(block = this.as_local_operand(block, expr)),
},
hair::InlineAsmOperand::Out { reg, late, expr } => {
thir::InlineAsmOperand::Out { reg, late, expr } => {
mir::InlineAsmOperand::Out {
reg,
late,
place: expr.map(|expr| unpack!(block = this.as_place(block, expr))),
}
}
hair::InlineAsmOperand::InOut { reg, late, expr } => {
thir::InlineAsmOperand::InOut { reg, late, expr } => {
let place = unpack!(block = this.as_place(block, expr));
mir::InlineAsmOperand::InOut {
reg,
Expand All @@ -346,7 +346,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
out_place: Some(place),
}
}
hair::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
thir::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
mir::InlineAsmOperand::InOut {
reg,
late,
Expand All @@ -356,13 +356,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}),
}
}
hair::InlineAsmOperand::Const { expr } => mir::InlineAsmOperand::Const {
thir::InlineAsmOperand::Const { expr } => mir::InlineAsmOperand::Const {
value: unpack!(block = this.as_local_operand(block, expr)),
},
hair::InlineAsmOperand::SymFn { expr } => {
thir::InlineAsmOperand::SymFn { expr } => {
mir::InlineAsmOperand::SymFn { value: box this.as_constant(expr) }
}
hair::InlineAsmOperand::SymStatic { def_id } => {
thir::InlineAsmOperand::SymStatic { def_id } => {
mir::InlineAsmOperand::SymStatic { def_id }
}
})
Expand Down
10 changes: 6 additions & 4 deletions src/librustc_mir_build/build/expr/stmt.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::build::scope::BreakableTarget;
use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::middle::region;
use rustc_middle::mir::*;

impl<'a, 'tcx> Builder<'a, 'tcx> {
/// Builds a block of MIR statements to evaluate the HAIR `expr`.
/// Builds a block of MIR statements to evaluate the THIR `expr`.
/// If the original expression was an AST statement,
/// (e.g., `some().code(&here());`) then `opt_stmt_span` is the
/// span of that statement (including its semicolon, if any).
Expand Down Expand Up @@ -150,8 +150,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
break;
}
}
this.block_context
.push(BlockFrame::TailExpr { tail_result_is_ignored: true, span: expr.span });
this.block_context.push(BlockFrame::TailExpr {
tail_result_is_ignored: true,
span: expr.span,
});
return Some(expr.span);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir_build/build/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! latter `EvalInto` trait.

use crate::build::{BlockAnd, Builder};
use crate::hair::*;
use crate::thir::*;
use rustc_middle::mir::*;

pub(in crate::build) trait EvalInto<'tcx> {
Expand Down
Loading