Skip to content

Commit d4ae855

Browse files
committed
Auto merge of #147220 - Zalathar:rollup-fubv0wy, r=Zalathar
Rollup of 11 pull requests Successful merges: - #146918 (add regression test) - #146980 (simplify setup_constraining_predicates, and note it is potentially cubic) - #147170 (compiletest: Pass around `DirectiveLine` instead of bare strings) - #147180 (add tests) - #147188 (Remove usage of `compiletest-use-stage0-libtest` from CI) - #147189 (Replace `rustc_span::Span` with a stripped down version for librustdoc's highlighter) - #147199 (remove outdated comment in (inner) `InferCtxt`) - #147200 (Fix autodiff empty ret regression) - #147209 (Remove `no-remap-src-base` from tests) - #147213 (Fix broken STD build for ESP-IDF) - #147217 (Don't create a top-level `true` directory when running UI tests) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1e1a394 + de20efd commit d4ae855

File tree

43 files changed

+420
-268
lines changed

Some content is hidden

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

43 files changed

+420
-268
lines changed

bootstrap.example.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,6 @@
476476
# when the stage 0 compiler is actually built from in-tree sources.
477477
#build.compiletest-allow-stage0 = false
478478

479-
# Whether to use the precompiled stage0 libtest with compiletest.
480-
#build.compiletest-use-stage0-libtest = true
481-
482479
# Default value for the `--extra-checks` flag of tidy.
483480
#
484481
# See `./x test tidy --help` for details.

compiler/rustc_codegen_llvm/src/builder/autodiff.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,5 +378,12 @@ pub(crate) fn generate_enzyme_call<'ll, 'tcx>(
378378

379379
let call = builder.call(enzyme_ty, None, None, ad_fn, &args, None, None);
380380

381-
builder.store_to_place(call, dest.val);
381+
let fn_ret_ty = builder.cx.val_ty(call);
382+
if fn_ret_ty != builder.cx.type_void() && fn_ret_ty != builder.cx.type_struct(&[], false) {
383+
// If we return void or an empty struct, then our caller (due to how we generated it)
384+
// does not expect a return value. As such, we have no pointer (or place) into which
385+
// we could store our value, and would store into an undef, which would cause UB.
386+
// As such, we just ignore the return value in those cases.
387+
builder.store_to_place(call, dest.val);
388+
}
382389
}

compiler/rustc_hir_analysis/src/constrained_generic_params.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,20 @@ pub(crate) fn setup_constraining_predicates<'tcx>(
167167
// which is `O(nt)` where `t` is the depth of type-parameter constraints,
168168
// remembering that `t` should be less than 7 in practice.
169169
//
170+
// FIXME(hkBst): the big-O bound above would be accurate for the number
171+
// of calls to `parameters_for`, which itself is some O(complexity of type).
172+
// That would make this potentially cubic instead of merely quadratic...
173+
// ...unless we cache those `parameters_for` calls.
174+
//
170175
// Basically, I iterate over all projections and swap every
171176
// "ready" projection to the start of the list, such that
172177
// all of the projections before `i` are topologically sorted
173178
// and constrain all the parameters in `input_parameters`.
174179
//
175-
// In the example, `input_parameters` starts by containing `U` - which
176-
// is constrained by the trait-ref - and so on the first pass we
180+
// In the first example, `input_parameters` starts by containing `U`,
181+
// which is constrained by the self type `U`. Then, on the first pass we
177182
// observe that `<U as Iterator>::Item = T` is a "ready" projection that
178-
// constrains `T` and swap it to front. As it is the sole projection,
183+
// constrains `T` and swap it to the front. As it is the sole projection,
179184
// no more swaps can take place afterwards, with the result being
180185
// * <U as Iterator>::Item = T
181186
// * T: Debug
@@ -193,33 +198,25 @@ pub(crate) fn setup_constraining_predicates<'tcx>(
193198
for j in i..predicates.len() {
194199
// Note that we don't have to care about binders here,
195200
// as the impl trait ref never contains any late-bound regions.
196-
if let ty::ClauseKind::Projection(projection) = predicates[j].0.kind().skip_binder() {
197-
// Special case: watch out for some kind of sneaky attempt
198-
// to project out an associated type defined by this very
199-
// trait.
200-
let unbound_trait_ref = projection.projection_term.trait_ref(tcx);
201-
if Some(unbound_trait_ref) == impl_trait_ref {
202-
continue;
203-
}
204-
205-
// A projection depends on its input types and determines its output
206-
// type. For example, if we have
207-
// `<<T as Bar>::Baz as Iterator>::Output = <U as Iterator>::Output`
208-
// Then the projection only applies if `T` is known, but it still
209-
// does not determine `U`.
210-
let inputs = parameters_for(tcx, projection.projection_term, true);
211-
let relies_only_on_inputs = inputs.iter().all(|p| input_parameters.contains(p));
212-
if !relies_only_on_inputs {
213-
continue;
214-
}
201+
if let ty::ClauseKind::Projection(projection) = predicates[j].0.kind().skip_binder() &&
202+
203+
// Special case: watch out for some kind of sneaky attempt to
204+
// project out an associated type defined by this very trait.
205+
!impl_trait_ref.is_some_and(|t| t == projection.projection_term.trait_ref(tcx)) &&
206+
207+
// A projection depends on its input types and determines its output
208+
// type. For example, if we have
209+
// `<<T as Bar>::Baz as Iterator>::Output = <U as Iterator>::Output`
210+
// then the projection only applies if `T` is known, but it still
211+
// does not determine `U`.
212+
parameters_for(tcx, projection.projection_term, true).iter().all(|p| input_parameters.contains(p))
213+
{
215214
input_parameters.extend(parameters_for(tcx, projection.term, false));
216-
} else {
217-
continue;
215+
216+
predicates.swap(i, j);
217+
i += 1;
218+
changed = true;
218219
}
219-
// fancy control flow to bypass borrow checker
220-
predicates.swap(i, j);
221-
i += 1;
222-
changed = true;
223220
}
224221
debug!(
225222
"setup_constraining_predicates: predicates={:?} \

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,6 @@ pub struct InferCtxtInner<'tcx> {
131131
/// `$0: 'static`. This will get checked later by regionck. (We
132132
/// can't generally check these things right away because we have
133133
/// to wait until types are resolved.)
134-
///
135-
/// These are stored in a map keyed to the id of the innermost
136-
/// enclosing fn body / static initializer expression. This is
137-
/// because the location where the obligation was incurred can be
138-
/// relevant with respect to which sublifetime assumptions are in
139-
/// place. The reason that we store under the fn-id, and not
140-
/// something more fine-grained, is so that it is easier for
141-
/// regionck to be sure that it has found *all* the region
142-
/// obligations (otherwise, it's easy to fail to walk to a
143-
/// particular node-id).
144-
///
145-
/// Before running `resolve_regions_and_report_errors`, the creator
146-
/// of the inference context is expected to invoke
147-
/// [`InferCtxt::process_registered_region_obligations`]
148-
/// for each body-id in this map, which will process the
149-
/// obligations within. This is expected to be done 'late enough'
150-
/// that all type inference variables have been bound and so forth.
151134
region_obligations: Vec<TypeOutlivesConstraint<'tcx>>,
152135

153136
/// The outlives bounds that we assume must hold about placeholders that

compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,10 @@ where
473473
// fails to reach a fixpoint but ends up getting an error after
474474
// running for some additional step.
475475
//
476-
// cc trait-system-refactor-initiative#105
476+
// FIXME(@lcnr): While I believe an error here to be possible, we
477+
// currently don't have any test which actually triggers it. @lqd
478+
// created a minimization for an ICE in typenum, but that one no
479+
// longer fails here. cc trait-system-refactor-initiative#105.
477480
let source = CandidateSource::BuiltinImpl(BuiltinImplSource::Misc);
478481
let certainty = Certainty::Maybe { cause, opaque_types_jank: OpaqueTypesJank::AllGood };
479482
self.probe_trait_candidate(source)

compiler/rustc_trait_selection/src/regions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ impl<'tcx> InferCtxt<'tcx> {
7777
///
7878
/// Prefer this method over `resolve_regions_with_normalize`, unless you are
7979
/// doing something specific for normalization.
80+
///
81+
/// This function assumes that all infer variables are already constrained.
8082
fn resolve_regions(
8183
&self,
8284
body_id: LocalDefId,

library/std/src/sys/net/hostname/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cfg_select! {
2-
target_family = "unix" => {
2+
all(target_family = "unix", not(target_os = "espidf")) => {
33
mod unix;
44
pub use unix::hostname;
55
}

src/bootstrap/defaults/bootstrap.dist.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ test-stage = 2
77
doc-stage = 2
88
# When compiling from source, you usually want all tools.
99
extended = true
10-
# Use libtest built from the source tree instead of the precompiled one from stage 0.
11-
compiletest-use-stage0-libtest = false
1210

1311
# Most users installing from source want to build all parts of the project from source.
1412
[llvm]

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ impl<'a> Builder<'a> {
11451145
test::RunMakeCargo,
11461146
),
11471147
Kind::Miri => describe!(test::Crate),
1148-
Kind::Bench => describe!(test::Crate, test::CrateLibrustc),
1148+
Kind::Bench => describe!(test::Crate, test::CrateLibrustc, test::CrateRustdoc),
11491149
Kind::Doc => describe!(
11501150
doc::UnstableBook,
11511151
doc::UnstableBookGen,

src/ci/citool/tests/test-jobs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ runners:
2727
<<: *base-job
2828
envs:
2929
env-x86_64-apple-tests: &env-x86_64-apple-tests
30-
SCRIPT: ./x.py check compiletest --set build.compiletest-use-stage0-libtest=true && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
30+
SCRIPT: ./x.py check compiletest && ./x.py --stage 2 test --skip tests/ui --skip tests/rustdoc -- --exact
3131
RUST_CONFIGURE_ARGS: --build=x86_64-apple-darwin --enable-sanitizers --enable-profiler --set rust.jemalloc
3232
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
3333
# Ensure that host tooling is tested on our minimum supported macOS version.

0 commit comments

Comments
 (0)