Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
146 changes: 0 additions & 146 deletions .github/workflows/dependencies.yml

This file was deleted.

4 changes: 4 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,10 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
half_open_range_patterns_in_slices,
"half-open range patterns in slices are unstable"
);
gate_all!(
named_fn_trait_parameters,
"named parameters in parenthesized generic argument lists are experimental"
);

// `associated_const_equality` will be stabilized as part of `min_generic_const_args`.
for &span in spans.get(&sym::associated_const_equality).into_flat_iter() {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,8 @@ declare_features! (
(unstable, naked_functions_rustic_abi, "1.88.0", Some(138997)),
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.
(unstable, naked_functions_target_feature, "1.86.0", Some(138568)),
/// Allows providing names to parameters of `impl Fn` etc
(incomplete, named_fn_trait_parameters, "CURRENT_RUSTC_VERSION", Some(158499)),
/// Allows specifying the as-needed link modifier
(unstable, native_link_modifiers_as_needed, "1.53.0", Some(81490)),
/// Allow negative trait implementations.
Expand Down
25 changes: 22 additions & 3 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2479,13 +2479,13 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
) -> Const<'tcx> {
let tcx = self.tcx();

let elem_ty = match ty.kind() {
ty::Array(elem_ty, _) => elem_ty,
let (elem_ty, len) = match ty.kind() {
ty::Array(elem_ty, len) => (elem_ty, len),
ty::Error(e) => return Const::new_error(tcx, *e),
_ => {
let e = tcx
.dcx()
.span_err(array_expr.span, format!("expected `{}`, found const array", ty));
.span_err(array_expr.span, format!("expected `{ty}`, found const array"));
return Const::new_error(tcx, e);
}
};
Expand All @@ -2496,6 +2496,25 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
.map(|elem| self.lower_const_arg(elem, *elem_ty))
.collect::<Vec<_>>();

let len = tcx
.try_normalize_erasing_regions(
ty::TypingEnv::new(ty::ParamEnv::empty(), TypingMode::non_body_analysis()),
Unnormalized::new_wip(*len),
)
.unwrap_or(*len);
if let Some(expected_len) = len.try_to_target_usize(tcx)
&& expected_len != elems.len() as u64
{
let e = tcx.dcx().span_err(
array_expr.span,
format!(
"expected array with {expected_len} elements, found {} elements",
array_expr.elems.len()
),
);
return Const::new_error(tcx, e);
}

let valtree = ty::ValTree::from_branches(tcx, elems);

ty::Const::new_value(tcx, valtree, ty)
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_parse/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2076,14 +2076,6 @@ pub(crate) struct ExpectedFnPathFoundFnKeyword {
pub fn_token_span: Span,
}

#[derive(Diagnostic)]
#[diag("`Trait(...)` syntax does not support named parameters")]
pub(crate) struct FnPathFoundNamedParams {
#[primary_span]
#[suggestion("remove the parameter name", applicability = "machine-applicable", code = "")]
pub named_param_span: Span,
}

#[derive(Diagnostic)]
#[diag("`Trait(...)` syntax does not support c_variadic parameters")]
pub(crate) struct PathFoundCVariadicParams {
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use super::{Parser, Restrictions, TokenType};
use crate::ast::{PatKind, TyKind};
use crate::diagnostics::{
self, AttributeOnEmptyType, AttributeOnGenericArg, ConstGenericWithoutBraces,
ConstGenericWithoutBracesSugg, FnPathFoundNamedParams, PathFoundAttributeInParams,
PathFoundCVariadicParams, PathSingleColon, PathTripleColon,
ConstGenericWithoutBracesSugg, PathFoundAttributeInParams, PathFoundCVariadicParams,
PathSingleColon, PathTripleColon,
};
use crate::exp;
use crate::parser::{
Expand Down Expand Up @@ -408,11 +408,11 @@ impl<'a> Parser<'a> {
req_body: false,
};
let param = p.parse_param_general(&mode, false, false);
param.map(move |param| {
param.map(|param| {
if !matches!(param.pat.kind, PatKind::Missing) {
dcx.emit_err(FnPathFoundNamedParams {
named_param_span: param.pat.span,
});
self.psess
.gated_spans
.gate(sym::named_fn_trait_parameters, param.pat.span);
}
if matches!(param.ty.kind, TyKind::CVarArgs) {
dcx.emit_err(PathFoundCVariadicParams { span: param.pat.span });
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::Session;
use crate::lint::{Lint, LintId};

/// Collected spans during parsing for places where a certain feature was
/// used and should be feature gated accordingly in `check_crate`.
/// used and should be feature gated accordingly in `check_crate` in `rustc_ast_passes`.
#[derive(Default)]
pub struct GatedSpans {
pub spans: Lock<FxHashMap<Symbol, Vec<Span>>>,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ symbols! {
naked_functions_rustic_abi,
naked_functions_target_feature,
name,
named_fn_trait_parameters,
names,
native_link_modifiers,
native_link_modifiers_as_needed,
Expand Down
18 changes: 0 additions & 18 deletions src/tools/update-lockfile.sh

This file was deleted.

26 changes: 26 additions & 0 deletions tests/crashes/160553.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//@ known-bug: #160553
//@ compile-flags: -Copt-level=0
#![allow(incomplete_features)]
#![feature(adt_const_params, min_generic_const_args, macroless_generic_const_args)]
#![feature(generic_const_parameter_types)]

trait Trait {
type const LEN: usize;
}

struct S;
impl Trait for S {
type const LEN: usize = 2;
}

fn foo<T: Trait, const A: [u8; <T as Trait>::LEN]>() -> [u8; <T as Trait>::LEN] {
A
}

fn bar<T: Trait>() -> [u8; <T as Trait>::LEN] {
foo::<T, { [1, 2, 3] }>()
}

fn main() {
bar::<S>();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/99630>.
//!
//! Re-exporting a type from another crate must not leak the private fields used
//! in the initializer of one of its associated constants.

//@ aux-build:assoc-const-private-fields.rs

#![crate_name = "foo"]

extern crate assoc_const_private_fields;

//@ has foo/struct.HasPrivateFields.html
//@ matches - '//*[@id="associatedconstant.ASSOC"]' '^pub const ASSOC: HasPrivateFields$'
pub use assoc_const_private_fields::HasPrivateFields;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pub struct HasPrivateFields {
_private: (),
}

impl HasPrivateFields {
pub const ASSOC: Self = Self { _private: () };
}
7 changes: 5 additions & 2 deletions tests/ui/autodiff/autodiff_illegal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,18 @@ pub fn f6(x: f64) {

fn dummy() {
#[autodiff_forward(df7, Dual)]
//~^ ERROR macro attributes on statements are unstable
let mut x = 5;
//~^ ERROR autodiff must be applied to function

#[autodiff_forward(df7, Dual)]
x = x + 3;
//~^^ ERROR attributes on expressions are experimental [E0658]
//~^^ ERROR autodiff must be applied to function
//~^^ ERROR attributes on expressions are experimental [E0658]
//~| ERROR macro attributes on expressions are unstable
//~^^^ ERROR autodiff must be applied to function

#[autodiff_forward(df7, Dual)]
//~^ ERROR macro attributes on statements are unstable
let add_one_v2 = |x: u32| -> u32 { x + 1 };
//~^ ERROR autodiff must be applied to function
}
Expand Down
Loading
Loading