mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Auto merge of #153770 - JonathanBrouwer:rollup-522Yrag, r=JonathanBrouwer
Rollup of 10 pull requests Successful merges: - rust-lang/rust#153726 (Add optional CI job to build the compiler with the parallel frontend) - rust-lang/rust#153763 (Don't add empty target features for target-cpu=native on macOS) - rust-lang/rust#153432 (Fix some comments about dataflow analysis.) - rust-lang/rust#153529 (Fix LegacyKeyValueFormat report from docker build: pr) - rust-lang/rust#153694 (fix(query): Pass Query Key to `value_from_cycle_error`) - rust-lang/rust#153717 (unused_macro_rules switched used and unused comments) - rust-lang/rust#153736 (add test that an incomplete feature emits a warning) - rust-lang/rust#153748 (editorconfig: css uses tabs) - rust-lang/rust#153750 (rustc-dev-guide subtree update) - rust-lang/rust#153762 (actually make the is-fn test test what it says it tests)
This commit is contained in:
@@ -12,6 +12,9 @@ trim_trailing_whitespace = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.css]
|
||||
indent_style = tab
|
||||
|
||||
# some tests need trailing whitespace in output snapshots
|
||||
[tests/**]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
@@ -702,7 +702,9 @@ pub(crate) fn global_llvm_features(sess: &Session, only_base_features: bool) ->
|
||||
|
||||
features_string
|
||||
};
|
||||
features.extend(features_string.split(',').map(String::from));
|
||||
if !features_string.is_empty() {
|
||||
features.extend(features_string.split(',').map(String::from));
|
||||
}
|
||||
}
|
||||
Some(_) | None => {}
|
||||
};
|
||||
|
||||
@@ -257,6 +257,8 @@ pub fn internal(&self, feature: Symbol) -> bool {
|
||||
(internal, rustc_attrs, "1.0.0", None),
|
||||
/// Allows using the `#[stable]` and `#[unstable]` attributes.
|
||||
(internal, staged_api, "1.0.0", None),
|
||||
/// Perma-unstable, only used to test the `incomplete_features` lint.
|
||||
(incomplete, test_incomplete_feature, "CURRENT_RUSTC_VERSION", None),
|
||||
/// Added for testing unstable lints; perma-unstable.
|
||||
(internal, test_unstable_lint, "1.60.0", None),
|
||||
/// Use for stable + negative coherence and strict coherence depending on trait's
|
||||
|
||||
@@ -1033,8 +1033,8 @@
|
||||
/// ```rust
|
||||
/// #[warn(unused_macro_rules)]
|
||||
/// macro_rules! unused_empty {
|
||||
/// (hello) => { println!("Hello, world!") }; // This rule is unused
|
||||
/// () => { println!("empty") }; // This rule is used
|
||||
/// (hello) => { println!("Hello, world!") }; // This rule is used
|
||||
/// () => { println!("empty") }; // This rule is unused
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
|
||||
@@ -65,7 +65,7 @@ pub fn predecessors(&self) -> &Predecessors {
|
||||
|
||||
/// Returns basic blocks in a reverse postorder.
|
||||
///
|
||||
/// See [`traversal::reverse_postorder`]'s docs to learn what is preorder traversal.
|
||||
/// See [`traversal::reverse_postorder`]'s docs to learn what is postorder traversal.
|
||||
///
|
||||
/// [`traversal::reverse_postorder`]: crate::mir::traversal::reverse_postorder
|
||||
#[inline]
|
||||
|
||||
@@ -136,8 +136,12 @@ pub struct QueryVTable<'tcx, C: QueryCache> {
|
||||
/// For `no_hash` queries, this function pointer is None.
|
||||
pub hash_value_fn: Option<fn(&mut StableHashingContext<'_>, &C::Value) -> Fingerprint>,
|
||||
|
||||
pub value_from_cycle_error:
|
||||
fn(tcx: TyCtxt<'tcx>, cycle_error: CycleError, guar: ErrorGuaranteed) -> C::Value,
|
||||
pub value_from_cycle_error: fn(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
key: C::Key,
|
||||
cycle_error: CycleError,
|
||||
guar: ErrorGuaranteed,
|
||||
) -> C::Value,
|
||||
pub format_value: fn(&C::Value) -> String,
|
||||
|
||||
/// Formats a human-readable description of this query and its key, as
|
||||
|
||||
@@ -109,21 +109,21 @@ fn new(
|
||||
/// ```rust
|
||||
/// struct S;
|
||||
/// #[rustfmt::skip]
|
||||
/// fn foo(pred: bool) { // maybe-init:
|
||||
/// // {}
|
||||
/// let a = S; let mut b = S; let c; let d; // {a, b}
|
||||
/// fn foo(p: bool) { // maybe-init:
|
||||
/// // {p}
|
||||
/// let a = S; let mut b = S; let c; let d; // {p, a, b}
|
||||
///
|
||||
/// if pred {
|
||||
/// drop(a); // { b}
|
||||
/// b = S; // { b}
|
||||
/// if p {
|
||||
/// drop(a); // {p, b}
|
||||
/// b = S; // {p, b}
|
||||
///
|
||||
/// } else {
|
||||
/// drop(b); // {a}
|
||||
/// d = S; // {a, d}
|
||||
/// drop(b); // {p, a}
|
||||
/// d = S; // {p, a, d}
|
||||
///
|
||||
/// } // {a, b, d}
|
||||
/// } // {p, a, b, d}
|
||||
///
|
||||
/// c = S; // {a, b, c, d}
|
||||
/// c = S; // {p, a, b, c, d}
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
@@ -199,11 +199,11 @@ fn move_data(&self) -> &MoveData<'tcx> {
|
||||
/// ```rust
|
||||
/// struct S;
|
||||
/// #[rustfmt::skip]
|
||||
/// fn foo(pred: bool) { // maybe-uninit:
|
||||
/// fn foo(p: bool) { // maybe-uninit:
|
||||
/// // {a, b, c, d}
|
||||
/// let a = S; let mut b = S; let c; let d; // { c, d}
|
||||
///
|
||||
/// if pred {
|
||||
/// if p {
|
||||
/// drop(a); // {a, c, d}
|
||||
/// b = S; // {a, c, d}
|
||||
///
|
||||
@@ -279,34 +279,36 @@ fn move_data(&self) -> &MoveData<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `EverInitializedPlaces` tracks all places that might have ever been
|
||||
/// initialized upon reaching a particular point in the control flow
|
||||
/// for a function, without an intervening `StorageDead`.
|
||||
/// `EverInitializedPlaces` tracks all initializations that may have occurred
|
||||
/// upon reaching a particular point in the control flow for a function,
|
||||
/// without an intervening `StorageDead`.
|
||||
///
|
||||
/// This dataflow is used to determine if an immutable local variable may
|
||||
/// be assigned to.
|
||||
///
|
||||
/// For example, in code like the following, we have corresponding
|
||||
/// dataflow information shown in the right-hand comments.
|
||||
/// dataflow information shown in the right-hand comments. Underscored indices
|
||||
/// are used to distinguish between multiple initializations of the same local
|
||||
/// variable, e.g. `b_0` and `b_1`.
|
||||
///
|
||||
/// ```rust
|
||||
/// struct S;
|
||||
/// #[rustfmt::skip]
|
||||
/// fn foo(pred: bool) { // ever-init:
|
||||
/// // { }
|
||||
/// let a = S; let mut b = S; let c; let d; // {a, b }
|
||||
/// fn foo(p: bool) { // ever-init:
|
||||
/// // {p, }
|
||||
/// let a = S; let mut b = S; let c; let d; // {p, a, b_0, }
|
||||
///
|
||||
/// if pred {
|
||||
/// drop(a); // {a, b, }
|
||||
/// b = S; // {a, b, }
|
||||
/// if p {
|
||||
/// drop(a); // {p, a, b_0, }
|
||||
/// b = S; // {p, a, b_0, b_1, }
|
||||
///
|
||||
/// } else {
|
||||
/// drop(b); // {a, b, }
|
||||
/// d = S; // {a, b, d }
|
||||
/// drop(b); // {p, a, b_0, b_1, }
|
||||
/// d = S; // {p, a, b_0, b_1, d}
|
||||
///
|
||||
/// } // {a, b, d }
|
||||
/// } // {p, a, b_0, b_1, d}
|
||||
///
|
||||
/// c = S; // {a, b, c, d }
|
||||
/// c = S; // {p, a, b_0, b_1, c, d}
|
||||
/// }
|
||||
/// ```
|
||||
pub struct EverInitializedPlaces<'a, 'tcx> {
|
||||
|
||||
@@ -125,17 +125,18 @@ fn gather_active_jobs<'tcx, C>(
|
||||
fn mk_cycle<'tcx, C: QueryCache>(
|
||||
query: &'tcx QueryVTable<'tcx, C>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
key: C::Key,
|
||||
cycle_error: CycleError,
|
||||
) -> C::Value {
|
||||
let error = report_cycle(tcx.sess, &cycle_error);
|
||||
match query.cycle_error_handling {
|
||||
CycleErrorHandling::Error => {
|
||||
let guar = error.emit();
|
||||
(query.value_from_cycle_error)(tcx, cycle_error, guar)
|
||||
(query.value_from_cycle_error)(tcx, key, cycle_error, guar)
|
||||
}
|
||||
CycleErrorHandling::DelayBug => {
|
||||
let guar = error.delay_as_bug();
|
||||
(query.value_from_cycle_error)(tcx, cycle_error, guar)
|
||||
(query.value_from_cycle_error)(tcx, key, cycle_error, guar)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,6 +220,7 @@ fn drop(&mut self) {
|
||||
fn cycle_error<'tcx, C: QueryCache>(
|
||||
query: &'tcx QueryVTable<'tcx, C>,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
key: C::Key,
|
||||
try_execute: QueryJobId,
|
||||
span: Span,
|
||||
) -> (C::Value, Option<DepNodeIndex>) {
|
||||
@@ -229,7 +231,7 @@ fn cycle_error<'tcx, C: QueryCache>(
|
||||
.expect("failed to collect active queries");
|
||||
|
||||
let error = find_cycle_in_stack(try_execute, job_map, ¤t_query_job(), span);
|
||||
(mk_cycle(query, tcx, error.lift()), None)
|
||||
(mk_cycle(query, tcx, key, error.lift()), None)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -274,7 +276,7 @@ fn wait_for_query<'tcx, C: QueryCache>(
|
||||
|
||||
(v, Some(index))
|
||||
}
|
||||
Err(cycle) => (mk_cycle(query, tcx, cycle.lift()), None),
|
||||
Err(cycle) => (mk_cycle(query, tcx, key, cycle.lift()), None),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +339,7 @@ fn try_execute_query<'tcx, C: QueryCache, const INCR: bool>(
|
||||
|
||||
// If we are single-threaded we know that we have cycle error,
|
||||
// so we just return the error.
|
||||
cycle_error(query, tcx, id, span)
|
||||
cycle_error(query, tcx, key, id, span)
|
||||
}
|
||||
}
|
||||
ActiveKeyStatus::Poisoned => FatalError.raise(),
|
||||
|
||||
@@ -15,34 +15,34 @@
|
||||
use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_middle::{bug, span_bug};
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::def_id::{DefId, LocalDefId};
|
||||
use rustc_span::{ErrorGuaranteed, Span};
|
||||
|
||||
use crate::job::report_cycle;
|
||||
|
||||
pub(crate) fn specialize_query_vtables<'tcx>(vtables: &mut QueryVTables<'tcx>) {
|
||||
vtables.type_of.value_from_cycle_error =
|
||||
|tcx, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
|
||||
|tcx, _, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
|
||||
|
||||
vtables.type_of_opaque_hir_typeck.value_from_cycle_error =
|
||||
|tcx, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
|
||||
|tcx, _, _, guar| erase_val(ty::EarlyBinder::bind(Ty::new_error(tcx, guar)));
|
||||
|
||||
vtables.erase_and_anonymize_regions_ty.value_from_cycle_error =
|
||||
|tcx, _, guar| erase_val(Ty::new_error(tcx, guar));
|
||||
|tcx, _, _, guar| erase_val(Ty::new_error(tcx, guar));
|
||||
|
||||
vtables.fn_sig.value_from_cycle_error = |tcx, cycle, guar| erase_val(fn_sig(tcx, cycle, guar));
|
||||
vtables.fn_sig.value_from_cycle_error = |tcx, key, _, guar| erase_val(fn_sig(tcx, key, guar));
|
||||
|
||||
vtables.check_representability.value_from_cycle_error =
|
||||
|tcx, cycle, guar| check_representability(tcx, cycle, guar);
|
||||
|tcx, _, cycle, guar| check_representability(tcx, cycle, guar);
|
||||
|
||||
vtables.check_representability_adt_ty.value_from_cycle_error =
|
||||
|tcx, cycle, guar| check_representability(tcx, cycle, guar);
|
||||
|tcx, _, cycle, guar| check_representability(tcx, cycle, guar);
|
||||
|
||||
vtables.variances_of.value_from_cycle_error =
|
||||
|tcx, cycle, guar| erase_val(variances_of(tcx, cycle, guar));
|
||||
|tcx, _, cycle, guar| erase_val(variances_of(tcx, cycle, guar));
|
||||
|
||||
vtables.layout_of.value_from_cycle_error =
|
||||
|tcx, cycle, guar| erase_val(layout_of(tcx, cycle, guar));
|
||||
|tcx, _, cycle, guar| erase_val(layout_of(tcx, cycle, guar));
|
||||
}
|
||||
|
||||
pub(crate) fn default<'tcx>(tcx: TyCtxt<'tcx>, cycle_error: CycleError, query_name: &str) -> ! {
|
||||
@@ -57,15 +57,12 @@ pub(crate) fn default<'tcx>(tcx: TyCtxt<'tcx>, cycle_error: CycleError, query_na
|
||||
|
||||
fn fn_sig<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
cycle_error: CycleError,
|
||||
def_id: DefId,
|
||||
guar: ErrorGuaranteed,
|
||||
) -> ty::EarlyBinder<'tcx, ty::PolyFnSig<'tcx>> {
|
||||
let err = Ty::new_error(tcx, guar);
|
||||
|
||||
let arity = if let Some(info) = cycle_error.cycle.get(0)
|
||||
&& info.frame.dep_kind == DepKind::fn_sig
|
||||
&& let Some(def_id) = info.frame.def_id
|
||||
&& let Some(node) = tcx.hir_get_if_local(def_id)
|
||||
let arity = if let Some(node) = tcx.hir_get_if_local(def_id)
|
||||
&& let Some(sig) = node.fn_sig()
|
||||
{
|
||||
sig.decl.inputs.len()
|
||||
|
||||
@@ -487,7 +487,7 @@ pub(crate) fn make_query_vtable<'tcx>(incremental: bool)
|
||||
#[cfg(not($cache_on_disk))]
|
||||
is_loadable_from_disk_fn: |_tcx, _key, _index| false,
|
||||
|
||||
value_from_cycle_error: |tcx, cycle, _| {
|
||||
value_from_cycle_error: |tcx, _, cycle, _| {
|
||||
$crate::from_cycle_error::default(tcx, cycle, stringify!($name))
|
||||
},
|
||||
|
||||
|
||||
@@ -2006,6 +2006,7 @@
|
||||
test_2018_feature,
|
||||
test_accepted_feature,
|
||||
test_case,
|
||||
test_incomplete_feature,
|
||||
test_removed_feature,
|
||||
test_runner,
|
||||
test_unstable_lint,
|
||||
|
||||
@@ -200,12 +200,14 @@ fn equivalent_modulo_carve_out(pr_job: &Job, auto_job: &Job) -> anyhow::Result<(
|
||||
equivalent_modulo_carve_out(pr_job, auto_job)?;
|
||||
}
|
||||
|
||||
// Auto CI jobs must all "fail-fast" to avoid wasting Auto CI resources. For instance, `tidy`.
|
||||
// Auto CI should "fail-fast" to avoid wasting Auto CI resources.
|
||||
// However, some experimental auto jobs can be made optional, for example if we are unsure about
|
||||
// their flakiness. Those have to be prefixed with `optional-`.
|
||||
for auto_job in &db.auto_jobs {
|
||||
if auto_job.continue_on_error == Some(true) {
|
||||
if auto_job.continue_on_error == Some(true) && !auto_job.name.starts_with("optional-") {
|
||||
return Err(anyhow!(
|
||||
"Auto job `{}` cannot have `continue_on_error: true`",
|
||||
auto_job.name
|
||||
"Auto job `{job}` cannot have `continue_on_error: true`. If the job should be optional, name it `optional-{job}`.",
|
||||
job = auto_job.name
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
FROM ubuntu:22.04
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
g++ \
|
||||
make \
|
||||
ninja-build \
|
||||
file \
|
||||
curl \
|
||||
ca-certificates \
|
||||
python3 \
|
||||
git \
|
||||
cmake \
|
||||
sudo \
|
||||
gdb \
|
||||
libssl-dev \
|
||||
pkg-config \
|
||||
xz-utils \
|
||||
mingw-w64 \
|
||||
zlib1g-dev \
|
||||
libzstd-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY scripts/sccache.sh /scripts/
|
||||
RUN sh /scripts/sccache.sh
|
||||
|
||||
ENV RUST_CONFIGURE_ARGS \
|
||||
--build=x86_64-unknown-linux-gnu \
|
||||
--enable-sanitizers \
|
||||
--enable-profiler \
|
||||
--enable-compiler-docs \
|
||||
--set llvm.libzstd=true
|
||||
|
||||
# Build the toolchain with multiple parallel frontend threads and then run tests
|
||||
# Tests are still compiled serially at the moment (intended to be changed in follow-ups).
|
||||
ENV SCRIPT python3 ../x.py --stage 2 test --set rust.parallel-frontend-threads=4
|
||||
@@ -39,7 +39,7 @@ COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/
|
||||
# Check library crates on all tier 1 targets.
|
||||
# We disable optimized compiler built-ins because that requires a C toolchain for the target.
|
||||
# We also skip the x86_64-unknown-linux-gnu target as it is well-tested by other jobs.
|
||||
ENV SCRIPT \
|
||||
ENV SCRIPT=" \
|
||||
# Check some tools that aren't included in `x check` by default, to
|
||||
# ensure that maintainers can still do check builds locally.
|
||||
python3 ../x.py check \
|
||||
@@ -58,4 +58,4 @@ ENV SCRIPT \
|
||||
python3 ../x.py check --set build.optimized-compiler-builtins=false core alloc std --target=aarch64-unknown-linux-gnu,i686-pc-windows-msvc,i686-unknown-linux-gnu,x86_64-apple-darwin,x86_64-pc-windows-gnu,x86_64-pc-windows-msvc && \
|
||||
/scripts/validate-toolstate.sh && \
|
||||
reuse --include-submodules lint && \
|
||||
python3 ../x.py test collect-license-metadata
|
||||
python3 ../x.py test collect-license-metadata"
|
||||
|
||||
@@ -30,8 +30,7 @@ ENV RUST_CONFIGURE_ARGS="--set rust.validate-mir-opts=3"
|
||||
COPY scripts/sccache.sh /scripts/
|
||||
RUN sh /scripts/sccache.sh
|
||||
|
||||
ENV SCRIPT \
|
||||
python3 ../x.py check && \
|
||||
ENV SCRIPT="python3 ../x.py check && \
|
||||
python3 ../x.py clippy ci --stage 2 && \
|
||||
python3 ../x.py test --stage 1 core alloc std test proc_macro && \
|
||||
# Elsewhere, we run all tests for the host. A number of codegen tests are sensitive to the target pointer
|
||||
@@ -48,4 +47,4 @@ ENV SCRIPT \
|
||||
RUSTDOCFLAGS=\"--document-private-items --document-hidden-items\" python3 ../x.py doc library/test --stage 1 && \
|
||||
# The BOOTSTRAP_TRACING flag is added to verify whether the
|
||||
# bootstrap process compiles successfully with this flag enabled.
|
||||
BOOTSTRAP_TRACING=1 python3 ../x.py --help
|
||||
BOOTSTRAP_TRACING=1 python3 ../x.py --help"
|
||||
|
||||
@@ -39,5 +39,5 @@ COPY host-x86_64/pr-check-1/validate-toolstate.sh /scripts/
|
||||
|
||||
# NOTE: intentionally uses python2 for x.py so we can test it still works.
|
||||
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
|
||||
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
|
||||
src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck
|
||||
ENV SCRIPT="TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
|
||||
src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck"
|
||||
|
||||
@@ -348,6 +348,11 @@ auto:
|
||||
- name: x86_64-gnu
|
||||
<<: *job-linux-4c
|
||||
|
||||
- name: optional-x86_64-gnu-parallel-frontend
|
||||
# This test can be flaky, so do not cancel CI if it fails, for now.
|
||||
continue_on_error: true
|
||||
<<: *job-linux-4c
|
||||
|
||||
- name: x86_64-gnu-gcc
|
||||
doc_url: https://rustc-dev-guide.rust-lang.org/tests/codegen-backend-tests/cg_gcc.html
|
||||
<<: *job-linux-4c
|
||||
|
||||
@@ -1 +1 @@
|
||||
c78a29473a68f07012904af11c92ecffa68fcc75
|
||||
eda4fc7733ee89e484d7120cafbd80dcb2fce66e
|
||||
|
||||
@@ -1,6 +1,50 @@
|
||||
# Installation
|
||||
|
||||
In the near future, `std::autodiff` should become available in nightly builds for users. As a contributor however, you will still need to build rustc from source. Please be aware that the msvc target is not supported at the moment, all other tier 1 targets should work. Please open an issue if you encounter any problems on a supported tier 1 target, or if you successfully build this project on a tier2/tier3 target.
|
||||
In the near future, `std::autodiff` should become available for users via rustup. As a rustc/enzyme/autodiff contributor however, you will still need to build rustc from source.
|
||||
For the meantime, you can download up-to-date builds to enable `std::autodiff` on your latest nightly toolchain, if you are using either of:
|
||||
**Linux**, with `x86_64-unknown-linux-gnu` or `aarch64-unknown-linux-gnu`
|
||||
**Windows**, with `x86_64-llvm-mingw` or `aarch64-llvm-mingw`
|
||||
|
||||
You can also download slightly outdated builds for **Apple** (aarch64-apple), which should generally work for now.
|
||||
|
||||
If you need any other platform, you can build rustc including autodiff from source. Please open an issue if you want to help enabling automatic builds for your prefered target.
|
||||
|
||||
## Installation guide
|
||||
|
||||
If you want to use `std::autodiff` and don't plan to contribute PR's to the project, then we recommend to just use your existing nightly installation and download the missing component. In the future, rustup will be able to do it for you.
|
||||
For now, you'll have to manually download and copy it.
|
||||
|
||||
1) On our github repository, find the last merged PR: [`Repo`]
|
||||
2) Scroll down to the lower end of the PR, where you'll find a rust-bors message saying `Test successful` with a `CI` link.
|
||||
3) Click on the `CI` link, and grep for your target. E.g. `dist-x86_64-linux` or `dist-aarch64-llvm-mingw` and click `Load summary`.
|
||||
4) Under the `CI artifacts` section, find the `enzyme-nightly` artifact, download, and unpack it.
|
||||
5) Copy the artifact (libEnzyme-22.so for linux, libEnzyme-22.dylib for apple, etc.), which should be in a folder named `enzyme-preview`, to your rust toolchain directory. E.g. for linux: `cp ~/Downloads/enzyme-nightly-x86_64-unknown-linux-gnu/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so ~/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib`
|
||||
|
||||
Apple support was temporarily reverted, due to downstream breakages. If you want to download autodiff for apple, please look at the artifacts from this [`run`].
|
||||
|
||||
## Installation guide for Nix user.
|
||||
|
||||
This setup was recommended by a nix and autodiff user. It uses [`Overlay`]. Please verify for yourself if you are comfortable using that repository.
|
||||
In that case you might use the following nix configuration to get a rustc that supports `std::autodiff`.
|
||||
```nix
|
||||
{
|
||||
enzymeLib = pkgs.fetchzip {
|
||||
url = "https://ci-artifacts.rust-lang.org/rustc-builds/ec818fda361ca216eb186f5cf45131bd9c776bb4/enzyme-nightly-x86_64-unknown-linux-gnu.tar.xz";
|
||||
sha256 = "sha256-Rnrop44vzS+qmYNaRoMNNMFyAc3YsMnwdNGYMXpZ5VY=";
|
||||
};
|
||||
|
||||
rustToolchain = pkgs.symlinkJoin {
|
||||
name = "rust-with-enzyme";
|
||||
paths = [pkgs.rust-bin.nightly.latest.default];
|
||||
nativeBuildInputs = [pkgs.makeWrapper];
|
||||
postBuild = ''
|
||||
libdir=$out/lib/rustlib/x86_64-unknown-linux-gnu/lib
|
||||
cp ${enzymeLib}/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so $libdir/
|
||||
wrapProgram $out/bin/rustc --add-flags "--sysroot $out"
|
||||
'';
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
## Build instructions
|
||||
|
||||
@@ -87,3 +131,6 @@ ninja
|
||||
```
|
||||
This will build Enzyme, and you can find it in `Enzyme/enzyme/build/lib/<LLD/Clang/LLVM/lib>Enzyme.so`. (Endings might differ based on your OS).
|
||||
|
||||
[`Repo`]: https://github.com/rust-lang/rust/
|
||||
[`run`]: https://github.com/rust-lang/rust/pull/153026#issuecomment-3950046599
|
||||
[`Overlay`]: https://github.com/oxalica/rust-overlay
|
||||
|
||||
@@ -6,7 +6,12 @@ Rust supports building against multiple LLVM versions:
|
||||
* Tip-of-tree for the current LLVM development branch is usually supported within a few days.
|
||||
PRs for such fixes are tagged with `llvm-main`.
|
||||
* The latest released major version is always supported.
|
||||
* The one or two preceding major versions are usually supported.
|
||||
* The one or two preceding major versions are usually supported in the sense that they are expected
|
||||
to build successfully and pass most tests.
|
||||
However, fixes for miscompilations often do not get
|
||||
backported to past LLVM versions, so using rustc with older versions of LLVM comes with an
|
||||
increased risk of soundness bugs.
|
||||
We strongly recommend using the latest version of LLVM.
|
||||
|
||||
By default, Rust uses its own fork in the [rust-lang/llvm-project repository].
|
||||
This fork is based on a `release/$N.x` branch of the upstream project, where
|
||||
|
||||
@@ -110,7 +110,6 @@ Also, using `x` rather than `x.py` is recommended as:
|
||||
Notice that this is not absolute.
|
||||
For instance, using Nushell in VSCode on Win10,
|
||||
typing `x` or `./x` still opens `x.py` in an editor rather than invoking the program.
|
||||
:)
|
||||
|
||||
In the rest of this guide, we use `x` rather than `x.py` directly.
|
||||
The following command:
|
||||
|
||||
@@ -139,6 +139,8 @@ if foo {
|
||||
}
|
||||
```
|
||||
|
||||
If you want to leave a note in the codebase, use `// FIXME` instead.
|
||||
|
||||
<a id="cio"></a>
|
||||
|
||||
## Using crates from crates.io
|
||||
|
||||
@@ -31,8 +31,7 @@ There are two ways of writing translatable diagnostics:
|
||||
("Simple" diagnostics being those that don't require a lot of logic in
|
||||
deciding to emit subdiagnostics and can therefore be represented as diagnostic structs).
|
||||
See [the diagnostic and subdiagnostic structs documentation](./diagnostic-structs.md).
|
||||
2. Using typed identifiers with `Diag` APIs (in
|
||||
`Diagnostic` or `Subdiagnostic` implementations).
|
||||
2. Using typed identifiers with `Diag` APIs (in `Diagnostic` or `Subdiagnostic` implementations).
|
||||
|
||||
When adding or changing a translatable diagnostic,
|
||||
you don't need to worry about the translations.
|
||||
|
||||
@@ -8,7 +8,7 @@ nightly-only `#![feature(...)]` opt-in.
|
||||
This chapter documents the implementation
|
||||
of feature gating: where gates are defined, how they are enabled, and how usage is verified.
|
||||
|
||||
<!-- data-check: Feb 2026 -->
|
||||
<!-- date-check: Feb 2026 -->
|
||||
|
||||
## Feature Definitions
|
||||
|
||||
|
||||
@@ -383,6 +383,13 @@ Both the upside and downside of this is that it simplifies the history.
|
||||
On the one hand, you lose track of the steps in which changes were made, but
|
||||
the history becomes easier to work with.
|
||||
|
||||
The easiest way to squash your commits in a PR on the `rust-lang/rust` repository is to use the `@bors squash` command in a comment on the PR.
|
||||
By default, [bors] combines all commit messages of the PR into the squashed commit message.
|
||||
To customize the commit message, use `@bors squash msg=<commit message>`.
|
||||
|
||||
|
||||
If you want to squash commits using local git operations, read on below.
|
||||
|
||||
If there are no conflicts and you are just squashing to clean up the history,
|
||||
use `git rebase --interactive --keep-base main`.
|
||||
This keeps the fork point of your PR the same, making it easier to review the diff of what happened
|
||||
@@ -410,11 +417,6 @@ because they only represent "fixups" and not real changes.
|
||||
For example,
|
||||
`git rebase --interactive HEAD~2` will allow you to edit the two commits only.
|
||||
|
||||
For pull requests in `rust-lang/rust`, you can ask [bors] to squash by commenting
|
||||
`@bors squash` on the PR.
|
||||
By default, [bors] combines all commit messages in the PR.
|
||||
To customize the commit message, use `@bors squash [msg|message=<commit-message>]`.
|
||||
|
||||
[bors]: https://github.com/rust-lang/bors
|
||||
|
||||
### `git range-diff`
|
||||
|
||||
@@ -90,7 +90,7 @@ dependencies of the local crate)
|
||||
Note that what determines the crate that a query is targeting is not the *kind* of query, but the *key*.
|
||||
For example, when you invoke `tcx.type_of(def_id)`, that could be a
|
||||
local query or an external query, depending on what crate the `def_id`
|
||||
is referring to (see the [`self::keys::Key`][Key] trait for more information on how that works).
|
||||
is referring to (see the [`self::keys::QueryKey`][QueryKey] trait for more information on how that works).
|
||||
|
||||
Providers always have the same signature:
|
||||
|
||||
@@ -308,7 +308,7 @@ Let's go over these elements one by one:
|
||||
Also used as the name of a struct (`ty::queries::type_of`) that will be generated to represent
|
||||
this query.
|
||||
- **Query key type:** the type of the argument to this query.
|
||||
This type must implement the [`ty::query::keys::Key`][Key] trait, which
|
||||
This type must implement the [`ty::query::keys::QueryKey`][QueryKey] trait, which
|
||||
defines (for example) how to map it to a crate, and so forth.
|
||||
- **Result type of query:** the type produced by this query.
|
||||
This type should (a) not use `RefCell` or other interior mutability and (b) be
|
||||
@@ -317,7 +317,7 @@ Let's go over these elements one by one:
|
||||
- **Query modifiers:** various flags and options that customize how the
|
||||
query is processed (mostly with respect to [incremental compilation][incrcomp]).
|
||||
|
||||
[Key]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/query/keys/trait.Key.html
|
||||
[QueryKey]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/query/keys/trait.QueryKey.html
|
||||
[incrcomp]: queries/incremental-compilation-in-detail.html#query-modifiers
|
||||
|
||||
So, to add a query:
|
||||
|
||||
@@ -109,6 +109,12 @@ The live results can be seen on [the GitHub Actions workflows page].
|
||||
At any given time, at most a single `auto` build is being executed.
|
||||
Find out more in [Merging PRs serially with bors](#merging-prs-serially-with-bors).
|
||||
|
||||
Normally, when an auto job fails, the whole CI workflow immediately ends. However, it can be useful to
|
||||
create auto jobs that are "non-blocking", or optional, to test them on CI for some time before blocking
|
||||
merges on them. This can be useful if those jobs can be flaky.
|
||||
|
||||
To do that, prefix such a job with `optional-`, and set `continue_on_error: true` for it in [`jobs.yml`].
|
||||
|
||||
[platform tiers]: https://forge.rust-lang.org/release/platform-support.html#rust-platform-support
|
||||
[auto]: https://github.com/rust-lang/rust/tree/automation/bors/auto
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ of `tracing-subscriber`](https://docs.rs/tracing-subscriber/0.2.24/tracing_subsc
|
||||
|
||||
## Environment variables
|
||||
|
||||
This is an overview of the environment variables rustc accepts to customize
|
||||
its tracing output. The definition of these can mostly be found in `compiler/rustc_log/src/lib.rs`.
|
||||
This is an overview of the environment variables rustc accepts to customize its tracing output.
|
||||
The definition of these can mostly be found in `compiler/rustc_log/src/lib.rs`.
|
||||
|
||||
| Name | Usage |
|
||||
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
fn main() {}
|
||||
|
||||
// This forces explicit emission of a +neon target feature on targets
|
||||
// where it is implied by the target-cpu, like aarch64-apple-darwin.
|
||||
// This is a regression test for #153397.
|
||||
#[cfg(target_feature = "neon")]
|
||||
#[target_feature(enable = "neon")]
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn with_neon() {}
|
||||
|
||||
@@ -8,7 +8,12 @@
|
||||
use run_make_support::{run, rustc};
|
||||
|
||||
fn main() {
|
||||
let out = rustc().input("foo.rs").arg("-Ctarget-cpu=native").run().stderr_utf8();
|
||||
let out = rustc()
|
||||
.input("foo.rs")
|
||||
.arg("-Ctarget-cpu=native")
|
||||
.arg("-Zverify-llvm-ir")
|
||||
.run()
|
||||
.stderr_utf8();
|
||||
run("foo");
|
||||
// There should be zero warnings emitted - the bug would cause "unknown CPU `native`"
|
||||
// to be printed out.
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
extern crate block_on;
|
||||
|
||||
// Check that closures that don't capture any state may implement `Fn`.
|
||||
// Check that async closures that don't capture any state may implement `Fn`.
|
||||
|
||||
fn main() {
|
||||
block_on::block_on(async {
|
||||
async fn call_once<F: Future>(x: impl FnOnce(&'static str) -> F) -> F::Output {
|
||||
async fn call_once<F: Future>(x: impl Fn(&'static str) -> F) -> F::Output {
|
||||
x("hello, world").await
|
||||
}
|
||||
call_once(async |x: &'static str| {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//! Make sure that incomplete features emit the `incomplete_features` lint.
|
||||
|
||||
// gate-test-test_incomplete_feature
|
||||
|
||||
//@ check-pass
|
||||
//@ revisions: warn expect
|
||||
|
||||
#![cfg_attr(warn, warn(incomplete_features))]
|
||||
#![cfg_attr(expect, expect(incomplete_features))]
|
||||
|
||||
#![feature(test_incomplete_feature)] //[warn]~ WARN the feature `test_incomplete_feature` is incomplete
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,14 @@
|
||||
warning: the feature `test_incomplete_feature` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/incomplete-features.rs:11:12
|
||||
|
|
||||
LL | #![feature(test_incomplete_feature)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/incomplete-features.rs:8:24
|
||||
|
|
||||
LL | #![cfg_attr(warn, warn(incomplete_features))]
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Regression test for #153391.
|
||||
//
|
||||
//@ edition:2024
|
||||
//@ compile-flags: -Z threads=16
|
||||
//@ compare-output-by-lines
|
||||
//@ ignore-test (#142063)
|
||||
|
||||
trait A {
|
||||
fn g() -> B;
|
||||
//~^ ERROR expected a type, found a trait
|
||||
}
|
||||
|
||||
trait B {
|
||||
fn bar(&self, x: &A);
|
||||
//~^ ERROR expected a type, found a trait
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
@@ -0,0 +1,31 @@
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/fn-sig-cycle-ice-153391.rs:8:15
|
||||
|
|
||||
LL | fn g() -> B;
|
||||
| ^
|
||||
|
|
||||
help: `B` is dyn-incompatible, use `impl B` to return an opaque type, as long as you return a single underlying type
|
||||
|
|
||||
LL | fn g() -> impl B;
|
||||
| ++++
|
||||
|
||||
error[E0782]: expected a type, found a trait
|
||||
--> $DIR/fn-sig-cycle-ice-153391.rs:13:23
|
||||
|
|
||||
LL | fn bar(&self, x: &A);
|
||||
| ^
|
||||
|
|
||||
= note: `A` is dyn-incompatible, otherwise a trait object could be used
|
||||
help: use a new generic type parameter, constrained by `A`
|
||||
|
|
||||
LL - fn bar(&self, x: &A);
|
||||
LL + fn bar<T: A>(&self, x: &T);
|
||||
|
|
||||
help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference
|
||||
|
|
||||
LL | fn bar(&self, x: &impl A);
|
||||
| ++++
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0782`.
|
||||
Reference in New Issue
Block a user