Skip to content

Commit

Permalink
Auto merge of #69724 - JohnTitor:rollup-vv7w65h, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

Successful merges:

 - #69520 (Make error message clearer about creating new module)
 - #69589 (ast: `Mac`/`Macro` -> `MacCall`)
 - #69614 (`delay_span_bug` when codegen cannot select obligation)
 - #69641 (Update books)
 - #69674 (Rename DefKind::Method and TraitItemKind::Method )
 - #69697 (Add explanation for E0380)
 - #69698 (Use associated constants of integer types)
 - #69705 (Toolstate: remove redundant beta-week check.)
 - #69711 (Update macros.rs: fix documentation typo.)
 - #69713 (more clippy cleanups)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Mar 5, 2020
2 parents 1e17969 + 5089e11 commit f6c22f0
Show file tree
Hide file tree
Showing 138 changed files with 470 additions and 447 deletions.
55 changes: 22 additions & 33 deletions src/bootstrap/toolstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,21 @@ impl Step for ToolStateCheck {
tool, old_state, state
);
} else {
// This warning only appears in the logs, which most
// people won't read. It's mostly here for testing and
// debugging.
eprintln!(
"warning: Tool `{}` is not test-pass (is `{}`), \
this should be fixed before beta is branched.",
tool, state
);
}
}
// `publish_toolstate.py` is responsible for updating
// `latest.json` and creating comments/issues warning people
// if there is a regression. That all happens in a separate CI
// job on the master branch once the PR has passed all tests
// on the `auto` branch.
}
}

Expand All @@ -230,7 +238,7 @@ impl Step for ToolStateCheck {
}

if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {
commit_toolstate_change(&toolstates, in_beta_week);
commit_toolstate_change(&toolstates);
}
}

Expand Down Expand Up @@ -325,11 +333,11 @@ fn prepare_toolstate_config(token: &str) {
Err(_) => false,
};
if !success {
panic!("git config key={} value={} successful (status: {:?})", key, value, status);
panic!("git config key={} value={} failed (status: {:?})", key, value, status);
}
}

// If changing anything here, then please check that src/ci/publish_toolstate.sh is up to date
// If changing anything here, then please check that `src/ci/publish_toolstate.sh` is up to date
// as well.
git_config("user.email", "7378925+rust-toolstate-update@users.noreply.github.com");
git_config("user.name", "Rust Toolstate Update");
Expand Down Expand Up @@ -373,14 +381,14 @@ fn read_old_toolstate() -> Vec<RepoState> {
///
/// * See <https://help.github.com/articles/about-commit-email-addresses/>
/// if a private email by GitHub is wanted.
fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool) {
let old_toolstate = read_old_toolstate();

fn commit_toolstate_change(current_toolstate: &ToolstateData) {
let message = format!("({} CI update)", OS.expect("linux/windows only"));
let mut success = false;
for _ in 1..=5 {
// Update the toolstate results (the new commit-to-toolstate mapping) in the toolstate repo.
change_toolstate(&current_toolstate, &old_toolstate, in_beta_week);
// Upload the test results (the new commit-to-toolstate mapping) to the toolstate repo.
// This does *not* change the "current toolstate"; that only happens post-landing
// via `src/ci/docker/publish_toolstate.sh`.
publish_test_results(&current_toolstate);

// `git commit` failing means nothing to commit.
let status = t!(Command::new("git")
Expand Down Expand Up @@ -429,31 +437,12 @@ fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool
}
}

fn change_toolstate(
current_toolstate: &ToolstateData,
old_toolstate: &[RepoState],
in_beta_week: bool,
) {
let mut regressed = false;
for repo_state in old_toolstate {
let tool = &repo_state.tool;
let state = repo_state.state();
let new_state = current_toolstate[tool.as_str()];

if new_state != state {
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
if new_state < state {
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
regressed = true;
}
}
}
}

if regressed && in_beta_week {
std::process::exit(1);
}

/// Updates the "history" files with the latest results.
///
/// These results will later be promoted to `latest.json` by the
/// `publish_toolstate.py` script if the PR passes all tests and is merged to
/// master.
fn publish_test_results(current_toolstate: &ToolstateData) {
let commit = t!(std::process::Command::new("git").arg("rev-parse").arg("HEAD").output());
let commit = t!(String::from_utf8(commit.stdout));

Expand Down
4 changes: 3 additions & 1 deletion src/ci/publish_toolstate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ GIT_COMMIT_MSG="$(git log --format=%s -n1 HEAD)"
cd rust-toolstate
FAILURE=1
for RETRY_COUNT in 1 2 3 4 5; do
# The purpose is to publish the new "current" toolstate in the toolstate repo.
# The purpose of this is to publish the new "current" toolstate in the toolstate repo.
# This happens post-landing, on master.
# (Publishing the per-commit test results happens pre-landing in src/bootstrap/toolstate.rs).
"$(ciCheckoutPath)/src/tools/publish_toolstate.py" "$GIT_COMMIT" \
"$GIT_COMMIT_MSG" \
"$MESSAGE_FILE" \
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ impl DepGraph {
edge_list_indices.push((start, end));
}

debug_assert!(edge_list_data.len() <= ::std::u32::MAX as usize);
debug_assert!(edge_list_data.len() <= u32::MAX as usize);
debug_assert_eq!(edge_list_data.len(), total_edge_count);

SerializedDepGraph { nodes, fingerprints, edge_list_indices, edge_list_data }
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> {
impl MaybeFnLike for hir::TraitItem<'_> {
fn is_fn_like(&self) -> bool {
match self.kind {
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
_ => false,
}
}
Expand Down Expand Up @@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> {
_ => bug!("item FnLikeNode that is not fn-like"),
},
Node::TraitItem(ti) => match ti.kind {
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
}
_ => bug!("trait method FnLikeNode that is not fn-like"),
Expand Down
16 changes: 8 additions & 8 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> {
},

Node::TraitItem(ref item) => match item.kind {
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
_ => None,
},

Expand All @@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> {
},

Node::TraitItem(item) => match &item.kind {
TraitItemKind::Method(sig, _) => Some(sig),
TraitItemKind::Fn(sig, _) => Some(sig),
_ => None,
},

Expand All @@ -101,7 +101,7 @@ impl<'hir> Entry<'hir> {

Node::TraitItem(item) => match item.kind {
TraitItemKind::Const(_, Some(body))
| TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
| TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body),
_ => None,
},

Expand Down Expand Up @@ -326,12 +326,12 @@ impl<'hir> Map<'hir> {
},
Node::TraitItem(item) => match item.kind {
TraitItemKind::Const(..) => DefKind::AssocConst,
TraitItemKind::Method(..) => DefKind::Method,
TraitItemKind::Fn(..) => DefKind::AssocFn,
TraitItemKind::Type(..) => DefKind::AssocTy,
},
Node::ImplItem(item) => match item.kind {
ImplItemKind::Const(..) => DefKind::AssocConst,
ImplItemKind::Method(..) => DefKind::Method,
ImplItemKind::Method(..) => DefKind::AssocFn,
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
},
Expand Down Expand Up @@ -472,7 +472,7 @@ impl<'hir> Map<'hir> {
| Node::AnonConst(_) => BodyOwnerKind::Const,
Node::Ctor(..)
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. })
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
Expand Down Expand Up @@ -800,7 +800,7 @@ impl<'hir> Map<'hir> {
_ => false,
},
Node::TraitItem(ti) => match ti.kind {
TraitItemKind::Method(..) => true,
TraitItemKind::Fn(..) => true,
_ => false,
},
Node::ImplItem(ii) => match ii.kind {
Expand Down Expand Up @@ -1311,7 +1311,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
Some(Node::TraitItem(ti)) => {
let kind = match ti.kind {
TraitItemKind::Const(..) => "assoc constant",
TraitItemKind::Method(..) => "trait method",
TraitItemKind::Fn(..) => "trait method",
TraitItemKind::Type(..) => "assoc type",
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub enum EvalResult {
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
// Check if `def_id` is a trait method.
match tcx.def_kind(def_id) {
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
// Trait methods do not declare visibility (even
// for visibility info in cstore). Use containing
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,9 @@ impl UndefMask {
// First set all bits except the first `bita`,
// then unset the last `64 - bitb` bits.
let range = if bitb == 0 {
u64::max_value() << bita
u64::MAX << bita
} else {
(u64::max_value() << bita) & (u64::max_value() >> (64 - bitb))
(u64::MAX << bita) & (u64::MAX >> (64 - bitb))
};
if new_state {
self.blocks[blocka] |= range;
Expand All @@ -832,21 +832,21 @@ impl UndefMask {
// across block boundaries
if new_state {
// Set `bita..64` to `1`.
self.blocks[blocka] |= u64::max_value() << bita;
self.blocks[blocka] |= u64::MAX << bita;
// Set `0..bitb` to `1`.
if bitb != 0 {
self.blocks[blockb] |= u64::max_value() >> (64 - bitb);
self.blocks[blockb] |= u64::MAX >> (64 - bitb);
}
// Fill in all the other blocks (much faster than one bit at a time).
for block in (blocka + 1)..blockb {
self.blocks[block] = u64::max_value();
self.blocks[block] = u64::MAX;
}
} else {
// Set `bita..64` to `0`.
self.blocks[blocka] &= !(u64::max_value() << bita);
self.blocks[blocka] &= !(u64::MAX << bita);
// Set `0..bitb` to `0`.
if bitb != 0 {
self.blocks[blockb] &= !(u64::max_value() >> (64 - bitb));
self.blocks[blockb] &= !(u64::MAX >> (64 - bitb));
}
// Fill in all the other blocks (much faster than one bit at a time).
for block in (blocka + 1)..blockb {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ pub trait PointerArithmetic: layout::HasDataLayout {
fn overflowing_signed_offset(&self, val: u64, i: i128) -> (u64, bool) {
// FIXME: is it possible to over/underflow here?
if i < 0 {
// Trickery to ensure that `i64::min_value()` works fine: compute `n = -i`.
// Trickery to ensure that `i64::MIN` works fine: compute `n = -i`.
// This formula only works for true negative values; it overflows for zero!
let n = u64::max_value() - (i as u64) + 1;
let n = u64::MAX - (i as u64) + 1;
let res = val.overflowing_sub(n);
self.truncate_to_ptr(res)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ rustc_queries! {
Codegen {
query codegen_fulfill_obligation(
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
) -> Vtable<'tcx, ()> {
) -> Option<Vtable<'tcx, ()>> {
no_force
cache_on_disk_if { true }
desc { |tcx|
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/traits/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
super::ReferenceOutlivesReferent(ty) => {
tcx.lift(&ty).map(super::ReferenceOutlivesReferent)
}
super::ObjectTypeBound(ty, r) => tcx
.lift(&ty)
.and_then(|ty| tcx.lift(&r).and_then(|r| Some(super::ObjectTypeBound(ty, r)))),
super::ObjectTypeBound(ty, r) => {
tcx.lift(&ty).and_then(|ty| tcx.lift(&r).map(|r| super::ObjectTypeBound(ty, r)))
}
super::ObjectCastObligation(ty) => tcx.lift(&ty).map(super::ObjectCastObligation),
super::Coercion { source, target } => {
Some(super::Coercion { source: tcx.lift(&source)?, target: tcx.lift(&target)? })
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> {
}

match self.type_dependent_defs().get(expr.hir_id) {
Some(Ok((DefKind::Method, _))) => true,
Some(Ok((DefKind::AssocFn, _))) => true,
_ => false,
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use rustc_span::DUMMY_SP;

use std::cmp;
use std::fmt;
use std::i128;
use std::iter;
use std::mem;
use std::ops::Bound;
Expand Down Expand Up @@ -1001,7 +1000,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
}
}

let (mut min, mut max) = (i128::max_value(), i128::min_value());
let (mut min, mut max) = (i128::MAX, i128::MIN);
let discr_type = def.repr.discr_type();
let bits = Integer::from_attr(self, discr_type).size().bits();
for (i, discr) in def.discriminants(tcx) {
Expand All @@ -1021,7 +1020,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
}
}
// We might have no inhabited variants, so pretend there's at least one.
if (min, max) == (i128::max_value(), i128::min_value()) {
if (min, max) == (i128::MAX, i128::MIN) {
min = 0;
max = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl AssocItem {
pub fn def_kind(&self) -> DefKind {
match self.kind {
AssocKind::Const => DefKind::AssocConst,
AssocKind::Method => DefKind::Method,
AssocKind::Method => DefKind::AssocFn,
AssocKind::Type => DefKind::AssocTy,
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
}
Expand Down Expand Up @@ -2872,7 +2872,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
} else {
match self.def_kind(def_id).expect("no def for `DefId`") {
DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true,
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true,
_ => false,
}
};
Expand Down Expand Up @@ -3051,7 +3051,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
let item = if def_id.krate != LOCAL_CRATE {
if let Some(DefKind::Method) = self.def_kind(def_id) {
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
Some(self.associated_item(def_id))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ pub trait PrettyPrinter<'tcx>:
}
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Uint(ui)) => {
let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size();
let max = truncate(u128::max_value(), bit_size);
let max = truncate(u128::MAX, bit_size);

let ui_str = ui.name_str();
if data == max {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ struct AbsoluteBytePos(u32);

impl AbsoluteBytePos {
fn new(pos: usize) -> AbsoluteBytePos {
debug_assert!(pos <= ::std::u32::MAX as usize);
debug_assert!(pos <= u32::MAX as usize);
AbsoluteBytePos(pos as u32)
}

Expand Down
Loading

0 comments on commit f6c22f0

Please sign in to comment.