Skip to content

Rollup of 10 pull requests #144138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3c56c2e
stabilize `const_slice_reverse`
fee1-dead Jul 3, 2025
229be21
Add ui test unnessary-error-issue-138401.rs
xizheyin Jun 24, 2025
45e04b8
Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too
scottmcm Jul 10, 2025
132a47e
Correct which exploit mitigations are enabled by default
1c3t3a Jul 15, 2025
49ae52e
Fix encoding of `link_section` and `no_mangle` cross crate
JonathanBrouwer Jul 17, 2025
9f16db6
Regression test
JonathanBrouwer Jul 17, 2025
12eedaf
Report the range of uninit bytes in CTFE errors
oli-obk Jun 18, 2025
2ce0b66
HIR ty lowering: Simplify signature of `lower_poly_trait_ref`
fmease Jun 18, 2025
10d7e5f
HIR ty lowering: Validate relaxed bounds in trait object types
fmease Jun 18, 2025
9788f59
Update comment about `where Ty:`
fmease Jun 18, 2025
1df99f2
AST lowering: More robustly deal with relaxed bounds
fmease Jun 18, 2025
652ba27
Show the memory of uninit reads
oli-obk Jun 18, 2025
8e840f7
opt-dist: make llvm builds optional
ognevny Jul 18, 2025
84ed70b
Reword diagnostics about relaxed bounds in invalid contexts
fmease Jun 20, 2025
879f62b
Reword diagnostic about relaxing non-`Sized` bound
fmease Jun 19, 2025
cdc3d70
Don't reject *multiple* relaxed bounds, reject *duplicate* ones.
fmease Jul 18, 2025
82a02ae
HIR ty lowering: Validate `PointeeSized` bounds
fmease Jun 20, 2025
466d33c
inline CrateLoader inside of CStore
LorrensP-2158466 Jul 15, 2025
181c1bd
Deduplicate `unmatched_delims` in `rustc_parse` to reduce confusion
xizheyin Jul 10, 2025
c65d3ce
Generalize `unsize` and `unsize_into` destinations
oli-obk Jul 3, 2025
af171b2
Rollup merge of #138554 - xizheyin:issue-138401, r=chenyukang
matthiaskrgr Jul 18, 2025
2ddbf3a
Rollup merge of #142673 - oli-obk:uninit-read-mem, r=RalfJung
matthiaskrgr Jul 18, 2025
c2dc9f3
Rollup merge of #142693 - fmease:unbound-bettering, r=compiler-errors
matthiaskrgr Jul 18, 2025
26ea00b
Rollup merge of #143382 - fee1-dead-contrib:push-trrymlzqmmoz, r=jhpratt
matthiaskrgr Jul 18, 2025
38859dd
Rollup merge of #143720 - scottmcm:rvalue-always-operand, r=lcnr
matthiaskrgr Jul 18, 2025
149c9db
Rollup merge of #143928 - ognevny:opt-dist-build-llvm, r=Kobzol
matthiaskrgr Jul 18, 2025
0818fba
Rollup merge of #143961 - 1c3t3a:correct-exploit-mitigations, r=rcvalle
matthiaskrgr Jul 18, 2025
dbdcc43
Rollup merge of #144050 - JonathanBrouwer:cross-crate-reexport, r=jdo…
matthiaskrgr Jul 18, 2025
70e8a77
Rollup merge of #144059 - LorrensP-2158466:remove-crate-loader, r=pet…
matthiaskrgr Jul 18, 2025
cb7cfa4
Rollup merge of #144123 - oli-obk:ctfe-unsize, r=RalfJung
matthiaskrgr Jul 18, 2025
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
3 changes: 0 additions & 3 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ ast_lowering_misplaced_impl_trait =
`impl Trait` is not allowed in {$position}
.note = `impl Trait` is only allowed in arguments and return types of functions and methods

ast_lowering_misplaced_relax_trait_bound =
`?Trait` bounds are only permitted at the point where a type parameter is declared

ast_lowering_never_pattern_with_body =
a never pattern is always unreachable
.label = this will never be executed
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,13 +324,6 @@ pub(crate) struct MisplacedDoubleDot {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_lowering_misplaced_relax_trait_bound)]
pub(crate) struct MisplacedRelaxTraitBound {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(ast_lowering_match_arm_with_no_body)]
pub(crate) struct MatchArmWithNoBody {
Expand Down
112 changes: 38 additions & 74 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ use smallvec::{SmallVec, smallvec};
use thin_vec::ThinVec;
use tracing::instrument;

use super::errors::{
InvalidAbi, InvalidAbiSuggestion, MisplacedRelaxTraitBound, TupleStructWithDefault,
UnionWithDefault,
};
use super::errors::{InvalidAbi, InvalidAbiSuggestion, TupleStructWithDefault, UnionWithDefault};
use super::stability::{enabled_names, gate_unstable_abi};
use super::{
AstOwner, FnDeclKind, ImplTraitContext, ImplTraitPosition, LoweringContext, ParamMode,
ResolverAstLoweringExt,
RelaxedBoundForbiddenReason, RelaxedBoundPolicy, ResolverAstLoweringExt,
};

pub(super) struct ItemLowerer<'a, 'hir> {
Expand Down Expand Up @@ -435,6 +432,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|this| {
let bounds = this.lower_param_bounds(
bounds,
RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::SuperTrait),
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
);
let items = this.arena.alloc_from_iter(
Expand All @@ -455,6 +453,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
|this| {
this.lower_param_bounds(
bounds,
RelaxedBoundPolicy::Allowed,
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
)
},
Expand Down Expand Up @@ -940,6 +939,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::TraitItemKind::Type(
this.lower_param_bounds(
bounds,
RelaxedBoundPolicy::Allowed,
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
),
ty,
Expand Down Expand Up @@ -1677,61 +1677,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
assert!(self.impl_trait_defs.is_empty());
assert!(self.impl_trait_bounds.is_empty());

// Error if `?Trait` bounds in where clauses don't refer directly to type parameters.
// Note: we used to clone these bounds directly onto the type parameter (and avoid lowering
// these into hir when we lower thee where clauses), but this makes it quite difficult to
// keep track of the Span info. Now, `<dyn HirTyLowerer>::add_implicit_sized_bound`
// checks both param bounds and where clauses for `?Sized`.
for pred in &generics.where_clause.predicates {
let WherePredicateKind::BoundPredicate(bound_pred) = &pred.kind else {
continue;
};
let compute_is_param = || {
// Check if the where clause type is a plain type parameter.
match self
.resolver
.get_partial_res(bound_pred.bounded_ty.id)
.and_then(|r| r.full_res())
{
Some(Res::Def(DefKind::TyParam, def_id))
if bound_pred.bound_generic_params.is_empty() =>
{
generics
.params
.iter()
.any(|p| def_id == self.local_def_id(p.id).to_def_id())
}
// Either the `bounded_ty` is not a plain type parameter, or
// it's not found in the generic type parameters list.
_ => false,
}
};
// We only need to compute this once per `WherePredicate`, but don't
// need to compute this at all unless there is a Maybe bound.
let mut is_param: Option<bool> = None;
for bound in &bound_pred.bounds {
if !matches!(
*bound,
GenericBound::Trait(PolyTraitRef {
modifiers: TraitBoundModifiers { polarity: BoundPolarity::Maybe(_), .. },
..
})
) {
continue;
}
let is_param = *is_param.get_or_insert_with(compute_is_param);
if !is_param && !self.tcx.features().more_maybe_bounds() {
self.tcx
.sess
.create_feature_err(
MisplacedRelaxTraitBound { span: bound.span() },
sym::more_maybe_bounds,
)
.emit();
}
}
}

let mut predicates: SmallVec<[hir::WherePredicate<'hir>; 4]> = SmallVec::new();
predicates.extend(generics.params.iter().filter_map(|param| {
self.lower_generic_bound_predicate(
Expand All @@ -1741,6 +1686,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
&param.bounds,
param.colon_span,
generics.span,
RelaxedBoundPolicy::Allowed,
itctx,
PredicateOrigin::GenericParam,
)
Expand All @@ -1750,7 +1696,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
.where_clause
.predicates
.iter()
.map(|predicate| self.lower_where_predicate(predicate)),
.map(|predicate| self.lower_where_predicate(predicate, &generics.params)),
);

let mut params: SmallVec<[hir::GenericParam<'hir>; 4]> = self
Expand Down Expand Up @@ -1827,6 +1773,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
bounds: &[GenericBound],
colon_span: Option<Span>,
parent_span: Span,
rbp: RelaxedBoundPolicy<'_>,
itctx: ImplTraitContext,
origin: PredicateOrigin,
) -> Option<hir::WherePredicate<'hir>> {
Expand All @@ -1835,7 +1782,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
return None;
}

let bounds = self.lower_param_bounds(bounds, itctx);
let bounds = self.lower_param_bounds(bounds, rbp, itctx);

let param_span = ident.span;

Expand Down Expand Up @@ -1887,7 +1834,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
Some(hir::WherePredicate { hir_id, span, kind })
}

fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicate<'hir> {
fn lower_where_predicate(
&mut self,
pred: &WherePredicate,
params: &[ast::GenericParam],
) -> hir::WherePredicate<'hir> {
let hir_id = self.lower_node_id(pred.id);
let span = self.lower_span(pred.span);
self.lower_attrs(hir_id, &pred.attrs, span);
Expand All @@ -1896,17 +1847,29 @@ impl<'hir> LoweringContext<'_, 'hir> {
bound_generic_params,
bounded_ty,
bounds,
}) => hir::WherePredicateKind::BoundPredicate(hir::WhereBoundPredicate {
bound_generic_params: self
.lower_generic_params(bound_generic_params, hir::GenericParamSource::Binder),
bounded_ty: self
.lower_ty(bounded_ty, ImplTraitContext::Disallowed(ImplTraitPosition::Bound)),
bounds: self.lower_param_bounds(
bounds,
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
),
origin: PredicateOrigin::WhereClause,
}),
}) => {
let rbp = if bound_generic_params.is_empty() {
RelaxedBoundPolicy::AllowedIfOnTyParam(bounded_ty.id, params)
} else {
RelaxedBoundPolicy::Forbidden(RelaxedBoundForbiddenReason::LateBoundVarsInScope)
};
hir::WherePredicateKind::BoundPredicate(hir::WhereBoundPredicate {
bound_generic_params: self.lower_generic_params(
bound_generic_params,
hir::GenericParamSource::Binder,
),
bounded_ty: self.lower_ty(
bounded_ty,
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
),
bounds: self.lower_param_bounds(
bounds,
rbp,
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
),
origin: PredicateOrigin::WhereClause,
})
}
WherePredicateKind::RegionPredicate(WhereRegionPredicate { lifetime, bounds }) => {
hir::WherePredicateKind::RegionPredicate(hir::WhereRegionPredicate {
lifetime: self.lower_lifetime(
Expand All @@ -1916,6 +1879,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
),
bounds: self.lower_param_bounds(
bounds,
RelaxedBoundPolicy::Allowed,
ImplTraitContext::Disallowed(ImplTraitPosition::Bound),
),
in_where_clause: true,
Expand Down
Loading
Loading