Skip to content

Commit f6c22f0

Browse files
committed
Auto merge of #69724 - JohnTitor:rollup-vv7w65h, r=JohnTitor
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
2 parents 1e17969 + 5089e11 commit f6c22f0

File tree

138 files changed

+470
-447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+470
-447
lines changed

src/bootstrap/toolstate.rs

+22-33
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,21 @@ impl Step for ToolStateCheck {
215215
tool, old_state, state
216216
);
217217
} else {
218+
// This warning only appears in the logs, which most
219+
// people won't read. It's mostly here for testing and
220+
// debugging.
218221
eprintln!(
219222
"warning: Tool `{}` is not test-pass (is `{}`), \
220223
this should be fixed before beta is branched.",
221224
tool, state
222225
);
223226
}
224227
}
228+
// `publish_toolstate.py` is responsible for updating
229+
// `latest.json` and creating comments/issues warning people
230+
// if there is a regression. That all happens in a separate CI
231+
// job on the master branch once the PR has passed all tests
232+
// on the `auto` branch.
225233
}
226234
}
227235

@@ -230,7 +238,7 @@ impl Step for ToolStateCheck {
230238
}
231239

232240
if builder.config.channel == "nightly" && env::var_os("TOOLSTATE_PUBLISH").is_some() {
233-
commit_toolstate_change(&toolstates, in_beta_week);
241+
commit_toolstate_change(&toolstates);
234242
}
235243
}
236244

@@ -325,11 +333,11 @@ fn prepare_toolstate_config(token: &str) {
325333
Err(_) => false,
326334
};
327335
if !success {
328-
panic!("git config key={} value={} successful (status: {:?})", key, value, status);
336+
panic!("git config key={} value={} failed (status: {:?})", key, value, status);
329337
}
330338
}
331339

332-
// If changing anything here, then please check that src/ci/publish_toolstate.sh is up to date
340+
// If changing anything here, then please check that `src/ci/publish_toolstate.sh` is up to date
333341
// as well.
334342
git_config("user.email", "7378925+rust-toolstate-update@users.noreply.github.com");
335343
git_config("user.name", "Rust Toolstate Update");
@@ -373,14 +381,14 @@ fn read_old_toolstate() -> Vec<RepoState> {
373381
///
374382
/// * See <https://help.github.com/articles/about-commit-email-addresses/>
375383
/// if a private email by GitHub is wanted.
376-
fn commit_toolstate_change(current_toolstate: &ToolstateData, in_beta_week: bool) {
377-
let old_toolstate = read_old_toolstate();
378-
384+
fn commit_toolstate_change(current_toolstate: &ToolstateData) {
379385
let message = format!("({} CI update)", OS.expect("linux/windows only"));
380386
let mut success = false;
381387
for _ in 1..=5 {
382-
// Update the toolstate results (the new commit-to-toolstate mapping) in the toolstate repo.
383-
change_toolstate(&current_toolstate, &old_toolstate, in_beta_week);
388+
// Upload the test results (the new commit-to-toolstate mapping) to the toolstate repo.
389+
// This does *not* change the "current toolstate"; that only happens post-landing
390+
// via `src/ci/docker/publish_toolstate.sh`.
391+
publish_test_results(&current_toolstate);
384392

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

432-
fn change_toolstate(
433-
current_toolstate: &ToolstateData,
434-
old_toolstate: &[RepoState],
435-
in_beta_week: bool,
436-
) {
437-
let mut regressed = false;
438-
for repo_state in old_toolstate {
439-
let tool = &repo_state.tool;
440-
let state = repo_state.state();
441-
let new_state = current_toolstate[tool.as_str()];
442-
443-
if new_state != state {
444-
eprintln!("The state of `{}` has changed from `{}` to `{}`", tool, state, new_state);
445-
if new_state < state {
446-
if !NIGHTLY_TOOLS.iter().any(|(name, _path)| name == tool) {
447-
regressed = true;
448-
}
449-
}
450-
}
451-
}
452-
453-
if regressed && in_beta_week {
454-
std::process::exit(1);
455-
}
456-
440+
/// Updates the "history" files with the latest results.
441+
///
442+
/// These results will later be promoted to `latest.json` by the
443+
/// `publish_toolstate.py` script if the PR passes all tests and is merged to
444+
/// master.
445+
fn publish_test_results(current_toolstate: &ToolstateData) {
457446
let commit = t!(std::process::Command::new("git").arg("rev-parse").arg("HEAD").output());
458447
let commit = t!(String::from_utf8(commit.stdout));
459448

src/ci/publish_toolstate.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ GIT_COMMIT_MSG="$(git log --format=%s -n1 HEAD)"
2323
cd rust-toolstate
2424
FAILURE=1
2525
for RETRY_COUNT in 1 2 3 4 5; do
26-
# The purpose is to publish the new "current" toolstate in the toolstate repo.
26+
# The purpose of this is to publish the new "current" toolstate in the toolstate repo.
27+
# This happens post-landing, on master.
28+
# (Publishing the per-commit test results happens pre-landing in src/bootstrap/toolstate.rs).
2729
"$(ciCheckoutPath)/src/tools/publish_toolstate.py" "$GIT_COMMIT" \
2830
"$GIT_COMMIT_MSG" \
2931
"$MESSAGE_FILE" \

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ impl DepGraph {
524524
edge_list_indices.push((start, end));
525525
}
526526

527-
debug_assert!(edge_list_data.len() <= ::std::u32::MAX as usize);
527+
debug_assert!(edge_list_data.len() <= u32::MAX as usize);
528528
debug_assert_eq!(edge_list_data.len(), total_edge_count);
529529

530530
SerializedDepGraph { nodes, fingerprints, edge_list_indices, edge_list_data }

src/librustc/hir/map/blocks.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl MaybeFnLike for hir::ImplItem<'_> {
6060
impl MaybeFnLike for hir::TraitItem<'_> {
6161
fn is_fn_like(&self) -> bool {
6262
match self.kind {
63-
hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
63+
hir::TraitItemKind::Fn(_, hir::TraitMethod::Provided(_)) => true,
6464
_ => false,
6565
}
6666
}
@@ -239,7 +239,7 @@ impl<'a> FnLikeNode<'a> {
239239
_ => bug!("item FnLikeNode that is not fn-like"),
240240
},
241241
Node::TraitItem(ti) => match ti.kind {
242-
hir::TraitItemKind::Method(ref sig, hir::TraitMethod::Provided(body)) => {
242+
hir::TraitItemKind::Fn(ref sig, hir::TraitMethod::Provided(body)) => {
243243
method(ti.hir_id, ti.ident, sig, None, body, ti.span, &ti.attrs)
244244
}
245245
_ => bug!("trait method FnLikeNode that is not fn-like"),

src/librustc/hir/map/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'hir> Entry<'hir> {
5151
},
5252

5353
Node::TraitItem(ref item) => match item.kind {
54-
TraitItemKind::Method(ref sig, _) => Some(&sig.decl),
54+
TraitItemKind::Fn(ref sig, _) => Some(&sig.decl),
5555
_ => None,
5656
},
5757

@@ -77,7 +77,7 @@ impl<'hir> Entry<'hir> {
7777
},
7878

7979
Node::TraitItem(item) => match &item.kind {
80-
TraitItemKind::Method(sig, _) => Some(sig),
80+
TraitItemKind::Fn(sig, _) => Some(sig),
8181
_ => None,
8282
},
8383

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

102102
Node::TraitItem(item) => match item.kind {
103103
TraitItemKind::Const(_, Some(body))
104-
| TraitItemKind::Method(_, TraitMethod::Provided(body)) => Some(body),
104+
| TraitItemKind::Fn(_, TraitMethod::Provided(body)) => Some(body),
105105
_ => None,
106106
},
107107

@@ -326,12 +326,12 @@ impl<'hir> Map<'hir> {
326326
},
327327
Node::TraitItem(item) => match item.kind {
328328
TraitItemKind::Const(..) => DefKind::AssocConst,
329-
TraitItemKind::Method(..) => DefKind::Method,
329+
TraitItemKind::Fn(..) => DefKind::AssocFn,
330330
TraitItemKind::Type(..) => DefKind::AssocTy,
331331
},
332332
Node::ImplItem(item) => match item.kind {
333333
ImplItemKind::Const(..) => DefKind::AssocConst,
334-
ImplItemKind::Method(..) => DefKind::Method,
334+
ImplItemKind::Method(..) => DefKind::AssocFn,
335335
ImplItemKind::TyAlias(..) => DefKind::AssocTy,
336336
ImplItemKind::OpaqueTy(..) => DefKind::AssocOpaqueTy,
337337
},
@@ -472,7 +472,7 @@ impl<'hir> Map<'hir> {
472472
| Node::AnonConst(_) => BodyOwnerKind::Const,
473473
Node::Ctor(..)
474474
| Node::Item(&Item { kind: ItemKind::Fn(..), .. })
475-
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Method(..), .. })
475+
| Node::TraitItem(&TraitItem { kind: TraitItemKind::Fn(..), .. })
476476
| Node::ImplItem(&ImplItem { kind: ImplItemKind::Method(..), .. }) => BodyOwnerKind::Fn,
477477
Node::Item(&Item { kind: ItemKind::Static(_, m, _), .. }) => BodyOwnerKind::Static(m),
478478
Node::Expr(&Expr { kind: ExprKind::Closure(..), .. }) => BodyOwnerKind::Closure,
@@ -800,7 +800,7 @@ impl<'hir> Map<'hir> {
800800
_ => false,
801801
},
802802
Node::TraitItem(ti) => match ti.kind {
803-
TraitItemKind::Method(..) => true,
803+
TraitItemKind::Fn(..) => true,
804804
_ => false,
805805
},
806806
Node::ImplItem(ii) => match ii.kind {
@@ -1311,7 +1311,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId, include_id: bool) -> String {
13111311
Some(Node::TraitItem(ti)) => {
13121312
let kind = match ti.kind {
13131313
TraitItemKind::Const(..) => "assoc constant",
1314-
TraitItemKind::Method(..) => "trait method",
1314+
TraitItemKind::Fn(..) => "trait method",
13151315
TraitItemKind::Type(..) => "assoc type",
13161316
};
13171317

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub enum EvalResult {
250250
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
251251
// Check if `def_id` is a trait method.
252252
match tcx.def_kind(def_id) {
253-
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
253+
Some(DefKind::AssocFn) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
254254
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
255255
// Trait methods do not declare visibility (even
256256
// for visibility info in cstore). Use containing

src/librustc/mir/interpret/allocation.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ impl UndefMask {
818818
// First set all bits except the first `bita`,
819819
// then unset the last `64 - bitb` bits.
820820
let range = if bitb == 0 {
821-
u64::max_value() << bita
821+
u64::MAX << bita
822822
} else {
823-
(u64::max_value() << bita) & (u64::max_value() >> (64 - bitb))
823+
(u64::MAX << bita) & (u64::MAX >> (64 - bitb))
824824
};
825825
if new_state {
826826
self.blocks[blocka] |= range;
@@ -832,21 +832,21 @@ impl UndefMask {
832832
// across block boundaries
833833
if new_state {
834834
// Set `bita..64` to `1`.
835-
self.blocks[blocka] |= u64::max_value() << bita;
835+
self.blocks[blocka] |= u64::MAX << bita;
836836
// Set `0..bitb` to `1`.
837837
if bitb != 0 {
838-
self.blocks[blockb] |= u64::max_value() >> (64 - bitb);
838+
self.blocks[blockb] |= u64::MAX >> (64 - bitb);
839839
}
840840
// Fill in all the other blocks (much faster than one bit at a time).
841841
for block in (blocka + 1)..blockb {
842-
self.blocks[block] = u64::max_value();
842+
self.blocks[block] = u64::MAX;
843843
}
844844
} else {
845845
// Set `bita..64` to `0`.
846-
self.blocks[blocka] &= !(u64::max_value() << bita);
846+
self.blocks[blocka] &= !(u64::MAX << bita);
847847
// Set `0..bitb` to `0`.
848848
if bitb != 0 {
849-
self.blocks[blockb] &= !(u64::max_value() >> (64 - bitb));
849+
self.blocks[blockb] &= !(u64::MAX >> (64 - bitb));
850850
}
851851
// Fill in all the other blocks (much faster than one bit at a time).
852852
for block in (blocka + 1)..blockb {

src/librustc/mir/interpret/pointer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ pub trait PointerArithmetic: layout::HasDataLayout {
7878
fn overflowing_signed_offset(&self, val: u64, i: i128) -> (u64, bool) {
7979
// FIXME: is it possible to over/underflow here?
8080
if i < 0 {
81-
// Trickery to ensure that `i64::min_value()` works fine: compute `n = -i`.
81+
// Trickery to ensure that `i64::MIN` works fine: compute `n = -i`.
8282
// This formula only works for true negative values; it overflows for zero!
83-
let n = u64::max_value() - (i as u64) + 1;
83+
let n = u64::MAX - (i as u64) + 1;
8484
let res = val.overflowing_sub(n);
8585
self.truncate_to_ptr(res)
8686
} else {

src/librustc/query/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ rustc_queries! {
650650
Codegen {
651651
query codegen_fulfill_obligation(
652652
key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)
653-
) -> Vtable<'tcx, ()> {
653+
) -> Option<Vtable<'tcx, ()>> {
654654
no_force
655655
cache_on_disk_if { true }
656656
desc { |tcx|

src/librustc/traits/structural_impls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,9 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
415415
super::ReferenceOutlivesReferent(ty) => {
416416
tcx.lift(&ty).map(super::ReferenceOutlivesReferent)
417417
}
418-
super::ObjectTypeBound(ty, r) => tcx
419-
.lift(&ty)
420-
.and_then(|ty| tcx.lift(&r).and_then(|r| Some(super::ObjectTypeBound(ty, r)))),
418+
super::ObjectTypeBound(ty, r) => {
419+
tcx.lift(&ty).and_then(|ty| tcx.lift(&r).map(|r| super::ObjectTypeBound(ty, r)))
420+
}
421421
super::ObjectCastObligation(ty) => tcx.lift(&ty).map(super::ObjectCastObligation),
422422
super::Coercion { source, target } => {
423423
Some(super::Coercion { source: tcx.lift(&source)?, target: tcx.lift(&target)? })

src/librustc/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl<'tcx> TypeckTables<'tcx> {
611611
}
612612

613613
match self.type_dependent_defs().get(expr.hir_id) {
614-
Some(Ok((DefKind::Method, _))) => true,
614+
Some(Ok((DefKind::AssocFn, _))) => true,
615615
_ => false,
616616
}
617617
}

src/librustc/ty/layout.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use rustc_span::DUMMY_SP;
77

88
use std::cmp;
99
use std::fmt;
10-
use std::i128;
1110
use std::iter;
1211
use std::mem;
1312
use std::ops::Bound;
@@ -1001,7 +1000,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
10011000
}
10021001
}
10031002

1004-
let (mut min, mut max) = (i128::max_value(), i128::min_value());
1003+
let (mut min, mut max) = (i128::MAX, i128::MIN);
10051004
let discr_type = def.repr.discr_type();
10061005
let bits = Integer::from_attr(self, discr_type).size().bits();
10071006
for (i, discr) in def.discriminants(tcx) {
@@ -1021,7 +1020,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
10211020
}
10221021
}
10231022
// We might have no inhabited variants, so pretend there's at least one.
1024-
if (min, max) == (i128::max_value(), i128::min_value()) {
1023+
if (min, max) == (i128::MAX, i128::MIN) {
10251024
min = 0;
10261025
max = 0;
10271026
}

src/librustc/ty/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl AssocItem {
230230
pub fn def_kind(&self) -> DefKind {
231231
match self.kind {
232232
AssocKind::Const => DefKind::AssocConst,
233-
AssocKind::Method => DefKind::Method,
233+
AssocKind::Method => DefKind::AssocFn,
234234
AssocKind::Type => DefKind::AssocTy,
235235
AssocKind::OpaqueTy => DefKind::AssocOpaqueTy,
236236
}
@@ -2872,7 +2872,7 @@ impl<'tcx> TyCtxt<'tcx> {
28722872
}
28732873
} else {
28742874
match self.def_kind(def_id).expect("no def for `DefId`") {
2875-
DefKind::AssocConst | DefKind::Method | DefKind::AssocTy => true,
2875+
DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy => true,
28762876
_ => false,
28772877
}
28782878
};
@@ -3051,7 +3051,7 @@ impl<'tcx> TyCtxt<'tcx> {
30513051
/// `DefId` of the impl that the method belongs to; otherwise, returns `None`.
30523052
pub fn impl_of_method(self, def_id: DefId) -> Option<DefId> {
30533053
let item = if def_id.krate != LOCAL_CRATE {
3054-
if let Some(DefKind::Method) = self.def_kind(def_id) {
3054+
if let Some(DefKind::AssocFn) = self.def_kind(def_id) {
30553055
Some(self.associated_item(def_id))
30563056
} else {
30573057
None

src/librustc/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ pub trait PrettyPrinter<'tcx>:
920920
}
921921
(ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Uint(ui)) => {
922922
let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size();
923-
let max = truncate(u128::max_value(), bit_size);
923+
let max = truncate(u128::MAX, bit_size);
924924

925925
let ui_str = ui.name_str();
926926
if data == max {

src/librustc/ty/query/on_disk_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ struct AbsoluteBytePos(u32);
9292

9393
impl AbsoluteBytePos {
9494
fn new(pos: usize) -> AbsoluteBytePos {
95-
debug_assert!(pos <= ::std::u32::MAX as usize);
95+
debug_assert!(pos <= u32::MAX as usize);
9696
AbsoluteBytePos(pos as u32)
9797
}
9898

0 commit comments

Comments
 (0)