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

[stable] 1.41.1 release #69359

Merged
merged 11 commits into from
Feb 24, 2020
16 changes: 13 additions & 3 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 1.41.1 (2020-02-27)
===========================

* [Always check types of static items][69145]
* [Always check lifetime bounds of `Copy` impls][69145]
* [Fix miscompilation in callers of `Layout::repeat`][69225]

[69225]: https://github.com/rust-lang/rust/issues/69225
[69145]: https://github.com/rust-lang/rust/pull/69145

Version 1.41.0 (2020-01-30)
===========================

Expand Down Expand Up @@ -62,9 +72,9 @@ Cargo
- [Cargo.lock now uses a more git friendly format that should help to reduce
merge conflicts.][cargo/7579]
- [You can now override specific dependencies's build settings][cargo/7591] E.g.
`[profile.dev.overrides.image] opt-level = 2` sets the `image` crate's
`[profile.dev.package.image] opt-level = 2` sets the `image` crate's
optimisation level to `2` for debug builds. You can also use
`[profile.<profile>.build_overrides]` to override build scripts and
`[profile.<profile>.build-override]` to override build scripts and
their dependencies.

Misc
Expand Down Expand Up @@ -208,7 +218,7 @@ Compatibility Notes
- [Using `#[inline]` on function prototypes and consts now emits a warning under
`unused_attribute` lint.][65294] Using `#[inline]` anywhere else inside traits
or `extern` blocks now correctly emits a hard error.

[65294]: https://github.com/rust-lang/rust/pull/65294/
[66103]: https://github.com/rust-lang/rust/pull/66103/
[65843]: https://github.com/rust-lang/rust/pull/65843/
Expand Down
33 changes: 15 additions & 18 deletions src/bootstrap/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use build_helper::output;
use crate::Build;

// The version number
pub const CFG_RELEASE_NUM: &str = "1.41.0";
pub const CFG_RELEASE_NUM: &str = "1.41.1";

pub struct GitInfo {
inner: Option<Info>,
Expand All @@ -29,31 +29,28 @@ impl GitInfo {
pub fn new(ignore_git: bool, dir: &Path) -> GitInfo {
// See if this even begins to look like a git dir
if ignore_git || !dir.join(".git").exists() {
return GitInfo { inner: None }
return GitInfo { inner: None };
}

// Make sure git commands work
match Command::new("git")
.arg("rev-parse")
.current_dir(dir)
.output()
{
match Command::new("git").arg("rev-parse").current_dir(dir).output() {
Ok(ref out) if out.status.success() => {}
_ => return GitInfo { inner: None },
}

// Ok, let's scrape some info
let ver_date = output(Command::new("git").current_dir(dir)
.arg("log").arg("-1")
.arg("--date=short")
.arg("--pretty=format:%cd"));
let ver_hash = output(Command::new("git").current_dir(dir)
.arg("rev-parse").arg("HEAD"));
let short_ver_hash = output(Command::new("git")
.current_dir(dir)
.arg("rev-parse")
.arg("--short=9")
.arg("HEAD"));
let ver_date = output(
Command::new("git")
.current_dir(dir)
.arg("log")
.arg("-1")
.arg("--date=short")
.arg("--pretty=format:%cd"),
);
let ver_hash = output(Command::new("git").current_dir(dir).arg("rev-parse").arg("HEAD"));
let short_ver_hash = output(
Command::new("git").current_dir(dir).arg("rev-parse").arg("--short=9").arg("HEAD"),
);
GitInfo {
inner: Some(Info {
commit_date: ver_date.trim().to_string(),
Expand Down
3 changes: 3 additions & 0 deletions src/ci/azure-pipelines/steps/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ steps:
- bash: src/ci/scripts/setup-environment.sh
displayName: Setup environment

- bash: src/ci/scripts/clean-disk.sh
displayName: Clean disk

- bash: src/ci/scripts/should-skip-this.sh
displayName: Decide whether to run this job

Expand Down
16 changes: 16 additions & 0 deletions src/ci/scripts/clean-disk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# This script deletes some of the Azure-provided artifacts. We don't use these,
# and disk space is at a premium on our builders.

set -euo pipefail
IFS=$'\n\t'

source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"

# All the Linux builds happen inside Docker.
if isLinux; then
# 6.7GB
sudo rm -rf /opt/ghc
# 16GB
sudo rm -rf /usr/share/dotnet
fi
13 changes: 7 additions & 6 deletions src/libcore/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,14 @@ impl Layout {
#[unstable(feature = "alloc_layout_extra", issue = "55724")]
#[inline]
pub fn repeat(&self, n: usize) -> Result<(Self, usize), LayoutErr> {
// This cannot overflow. Quoting from the invariant of Layout:
// > `size`, when rounded up to the nearest multiple of `align`,
// > must not overflow (i.e., the rounded value must be less than
// > `usize::MAX`)
let padded_size = self.size() + self.padding_needed_for(self.align());
let alloc_size = padded_size.checked_mul(n)
// Warning, removing the checked_add here led to segfaults in #67174. Further
// analysis in #69225 seems to indicate that this is an LTO-related
// miscompilation, so #67174 might be able to be reapplied in the future.
let padded_size = self
.size()
.checked_add(self.padding_needed_for(self.align()))
.ok_or(LayoutErr { private: () })?;
let alloc_size = padded_size.checked_mul(n).ok_or(LayoutErr { private: () })?;

unsafe {
// self.align is already known to be valid and alloc_size has been
Expand Down
132 changes: 68 additions & 64 deletions src/librustc/hir/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
//! for the `Code` associated with a particular NodeId.

use crate::hir as ast;
use crate::hir::intravisit::FnKind;
use crate::hir::map;
use crate::hir::{Expr, FnDecl, Node};
use crate::hir::intravisit::FnKind;
use syntax::ast::{Attribute, Ident};
use syntax_pos::Span;

Expand All @@ -29,11 +29,15 @@ use syntax_pos::Span;
///
/// To construct one, use the `Code::from_node` function.
#[derive(Copy, Clone, Debug)]
pub struct FnLikeNode<'a> { node: Node<'a> }
pub struct FnLikeNode<'a> {
node: Node<'a>,
}

/// MaybeFnLike wraps a method that indicates if an object
/// corresponds to some FnLikeNode.
trait MaybeFnLike { fn is_fn_like(&self) -> bool; }
trait MaybeFnLike {
fn is_fn_like(&self) -> bool;
}

impl MaybeFnLike for ast::Item {
fn is_fn_like(&self) -> bool {
Expand Down Expand Up @@ -96,23 +100,23 @@ impl<'a> Code<'a> {
Code::from_node(map, map.get_parent_node(id))
}
map::Node::Expr(expr) => Some(Code::Expr(expr)),
node => FnLikeNode::from_node(node).map(Code::FnLike)
node => FnLikeNode::from_node(node).map(Code::FnLike),
}
}
}

/// These are all the components one can extract from a fn item for
/// use when implementing FnLikeNode operations.
struct ItemFnParts<'a> {
ident: Ident,
decl: &'a ast::FnDecl,
header: ast::FnHeader,
vis: &'a ast::Visibility,
ident: Ident,
decl: &'a ast::FnDecl,
header: ast::FnHeader,
vis: &'a ast::Visibility,
generics: &'a ast::Generics,
body: ast::BodyId,
id: ast::HirId,
span: Span,
attrs: &'a [Attribute],
body: ast::BodyId,
id: ast::HirId,
span: Span,
attrs: &'a [Attribute],
}

/// These are all the components one can extract from a closure expr
Expand All @@ -127,13 +131,7 @@ struct ClosureParts<'a> {

impl<'a> ClosureParts<'a> {
fn new(d: &'a FnDecl, b: ast::BodyId, id: ast::HirId, s: Span, attrs: &'a [Attribute]) -> Self {
ClosureParts {
decl: d,
body: b,
id,
span: s,
attrs,
}
ClosureParts { decl: d, body: b, id, span: s, attrs }
}
}

Expand All @@ -145,33 +143,41 @@ impl<'a> FnLikeNode<'a> {
map::Node::TraitItem(tm) => tm.is_fn_like(),
map::Node::ImplItem(it) => it.is_fn_like(),
map::Node::Expr(e) => e.is_fn_like(),
_ => false
_ => false,
};
fn_like.then_some(FnLikeNode { node })
}

pub fn body(self) -> ast::BodyId {
self.handle(|i: ItemFnParts<'a>| i.body,
|_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body,
|c: ClosureParts<'a>| c.body)
self.handle(
|i: ItemFnParts<'a>| i.body,
|_, _, _: &'a ast::FnSig, _, body: ast::BodyId, _, _| body,
|c: ClosureParts<'a>| c.body,
)
}

pub fn decl(self) -> &'a FnDecl {
self.handle(|i: ItemFnParts<'a>| &*i.decl,
|_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
|c: ClosureParts<'a>| c.decl)
self.handle(
|i: ItemFnParts<'a>| &*i.decl,
|_, _, sig: &'a ast::FnSig, _, _, _, _| &sig.decl,
|c: ClosureParts<'a>| c.decl,
)
}

pub fn span(self) -> Span {
self.handle(|i: ItemFnParts<'_>| i.span,
|_, _, _: &'a ast::FnSig, _, _, span, _| span,
|c: ClosureParts<'_>| c.span)
self.handle(
|i: ItemFnParts<'_>| i.span,
|_, _, _: &'a ast::FnSig, _, _, span, _| span,
|c: ClosureParts<'_>| c.span,
)
}

pub fn id(self) -> ast::HirId {
self.handle(|i: ItemFnParts<'_>| i.id,
|id, _, _: &'a ast::FnSig, _, _, _, _| id,
|c: ClosureParts<'_>| c.id)
self.handle(
|i: ItemFnParts<'_>| i.id,
|id, _, _: &'a ast::FnSig, _, _, _, _| id,
|c: ClosureParts<'_>| c.id,
)
}

pub fn constness(self) -> ast::Constness {
Expand All @@ -190,41 +196,40 @@ impl<'a> FnLikeNode<'a> {
let item = |p: ItemFnParts<'a>| -> FnKind<'a> {
FnKind::ItemFn(p.ident, p.generics, p.header, p.vis, p.attrs)
};
let closure = |c: ClosureParts<'a>| {
FnKind::Closure(c.attrs)
};
let closure = |c: ClosureParts<'a>| FnKind::Closure(c.attrs);
let method = |_, ident: Ident, sig: &'a ast::FnSig, vis, _, _, attrs| {
FnKind::Method(ident, sig, vis, attrs)
};
self.handle(item, method, closure)
}

fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A where
fn handle<A, I, M, C>(self, item_fn: I, method: M, closure: C) -> A
where
I: FnOnce(ItemFnParts<'a>) -> A,
M: FnOnce(ast::HirId,
Ident,
&'a ast::FnSig,
Option<&'a ast::Visibility>,
ast::BodyId,
Span,
&'a [Attribute])
-> A,
M: FnOnce(
ast::HirId,
Ident,
&'a ast::FnSig,
Option<&'a ast::Visibility>,
ast::BodyId,
Span,
&'a [Attribute],
) -> A,
C: FnOnce(ClosureParts<'a>) -> A,
{
match self.node {
map::Node::Item(i) => match i.kind {
ast::ItemKind::Fn(ref sig, ref generics, block) =>
item_fn(ItemFnParts {
id: i.hir_id,
ident: i.ident,
decl: &sig.decl,
body: block,
vis: &i.vis,
span: i.span,
attrs: &i.attrs,
header: sig.header,
generics,
}),
ast::ItemKind::Fn(ref sig, ref generics, block) => item_fn(ItemFnParts {
id: i.hir_id,
ident: i.ident,
decl: &sig.decl,
body: block,
vis: &i.vis,
span: i.span,
attrs: &i.attrs,
header: sig.header,
generics,
}),
_ => bug!("item FnLikeNode that is not fn-like"),
},
map::Node::TraitItem(ti) => match ti.kind {
Expand All @@ -233,17 +238,16 @@ impl<'a> FnLikeNode<'a> {
}
_ => bug!("trait method FnLikeNode that is not fn-like"),
},
map::Node::ImplItem(ii) => {
match ii.kind {
ast::ImplItemKind::Method(ref sig, body) => {
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
}
_ => bug!("impl method FnLikeNode that is not fn-like")
map::Node::ImplItem(ii) => match ii.kind {
ast::ImplItemKind::Method(ref sig, body) => {
method(ii.hir_id, ii.ident, sig, Some(&ii.vis), body, ii.span, &ii.attrs)
}
_ => bug!("impl method FnLikeNode that is not fn-like"),
},
map::Node::Expr(e) => match e.kind {
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) =>
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs)),
ast::ExprKind::Closure(_, ref decl, block, _fn_decl_span, _gen) => {
closure(ClosureParts::new(&decl, block, e.hir_id, e.span, &e.attrs))
}
_ => bug!("expr FnLikeNode that is not fn-like"),
},
_ => bug!("other FnLikeNode that is not fn-like"),
Expand Down
Loading