Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e264a92
gracefully handle invalid string/vec
Walnut356 Apr 27, 2026
378a8c3
Install additional LLVM DLL on Windows
mati865 May 6, 2026
63d1985
Allow forbidden target features to be hard errors
wesleywiser Jan 28, 2026
23bd862
move string read logic to standalone function
Walnut356 Apr 28, 2026
6a54c92
compiler: fix duplicated "the" in two doc-comments
lphuc2250gma May 14, 2026
81e2d25
Remove stale RTN FIXME for assoc item constraint fallback
P8L1 May 19, 2026
2efbdb9
Treat THIR reborrow as rvalue during MIR place categorization
P8L1 May 21, 2026
a29df2a
Rustfmt: format const trait impls to `const impl` for syntax transition
fee1-dead May 22, 2026
5d39414
Privacy: enqueue type alias
Bryanskiy May 22, 2026
a83eba4
Visit delegation body under elided-infer lifetime rib
aerooneqq May 22, 2026
ee30e61
Move comments to top of test file
P8L1 May 22, 2026
4f12864
make `lint_index` field not Optional in LintExpectationId
Bryntet May 22, 2026
42bd6de
Rollup merge of #155509 - Walnut356:string_crash, r=Mark-Simulacrum
JonathanBrouwer May 22, 2026
827f692
Rollup merge of #156229 - mati865:llvm-mingw-libllvm-fix, r=clubby789
JonathanBrouwer May 22, 2026
7ab3168
Rollup merge of #152821 - wesleywiser:add_forbidden_ctarget_feature_h…
JonathanBrouwer May 22, 2026
2ad4f83
Rollup merge of #156560 - lphuc2250gma:fix/duplicated-the-in-compiler…
JonathanBrouwer May 22, 2026
5b0cfaf
Rollup merge of #156725 - P8L1:fix/rtn-assoc-ty-parentheses-diagnosti…
JonathanBrouwer May 22, 2026
59a0d08
Rollup merge of #156803 - P8L1:fix/reborrow-thir-mir-rvalue-contract,…
JonathanBrouwer May 22, 2026
1dcd2ae
Rollup merge of #156815 - fee1-dead-contrib:rustfmt-const-traits, r=y…
JonathanBrouwer May 22, 2026
fc73322
Rollup merge of #156818 - Bryanskiy:privacy_alias, r=petrochenkov
JonathanBrouwer May 22, 2026
7908120
Rollup merge of #156820 - aerooneqq:delegation-visit-body-elided-infe…
JonathanBrouwer May 22, 2026
29eaf53
Rollup merge of #156829 - Bryntet:levels_options_removal, r=nnethercote
JonathanBrouwer May 22, 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
2 changes: 0 additions & 2 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1197,8 +1197,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
}
} else {
self.emit_bad_parenthesized_trait_in_assoc_ty(data);
// FIXME(return_type_notation): we could issue a feature error
// if the parens are empty and there's no return type.
self.lower_angle_bracketed_parameter_data(
&data.as_angle_bracketed_args(),
ParamMode::Explicit,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/var_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tracing::debug;
use crate::region_infer::RegionInferenceContext;

impl<'tcx> RegionInferenceContext<'tcx> {
/// Find the the name and span of the variable corresponding to the given region.
/// Find the name and span of the variable corresponding to the given region.
/// The returned var will also be ensured to actually be used in `body`.
pub(crate) fn get_var_name_and_span_for_region(
&self,
Expand Down
11 changes: 7 additions & 4 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1220,14 +1220,17 @@ pub(crate) struct UnstableCTargetFeature<'a> {

#[derive(Diagnostic)]
#[diag("target feature `{$feature}` cannot be {$enabled} with `-Ctarget-feature`: {$reason}")]
#[note(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
#[note("for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>")]
pub(crate) struct ForbiddenCTargetFeature<'a> {
pub feature: &'a str,
pub enabled: &'a str,
pub reason: &'a str,
#[note(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
#[note(
"for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>"
)]
pub future_compat_note: bool,
}

pub(crate) struct TargetFeatureDisableOrEnable<'a> {
Expand Down
13 changes: 10 additions & 3 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,19 @@ pub fn cfg_target_feature<'a, const N: usize>(
sess.dcx().emit_warn(unknown_feature);
}
Some((_, stability, _)) => {
if let Err(reason) = stability.toggle_allowed() {
sess.dcx().emit_warn(errors::ForbiddenCTargetFeature {
if let Stability::Forbidden { reason, hard_error } = stability {
let diag = errors::ForbiddenCTargetFeature {
feature: base_feature,
enabled: if enable { "enabled" } else { "disabled" },
reason,
});
future_compat_note: !hard_error,
};

if *hard_error {
sess.dcx().emit_err(diag);
} else {
sess.dcx().emit_warn(diag);
}
} else if stability.requires_nightly(/* in_cfg */ false).is_some() {
// An unstable feature. Warn about using it. It makes little sense
// to hard-error here since we just warn about fully unknown
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn check_expectations(tcx: TyCtxt<'_>, tool_filter: Option<Symbol>) {
(tcx.hir_attrs(id.hir_id)[id.attr_index as usize].id(), id.lint_index)
}
};
(attr_id, lint_index.expect("fulfilled expectations must have a lint index"))
(attr_id, lint_index)
};

let fulfilled_expectations: FxHashSet<_> =
Expand Down
12 changes: 4 additions & 8 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub trait LintLevelsProvider {
&self,
attr_id: AttrId,
attr_index: usize,
lint_index: Option<u16>,
lint_index: u16,
) -> Self::LintExpectationId;
}

Expand All @@ -258,7 +258,7 @@ impl LintLevelsProvider for TopDown {
&self,
attr_id: AttrId,
_attr_index: usize,
lint_index: Option<u16>,
lint_index: u16,
) -> Self::LintExpectationId {
UnstableLintExpectationId { attr_id, lint_index }
}
Expand Down Expand Up @@ -296,7 +296,7 @@ impl LintLevelsProvider for LintLevelQueryMap<'_> {
&self,
_attr_id: AttrId,
attr_index: usize,
lint_index: Option<u16>,
lint_index: u16,
) -> Self::LintExpectationId {
let attr_index = attr_index.try_into().unwrap();
StableLintExpectationId { hir_id: self.cur, attr_index, lint_index }
Expand Down Expand Up @@ -740,11 +740,7 @@ where
// `Expect` is the only lint level with a `LintExpectationId` that can be created
// from an attribute.
let lint_id = (level == Level::Expect).then(|| {
self.provider.mk_lint_expectation_id(
attr.id(),
attr_index,
Some(lint_index as u16),
)
self.provider.mk_lint_expectation_id(attr.id(), attr_index, lint_index as u16)
});

let sp = li.span();
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub enum LintExpectationId {
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Encodable, Decodable)]
pub struct UnstableLintExpectationId {
pub attr_id: AttrId,
pub lint_index: Option<u16>,
pub lint_index: u16,
}

impl From<UnstableLintExpectationId> for LintExpectationId {
Expand All @@ -125,7 +125,7 @@ impl From<UnstableLintExpectationId> for LintExpectationId {
pub struct StableLintExpectationId {
pub hir_id: HirId,
pub attr_index: u16,
pub lint_index: Option<u16>,
pub lint_index: u16,
}

impl StableHash for StableLintExpectationId {
Expand All @@ -135,7 +135,7 @@ impl StableHash for StableLintExpectationId {

hir_id.stable_hash(hcx, hasher);
attr_index.stable_hash(hcx, hasher);
lint_index.expect("must be filled to call `stable_hash`").stable_hash(hcx, hasher);
lint_index.stable_hash(hcx, hasher);
}
}

Expand Down
10 changes: 4 additions & 6 deletions compiler/rustc_mir_build/src/builder/expr/as_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,19 +583,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
| ExprKind::ThreadLocalRef(_)
| ExprKind::Call { .. }
| ExprKind::ByUse { .. }
// A reborrow is an rvalue. If a place is needed for it, materialize
// the rvalue in a temporary instead of treating the reborrow
// expression itself as an assignable place.
| ExprKind::Reborrow { .. }
| ExprKind::WrapUnsafeBinder { .. } => {
// these are not places, so we need to make a temporary.
debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Place)));
let temp_lifetime = this.region_scope_tree.temporary_scope(expr.temp_scope_id);
let temp = unpack!(block = this.as_temp(block, temp_lifetime, expr_id, mutability));
block.and(PlaceBuilder::from(temp))
}
ExprKind::Reborrow { .. } => {
// FIXME(reborrow): it should currently be impossible to end up evaluating a
// Reborrow expression as a place. That might not in the future, but what this then
// evaluates to requires further thought.
unreachable!();
}
}
}

Expand Down
7 changes: 5 additions & 2 deletions compiler/rustc_mir_build/src/builder/expr/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ impl Category {
| ExprKind::PlaceTypeAscription { .. }
| ExprKind::ValueTypeAscription { .. }
| ExprKind::PlaceUnwrapUnsafeBinder { .. }
| ExprKind::ValueUnwrapUnsafeBinder { .. }
| ExprKind::Reborrow { .. } => Some(Category::Place),
| ExprKind::ValueUnwrapUnsafeBinder { .. } => Some(Category::Place),

ExprKind::LogicalOp { .. }
| ExprKind::Match { .. }
Expand All @@ -70,6 +69,10 @@ impl Category {
| ExprKind::Repeat { .. }
| ExprKind::Assign { .. }
| ExprKind::AssignOp { .. }
// A reborrow expression produces a value represented in MIR as
// `Rvalue::Reborrow`. Its source may be a place, but the reborrow
// expression itself does not denote an assignable place.
| ExprKind::Reborrow { .. }
| ExprKind::ThreadLocalRef(_)
| ExprKind::WrapUnsafeBinder { .. } => Some(Category::Rvalue(RvalueFunc::AsRvalue)),

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> {
}
}

DefKind::TraitAlias | DefKind::Fn => {
DefKind::TraitAlias | DefKind::Fn | DefKind::TyAlias => {
self.ev.queue.insert(def_id);
}

Expand All @@ -808,7 +808,6 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> {

// Can't be reached
DefKind::Impl { .. }
| DefKind::TyAlias
| DefKind::Field
| DefKind::Variant
| DefKind::Static { .. }
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3937,7 +3937,9 @@ impl<'a, 'ast, 'ra, 'tcx> LateResolutionVisitor<'a, 'ast, 'ra, 'tcx> {

//As we lower target_expr_template body to a body of a function we need a label rib (#148889)
this.with_label_rib(RibKind::FnOrCoroutine, |this| {
this.visit_block(body);
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Infer), |this| {
this.visit_block(body);
});
});
});
}
Expand Down
62 changes: 49 additions & 13 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ pub enum Stability {
/// set in the target spec. It is never set in `cfg(target_feature)`. Used in
/// particular for features are actually ABI configuration flags (not all targets are as nice as
/// RISC-V and have an explicit way to set the ABI separate from target features).
Forbidden { reason: &'static str },
Forbidden {
reason: &'static str,
/// True if this is always an error, false if this can be reported as a warning when set via
/// `-Ctarget-feature`.
hard_error: bool,
},
}
use Stability::*;

Expand Down Expand Up @@ -85,14 +90,14 @@ impl Stability {
}

/// Returns whether the feature may be toggled via `#[target_feature]` or `-Ctarget-feature`.
/// (It might still be nightly-only even if this returns `true`, so make sure to also check
/// (It might still be nightly-only even if this returns `Ok(())`, so make sure to also check
/// `requires_nightly`.)
pub fn toggle_allowed(&self) -> Result<(), &'static str> {
match self {
Stability::Unstable(_)
| Stability::CfgStableToggleUnstable(_)
| Stability::Stable { .. } => Ok(()),
Stability::Forbidden { reason } => Err(reason),
Stability::Forbidden { reason, hard_error: _ } => Err(reason),
}
}
}
Expand Down Expand Up @@ -149,7 +154,10 @@ static ARM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("aes", Unstable(sym::arm_target_feature), &["neon"]),
(
"atomics-32",
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
Stability::Forbidden {
reason: "unsound because it changes the ABI of atomic operations",
hard_error: false,
},
&[],
),
("crc", Unstable(sym::arm_target_feature), &[]),
Expand Down Expand Up @@ -225,7 +233,11 @@ static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// FEAT_FLAGM2
("flagm2", Unstable(sym::aarch64_unstable_target_feature), &[]),
// We forbid directly toggling just `fp-armv8`; it must be toggled with `neon`.
("fp-armv8", Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`" }, &[]),
(
"fp-armv8",
Stability::Forbidden { reason: "Rust ties `fp-armv8` to `neon`", hard_error: false },
&[],
),
// FEAT_FP8
("fp8", Unstable(sym::aarch64_unstable_target_feature), &["faminmax", "lut", "bf16"]),
// FEAT_FP8DOT2
Expand Down Expand Up @@ -288,7 +300,11 @@ static AARCH64_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("rcpc3", Unstable(sym::aarch64_unstable_target_feature), &["rcpc2"]),
// FEAT_RDM
("rdm", Stable, &["neon"]),
("reserve-x18", Forbidden { reason: "use `-Zfixed-x18` compiler flag instead" }, &[]),
(
"reserve-x18",
Forbidden { reason: "use `-Zfixed-x18` compiler flag instead", hard_error: false },
&[],
),
// FEAT_SB
("sb", Stable, &[]),
// FEAT_SHA1 & FEAT_SHA256
Expand Down Expand Up @@ -467,25 +483,38 @@ static X86_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("rdseed", Stable, &[]),
(
"retpoline-external-thunk",
Stability::Forbidden { reason: "use `-Zretpoline-external-thunk` compiler flag instead" },
Stability::Forbidden {
reason: "use `-Zretpoline-external-thunk` compiler flag instead",
hard_error: false,
},
&[],
),
(
"retpoline-indirect-branches",
Stability::Forbidden { reason: "use `-Zretpoline` compiler flag instead" },
Stability::Forbidden {
reason: "use `-Zretpoline` compiler flag instead",
hard_error: false,
},
&[],
),
(
"retpoline-indirect-calls",
Stability::Forbidden { reason: "use `-Zretpoline` compiler flag instead" },
Stability::Forbidden {
reason: "use `-Zretpoline` compiler flag instead",
hard_error: false,
},
&[],
),
("rtm", Unstable(sym::rtm_target_feature), &[]),
("sha", Stable, &["sse2"]),
("sha512", Stable, &["avx2"]),
("sm3", Stable, &["avx"]),
("sm4", Stable, &["avx2"]),
("soft-float", Stability::Forbidden { reason: "use a soft-float target instead" }, &[]),
(
"soft-float",
Stability::Forbidden { reason: "use a soft-float target instead", hard_error: false },
&[],
),
("sse", Stable, &[]),
("sse2", Stable, &["sse"]),
("sse3", Stable, &["sse2"]),
Expand Down Expand Up @@ -615,7 +644,10 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("f", Unstable(sym::riscv_target_feature), &["zicsr"]),
(
"forced-atomics",
Stability::Forbidden { reason: "unsound because it changes the ABI of atomic operations" },
Stability::Forbidden {
reason: "unsound because it changes the ABI of atomic operations",
hard_error: false,
},
&[],
),
("m", Stable, &[]),
Expand Down Expand Up @@ -872,7 +904,7 @@ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("miscellaneous-extensions-3", Stable, &[]),
("miscellaneous-extensions-4", Stable, &[]),
("nnp-assist", Stable, &["vector"]),
("soft-float", Forbidden { reason: "unsupported ABI-configuration feature" }, &[]),
("soft-float", Forbidden { reason: "unsupported ABI-configuration feature", hard_error: false }, &[]),
("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
("vector", Stable, &[]),
("vector-enhancements-1", Stable, &["vector"]),
Expand Down Expand Up @@ -924,7 +956,11 @@ static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("rmw", Unstable(sym::avr_target_feature), &[]),
("spm", Unstable(sym::avr_target_feature), &[]),
("spmx", Unstable(sym::avr_target_feature), &[]),
("sram", Forbidden { reason: "devices that have no SRAM are unsupported" }, &[]),
(
"sram",
Forbidden { reason: "devices that have no SRAM are unsupported", hard_error: false },
&[],
),
("tinyencoding", Unstable(sym::avr_target_feature), &[]),
// tidy-alphabetical-end
];
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/solve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<T: Copy + Debug + Hash + Eq> AsRef<[T]> for SmallCopyList<T> {
/// | never | no | no |
/// | always | yes | yes |
/// | [defid in storage] | no | only if any of the defids in the list is in the opaque type storage OR if TypingMode::PostAnalysis |
/// | opaque with hidden type | no | only if any of the the opaques in the opaque type storage has a hidden type in this list AND if TypingMode::Analysis |
/// | opaque with hidden type | no | only if any of the opaques in the opaque type storage has a hidden type in this list AND if TypingMode::Analysis |
///
/// - "bail" is implemented with [`should_bail`](Self::should_bail).
/// If true, we're abandoning our attempt to canonicalize in [`TypingMode::ErasedNotCoherence`],
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2587,6 +2587,12 @@ pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection
// statically.
if builder.llvm_link_shared() {
maybe_install_llvm(builder, target, &dst_libdir, false);

// To workaround lack of rpath on Windows, we bundle another copy of
// the LLVM DLL to make rust-lld and llvm-tools work when `sysroot/bin`
// is missing from PATH, i.e. when they not launched by rustc.
let dst_libdir = sysroot.join("lib/rustlib").join(target).join("bin");
maybe_install_llvm(builder, target, &dst_libdir, false);
}
}

Expand Down
Loading
Loading