Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bff5a0e
core: fix the docs of PanicInfo::location
valentynkit Aug 31, 2026
5040a04
docs: PanicInfo::location handling example with no location
valentynkit Sep 15, 2026
9379da6
Don't imply incorrect things about `Global` in the docs of `System`
maxdexh Sep 25, 2026
4ce013c
Align the fallback message in panic location examples
valentynkit Sep 27, 2026
99cc8cf
document safety requirements for atomic intrinsics
yilin0518 Sep 28, 2026
0012416
Add safety comments for alloc::str
yilin0518 Sep 28, 2026
583e737
Mark Rc strong/weak count methods must_use
jeffs Sep 29, 2026
06660e6
simplify and clarify fs::set_permissions_nofollow tests
RalfJung Sep 30, 2026
1188653
create `debugger_visualizer` assign group
Walnut356 Oct 1, 2026
64f5516
Add `SplitPathsRef` implementation for motor
maxdexh Oct 1, 2026
a44e8af
Move media & home dirs tests to fs tests.
Oct 1, 2026
b999348
Fix capitalisation issues in fmt documentation
DeaconSteiner Oct 2, 2026
19fad96
chore: fix codegen backend comment
TechnoPorg Oct 2, 2026
afc0663
add Android support based on fallback path
RalfJung Sep 30, 2026
56bb244
Correctly link to enum variants when present in `Cache::external_path…
GuillaumeGomez Oct 2, 2026
73b2a84
Move `rustdoc-html` tests into the right location
GuillaumeGomez Oct 3, 2026
d78744a
Remove `@ !has` annotations from `tests/rustdoc-html/reexport/doc-hid…
GuillaumeGomez Oct 3, 2026
c1259d2
Point at found impl in "not general enough"
estebank Sep 30, 2026
3862c50
Tweak "not general enough" rendering
estebank Sep 30, 2026
cf56d12
Tweak wording
estebank Sep 30, 2026
ca762cf
Remove redundant information
estebank Sep 30, 2026
337f98d
Tweak note to include trait/impl when appropriate
estebank Sep 30, 2026
f296fdf
implement FCW for `rustc_allowed_through_unstable_modules` items
mejrs Oct 3, 2026
0103c94
When compiling without a specified `--edition`, emit a `eprintln` mes…
estebank Jun 18, 2026
465aca6
Route `fn_hir_id` into `lower_fn_decl`
JonathanBrouwer Sep 14, 2026
539bfe3
Add regression tests
JonathanBrouwer Sep 14, 2026
9c9d810
Lower attributes for functions without bodies
JonathanBrouwer Sep 14, 2026
143dcb5
some crashes fixed with next-solver
lcnr Oct 3, 2026
36dede8
Rollup merge of #158102 - estebank:note-default-edition, r=jieyouxu
jhpratt Oct 4, 2026
dc179d7
Rollup merge of #162761 - JonathanBrouwer:lower-param-attrs, r=jdonsz…
jhpratt Oct 4, 2026
10ea96f
Rollup merge of #163161 - mejrs:deprecated_intrinsic_imports, r=nneth…
jhpratt Oct 4, 2026
c49221b
Rollup merge of #163613 - estebank:not-general-enough, r=JonathanBrouwer
jhpratt Oct 4, 2026
171a9aa
Rollup merge of #162062 - valentynkit:docs/panic-info-location, r=Mar…
jhpratt Oct 4, 2026
cab3473
Rollup merge of #163140 - yilin0518:fix_atomic_ops, r=Mark-Simulacrum
jhpratt Oct 4, 2026
e08099d
Rollup merge of #163342 - maxdexh:global-and-system-are-not-the-same,…
jhpratt Oct 4, 2026
2f03ab2
Rollup merge of #163445 - yilin0518:fix_untidy, r=Mark-Simulacrum
jhpratt Oct 4, 2026
1459305
Rollup merge of #163503 - jeffs:must-use-strong-count, r=Mark-Simulacrum
jhpratt Oct 4, 2026
6728311
Rollup merge of #163548 - RalfJung:set_permissions_nofollow-tests, r=…
jhpratt Oct 4, 2026
a7b867d
Rollup merge of #163585 - Walnut356:di_assign, r=Mark-Simulacrum
jhpratt Oct 4, 2026
9bc02a9
Rollup merge of #163597 - maxdexh:motor-split-paths-ref, r=Mark-Simul…
jhpratt Oct 4, 2026
0aab29c
Rollup merge of #163602 - sardok:sgx_disable_test_dirs, r=Mark-Simula…
jhpratt Oct 4, 2026
9d0d75c
Rollup merge of #163667 - DeaconSteiner:issue-159751-fmt, r=Mark-Simu…
jhpratt Oct 4, 2026
969f99c
Rollup merge of #163682 - GuillaumeGomez:jump-to-variant, r=Urgau
jhpratt Oct 4, 2026
dd6b5db
Rollup merge of #163683 - TechnoPorg:push-oyprxnttwmmo, r=Mark-Simula…
jhpratt Oct 4, 2026
ab7da91
Rollup merge of #163703 - GuillaumeGomez:clean-rustdoc-html-tests, r=…
jhpratt Oct 4, 2026
877022b
Rollup merge of #163725 - lcnr:fixes-crashes, r=lqd
jhpratt Oct 4, 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
22 changes: 19 additions & 3 deletions compiler/rustc_ast_lowering/src/expr/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use rustc_hir::HirId;
use rustc_span::{Span, span_bug};

use super::{LoweringContext, MoveExprState};
use crate::FnDeclKind;
use crate::diagnostics::{ClosureCannotBeStatic, CoroutineTooManyParameters};
use crate::{DiscardParams, FnDeclKind};

impl<'hir> LoweringContext<'_, 'hir> {
// Entry point for `ExprKind::Closure`. Plain closures go through
Expand Down Expand Up @@ -133,6 +133,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
binder,
capture_clause,
closure_id,
expr_hir_id,
constness,
movability,
decl,
Expand All @@ -159,6 +160,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
binder: &ClosureBinder,
capture_clause: CaptureBy,
closure_id: NodeId,
closure_hir_id: HirId,
constness: Const,
movability: Movability,
decl: &FnDecl,
Expand Down Expand Up @@ -205,7 +207,14 @@ impl<'hir> LoweringContext<'_, 'hir> {

let bound_generic_params = self.lower_lifetime_binder(closure_id, generic_params);
// Lower outside new scope to preserve `is_in_loop_condition`.
let fn_decl = self.lower_fn_decl(decl, closure_id, FnDeclKind::Closure, None);
let fn_decl = self.lower_fn_decl(
decl,
closure_id,
closure_hir_id,
FnDeclKind::Closure,
None,
DiscardParams::No,
);

let c = self.arena.alloc(hir::Closure {
def_id: closure_def_id,
Expand Down Expand Up @@ -328,7 +337,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
// We need to lower the declaration outside the new scope, because we
// have to conserve the state of being inside a loop condition for the
// closure argument types.
let fn_decl = self.lower_fn_decl(&decl, closure_id, FnDeclKind::Closure, None);
let fn_decl = self.lower_fn_decl(
&decl,
closure_id,
closure_hir_id,
FnDeclKind::Closure,
None,
DiscardParams::No,
);

if let Const::Yes(span) = constness {
self.dcx().span_err(span, "const coroutines are not supported");
Expand Down
36 changes: 30 additions & 6 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use super::diagnostics::{
};
use super::stability::{enabled_names, gate_unstable_abi};
use super::{
FnDeclKind, GenericArgsMode, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
RelaxedBoundForbiddenReason, RelaxedBoundPolicy,
DiscardParams, FnDeclKind, GenericArgsMode, ImplTraitContext, ImplTraitPosition,
LoweringContext, ParamMode, RelaxedBoundForbiddenReason, RelaxedBoundPolicy,
};
use crate::diagnostics::{ConstComptimeFn, ResolvingRestrictionKind, RestrictionAncestorOnly};

Expand Down Expand Up @@ -278,7 +278,14 @@ impl<'hir> LoweringContext<'_, 'hir> {

let itctx = ImplTraitContext::Universal;
let (generics, decl) = this.lower_generics(generics, itctx, |this| {
this.lower_fn_decl(decl, id, FnDeclKind::Fn, coroutine_marker)
this.lower_fn_decl(
decl,
id,
hir_id,
FnDeclKind::Fn,
coroutine_marker,
if body.is_none() { DiscardParams::Yes } else { DiscardParams::No },
)
});
let sig = hir::FnSig {
decl,
Expand Down Expand Up @@ -616,7 +623,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
let (generics, (decl, fn_args)) = self.lower_generics(generics, itctx, |this| {
(
// Disallow `impl Trait` in foreign items.
this.lower_fn_decl(fdec, i.id, FnDeclKind::ExternFn, None),
// Parameters are discarded because foreign functions don't have a body
this.lower_fn_decl(
fdec,
i.id,
hir_id,
FnDeclKind::ExternFn,
None,
DiscardParams::Yes,
),
this.lower_fn_params_to_idents(fdec),
)
});
Expand Down Expand Up @@ -838,9 +853,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
generics,
sig,
i.id,
hir_id,
FnDeclKind::Trait,
sig.header.coroutine_marker,
attrs,
// Parameters are discarded for functions without a body
DiscardParams::Yes,
);
if define_opaque.is_some() {
self.dcx().span_err(
Expand Down Expand Up @@ -878,9 +896,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
generics,
sig,
i.id,
hir_id,
FnDeclKind::Trait,
sig.header.coroutine_marker,
attrs,
DiscardParams::No,
);
self.lower_define_opaque(hir_id, &define_opaque);
(
Expand Down Expand Up @@ -1088,9 +1108,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
generics,
sig,
i.id,
hir_id,
if is_in_trait_impl { FnDeclKind::Impl } else { FnDeclKind::Inherent },
sig.header.coroutine_marker,
attrs,
if body.is_none() { DiscardParams::Yes } else { DiscardParams::No },
);
self.lower_define_opaque(hir_id, &define_opaque);

Expand Down Expand Up @@ -1533,15 +1555,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
&mut self,
generics: &Generics,
sig: &FnSig,
id: NodeId,
node_id: NodeId,
hir_id: HirId,
kind: FnDeclKind,
coroutine_marker: Option<CoroutineMarker>,
attrs: &[rustc_attr_ir::Attribute],
discard_params: DiscardParams,
) -> (&'hir hir::Generics<'hir>, hir::FnSig<'hir>) {
let header = self.lower_fn_header(sig.header, hir::Safety::Safe, attrs);
let itctx = ImplTraitContext::Universal;
let (generics, decl) = self.lower_generics(generics, itctx, |this| {
this.lower_fn_decl(&sig.decl, id, kind, coroutine_marker)
this.lower_fn_decl(&sig.decl, node_id, hir_id, kind, coroutine_marker, discard_params)
});
(generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })
}
Expand Down
45 changes: 38 additions & 7 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,14 @@ enum GenericArgsMode {
Silence,
}

#[derive(Debug, Copy, Clone)]
enum DiscardParams {
/// Should be used for functions without a body. Lowers the attributes on the parameter and then discards them.
Yes,
/// Should be used for functions with a body. Does not lower the attributes, as lowering of the parameters is done by `lower_body`.
No,
}

impl<'hir> LoweringContext<'_, 'hir> {
fn create_def(
&mut self,
Expand Down Expand Up @@ -1547,14 +1555,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::TyKind::Path(path)
}
TyKind::FnPtr(f) => {
let hir_id = self.lower_node_id(t.id);
let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
let kind = hir::TyKind::FnPtr(self.arena.alloc(hir::FnPtrTy {
generic_params,
safety: self.lower_safety(f.safety, hir::Safety::Safe),
abi: self.lower_extern(f.ext),
decl: self.lower_fn_decl(&f.decl, t.id, FnDeclKind::Pointer, None),
decl: self.lower_fn_decl(
&f.decl,
t.id,
hir_id,
FnDeclKind::Pointer,
None,
DiscardParams::Yes,
),
param_idents: self.lower_fn_params_to_idents(&f.decl),
}))
}));
return hir::Ty { kind, span: self.lower_span(t.span), hir_id };
}
TyKind::UnsafeBinder(f) => {
let generic_params = self.lower_lifetime_binder(t.id, &f.generic_params);
Expand Down Expand Up @@ -1900,18 +1917,26 @@ impl<'hir> LoweringContext<'_, 'hir> {
///
/// `decl`: the unlowered (AST) function declaration.
///
/// `fn_node_id`: `impl Trait` arguments are lowered into generic parameters on the given
/// `NodeId`.
/// `fn_node_id`: Node Id of the function.
///
/// `fn_hir_id`: Hir Id of the function. Used for attribute parsing.
///
/// `kind`: The kind of function.
///
/// `transform_return_type`: if `Some`, applies some conversion to the return type, such as is
/// needed for `async fn` and `gen fn`. See [`CoroutineKind`] for more details.
/// `coro`: If the function is a coroutine, information about the coroutine.
///
/// `discard_params`: if `DiscardParams::Yes`, the parameters are lowered and then discarded. Set this to `DiscardParams::Yes`
/// for functions without bodies, as attributes on parameters are otherwise not validated.
/// Set this to `DiscardParams::No` for functions with bodies, as lowering of the parameters is done by `lower_body`.
#[instrument(level = "debug", skip(self))]
fn lower_fn_decl(
&mut self,
decl: &FnDecl,
fn_node_id: NodeId,
fn_hir_id: HirId,
kind: FnDeclKind,
coro: Option<CoroutineMarker>,
discard_params: DiscardParams,
) -> &'hir hir::FnDecl<'hir> {
let c_variadic = decl.c_variadic();
let mut splatted = decl.splatted();
Expand All @@ -1926,6 +1951,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
inputs = &inputs[..inputs.len() - 1];
}
let inputs = self.arena.alloc_from_iter(inputs.iter().map(|param| {
if let DiscardParams::Yes = discard_params {
// FIXME This uses `fn_hir_id`, which is not correct, it should use the parameter hir id instead
// The parameter is currently not lowered for functions without bodies, so there is no place to store the lowered hir id
// This should be fixed by storing function parameters in the `hir::FnSig` instead of `hir::Body`
self.lower_attrs(fn_hir_id, &param.attrs, param.span, Target::Param);
}
let itctx = match kind {
FnDeclKind::Fn | FnDeclKind::Inherent | FnDeclKind::Impl | FnDeclKind::Trait => {
ImplTraitContext::Universal
Expand Down
14 changes: 12 additions & 2 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,24 @@ pub fn compiler_entrypoint(at_args: &[String], callbacks: &mut (dyn Callbacks +

let args = args::arg_expand_all(&default_early_dcx, at_args);

// For the purposes of checking that an --edition was passed, we only emit a message if the only
// argument passed to rustc is a file name.
let warn_unspecified_edition = match &args[..] {
[] => false,
// We explicitly don't emit the note if we're consuming code from stdin, or passing non-file
// flags. This can happen on some cargo invocations too.
[name] if name.starts_with("-") => false,
[_] => true,
_ => false,
};
let (matches, help_only) = match handle_options(&default_early_dcx, &args) {
HandledOptions::None => return,
HandledOptions::Normal(matches) => (matches, false),
HandledOptions::HelpOnly(matches) => (matches, true),
};

let sopts = config::build_session_options(&mut default_early_dcx, &matches);
// fully initialize ice path static once unstable options are available as context
let sopts =
config::build_session_options(&mut default_early_dcx, &matches, warn_unspecified_edition);
let ice_file = ice_path_with_config(Some(&sopts.unstable_opts)).clone();

if let Some(ref code) = matches.opt_str("explain") {
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_error_messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ impl From<Span> for MultiSpan {
}
}

impl From<Option<Span>> for MultiSpan {
fn from(span: Option<Span>) -> MultiSpan {
MultiSpan::from_spans(span.into_iter().collect())
}
}

impl From<Vec<Span>> for MultiSpan {
fn from(spans: Vec<Span>) -> MultiSpan {
MultiSpan::from_spans(spans)
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ where
{
let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());
let matches = optgroups().parse(args).unwrap();
let sessopts = build_session_options(&mut early_dcx, &matches);
let sessopts = build_session_options(&mut early_dcx, &matches, true);
let target = rustc_session::config::build_target_config(
&early_dcx,
&sessopts.target_triple,
Expand Down Expand Up @@ -942,7 +942,7 @@ fn test_edition_parsing() {
let mut early_dcx = EarlyDiagCtxt::new(ErrorOutputType::default());

let matches = optgroups().parse(&["--edition=2018".to_string()]).unwrap();
let sessopts = build_session_options(&mut early_dcx, &matches);
let sessopts = build_session_options(&mut early_dcx, &matches, false);
assert!(sessopts.edition == Edition::Edition2018)
}

Expand All @@ -953,7 +953,7 @@ fn test_assumptions_on_binders_enables_next_solver_globally() {

// `-Zassumptions-on-binders` alone enables the next solver globally.
let matches = optgroups().parse(&["-Zassumptions-on-binders".to_string()]).unwrap();
let opts = build_session_options(&mut early_dcx, &matches);
let opts = build_session_options(&mut early_dcx, &matches, false);
assert!(opts.unstable_opts.assumptions_on_binders);
assert_eq!(opts.unstable_opts.next_solver, globally);

Expand All @@ -964,7 +964,7 @@ fn test_assumptions_on_binders_enables_next_solver_globally() {
["-Znext-solver=coherence".to_string(), "-Zassumptions-on-binders".to_string()],
] {
let matches = optgroups().parse(&args).unwrap();
let opts = build_session_options(&mut early_dcx, &matches);
let opts = build_session_options(&mut early_dcx, &matches, false);
assert!(opts.unstable_opts.assumptions_on_binders);
assert_eq!(opts.unstable_opts.next_solver, globally);
}
Expand All @@ -977,7 +977,7 @@ fn test_assumptions_on_binders_enables_next_solver_globally() {
["-Znext-solver=no".to_string(), "-Zassumptions-on-binders".to_string()],
] {
let matches = optgroups().parse(&args).unwrap();
let opts = build_session_options(&mut early_dcx, &matches);
let opts = build_session_options(&mut early_dcx, &matches, false);
assert!(opts.unstable_opts.assumptions_on_binders);
assert_eq!(opts.unstable_opts.next_solver, globally);
}
Expand Down
26 changes: 26 additions & 0 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub mod hardwired {
UNREACHABLE_PATTERNS,
UNSAFE_ATTR_OUTSIDE_UNSAFE,
UNSAFE_OP_IN_UNSAFE_FN,
UNSTABLE_IMPORTS,
UNSTABLE_NAME_COLLISIONS,
UNSTABLE_SYNTAX_PRE_EXPANSION,
UNSUPPORTED_CALLING_CONVENTIONS,
Expand Down Expand Up @@ -5857,3 +5858,28 @@ declare_lint! {
"`repr(C, align)` types nested inside `repr(C, packed)` types \
do not always have a C-compatible layout",
}

declare_lint! {
/// The `unstable_imports` lints detects imports that go through unstable modules.
///
/// ### Example
///
/// ```rust
/// use core::intrinsics::transmute;
/// ```
///
/// {{produces}}
///
/// ### Explanation
///
/// Previous versions of Rust accidentally allowed certain imports through unstable modules
/// because stability information of modules was not correctly accounted for if the imported
/// item was stable itself.
pub UNSTABLE_IMPORTS,
Deny,
"lints on accidentally allowed unstable imports",
@future_incompatible = FutureIncompatibleInfo {
reason: fcw!(FutureReleaseError # 163160),
report_in_deps: true,
};
}
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/diagnostics/subdiagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ impl<'parent, 'a> SubdiagnosticDeriveVariantBuilder<'parent, 'a> {
let binding = info.binding.binding.clone();
// FIXME(#100717): support `Option<Span>` on `primary_span` like in the
// diagnostic derive
if !matches!(info.ty, FieldInnerTy::Plain(_)) {
if !matches!(info.ty, FieldInnerTy::Plain(_) | FieldInnerTy::Option(_)) {
throw_invalid_attr!(attr, |diag| {
let diag = diag.note("there must be exactly one primary span");

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use rustc_hir::{
UsePath, Variant,
};
use rustc_lint_defs::builtin::{
DEPRECATED, DUPLICATE_FEATURES, INEFFECTIVE_UNSTABLE_REEXPORTS,
INEFFECTIVE_UNSTABLE_TRAIT_IMPL, STABLE_FEATURES,
DUPLICATE_FEATURES, INEFFECTIVE_UNSTABLE_REEXPORTS, INEFFECTIVE_UNSTABLE_TRAIT_IMPL,
STABLE_FEATURES, UNSTABLE_IMPORTS,
};
use rustc_middle::hir::nested_filter;
use rustc_middle::middle::lib_features::{FeatureStability, LibFeatures};
Expand Down Expand Up @@ -1079,7 +1079,7 @@ impl<'tcx> Checker<'tcx> {
suggestion,
};
self.tcx.emit_node_span_lint(
DEPRECATED,
UNSTABLE_IMPORTS,
id,
method_span.unwrap_or(span),
diag,
Expand Down
Loading
Loading