Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
223cbad
update compare modes
cijiugechu Apr 24, 2026
ab450e9
Add CI testing instructions for offload
xkevio Apr 30, 2026
8c9e9e8
Merge pull request #2852 from cijiugechu/compare-modes
BoxyUwU May 1, 2026
5f46b81
Fix tip on unstable syntax gating
kupiakos May 2, 2026
96ea7ec
Merge pull request rust-lang/rustc-dev-guide#2862 from kupiakos/patch-1
reddevilmidzy May 2, 2026
6158d6e
Prepare for merging from rust-lang/rust
invalid-email-address May 4, 2026
8a9c08a
Merge ref '045b17737dab' from rust-lang/rust
invalid-email-address May 4, 2026
fc4ab61
Merge pull request rust-lang/rustc-dev-guide#2863 from rust-lang/rust…
reddevilmidzy May 4, 2026
a2c0e02
skip incorrect suggestion in nested imports
el-ev May 6, 2026
05b97f7
address review comment
el-ev May 7, 2026
dcaef5f
move consts ui tests into its folder
danieljofficial May 7, 2026
64398c3
Merge pull request #2857 from xkevio/patch-1
jyn514 May 7, 2026
1ad59ef
mark the suggestion as directly when it is
el-ev May 7, 2026
b7d22fd
refactor path construction
el-ev May 8, 2026
2a119e8
add issue links and bless
danieljofficial May 8, 2026
a28de9f
update tests
el-ev May 8, 2026
22d2826
remove param_env from HasTypingEnv
jdonszelmann May 1, 2026
68f9143
use the right typing mode for each mir phase
jdonszelmann May 1, 2026
0aefbd1
use the right typing mode in lints
jdonszelmann May 4, 2026
0d65aa2
move drop bomb from OpaqueTypeStorage into InferCtxt's Drop
jdonszelmann May 5, 2026
6d5fc32
combine tests into one file
el-ev May 8, 2026
aa43cd2
Remove outdated apple download instructions
ZuseZ4 May 8, 2026
0e45f1e
Merge pull request #2865 from rust-lang/apple-autodiff
ZuseZ4 May 8, 2026
37f7a97
Prepare for merging from rust-lang/rust
invalid-email-address May 8, 2026
522e38a
Merge ref 'f2b291d902bf' from rust-lang/rust
invalid-email-address May 8, 2026
5588a5b
Merge pull request #2866 from rust-lang/rustc-pull
tshepang May 8, 2026
497a0eb
sembr src/autodiff/installation.md
tshepang May 8, 2026
a6c134c
sembr src/unsafety-checking.md
tshepang May 8, 2026
66882cf
add a pause (and remove redundant word)
tshepang May 8, 2026
2206653
add some pauses
tshepang May 8, 2026
1eb7b46
replace awkward wording
tshepang May 8, 2026
e2b66ef
add regression test for unicode dotdotdot rest pattern
TaKO8Ki May 8, 2026
431017b
avoid byte slicing in dotdotdot rest pattern suggestion
TaKO8Ki May 8, 2026
f3fb571
line reflow is not part of sembr compliance
tshepang May 8, 2026
a993479
sembr src/building/build-install-distribution-artifacts.md
tshepang May 8, 2026
fb8270d
use a more correct code marker
tshepang May 8, 2026
3409a91
Merge pull request #2867 from rust-lang/tshepang/sembr
tshepang May 8, 2026
dbc4f62
Rollup merge of #156141 - jdonszelmann:use-right-typingmode, r=lcnr
matthiaskrgr May 8, 2026
62396df
Rollup merge of #156244 - el-ev:issue156060, r=mu001999
matthiaskrgr May 8, 2026
b2cdfa2
Rollup merge of #156306 - danieljofficial:move-tests-consts, r=TaKO8Ki
matthiaskrgr May 8, 2026
eabe462
Rollup merge of #156333 - TaKO8Ki:fix-dotdotdot-rest-pattern-unicode-…
matthiaskrgr May 8, 2026
53526f5
Rollup merge of #156337 - tshepang:rdg-sync, r=tshepang
matthiaskrgr May 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_errors::ErrorGuaranteed;
use rustc_hir::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::*;
use rustc_middle::ty::{self, AdtDef, Ty};
use rustc_middle::ty::{self, AdtDef, Ty, TypingMode};
use rustc_middle::{bug, mir};
use rustc_trait_selection::traits::{Obligation, ObligationCause, ObligationCtxt};
use tracing::instrument;
Expand Down Expand Up @@ -100,13 +100,14 @@ impl Qualif for HasMutInterior {
// Instead we invoke an obligation context manually, and provide the opaque type inference settings
// that allow the trait solver to just error out instead of cycling.
let freeze_def_id = cx.tcx.require_lang_item(LangItem::Freeze, cx.body.span);
// FIXME(#132279): Once we've got a typing mode which reveals opaque types using the HIR
// typeck results without causing query cycles, we should use this here instead of defining
// opaque types.
let typing_env = ty::TypingEnv::new(
cx.typing_env.param_env,
ty::TypingMode::analysis_in_body(cx.tcx, cx.body.source.def_id().expect_local()),
);
let did = cx.body.source.def_id().expect_local();

let typing_env = if cx.tcx.use_typing_mode_borrowck() {
cx.typing_env
} else {
ty::TypingEnv::new(cx.typing_env.param_env, TypingMode::analysis_in_body(cx.tcx, did))
};

let (infcx, param_env) = cx.tcx.infer_ctxt().build_with_typing_env(typing_env);
let ocx = ObligationCtxt::new(&infcx);
let obligation = Obligation::new(
Expand Down
29 changes: 29 additions & 0 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,35 @@ pub struct InferCtxt<'tcx> {
pub obligation_inspector: Cell<Option<ObligationInspector<'tcx>>>,
}

impl<'tcx> Drop for InferCtxt<'tcx> {
fn drop(&mut self) {
let mut inner = self.inner.borrow_mut();
let opaque_type_storage = &mut inner.opaque_type_storage;

// No need for the drop bomb when we're in TypingMode::Borrowck, and the InferCtxt doesn't consider regions.
// This is okay since in `Borrowck`, the only reason we care about opaques is in relation to regions.
// In some places *after* typeck, like in lints we use `TypingMode::Borrowck`
// to prevent defining opaque types and we simply don't care about regions.
match self.typing_mode_raw() {
TypingMode::Coherence
| TypingMode::Analysis { .. }
| TypingMode::PostBorrowckAnalysis { .. }
| TypingMode::PostAnalysis => {}
// In erased mode, the opaque type storage is always empty
TypingMode::ErasedNotCoherence(..) => {}
TypingMode::Borrowck { .. } => {
if !self.considering_regions {
return;
}
}
}

if !opaque_type_storage.is_empty() {
ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{opaque_type_storage:?}")));
Copy link
Copy Markdown
Member Author

@matthiaskrgr matthiaskrgr May 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}
}

/// See the `error_reporting` module for more details.
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable, TypeVisitable)]
pub enum ValuePairs<'tcx> {
Expand Down
10 changes: 1 addition & 9 deletions compiler/rustc_infer/src/infer/opaque_types/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::ops::Deref;
use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::undo_log::UndoLogs;
use rustc_middle::bug;
use rustc_middle::ty::{self, OpaqueTypeKey, ProvisionalHiddenType, Ty};
use rustc_middle::ty::{OpaqueTypeKey, ProvisionalHiddenType, Ty};
use tracing::instrument;

use crate::infer::snapshot::undo_log::{InferCtxtUndoLogs, UndoLog};
Expand Down Expand Up @@ -121,14 +121,6 @@ impl<'tcx> OpaqueTypeStorage<'tcx> {
}
}

impl<'tcx> Drop for OpaqueTypeStorage<'tcx> {
fn drop(&mut self) {
if !self.is_empty() {
ty::tls::with(|tcx| tcx.dcx().delayed_bug(format!("{:?}", self.opaque_types)));
}
}
}

pub struct OpaqueTypeTable<'a, 'tcx> {
storage: &'a mut OpaqueTypeStorage<'tcx>,

Expand Down
11 changes: 8 additions & 3 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,14 @@ impl<'tcx> LateContext<'tcx> {
/// The typing mode of the currently visited node. Use this when
/// building a new `InferCtxt`.
pub fn typing_mode(&self) -> TypingMode<'tcx> {
// FIXME(#132279): In case we're in a body, we should use a typing
// mode which reveals the opaque types defined by that body.
TypingMode::non_body_analysis()
if let Some(body_id) = self.enclosing_body
&& self.tcx.use_typing_mode_borrowck()
{
let def_id = self.tcx.hir_enclosing_body_owner(body_id.hir_id);
TypingMode::borrowck(self.tcx, def_id)
} else {
TypingMode::non_body_analysis()
}
}

pub fn typing_env(&self) -> TypingEnv<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/opaque_hidden_inferred_bound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'tcx> LateLintPass<'tcx> for OpaqueHiddenInferredBound {
}

let def_id = opaque.def_id.to_def_id();
let infcx = &cx.tcx.infer_ctxt().build(cx.typing_mode());
let infcx = &cx.tcx.infer_ctxt().ignoring_regions().build(cx.typing_mode());
// For every projection predicate in the opaque type's explicit bounds,
// check that the type that we're assigning actually satisfies the bounds
// of the associated type.
Expand Down
37 changes: 30 additions & 7 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,36 @@ impl<'tcx> Body<'tcx> {
}

pub fn typing_env(&self, tcx: TyCtxt<'tcx>) -> TypingEnv<'tcx> {
match self.phase {
// FIXME(#132279): we should reveal the opaques defined in the body during analysis.
MirPhase::Built | MirPhase::Analysis(_) => TypingEnv::new(
tcx.param_env(self.source.def_id()),
ty::TypingMode::non_body_analysis(),
),
MirPhase::Runtime(_) => TypingEnv::post_analysis(tcx, self.source.def_id()),
if tcx.use_typing_mode_borrowck() {
match self.phase {
MirPhase::Built if let Some(def_id) = self.source.def_id().as_local() => {
TypingEnv::new(
tcx.param_env(self.source.def_id()),
ty::TypingMode::borrowck(tcx, def_id),
)
}
MirPhase::Analysis(_) if let Some(def_id) = self.source.def_id().as_local() => {
TypingEnv::new(
tcx.param_env(self.source.def_id()),
ty::TypingMode::post_borrowck_analysis(tcx, def_id),
)
}
MirPhase::Built | MirPhase::Analysis(_) => {
// This branch happens for drop glue and fn ptr shims.
// FIXME: why do we do any of this analysis on drop glue etc?
// This should ideally all be skipped.
TypingEnv::post_analysis(tcx, self.source.def_id())
}
MirPhase::Runtime(_) => TypingEnv::post_analysis(tcx, self.source.def_id()),
}
} else {
match self.phase {
MirPhase::Built | MirPhase::Analysis(_) => TypingEnv::new(
tcx.param_env(self.source.def_id()),
ty::TypingMode::non_body_analysis(),
),
MirPhase::Runtime(_) => TypingEnv::post_analysis(tcx, self.source.def_id()),
}
}
}

Expand Down
6 changes: 0 additions & 6 deletions compiler/rustc_middle/src/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,6 @@ pub trait HasTyCtxt<'tcx>: HasDataLayout {

pub trait HasTypingEnv<'tcx> {
fn typing_env(&self) -> ty::TypingEnv<'tcx>;

/// FIXME(#132279): This method should not be used as in the future
/// everything should take a `TypingEnv` instead. Remove it as that point.
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.typing_env().param_env
}
}

impl<'tcx> HasDataLayout for TyCtxt<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3238,7 +3238,7 @@ pub(crate) struct DotDotDotRestPattern {
#[suggestion(
"for a rest pattern, use `..` instead of `...`",
style = "verbose",
code = "",
code = "..",
applicability = "machine-applicable"
)]
pub suggestion: Option<Span>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ impl<'a> Parser<'a> {
// The user probably mistook `...` for a rest pattern `..`.
self.dcx().emit_err(DotDotDotRestPattern {
span: lo,
suggestion: Some(lo.with_lo(lo.hi() - BytePos(1))),
suggestion: Some(lo),
var_args: None,
});
PatKind::Rest
Expand Down
70 changes: 38 additions & 32 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {

self.mention_default_field_values(source, ident, &mut err);

let mut not_publicly_reexported = false;
if let Some((this_res, outer_ident)) = outermost_res {
let mut import_suggestions = self.lookup_import_candidates(
outer_ident,
Expand All @@ -2332,7 +2331,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
);
// If we suggest importing a public re-export, don't point at the definition.
if point_to_def && ident.span != outer_ident.span {
not_publicly_reexported = true;
let label = errors::OuterIdentIsNotPubliclyReexported {
span: outer_ident.span,
outer_ident_descr: this_res.descr(),
Expand Down Expand Up @@ -2408,7 +2406,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let first_binding = decl;
let mut next_binding = Some(decl);
let mut next_ident = ident;
let mut path = vec![];
while let Some(binding) = next_binding {
let name = next_ident;
next_binding = match binding.kind {
Expand All @@ -2428,18 +2425,18 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
};

match binding.kind {
DeclKind::Import { import, .. } => {
for segment in import.module_path.iter().skip(1) {
// Don't include `{{root}}` in suggestions - it's an internal symbol
// that should never be shown to users.
if segment.ident.name != kw::PathRoot {
path.push(segment.ident);
}
}
sugg_paths.push((
path.iter().cloned().chain(std::iter::once(ident)).collect::<Vec<_>>(),
true, // re-export
));
DeclKind::Import { source_decl, import, .. } => {
// Don't include `{{root}}` in suggestions - it's an internal symbol
// that should never be shown to users.
let path = import
.module_path
.iter()
.filter(|seg| seg.ident.name != kw::PathRoot)
.map(|seg| seg.ident.clone())
.chain(std::iter::once(ident))
.collect::<Vec<_>>();
let through_reexport = !matches!(source_decl.kind, DeclKind::Def(_));
sugg_paths.push((path, through_reexport));
}
DeclKind::Def(_) => {}
}
Expand Down Expand Up @@ -2472,25 +2469,34 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
};
err.subdiagnostic(note);
}
// We prioritize shorter paths, non-core imports and direct imports over the alternatives.
sugg_paths.sort_by_key(|(p, reexport)| (p.len(), p[0].name == sym::core, *reexport));
for (sugg, reexport) in sugg_paths {
if not_publicly_reexported {
// The suggestion replaces `dedup_span` with a path reaching the failing ident.
// That's valid only when
// 1) the failing ident is the imported leaf, otherwise `as` renames and trailing segments
// get dropped, and
// 2) the use isn't nested, otherwise `dedup_span` is one ident in `{...}`.
//
// See issue #156060.
let can_replace_use =
!single_nested && !outermost_res.is_some_and(|(_, outer)| outer.span != ident.span);
if can_replace_use {
// We prioritize shorter paths, non-core imports and direct imports over the
// alternatives.
sugg_paths.sort_by_key(|(p, reexport)| (p.len(), p[0].name == sym::core, *reexport));
for (sugg, reexport) in sugg_paths {
if sugg.len() <= 1 {
// A single path segment suggestion is wrong. This happens on circular
// imports. `tests/ui/imports/issue-55884-2.rs`
continue;
}
let path = join_path_idents(sugg);
let sugg = if reexport {
errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path }
} else {
errors::ImportIdent::Directly { span: dedup_span, ident, path }
};
err.subdiagnostic(sugg);
break;
}
if sugg.len() <= 1 {
// A single path segment suggestion is wrong. This happens on circular imports.
// `tests/ui/imports/issue-55884-2.rs`
continue;
}
let path = join_path_idents(sugg);
let sugg = if reexport {
errors::ImportIdent::ThroughReExport { span: dedup_span, ident, path }
} else {
errors::ImportIdent::Directly { span: dedup_span, ident, path }
};
err.subdiagnostic(sugg);
break;
}

err.emit();
Expand Down
12 changes: 7 additions & 5 deletions src/doc/rustc-dev-guide/ci/sembr/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ fn main() -> Result<()> {
continue;
}
let old = fs::read_to_string(&path)?;
let new = lengthen_lines(&comply(&old), cli.line_length_limit);
let new = comply(&old);
if new == old {
compliant.push(path.clone());
} else if cli.overwrite {
fs::write(&path, new)?;
made_compliant.push(path.clone());
} else {
not_compliant.push(path.clone());
if cli.overwrite {
fs::write(&path, lengthen_lines(&new, cli.line_length_limit))?;
made_compliant.push(path.clone());
} else {
not_compliant.push(path.clone());
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide/rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f53b654a8882fd5fc036c4ca7a4ff41ce32497a6
f2b291d902bfde7d7f209fc3a64908134bcef201
8 changes: 3 additions & 5 deletions src/doc/rustc-dev-guide/src/autodiff/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ For the meantime, you can download up-to-date builds to enable `std::autodiff` o
**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.
In the past you could also download builds for **Apple** (aarch64-apple), however they are not usable at the moment.

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.
Expand All @@ -24,7 +24,7 @@ For now, you'll have to manually download and copy 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`].
Please (currently) build it from source.

## Installation guide for Nix user.

Expand Down Expand Up @@ -111,8 +111,7 @@ docker cp <dockerid>:/rust/build/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.
Afterwards we can create a new (pre-release) tag on the EnzymeAD/rust repository and make a PR against the EnzymeAD/enzyme-explorer repository to update the tag.
Remember to ping `tgymnich` on the PR to run his update script.
Note: We should archive EnzymeAD/rust and update the instructions here.
The explorer should soon
be able to get the rustc toolchain from the official rust servers.
The explorer should soon be able to get the rustc toolchain from the official rust servers.


## Build instruction for Enzyme itself
Expand Down Expand Up @@ -144,5 +143,4 @@ This will build Enzyme, and you can find it in `Enzyme/enzyme/build/lib/<LLD/Cla
(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
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
You might want to build and package up the compiler for distribution.
You’ll want to run this command to do it:

```bash
```console
./x dist
```

# Install from source

You might want to prefer installing Rust (and tools configured in your configuration)
by building from source. If so, you want to run this command:
by building from source.
If so, you want to run this command:

```bash
```console
./x install
```

Expand All @@ -24,8 +25,9 @@ by building from source. If so, you want to run this command:
invoke it with `rustc +foo ...` (where ... represents the rest of the arguments).

Instead of installing Rust (and tools in your config file) globally, you can set `DESTDIR`
environment variable to change the installation path. If you want to set installation paths
environment variable to change the installation path.
If you want to set installation paths
more dynamically, you should prefer [install options] in your config file to achieve that.

[create-rustup-toolchain]: ./how-to-build-and-run.md#creating-a-rustup-toolchain
[install options]: https://github.com/rust-lang/rust/blob/f7c8928f035370be33463bb7f1cd1aeca2c5f898/config.example.toml#L422-L442
[install options]: https://github.com/rust-lang/rust/blob/f7c8928f035370be33463bb7f1cd1aeca2c5f898/config.example.toml#L422-L442
Loading
Loading