Skip to content

Commit c234b83

Browse files
committed
Auto merge of #135848 - matthiaskrgr:rollup-sftciqm, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #132232 (CI: build FreeBSD artifacts on FreeBSD 13.4) - #135706 (Move `supertrait_def_ids` into the elaborate module like all other fns) - #135750 (Add an example of using `carrying_mul_add` to write wider multiplication) - #135793 (Ignore `mermaid.min.js`) - #135810 (Add Kobzol on vacation) - #135821 (fix OsString::from_encoded_bytes_unchecked description) - #135824 (tests: delete `cat-and-grep-sanity-check`) - #135833 (Add fixme and test for issue #135289) Failed merges: - #135816 (Use `structurally_normalize` instead of manual `normalizes-to` goals in alias relate errors) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a24bdc6 + a7408c4 commit c234b83

File tree

23 files changed

+107
-90
lines changed

23 files changed

+107
-90
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ __pycache__/
8383
node_modules
8484
package-lock.json
8585
package.json
86+
/src/doc/rustc-dev-guide/mermaid.min.js
8687

8788
## Rustdoc GUI tests
8889
tests/rustdoc-gui/src/**.lock

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ use rustc_trait_selection::error_reporting::traits::FindExprBySpan;
3939
use rustc_trait_selection::error_reporting::traits::call_kind::CallKind;
4040
use rustc_trait_selection::infer::InferCtxtExt;
4141
use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt as _;
42-
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
42+
use rustc_trait_selection::traits::{
43+
Obligation, ObligationCause, ObligationCtxt, supertrait_def_ids,
44+
};
4345
use tracing::{debug, instrument};
4446

4547
use super::explain_borrow::{BorrowExplanation, LaterUseKind};
@@ -658,8 +660,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
658660
clause.as_trait_clause().is_some_and(|tc| {
659661
tc.self_ty().skip_binder().is_param(param.index)
660662
&& tc.polarity() == ty::PredicatePolarity::Positive
661-
&& tcx
662-
.supertrait_def_ids(tc.def_id())
663+
&& supertrait_def_ids(tcx, tc.def_id())
663664
.flat_map(|trait_did| tcx.associated_items(trait_did).in_definition_order())
664665
.any(|item| item.fn_has_self_parameter)
665666
})

compiler/rustc_hir_analysis/src/coherence/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_middle::query::Providers;
1313
use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt};
1414
use rustc_session::parse::feature_err;
1515
use rustc_span::{ErrorGuaranteed, sym};
16+
use rustc_type_ir::elaborate;
1617
use tracing::debug;
1718

1819
use crate::errors;
@@ -205,7 +206,7 @@ fn check_object_overlap<'tcx>(
205206
// With the feature enabled, the trait is not implemented automatically,
206207
// so this is valid.
207208
} else {
208-
let mut supertrait_def_ids = tcx.supertrait_def_ids(component_def_id);
209+
let mut supertrait_def_ids = elaborate::supertrait_def_ids(tcx, component_def_id);
209210
if supertrait_def_ids
210211
.any(|d| d == trait_def_id && tcx.trait_def(d).implement_via_object)
211212
{

compiler/rustc_hir_typeck/src/cast.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use rustc_session::lint;
4545
use rustc_span::def_id::LOCAL_CRATE;
4646
use rustc_span::{DUMMY_SP, Span, sym};
4747
use rustc_trait_selection::infer::InferCtxtExt;
48+
use rustc_type_ir::elaborate;
4849
use tracing::{debug, instrument};
4950

5051
use super::FnCtxt;
@@ -923,7 +924,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
923924
let src_auto: FxHashSet<_> = src_tty
924925
.auto_traits()
925926
.chain(
926-
tcx.supertrait_def_ids(src_principal.def_id())
927+
elaborate::supertrait_def_ids(tcx, src_principal.def_id())
927928
.filter(|def_id| tcx.trait_is_auto(*def_id)),
928929
)
929930
.collect();

compiler/rustc_middle/src/ty/context.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ use rustc_type_ir::TyKind::*;
5252
use rustc_type_ir::fold::TypeFoldable;
5353
use rustc_type_ir::lang_items::TraitSolverLangItem;
5454
pub use rustc_type_ir::lift::Lift;
55-
use rustc_type_ir::{CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo, search_graph};
55+
use rustc_type_ir::{
56+
CollectAndApply, Interner, TypeFlags, WithCachedTypeInfo, elaborate, search_graph,
57+
};
5658
use tracing::{debug, instrument};
5759

5860
use crate::arena::Arena;
@@ -2558,7 +2560,7 @@ impl<'tcx> TyCtxt<'tcx> {
25582560
/// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name`
25592561
/// returns true if the `trait_def_id` defines an associated item of name `assoc_name`.
25602562
pub fn trait_may_define_assoc_item(self, trait_def_id: DefId, assoc_name: Ident) -> bool {
2561-
self.supertrait_def_ids(trait_def_id).any(|trait_did| {
2563+
elaborate::supertrait_def_ids(self, trait_def_id).any(|trait_did| {
25622564
self.associated_items(trait_did)
25632565
.filter_by_name_unhygienic(assoc_name.name)
25642566
.any(|item| self.hygienic_eq(assoc_name, item.ident(self), trait_did))
@@ -2579,14 +2581,6 @@ impl<'tcx> TyCtxt<'tcx> {
25792581
})
25802582
}
25812583

2582-
/// Computes the def-ids of the transitive supertraits of `trait_def_id`. This (intentionally)
2583-
/// does not compute the full elaborated super-predicates but just the set of def-ids. It is used
2584-
/// to identify which traits may define a given associated type to help avoid cycle errors,
2585-
/// and to make size estimates for vtable layout computation.
2586-
pub fn supertrait_def_ids(self, trait_def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
2587-
rustc_type_ir::elaborate::supertrait_def_ids(self, trait_def_id)
2588-
}
2589-
25902584
/// Given a closure signature, returns an equivalent fn signature. Detuples
25912585
/// and so forth -- so e.g., if we have a sig with `Fn<(u32, i32)>` then
25922586
/// you would get a `fn(u32, i32)`.

compiler/rustc_middle/src/ty/vtable.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::fmt;
22

33
use rustc_ast::Mutability;
44
use rustc_macros::HashStable;
5+
use rustc_type_ir::elaborate;
56

67
use crate::mir::interpret::{AllocId, Allocation, CTFE_ALLOC_SALT, Pointer, Scalar, alloc_range};
78
use crate::ty::{self, Instance, PolyTraitRef, Ty, TyCtxt};
@@ -64,7 +65,7 @@ pub(crate) fn vtable_min_entries<'tcx>(
6465
};
6566

6667
// This includes self in supertraits.
67-
for def_id in tcx.supertrait_def_ids(trait_ref.def_id()) {
68+
for def_id in elaborate::supertrait_def_ids(tcx, trait_ref.def_id()) {
6869
count += tcx.own_existential_vtable_entries(def_id).len();
6970
}
7071

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,12 @@ fn find_fallback_pattern_typo<'tcx>(
10861086
let vis = cx.tcx.visibility(item.owner_id);
10871087
if vis.is_accessible_from(parent, cx.tcx) {
10881088
accessible.push(item_name);
1089+
// FIXME: the line below from PR #135310 is a workaround for the ICE in issue
1090+
// #135289, where a macro in a dependency can create unreachable patterns in the
1091+
// current crate. Path trimming expects diagnostics for a typoed const, but no
1092+
// diagnostics are emitted and we ICE. See
1093+
// `tests/ui/resolve/const-with-typo-in-pattern-binding-ice-135289.rs` for a
1094+
// test that reproduces the ICE if we don't use `with_no_trimmed_paths!`.
10891095
let path = with_no_trimmed_paths!(cx.tcx.def_path_str(item.owner_id));
10901096
accessible_path.push(path);
10911097
} else if name == item_name {

compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use rustc_middle::ty::{
1919
TypeVisitableExt, TypeVisitor, TypingMode, Upcast,
2020
};
2121
use rustc_span::Span;
22+
use rustc_type_ir::elaborate;
2223
use smallvec::SmallVec;
2324
use tracing::{debug, instrument};
2425

@@ -39,7 +40,7 @@ pub fn hir_ty_lowering_dyn_compatibility_violations(
3940
trait_def_id: DefId,
4041
) -> Vec<DynCompatibilityViolation> {
4142
debug_assert!(tcx.generics_of(trait_def_id).has_self);
42-
tcx.supertrait_def_ids(trait_def_id)
43+
elaborate::supertrait_def_ids(tcx, trait_def_id)
4344
.map(|def_id| predicates_reference_self(tcx, def_id, true))
4445
.filter(|spans| !spans.is_empty())
4546
.map(DynCompatibilityViolation::SupertraitSelf)
@@ -54,7 +55,7 @@ fn dyn_compatibility_violations(
5455
debug!("dyn_compatibility_violations: {:?}", trait_def_id);
5556

5657
tcx.arena.alloc_from_iter(
57-
tcx.supertrait_def_ids(trait_def_id)
58+
elaborate::supertrait_def_ids(tcx, trait_def_id)
5859
.flat_map(|def_id| dyn_compatibility_violations_for_trait(tcx, def_id)),
5960
)
6061
}

compiler/rustc_trait_selection/src/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub use self::specialize::{
6767
pub use self::structural_normalize::StructurallyNormalizeExt;
6868
pub use self::util::{
6969
BoundVarReplacer, PlaceholderReplacer, elaborate, expand_trait_aliases, impl_item_is_final,
70-
supertraits, transitive_bounds_that_define_assoc_item, upcast_choices,
70+
supertrait_def_ids, supertraits, transitive_bounds_that_define_assoc_item, upcast_choices,
7171
with_replaced_escaping_bound_vars,
7272
};
7373
use crate::error_reporting::InferCtxtErrorExt;

compiler/rustc_trait_selection/src/traits/project.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_middle::ty::visit::TypeVisitableExt;
1818
use rustc_middle::ty::{self, Term, Ty, TyCtxt, TypingMode, Upcast};
1919
use rustc_middle::{bug, span_bug};
2020
use rustc_span::sym;
21+
use rustc_type_ir::elaborate;
2122
use thin_vec::thin_vec;
2223
use tracing::{debug, instrument};
2324

@@ -836,8 +837,7 @@ fn assemble_candidates_from_object_ty<'cx, 'tcx>(
836837
if tcx.is_impl_trait_in_trait(obligation.predicate.def_id)
837838
&& let Some(out_trait_def_id) = data.principal_def_id()
838839
&& let rpitit_trait_def_id = tcx.parent(obligation.predicate.def_id)
839-
&& tcx
840-
.supertrait_def_ids(out_trait_def_id)
840+
&& elaborate::supertrait_def_ids(tcx, out_trait_def_id)
841841
.any(|trait_def_id| trait_def_id == rpitit_trait_def_id)
842842
{
843843
candidate_set.push_candidate(ProjectionCandidate::ObjectRpitit);

compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_infer::traits::{
1818
use rustc_middle::ty::fast_reject::DeepRejectCtxt;
1919
use rustc_middle::ty::{self, Ty, TypeVisitableExt, TypingMode};
2020
use rustc_middle::{bug, span_bug};
21-
use rustc_type_ir::Interner;
21+
use rustc_type_ir::{Interner, elaborate};
2222
use tracing::{debug, instrument, trace};
2323

2424
use super::SelectionCandidate::*;
@@ -1003,8 +1003,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
10031003
let a_auto_traits: FxIndexSet<DefId> = a_data
10041004
.auto_traits()
10051005
.chain(principal_def_id_a.into_iter().flat_map(|principal_def_id| {
1006-
self.tcx()
1007-
.supertrait_def_ids(principal_def_id)
1006+
elaborate::supertrait_def_ids(self.tcx(), principal_def_id)
10081007
.filter(|def_id| self.tcx().trait_is_auto(*def_id))
10091008
}))
10101009
.collect();

compiler/rustc_trait_selection/src/traits/select/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use rustc_middle::ty::{
3232
TypingMode, Upcast,
3333
};
3434
use rustc_span::{Symbol, sym};
35+
use rustc_type_ir::elaborate;
3536
use tracing::{debug, instrument, trace};
3637

3738
use self::EvaluationResult::*;
@@ -2531,7 +2532,8 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
25312532
let a_auto_traits: FxIndexSet<DefId> = a_data
25322533
.auto_traits()
25332534
.chain(a_data.principal_def_id().into_iter().flat_map(|principal_def_id| {
2534-
tcx.supertrait_def_ids(principal_def_id).filter(|def_id| tcx.trait_is_auto(*def_id))
2535+
elaborate::supertrait_def_ids(tcx, principal_def_id)
2536+
.filter(|def_id| tcx.trait_is_auto(*def_id))
25352537
}))
25362538
.collect();
25372539

library/core/src/num/uint_macros.rs

+31-2
Original file line numberDiff line numberDiff line change
@@ -2663,8 +2663,8 @@ macro_rules! uint_impl {
26632663
///
26642664
/// Basic usage:
26652665
///
2666-
/// Please note that this example is shared between integer types.
2667-
/// Which explains why `u32` is used here.
2666+
/// Please note that this example is shared between integer types,
2667+
/// which explains why `u32` is used here.
26682668
///
26692669
/// ```
26702670
/// #![feature(bigint_helper_methods)]
@@ -2677,6 +2677,35 @@ macro_rules! uint_impl {
26772677
"(", stringify!($SelfT), "::MAX, ", stringify!($SelfT), "::MAX));"
26782678
)]
26792679
/// ```
2680+
///
2681+
/// This is the core per-digit operation for "grade school" O(n²) multiplication.
2682+
///
2683+
/// Please note that this example is shared between integer types,
2684+
/// using `u8` for simplicity of the demonstration.
2685+
///
2686+
/// ```
2687+
/// #![feature(bigint_helper_methods)]
2688+
///
2689+
/// fn quadratic_mul<const N: usize>(a: [u8; N], b: [u8; N]) -> [u8; N] {
2690+
/// let mut out = [0; N];
2691+
/// for j in 0..N {
2692+
/// let mut carry = 0;
2693+
/// for i in 0..(N - j) {
2694+
/// (out[j + i], carry) = u8::carrying_mul_add(a[i], b[j], out[j + i], carry);
2695+
/// }
2696+
/// }
2697+
/// out
2698+
/// }
2699+
///
2700+
/// // -1 * -1 == 1
2701+
/// assert_eq!(quadratic_mul([0xFF; 3], [0xFF; 3]), [1, 0, 0]);
2702+
///
2703+
/// assert_eq!(u32::wrapping_mul(0x9e3779b9, 0x7f4a7c15), 0xCFFC982D);
2704+
/// assert_eq!(
2705+
/// quadratic_mul(u32::to_le_bytes(0x9e3779b9), u32::to_le_bytes(0x7f4a7c15)),
2706+
/// u32::to_le_bytes(0xCFFC982D)
2707+
/// );
2708+
/// ```
26802709
#[unstable(feature = "bigint_helper_methods", issue = "85532")]
26812710
#[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")]
26822711
#[must_use = "this returns the result of the operation, \

library/std/src/ffi/os_str.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ impl OsString {
203203
self
204204
}
205205

206-
/// Converts the `OsString` into a byte slice. To convert the byte slice back into an
207-
/// `OsString`, use the [`OsStr::from_encoded_bytes_unchecked`] function.
206+
/// Converts the `OsString` into a byte vector. To convert the byte vector back into an
207+
/// `OsString`, use the [`OsString::from_encoded_bytes_unchecked`] function.
208208
///
209209
/// The byte encoding is an unspecified, platform-specific, self-synchronizing superset of UTF-8.
210210
/// By being a self-synchronizing superset of UTF-8, this encoding is also a superset of 7-bit

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ ENV \
5656
CFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \
5757
CXX_x86_64_fortanix_unknown_sgx=clang++-11 \
5858
CXXFLAGS_x86_64_fortanix_unknown_sgx="-D__ELF__ -isystem/usr/include/x86_64-linux-gnu -mlvi-hardening -mllvm -x86-experimental-lvi-inline-asm-hardening" \
59-
AR_i686_unknown_freebsd=i686-unknown-freebsd12-ar \
60-
CC_i686_unknown_freebsd=i686-unknown-freebsd12-clang \
61-
CXX_i686_unknown_freebsd=i686-unknown-freebsd12-clang++ \
59+
AR_i686_unknown_freebsd=i686-unknown-freebsd13-ar \
60+
CC_i686_unknown_freebsd=i686-unknown-freebsd13-clang \
61+
CXX_i686_unknown_freebsd=i686-unknown-freebsd13-clang++ \
6262
CC_aarch64_unknown_uefi=clang-11 \
6363
CXX_aarch64_unknown_uefi=clang++-11 \
6464
CC_i686_unknown_uefi=clang-11 \

src/ci/docker/host-x86_64/dist-x86_64-freebsd/Dockerfile

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ COPY scripts/cmake.sh /scripts/
2929
RUN /scripts/cmake.sh
3030

3131
ENV \
32-
AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-ar \
33-
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-clang \
34-
CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd12-clang++
32+
AR_x86_64_unknown_freebsd=x86_64-unknown-freebsd13-ar \
33+
CC_x86_64_unknown_freebsd=x86_64-unknown-freebsd13-clang \
34+
CXX_x86_64_unknown_freebsd=x86_64-unknown-freebsd13-clang++
3535

3636
ENV HOSTS=x86_64-unknown-freebsd
3737

src/ci/docker/scripts/freebsd-toolchain.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -eux
55

66
arch=$1
77
binutils_version=2.40
8-
freebsd_version=12.3
9-
triple=$arch-unknown-freebsd12
8+
freebsd_version=13.4
9+
triple=$arch-unknown-freebsd13
1010
sysroot=/usr/local/$triple
1111

1212
hide_output() {
@@ -59,7 +59,7 @@ done
5959

6060
# Originally downloaded from:
6161
# URL=https://download.freebsd.org/ftp/releases/${freebsd_arch}/${freebsd_version}-RELEASE/base.txz
62-
URL=https://ci-mirrors.rust-lang.org/rustc/2022-05-06-freebsd-${freebsd_version}-${freebsd_arch}-base.txz
62+
URL=https://ci-mirrors.rust-lang.org/rustc/2024-09-13-freebsd-${freebsd_version}-${freebsd_arch}-base.txz
6363
curl "$URL" | tar xJf - -C "$sysroot" --wildcards "${files_to_extract[@]}"
6464

6565
# Clang can do cross-builds out of the box, if we give it the right

src/tools/clippy/clippy_lints/src/len_zero.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_session::declare_lint_pass;
1818
use rustc_span::source_map::Spanned;
1919
use rustc_span::symbol::sym;
2020
use rustc_span::{Span, Symbol};
21+
use rustc_trait_selection::traits::supertrait_def_ids;
2122

2223
declare_clippy_lint! {
2324
/// ### What it does
@@ -270,7 +271,7 @@ fn check_trait_items(cx: &LateContext<'_>, visited_trait: &Item<'_>, trait_items
270271
// fill the set with current and super traits
271272
fn fill_trait_set(traitt: DefId, set: &mut DefIdSet, cx: &LateContext<'_>) {
272273
if set.insert(traitt) {
273-
for supertrait in cx.tcx.supertrait_def_ids(traitt) {
274+
for supertrait in supertrait_def_ids(cx.tcx, traitt) {
274275
fill_trait_set(supertrait, set, cx);
275276
}
276277
}

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
run-make/cat-and-grep-sanity-check/Makefile
21
run-make/jobserver-error/Makefile
32
run-make/split-debuginfo/Makefile
43
run-make/symbol-mangling-hashed/Makefile

tests/run-make/cat-and-grep-sanity-check/Makefile

-50
This file was deleted.

0 commit comments

Comments
 (0)