Rollup merge of #88410 - camelid:fix-assoc-bold, r=GuillaumeGomez
Remove bolding on associated constants
Associated types don't get bolded, so it looks off to have one kind
bolded and one not.
diff --git a/Cargo.lock b/Cargo.lock
index cef4f11..f49c851 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -765,9 +765,9 @@
[[package]]
name = "crossbeam-deque"
-version = "0.7.3"
+version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285"
+checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed"
dependencies = [
"crossbeam-epoch",
"crossbeam-utils 0.7.2",
@@ -2297,9 +2297,9 @@
[[package]]
name = "object"
-version = "0.26.1"
+version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee2766204889d09937d00bfbb7fec56bb2a199e2ade963cab19185d8a6104c7c"
+checksum = "39f37e50073ccad23b6d09bcb5b263f4e76d3bb6038e4a3c08e52162ffa8abc2"
dependencies = [
"compiler_builtins",
"crc32fast",
@@ -2368,9 +2368,9 @@
[[package]]
name = "openssl-src"
-version = "111.15.0+1.1.1k"
+version = "111.16.0+1.1.1l"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1a5f6ae2ac04393b217ea9f700cd04fa9bf3d93fae2872069f3d15d908af70a"
+checksum = "7ab2173f69416cf3ec12debb5823d244127d23a9b127d5a5189aa97c5fa2859f"
dependencies = [
"cc",
]
@@ -2729,9 +2729,9 @@
[[package]]
name = "psm"
-version = "0.1.11"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "96e0536f6528466dbbbbe6b986c34175a8d0ff25b794c4bacda22e068cd2f2c5"
+checksum = "cd136ff4382c4753fc061cb9e4712ab2af263376b95bbd5bd8cd50c020b78e69"
dependencies = [
"cc",
]
@@ -4146,6 +4146,7 @@
name = "rustc_privacy"
version = "0.0.0"
dependencies = [
+ "rustc_ast",
"rustc_attr",
"rustc_data_structures",
"rustc_errors",
@@ -4404,6 +4405,7 @@
"rustc_hir_pretty",
"rustc_index",
"rustc_infer",
+ "rustc_lint",
"rustc_macros",
"rustc_middle",
"rustc_session",
@@ -4812,12 +4814,12 @@
[[package]]
name = "stacker"
-version = "0.1.12"
+version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "21ccb4c06ec57bc82d0f610f1a2963d7648700e43a6f513e564b9c89f7991786"
+checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4"
dependencies = [
"cc",
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
"libc",
"psm",
"winapi",
@@ -4967,9 +4969,9 @@
[[package]]
name = "tar"
-version = "0.4.35"
+version = "0.4.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7d779dc6aeff029314570f666ec83f19df7280bb36ef338442cfa8c604021b80"
+checksum = "d6f5515d3add52e0bbdcad7b83c388bb36ba7b754dda3b5f5bc2d38640cdba5c"
dependencies = [
"filetime",
"libc",
diff --git a/RELEASES.md b/RELEASES.md
index dd299ca..2124195 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -70,7 +70,8 @@
- [The package definition in `cargo metadata` now includes the `"default_run"`
field from the manifest.][cargo/9550]
- [Added `cargo d` as an alias for `cargo doc`.][cargo/9680]
-- [Added `{lib}` as formatting option for `cargo tree` to print the "lib_name" of packages.][cargo/9663]
+- [Added `{lib}` as formatting option for `cargo tree` to print the `"lib_name"`
+ of packages.][cargo/9663]
Rustdoc
-------
@@ -116,9 +117,11 @@
[79965]: https://github.com/rust-lang/rust/pull/79965
[87370]: https://github.com/rust-lang/rust/pull/87370
[87298]: https://github.com/rust-lang/rust/pull/87298
+[cargo/9663]: https://github.com/rust-lang/cargo/pull/9663
[cargo/9675]: https://github.com/rust-lang/cargo/pull/9675
[cargo/9550]: https://github.com/rust-lang/cargo/pull/9550
[cargo/9680]: https://github.com/rust-lang/cargo/pull/9680
+[cargo/9663]: https://github.com/rust-lang/cargo/pull/9663
[`array::map`]: https://doc.rust-lang.org/stable/std/primitive.array.html#method.map
[`Bound::cloned`]: https://doc.rust-lang.org/stable/std/ops/enum.Bound.html#method.cloned
[`Drain::as_str`]: https://doc.rust-lang.org/stable/std/string/struct.Drain.html#method.as_str
diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs
index c3e4945..6d5f47a 100644
--- a/compiler/rustc_arena/src/lib.rs
+++ b/compiler/rustc_arena/src/lib.rs
@@ -15,6 +15,8 @@
#![feature(new_uninit)]
#![feature(maybe_uninit_slice)]
#![feature(min_specialization)]
+#![feature(decl_macro)]
+#![feature(rustc_attrs)]
#![cfg_attr(test, feature(test))]
use rustc_data_structures::sync;
@@ -608,117 +610,113 @@ pub unsafe fn alloc_from_iter<T, I>(&self, iter: I) -> &mut [T]
}
}
-#[macro_export]
-macro_rules! arena_for_type {
+pub macro arena_for_type {
([][$ty:ty]) => {
$crate::TypedArena<$ty>
- };
+ },
([few $(, $attrs:ident)*][$ty:ty]) => {
::std::marker::PhantomData<$ty>
- };
+ },
([$ignore:ident $(, $attrs:ident)*]$args:tt) => {
$crate::arena_for_type!([$($attrs),*]$args)
- };
+ },
}
-#[macro_export]
-macro_rules! which_arena_for_type {
+pub macro which_arena_for_type {
([][$arena:expr]) => {
::std::option::Option::Some($arena)
- };
+ },
([few$(, $attrs:ident)*][$arena:expr]) => {
::std::option::Option::None
- };
+ },
([$ignore:ident$(, $attrs:ident)*]$args:tt) => {
$crate::which_arena_for_type!([$($attrs),*]$args)
- };
+ },
}
-#[macro_export]
-macro_rules! declare_arena {
- ([], [$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => {
- #[derive(Default)]
- pub struct Arena<$tcx> {
- pub dropless: $crate::DroplessArena,
- drop: $crate::DropArena,
- $($name: $crate::arena_for_type!($a[$ty]),)*
+#[rustc_macro_transparency = "semitransparent"]
+pub macro declare_arena([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) {
+ #[derive(Default)]
+ pub struct Arena<$tcx> {
+ pub dropless: $crate::DroplessArena,
+ drop: $crate::DropArena,
+ $($name: $crate::arena_for_type!($a[$ty]),)*
+ }
+
+ pub trait ArenaAllocatable<'tcx, T = Self>: Sized {
+ fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self;
+ fn allocate_from_iter<'a>(
+ arena: &'a Arena<'tcx>,
+ iter: impl ::std::iter::IntoIterator<Item = Self>,
+ ) -> &'a mut [Self];
+ }
+
+ impl<'tcx, T: Copy> ArenaAllocatable<'tcx, ()> for T {
+ #[inline]
+ fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
+ arena.dropless.alloc(self)
+ }
+ #[inline]
+ fn allocate_from_iter<'a>(
+ arena: &'a Arena<'tcx>,
+ iter: impl ::std::iter::IntoIterator<Item = Self>,
+ ) -> &'a mut [Self] {
+ arena.dropless.alloc_from_iter(iter)
}
- pub trait ArenaAllocatable<'tcx, T = Self>: Sized {
- fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self;
- fn allocate_from_iter<'a>(
- arena: &'a Arena<'tcx>,
- iter: impl ::std::iter::IntoIterator<Item = Self>,
- ) -> &'a mut [Self];
- }
-
- impl<'tcx, T: Copy> ArenaAllocatable<'tcx, ()> for T {
+ }
+ $(
+ impl<$tcx> ArenaAllocatable<$tcx, $ty> for $ty {
#[inline]
- fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut Self {
- arena.dropless.alloc(self)
+ fn allocate_on<'a>(self, arena: &'a Arena<$tcx>) -> &'a mut Self {
+ if !::std::mem::needs_drop::<Self>() {
+ return arena.dropless.alloc(self);
+ }
+ match $crate::which_arena_for_type!($a[&arena.$name]) {
+ ::std::option::Option::<&$crate::TypedArena<Self>>::Some(ty_arena) => {
+ ty_arena.alloc(self)
+ }
+ ::std::option::Option::None => unsafe { arena.drop.alloc(self) },
+ }
}
+
#[inline]
fn allocate_from_iter<'a>(
- arena: &'a Arena<'tcx>,
+ arena: &'a Arena<$tcx>,
iter: impl ::std::iter::IntoIterator<Item = Self>,
) -> &'a mut [Self] {
- arena.dropless.alloc_from_iter(iter)
+ if !::std::mem::needs_drop::<Self>() {
+ return arena.dropless.alloc_from_iter(iter);
+ }
+ match $crate::which_arena_for_type!($a[&arena.$name]) {
+ ::std::option::Option::<&$crate::TypedArena<Self>>::Some(ty_arena) => {
+ ty_arena.alloc_from_iter(iter)
+ }
+ ::std::option::Option::None => unsafe { arena.drop.alloc_from_iter(iter) },
+ }
}
-
}
- $(
- impl<$tcx> ArenaAllocatable<$tcx, $ty> for $ty {
- #[inline]
- fn allocate_on<'a>(self, arena: &'a Arena<$tcx>) -> &'a mut Self {
- if !::std::mem::needs_drop::<Self>() {
- return arena.dropless.alloc(self);
- }
- match $crate::which_arena_for_type!($a[&arena.$name]) {
- ::std::option::Option::<&$crate::TypedArena<Self>>::Some(ty_arena) => {
- ty_arena.alloc(self)
- }
- ::std::option::Option::None => unsafe { arena.drop.alloc(self) },
- }
- }
+ )*
- #[inline]
- fn allocate_from_iter<'a>(
- arena: &'a Arena<$tcx>,
- iter: impl ::std::iter::IntoIterator<Item = Self>,
- ) -> &'a mut [Self] {
- if !::std::mem::needs_drop::<Self>() {
- return arena.dropless.alloc_from_iter(iter);
- }
- match $crate::which_arena_for_type!($a[&arena.$name]) {
- ::std::option::Option::<&$crate::TypedArena<Self>>::Some(ty_arena) => {
- ty_arena.alloc_from_iter(iter)
- }
- ::std::option::Option::None => unsafe { arena.drop.alloc_from_iter(iter) },
- }
- }
- }
- )*
+ impl<'tcx> Arena<'tcx> {
+ #[inline]
+ pub fn alloc<T: ArenaAllocatable<'tcx, U>, U>(&self, value: T) -> &mut T {
+ value.allocate_on(self)
+ }
- impl<'tcx> Arena<'tcx> {
- #[inline]
- pub fn alloc<T: ArenaAllocatable<'tcx, U>, U>(&self, value: T) -> &mut T {
- value.allocate_on(self)
+ #[inline]
+ pub fn alloc_slice<T: ::std::marker::Copy>(&self, value: &[T]) -> &mut [T] {
+ if value.is_empty() {
+ return &mut [];
}
+ self.dropless.alloc_slice(value)
+ }
- #[inline]
- pub fn alloc_slice<T: ::std::marker::Copy>(&self, value: &[T]) -> &mut [T] {
- if value.is_empty() {
- return &mut [];
- }
- self.dropless.alloc_slice(value)
- }
-
- pub fn alloc_from_iter<'a, T: ArenaAllocatable<'tcx, U>, U>(
- &'a self,
- iter: impl ::std::iter::IntoIterator<Item = T>,
- ) -> &'a mut [T] {
- T::allocate_from_iter(self, iter)
- }
+ pub fn alloc_from_iter<'a, T: ArenaAllocatable<'tcx, U>, U>(
+ &'a self,
+ iter: impl ::std::iter::IntoIterator<Item = T>,
+ ) -> &'a mut [T] {
+ T::allocate_from_iter(self, iter)
}
}
}
diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs
index 2c2d30d..0632d93 100644
--- a/compiler/rustc_ast/src/ast.rs
+++ b/compiler/rustc_ast/src/ast.rs
@@ -284,7 +284,7 @@ pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
pub use crate::node_id::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
-/// A modifier on a bound, e.g., `?Sized` or `?const Trait`.
+/// A modifier on a bound, e.g., `?Sized` or `~const Trait`.
///
/// Negative bounds should also be handled here.
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
@@ -295,10 +295,10 @@ pub enum TraitBoundModifier {
/// `?Trait`
Maybe,
- /// `?const Trait`
+ /// `~const Trait`
MaybeConst,
- /// `?const ?Trait`
+ /// `~const ?Trait`
//
// This parses but will be rejected during AST validation.
MaybeConstMaybe,
@@ -332,8 +332,8 @@ pub fn span(&self) -> Span {
pub enum ParamKindOrd {
Lifetime,
Type,
- // `unordered` is only `true` if `sess.has_features().const_generics`
- // is active. Specifically, if it's only `min_const_generics`, it will still require
+ // `unordered` is only `true` if `sess.unordered_const_ty_params()`
+ // returns true. Specifically, if it's only `min_const_generics`, it will still require
// ordering consts after types.
Const { unordered: bool },
// `Infer` is not actually constructed directly from the AST, but is implicitly constructed
@@ -1005,13 +1005,42 @@ pub struct Local {
pub id: NodeId,
pub pat: P<Pat>,
pub ty: Option<P<Ty>>,
- /// Initializer expression to set the value, if any.
- pub init: Option<P<Expr>>,
+ pub kind: LocalKind,
pub span: Span,
pub attrs: AttrVec,
pub tokens: Option<LazyTokenStream>,
}
+#[derive(Clone, Encodable, Decodable, Debug)]
+pub enum LocalKind {
+ /// Local declaration.
+ /// Example: `let x;`
+ Decl,
+ /// Local declaration with an initializer.
+ /// Example: `let x = y;`
+ Init(P<Expr>),
+ /// Local declaration with an initializer and an `else` clause.
+ /// Example: `let Some(x) = y else { return };`
+ InitElse(P<Expr>, P<Block>),
+}
+
+impl LocalKind {
+ pub fn init(&self) -> Option<&Expr> {
+ match self {
+ Self::Decl => None,
+ Self::Init(i) | Self::InitElse(i, _) => Some(i),
+ }
+ }
+
+ pub fn init_else_opt(&self) -> Option<(&Expr, Option<&Block>)> {
+ match self {
+ Self::Decl => None,
+ Self::Init(init) => Some((init, None)),
+ Self::InitElse(init, els) => Some((init, Some(els))),
+ }
+ }
+}
+
/// An arm of a 'match'.
///
/// E.g., `0..=10 => { println!("match!") }` as in
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs
index fb4db60..368a23e 100644
--- a/compiler/rustc_ast/src/mut_visit.rs
+++ b/compiler/rustc_ast/src/mut_visit.rs
@@ -571,11 +571,20 @@ pub fn noop_visit_parenthesized_parameter_data<T: MutVisitor>(
}
pub fn noop_visit_local<T: MutVisitor>(local: &mut P<Local>, vis: &mut T) {
- let Local { id, pat, ty, init, span, attrs, tokens } = local.deref_mut();
+ let Local { id, pat, ty, kind, span, attrs, tokens } = local.deref_mut();
vis.visit_id(id);
vis.visit_pat(pat);
visit_opt(ty, |ty| vis.visit_ty(ty));
- visit_opt(init, |init| vis.visit_expr(init));
+ match kind {
+ LocalKind::Decl => {}
+ LocalKind::Init(init) => {
+ vis.visit_expr(init);
+ }
+ LocalKind::InitElse(init, els) => {
+ vis.visit_expr(init);
+ vis.visit_block(els);
+ }
+ }
vis.visit_span(span);
visit_thin_attrs(attrs, vis);
visit_lazy_tts(tokens, vis);
diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs
index 9078652..6ea3db6 100644
--- a/compiler/rustc_ast/src/util/classify.rs
+++ b/compiler/rustc_ast/src/util/classify.rs
@@ -23,3 +23,30 @@ pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
| ast::ExprKind::TryBlock(..)
)
}
+
+/// If an expression ends with `}`, returns the innermost expression ending in the `}`
+pub fn expr_trailing_brace(mut expr: &ast::Expr) -> Option<&ast::Expr> {
+ use ast::ExprKind::*;
+
+ loop {
+ match &expr.kind {
+ AddrOf(_, _, e)
+ | Assign(_, e, _)
+ | AssignOp(_, _, e)
+ | Binary(_, _, e)
+ | Box(e)
+ | Break(_, Some(e))
+ | Closure(.., e, _)
+ | Let(_, e, _)
+ | Range(_, Some(e), _)
+ | Ret(Some(e))
+ | Unary(_, e)
+ | Yield(Some(e)) => {
+ expr = e;
+ }
+ Async(..) | Block(..) | ForLoop(..) | If(..) | Loop(..) | Match(..) | Struct(..)
+ | TryBlock(..) | While(..) => break Some(expr),
+ _ => break None,
+ }
+ }
+}
diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs
index dd89274..c30f711 100644
--- a/compiler/rustc_ast/src/visit.rs
+++ b/compiler/rustc_ast/src/visit.rs
@@ -242,7 +242,10 @@ pub fn walk_local<'a, V: Visitor<'a>>(visitor: &mut V, local: &'a Local) {
}
visitor.visit_pat(&local.pat);
walk_list!(visitor, visit_ty, &local.ty);
- walk_list!(visitor, visit_expr, &local.init);
+ if let Some((init, els)) = local.kind.init_else_opt() {
+ visitor.visit_expr(init);
+ walk_list!(visitor, visit_block, els);
+ }
}
pub fn walk_label<'a, V: Visitor<'a>>(visitor: &mut V, label: &'a Label) {
diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs
index b9b2785..7165b3b 100644
--- a/compiler/rustc_ast_lowering/src/asm.rs
+++ b/compiler/rustc_ast_lowering/src/asm.rs
@@ -128,7 +128,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
hir::InlineAsmOperand::Sym { expr: self.lower_expr_mut(expr) }
}
};
- (op, *op_sp)
+ (op, self.lower_span(*op_sp))
})
.collect();
@@ -384,7 +384,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
late: true,
expr: None,
},
- abi_span,
+ self.lower_span(abi_span),
));
}
}
@@ -392,8 +392,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let operands = self.arena.alloc_from_iter(operands);
let template = self.arena.alloc_from_iter(asm.template.iter().cloned());
- let template_strs = self.arena.alloc_from_iter(asm.template_strs.iter().cloned());
- let line_spans = self.arena.alloc_slice(&asm.line_spans[..]);
+ let template_strs = self.arena.alloc_from_iter(
+ asm.template_strs
+ .iter()
+ .map(|(sym, snippet, span)| (*sym, *snippet, self.lower_span(*span))),
+ );
+ let line_spans =
+ self.arena.alloc_from_iter(asm.line_spans.iter().map(|span| self.lower_span(*span)));
let hir_asm =
hir::InlineAsm { template, template_strs, operands, options: asm.options, line_spans };
self.arena.alloc(hir_asm)
diff --git a/compiler/rustc_ast_lowering/src/block.rs b/compiler/rustc_ast_lowering/src/block.rs
new file mode 100644
index 0000000..ca804ec
--- /dev/null
+++ b/compiler/rustc_ast_lowering/src/block.rs
@@ -0,0 +1,185 @@
+use crate::{ImplTraitContext, ImplTraitPosition, LoweringContext};
+use rustc_ast::{AttrVec, Block, BlockCheckMode, Expr, Local, LocalKind, Stmt, StmtKind};
+use rustc_hir as hir;
+use rustc_session::parse::feature_err;
+use rustc_span::symbol::Ident;
+use rustc_span::{sym, DesugaringKind};
+
+use smallvec::SmallVec;
+
+impl<'a, 'hir> LoweringContext<'a, 'hir> {
+ pub(super) fn lower_block(
+ &mut self,
+ b: &Block,
+ targeted_by_break: bool,
+ ) -> &'hir hir::Block<'hir> {
+ self.arena.alloc(self.lower_block_noalloc(b, targeted_by_break))
+ }
+
+ pub(super) fn lower_block_noalloc(
+ &mut self,
+ b: &Block,
+ targeted_by_break: bool,
+ ) -> hir::Block<'hir> {
+ let (stmts, expr) = self.lower_stmts(&b.stmts);
+ let rules = self.lower_block_check_mode(&b.rules);
+ let hir_id = self.lower_node_id(b.id);
+ hir::Block { hir_id, stmts, expr, rules, span: self.lower_span(b.span), targeted_by_break }
+ }
+
+ fn lower_stmts(
+ &mut self,
+ mut ast_stmts: &[Stmt],
+ ) -> (&'hir [hir::Stmt<'hir>], Option<&'hir hir::Expr<'hir>>) {
+ let mut stmts = SmallVec::<[hir::Stmt<'hir>; 8]>::new();
+ let mut expr = None;
+ while let [s, tail @ ..] = ast_stmts {
+ match s.kind {
+ StmtKind::Local(ref local) => {
+ let hir_id = self.lower_node_id(s.id);
+ match &local.kind {
+ LocalKind::InitElse(init, els) => {
+ let (s, e) = self.lower_let_else(hir_id, local, init, els, tail);
+ stmts.push(s);
+ expr = Some(e);
+ // remaining statements are in let-else expression
+ break;
+ }
+ _ => {
+ let local = self.lower_local(local);
+ self.alias_attrs(hir_id, local.hir_id);
+ let kind = hir::StmtKind::Local(local);
+ let span = self.lower_span(s.span);
+ stmts.push(hir::Stmt { hir_id, kind, span });
+ }
+ }
+ }
+ StmtKind::Item(ref it) => {
+ stmts.extend(self.lower_item_id(it).into_iter().enumerate().map(
+ |(i, item_id)| {
+ let hir_id = match i {
+ 0 => self.lower_node_id(s.id),
+ _ => self.next_id(),
+ };
+ let kind = hir::StmtKind::Item(item_id);
+ let span = self.lower_span(s.span);
+ hir::Stmt { hir_id, kind, span }
+ },
+ ));
+ }
+ StmtKind::Expr(ref e) => {
+ let e = self.lower_expr(e);
+ if tail.is_empty() {
+ expr = Some(e);
+ } else {
+ let hir_id = self.lower_node_id(s.id);
+ self.alias_attrs(hir_id, e.hir_id);
+ let kind = hir::StmtKind::Expr(e);
+ let span = self.lower_span(s.span);
+ stmts.push(hir::Stmt { hir_id, kind, span });
+ }
+ }
+ StmtKind::Semi(ref e) => {
+ let e = self.lower_expr(e);
+ let hir_id = self.lower_node_id(s.id);
+ self.alias_attrs(hir_id, e.hir_id);
+ let kind = hir::StmtKind::Semi(e);
+ let span = self.lower_span(s.span);
+ stmts.push(hir::Stmt { hir_id, kind, span });
+ }
+ StmtKind::Empty => {}
+ StmtKind::MacCall(..) => panic!("shouldn't exist here"),
+ }
+ ast_stmts = &ast_stmts[1..];
+ }
+ (self.arena.alloc_from_iter(stmts), expr)
+ }
+
+ fn lower_local(&mut self, l: &Local) -> &'hir hir::Local<'hir> {
+ let ty = l
+ .ty
+ .as_ref()
+ .map(|t| self.lower_ty(t, ImplTraitContext::Disallowed(ImplTraitPosition::Binding)));
+ let init = l.kind.init().map(|init| self.lower_expr(init));
+ let hir_id = self.lower_node_id(l.id);
+ let pat = self.lower_pat(&l.pat);
+ let span = self.lower_span(l.span);
+ let source = hir::LocalSource::Normal;
+ self.lower_attrs(hir_id, &l.attrs);
+ self.arena.alloc(hir::Local { hir_id, ty, pat, init, span, source })
+ }
+
+ fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {
+ match *b {
+ BlockCheckMode::Default => hir::BlockCheckMode::DefaultBlock,
+ BlockCheckMode::Unsafe(u) => {
+ hir::BlockCheckMode::UnsafeBlock(self.lower_unsafe_source(u))
+ }
+ }
+ }
+
+ fn lower_let_else(
+ &mut self,
+ stmt_hir_id: hir::HirId,
+ local: &Local,
+ init: &Expr,
+ els: &Block,
+ tail: &[Stmt],
+ ) -> (hir::Stmt<'hir>, &'hir hir::Expr<'hir>) {
+ let ty = local
+ .ty
+ .as_ref()
+ .map(|t| self.lower_ty(t, ImplTraitContext::Disallowed(ImplTraitPosition::Binding)));
+ let span = self.lower_span(local.span);
+ let span = self.mark_span_with_reason(DesugaringKind::LetElse, span, None);
+ let init = Some(self.lower_expr(init));
+ let val = Ident::with_dummy_span(sym::val);
+ let (pat, val_id) =
+ self.pat_ident_binding_mode(span, val, hir::BindingAnnotation::Unannotated);
+ let local_hir_id = self.lower_node_id(local.id);
+ self.lower_attrs(local_hir_id, &local.attrs);
+ // first statement which basically exists for the type annotation
+ let stmt = {
+ let local = self.arena.alloc(hir::Local {
+ hir_id: local_hir_id,
+ ty,
+ pat,
+ init,
+ span,
+ source: hir::LocalSource::Normal,
+ });
+ let kind = hir::StmtKind::Local(local);
+ hir::Stmt { hir_id: stmt_hir_id, kind, span }
+ };
+ let let_expr = {
+ let scrutinee = self.expr_ident(span, val, val_id);
+ let let_kind = hir::ExprKind::Let(self.lower_pat(&local.pat), scrutinee, span);
+ self.arena.alloc(self.expr(span, let_kind, AttrVec::new()))
+ };
+ let then_expr = {
+ let (stmts, expr) = self.lower_stmts(tail);
+ let block = self.block_all(span, stmts, expr);
+ self.arena.alloc(self.expr_block(block, AttrVec::new()))
+ };
+ let else_expr = {
+ let block = self.lower_block(els, false);
+ self.arena.alloc(self.expr_block(block, AttrVec::new()))
+ };
+ self.alias_attrs(else_expr.hir_id, local_hir_id);
+ let if_expr = self.arena.alloc(hir::Expr {
+ hir_id: self.next_id(),
+ span,
+ kind: hir::ExprKind::If(let_expr, then_expr, Some(else_expr)),
+ });
+ if !self.sess.features_untracked().let_else {
+ feature_err(
+ &self.sess.parse_sess,
+ sym::let_else,
+ local.span,
+ "`let...else` statements are unstable",
+ )
+ .emit();
+ }
+ (stmt, if_expr)
+ }
+}
diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs
index bf7589e..80633e1 100644
--- a/compiler/rustc_ast_lowering/src/expr.rs
+++ b/compiler/rustc_ast_lowering/src/expr.rs
@@ -58,7 +58,12 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
None,
));
let args = self.lower_exprs(args);
- hir::ExprKind::MethodCall(hir_seg, seg.ident.span, args, span)
+ hir::ExprKind::MethodCall(
+ hir_seg,
+ self.lower_span(seg.ident.span),
+ args,
+ self.lower_span(span),
+ )
}
ExprKind::Binary(binop, ref lhs, ref rhs) => {
let binop = self.lower_binop(binop);
@@ -71,7 +76,9 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
let ohs = self.lower_expr(ohs);
hir::ExprKind::Unary(op, ohs)
}
- ExprKind::Lit(ref l) => hir::ExprKind::Lit(respan(l.span, l.kind.clone())),
+ ExprKind::Lit(ref l) => {
+ hir::ExprKind::Lit(respan(self.lower_span(l.span), l.kind.clone()))
+ }
ExprKind::Cast(ref expr, ref ty) => {
let expr = self.lower_expr(expr);
let ty = self.lower_ty(ty, ImplTraitContext::disallowed());
@@ -86,9 +93,11 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
let ohs = self.lower_expr(ohs);
hir::ExprKind::AddrOf(k, m, ohs)
}
- ExprKind::Let(ref pat, ref scrutinee, span) => {
- hir::ExprKind::Let(self.lower_pat(pat), self.lower_expr(scrutinee), span)
- }
+ ExprKind::Let(ref pat, ref scrutinee, span) => hir::ExprKind::Let(
+ self.lower_pat(pat),
+ self.lower_expr(scrutinee),
+ self.lower_span(span),
+ ),
ExprKind::If(ref cond, ref then, ref else_opt) => {
self.lower_expr_if(cond, then, else_opt.as_deref())
}
@@ -99,7 +108,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
ExprKind::Loop(ref body, opt_label) => self.with_loop_scope(e.id, |this| {
hir::ExprKind::Loop(
this.lower_block(body, false),
- opt_label,
+ this.lower_label(opt_label),
hir::LoopSource::Loop,
DUMMY_SP,
)
@@ -147,6 +156,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
}
}
ExprKind::Block(ref blk, opt_label) => {
+ let opt_label = self.lower_label(opt_label);
hir::ExprKind::Block(self.lower_block(blk, opt_label.is_some()), opt_label)
}
ExprKind::Assign(ref el, ref er, span) => {
@@ -157,7 +167,9 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
self.lower_expr(el),
self.lower_expr(er),
),
- ExprKind::Field(ref el, ident) => hir::ExprKind::Field(self.lower_expr(el), ident),
+ ExprKind::Field(ref el, ident) => {
+ hir::ExprKind::Field(self.lower_expr(el), self.lower_ident(ident))
+ }
ExprKind::Index(ref el, ref er) => {
hir::ExprKind::Index(self.lower_expr(el), self.lower_expr(er))
}
@@ -234,7 +246,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
let mut ex = self.lower_expr_mut(ex);
// Include parens in span, but only if it is a super-span.
if e.span.contains(ex.span) {
- ex.span = e.span;
+ ex.span = self.lower_span(e.span);
}
// Merge attributes into the inner expression.
if !e.attrs.is_empty() {
@@ -262,7 +274,7 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
let hir_id = self.lower_node_id(e.id);
self.lower_attrs(hir_id, &e.attrs);
- hir::Expr { hir_id, kind, span: e.span }
+ hir::Expr { hir_id, kind, span: self.lower_span(e.span) }
})
}
@@ -296,7 +308,7 @@ fn lower_binop(&mut self, b: BinOp) -> hir::BinOp {
BinOpKind::Ge => hir::BinOpKind::Ge,
BinOpKind::Gt => hir::BinOpKind::Gt,
},
- span: b.span,
+ span: self.lower_span(b.span),
}
}
@@ -478,7 +490,13 @@ fn lower_arm(&mut self, arm: &Arm) -> hir::Arm<'hir> {
});
let hir_id = self.next_id();
self.lower_attrs(hir_id, &arm.attrs);
- hir::Arm { hir_id, pat, guard, body: self.lower_expr(&arm.body), span: arm.span }
+ hir::Arm {
+ hir_id,
+ pat,
+ guard,
+ body: self.lower_expr(&arm.body),
+ span: self.lower_span(arm.span),
+ }
}
/// Lower an `async` construct to a generator that is then wrapped so it implements `Future`.
@@ -501,12 +519,16 @@ pub(super) fn make_async_expr(
) -> hir::ExprKind<'hir> {
let output = match ret_ty {
Some(ty) => hir::FnRetTy::Return(self.lower_ty(&ty, ImplTraitContext::disallowed())),
- None => hir::FnRetTy::DefaultReturn(span),
+ None => hir::FnRetTy::DefaultReturn(self.lower_span(span)),
};
// Resume argument type. We let the compiler infer this to simplify the lowering. It is
// fully constrained by `future::from_generator`.
- let input_ty = hir::Ty { hir_id: self.next_id(), kind: hir::TyKind::Infer, span };
+ let input_ty = hir::Ty {
+ hir_id: self.next_id(),
+ kind: hir::TyKind::Infer,
+ span: self.lower_span(span),
+ };
// The closure/generator `FnDecl` takes a single (resume) argument of type `input_ty`.
let decl = self.arena.alloc(hir::FnDecl {
@@ -522,7 +544,12 @@ pub(super) fn make_async_expr(
Ident::with_dummy_span(sym::_task_context),
hir::BindingAnnotation::Mutable,
);
- let param = hir::Param { hir_id: self.next_id(), pat, ty_span: span, span };
+ let param = hir::Param {
+ hir_id: self.next_id(),
+ pat,
+ ty_span: self.lower_span(span),
+ span: self.lower_span(span),
+ };
let params = arena_vec![self; param];
let body_id = self.lower_body(move |this| {
@@ -540,11 +567,14 @@ pub(super) fn make_async_expr(
capture_clause,
decl,
body_id,
- span,
+ self.lower_span(span),
Some(hir::Movability::Static),
);
- let generator =
- hir::Expr { hir_id: self.lower_node_id(closure_node_id), kind: generator_kind, span };
+ let generator = hir::Expr {
+ hir_id: self.lower_node_id(closure_node_id),
+ kind: generator_kind,
+ span: self.lower_span(span),
+ };
// `future::from_generator`:
let unstable_span =
@@ -681,8 +711,11 @@ fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind<'
if let Some(task_context_hid) = self.task_context {
let lhs = self.expr_ident(span, task_context_ident, task_context_hid);
- let assign =
- self.expr(span, hir::ExprKind::Assign(lhs, yield_expr, span), AttrVec::new());
+ let assign = self.expr(
+ span,
+ hir::ExprKind::Assign(lhs, yield_expr, self.lower_span(span)),
+ AttrVec::new(),
+ );
self.stmt_expr(span, assign)
} else {
// Use of `await` outside of an async context. Return `yield_expr` so that we can
@@ -696,8 +729,13 @@ fn lower_expr_await(&mut self, await_span: Span, expr: &Expr) -> hir::ExprKind<'
// loop { .. }
let loop_expr = self.arena.alloc(hir::Expr {
hir_id: loop_hir_id,
- kind: hir::ExprKind::Loop(loop_block, None, hir::LoopSource::Loop, span),
- span,
+ kind: hir::ExprKind::Loop(
+ loop_block,
+ None,
+ hir::LoopSource::Loop,
+ self.lower_span(span),
+ ),
+ span: self.lower_span(span),
});
// mut pinned => loop { ... }
@@ -735,7 +773,13 @@ fn lower_expr_closure(
// Lower outside new scope to preserve `is_in_loop_condition`.
let fn_decl = self.lower_fn_decl(decl, None, false, None);
- hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, generator_option)
+ hir::ExprKind::Closure(
+ capture_clause,
+ fn_decl,
+ body_id,
+ self.lower_span(fn_decl_span),
+ generator_option,
+ )
}
fn generator_movability_for_fn(
@@ -821,7 +865,13 @@ fn lower_expr_async_closure(
// closure argument types.
let fn_decl = self.lower_fn_decl(&outer_decl, None, false, None);
- hir::ExprKind::Closure(capture_clause, fn_decl, body_id, fn_decl_span, None)
+ hir::ExprKind::Closure(
+ capture_clause,
+ fn_decl,
+ body_id,
+ self.lower_span(fn_decl_span),
+ None,
+ )
}
/// Destructure the LHS of complex assignments.
@@ -853,7 +903,11 @@ fn is_ordinary(lower_ctx: &mut LoweringContext<'_, '_>, lhs: &Expr) -> bool {
}
}
if is_ordinary(self, lhs) {
- return hir::ExprKind::Assign(self.lower_expr(lhs), self.lower_expr(rhs), eq_sign_span);
+ return hir::ExprKind::Assign(
+ self.lower_expr(lhs),
+ self.lower_expr(rhs),
+ self.lower_span(eq_sign_span),
+ );
}
if !self.sess.features_untracked().destructuring_assignment {
feature_err(
@@ -878,7 +932,7 @@ fn is_ordinary(lower_ctx: &mut LoweringContext<'_, '_>, lhs: &Expr) -> bool {
whole_span,
Some(rhs),
pat,
- hir::LocalSource::AssignDesugar(eq_sign_span),
+ hir::LocalSource::AssignDesugar(self.lower_span(eq_sign_span)),
);
// `a = lhs1; b = lhs2;`.
@@ -978,10 +1032,10 @@ fn destructure_assign_mut(
let pat = self.destructure_assign(&f.expr, eq_sign_span, assignments);
hir::PatField {
hir_id: self.next_id(),
- ident: f.ident,
+ ident: self.lower_ident(f.ident),
pat,
is_shorthand: f.is_shorthand,
- span: f.span,
+ span: self.lower_span(f.span),
}
}));
let qpath = self.lower_qpath(
@@ -1033,10 +1087,11 @@ fn destructure_assign_mut(
_ => {}
}
// Treat all other cases as normal lvalue.
- let ident = Ident::new(sym::lhs, lhs.span);
+ let ident = Ident::new(sym::lhs, self.lower_span(lhs.span));
let (pat, binding) = self.pat_ident_mut(lhs.span, ident);
let ident = self.expr_ident(lhs.span, ident, binding);
- let assign = hir::ExprKind::Assign(self.lower_expr(lhs), ident, eq_sign_span);
+ let assign =
+ hir::ExprKind::Assign(self.lower_expr(lhs), ident, self.lower_span(eq_sign_span));
let expr = self.expr(lhs.span, assign, ThinVec::new());
assignments.push(self.stmt_expr(lhs.span, expr));
pat
@@ -1076,7 +1131,7 @@ fn destructure_sequence(
fn lower_expr_range_closed(&mut self, span: Span, e1: &Expr, e2: &Expr) -> hir::ExprKind<'hir> {
let e1 = self.lower_expr_mut(e1);
let e2 = self.lower_expr_mut(e2);
- let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, span);
+ let fn_path = hir::QPath::LangItem(hir::LangItem::RangeInclusiveNew, self.lower_span(span));
let fn_expr =
self.arena.alloc(self.expr(span, hir::ExprKind::Path(fn_path), ThinVec::new()));
hir::ExprKind::Call(fn_expr, arena_vec![self; e1, e2])
@@ -1104,12 +1159,21 @@ fn lower_expr_range(
let fields = self.arena.alloc_from_iter(
e1.iter().map(|e| ("start", e)).chain(e2.iter().map(|e| ("end", e))).map(|(s, e)| {
let expr = self.lower_expr(&e);
- let ident = Ident::new(Symbol::intern(s), e.span);
+ let ident = Ident::new(Symbol::intern(s), self.lower_span(e.span));
self.expr_field(ident, expr, e.span)
}),
);
- hir::ExprKind::Struct(self.arena.alloc(hir::QPath::LangItem(lang_item, span)), fields, None)
+ hir::ExprKind::Struct(
+ self.arena.alloc(hir::QPath::LangItem(lang_item, self.lower_span(span))),
+ fields,
+ None,
+ )
+ }
+
+ fn lower_label(&self, opt_label: Option<Label>) -> Option<Label> {
+ let label = opt_label?;
+ Some(Label { ident: self.lower_ident(label.ident) })
}
fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hir::Destination {
@@ -1128,7 +1192,8 @@ fn lower_loop_destination(&mut self, destination: Option<(NodeId, Label)>) -> hi
.map(|id| Ok(self.lower_node_id(id)))
.unwrap_or(Err(hir::LoopIdError::OutsideLoopScope)),
};
- hir::Destination { label: destination.map(|(_, label)| label), target_id }
+ let label = self.lower_label(destination.map(|(_, label)| label));
+ hir::Destination { label, target_id }
}
fn lower_jump_destination(&mut self, id: NodeId, opt_label: Option<Label>) -> hir::Destination {
@@ -1201,7 +1266,7 @@ fn lower_expr_llvm_asm(&mut self, asm: &LlvmInlineAsm) -> hir::ExprKind<'hir> {
constraint: out.constraint,
is_rw: out.is_rw,
is_indirect: out.is_indirect,
- span: out.expr.span,
+ span: self.lower_span(out.expr.span),
})
.collect(),
asm: asm.asm,
@@ -1226,9 +1291,9 @@ fn lower_expr_llvm_asm(&mut self, asm: &LlvmInlineAsm) -> hir::ExprKind<'hir> {
fn lower_expr_field(&mut self, f: &ExprField) -> hir::ExprField<'hir> {
hir::ExprField {
hir_id: self.next_id(),
- ident: f.ident,
+ ident: self.lower_ident(f.ident),
expr: self.lower_expr(&f.expr),
- span: f.span,
+ span: self.lower_span(f.span),
is_shorthand: f.is_shorthand,
}
}
@@ -1289,7 +1354,7 @@ fn lower_expr_for(
orig_head_span,
None,
);
- head.span = desugared_span;
+ head.span = self.lower_span(desugared_span);
let iter = Ident::with_dummy_span(sym::iter);
@@ -1308,7 +1373,7 @@ fn lower_expr_for(
let next_expr = self.expr_ident(pat.span, next_ident, next_pat_hid);
let assign = self.arena.alloc(self.expr(
pat.span,
- hir::ExprKind::Assign(next_expr, val_expr, pat.span),
+ hir::ExprKind::Assign(next_expr, val_expr, self.lower_span(pat.span)),
ThinVec::new(),
));
let some_pat = self.pat_some(pat.span, val_pat);
@@ -1376,12 +1441,15 @@ fn lower_expr_for(
// `[opt_ident]: loop { ... }`
let kind = hir::ExprKind::Loop(
loop_block,
- opt_label,
+ self.lower_label(opt_label),
hir::LoopSource::ForLoop,
- e.span.with_hi(orig_head_span.hi()),
+ self.lower_span(e.span.with_hi(orig_head_span.hi())),
);
- let loop_expr =
- self.arena.alloc(hir::Expr { hir_id: self.lower_node_id(e.id), kind, span: e.span });
+ let loop_expr = self.arena.alloc(hir::Expr {
+ hir_id: self.lower_node_id(e.id),
+ kind,
+ span: self.lower_span(e.span),
+ });
// `mut iter => { ... }`
let iter_arm = self.arm(iter_pat, loop_expr);
@@ -1460,8 +1528,8 @@ fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind<'hir>
let attr = {
// `allow(unreachable_code)`
let allow = {
- let allow_ident = Ident::new(sym::allow, span);
- let uc_ident = Ident::new(sym::unreachable_code, span);
+ let allow_ident = Ident::new(sym::allow, self.lower_span(span));
+ let uc_ident = Ident::new(sym::unreachable_code, self.lower_span(span));
let uc_nested = attr::mk_nested_word_item(uc_ident);
attr::mk_list_item(allow_ident, vec![uc_nested])
};
@@ -1630,7 +1698,11 @@ fn expr_lang_item_path(
lang_item: hir::LangItem,
attrs: AttrVec,
) -> hir::Expr<'hir> {
- self.expr(span, hir::ExprKind::Path(hir::QPath::LangItem(lang_item, span)), attrs)
+ self.expr(
+ span,
+ hir::ExprKind::Path(hir::QPath::LangItem(lang_item, self.lower_span(span))),
+ attrs,
+ )
}
pub(super) fn expr_ident(
@@ -1661,7 +1733,7 @@ fn expr_ident_with_attrs(
let expr_path = hir::ExprKind::Path(hir::QPath::Resolved(
None,
self.arena.alloc(hir::Path {
- span,
+ span: self.lower_span(span),
res: Res::Local(binding),
segments: arena_vec![self; hir::PathSegment::from_ident(ident)],
}),
@@ -1681,7 +1753,7 @@ fn expr_unsafe(&mut self, expr: &'hir hir::Expr<'hir>) -> hir::Expr<'hir> {
expr: Some(expr),
hir_id,
rules: hir::BlockCheckMode::UnsafeBlock(hir::UnsafeSource::CompilerGenerated),
- span,
+ span: self.lower_span(span),
targeted_by_break: false,
}),
None,
@@ -1712,7 +1784,7 @@ pub(super) fn expr(
) -> hir::Expr<'hir> {
let hir_id = self.next_id();
self.lower_attrs(hir_id, &attrs);
- hir::Expr { hir_id, kind, span }
+ hir::Expr { hir_id, kind, span: self.lower_span(span) }
}
fn expr_field(
@@ -1721,10 +1793,22 @@ fn expr_field(
expr: &'hir hir::Expr<'hir>,
span: Span,
) -> hir::ExprField<'hir> {
- hir::ExprField { hir_id: self.next_id(), ident, span, expr, is_shorthand: false }
+ hir::ExprField {
+ hir_id: self.next_id(),
+ ident,
+ span: self.lower_span(span),
+ expr,
+ is_shorthand: false,
+ }
}
fn arm(&mut self, pat: &'hir hir::Pat<'hir>, expr: &'hir hir::Expr<'hir>) -> hir::Arm<'hir> {
- hir::Arm { hir_id: self.next_id(), pat, guard: None, span: expr.span, body: expr }
+ hir::Arm {
+ hir_id: self.next_id(),
+ pat,
+ guard: None,
+ span: self.lower_span(expr.span),
+ body: expr,
+ }
}
}
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs
index 3acf69e..8daeef0 100644
--- a/compiler/rustc_ast_lowering/src/item.rs
+++ b/compiler/rustc_ast_lowering/src/item.rs
@@ -26,44 +26,43 @@ pub(super) struct ItemLowerer<'a, 'lowering, 'hir> {
}
impl ItemLowerer<'_, '_, '_> {
- fn with_trait_impl_ref(&mut self, impl_ref: &Option<TraitRef>, f: impl FnOnce(&mut Self)) {
+ fn with_trait_impl_ref<T>(
+ &mut self,
+ impl_ref: &Option<TraitRef>,
+ f: impl FnOnce(&mut Self) -> T,
+ ) -> T {
let old = self.lctx.is_in_trait_impl;
self.lctx.is_in_trait_impl = impl_ref.is_some();
- f(self);
+ let ret = f(self);
self.lctx.is_in_trait_impl = old;
+ ret
}
}
impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> {
fn visit_item(&mut self, item: &'a Item) {
- let mut item_hir_id = None;
- self.lctx.with_hir_id_owner(item.id, |lctx| {
+ let hir_id = self.lctx.with_hir_id_owner(item.id, |lctx| {
lctx.without_in_scope_lifetime_defs(|lctx| {
- if let Some(hir_item) = lctx.lower_item(item) {
- let id = lctx.insert_item(hir_item);
- item_hir_id = Some(id);
- }
+ let hir_item = lctx.lower_item(item);
+ lctx.insert_item(hir_item)
})
});
- if let Some(hir_id) = item_hir_id {
- self.lctx.with_parent_item_lifetime_defs(hir_id, |this| {
- let this = &mut ItemLowerer { lctx: this };
- match item.kind {
- ItemKind::Mod(..) => {
- let def_id = this.lctx.lower_node_id(item.id).expect_owner();
- let old_current_module =
- mem::replace(&mut this.lctx.current_module, def_id);
- visit::walk_item(this, item);
- this.lctx.current_module = old_current_module;
- }
- ItemKind::Impl(box ImplKind { ref of_trait, .. }) => {
- this.with_trait_impl_ref(of_trait, |this| visit::walk_item(this, item));
- }
- _ => visit::walk_item(this, item),
+ self.lctx.with_parent_item_lifetime_defs(hir_id, |this| {
+ let this = &mut ItemLowerer { lctx: this };
+ match item.kind {
+ ItemKind::Mod(..) => {
+ let def_id = this.lctx.lower_node_id(item.id).expect_owner();
+ let old_current_module = mem::replace(&mut this.lctx.current_module, def_id);
+ visit::walk_item(this, item);
+ this.lctx.current_module = old_current_module;
}
- });
- }
+ ItemKind::Impl(box ImplKind { ref of_trait, .. }) => {
+ this.with_trait_impl_ref(of_trait, |this| visit::walk_item(this, item));
+ }
+ _ => visit::walk_item(this, item),
+ }
+ });
}
fn visit_fn(&mut self, fk: FnKind<'a>, sp: Span, _: NodeId) {
@@ -113,7 +112,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
fn with_parent_item_lifetime_defs<T>(
&mut self,
parent_hir_id: hir::ItemId,
- f: impl FnOnce(&mut LoweringContext<'_, '_>) -> T,
+ f: impl FnOnce(&mut Self) -> T,
) -> T {
let old_len = self.in_scope_lifetimes.len();
@@ -137,10 +136,7 @@ fn with_parent_item_lifetime_defs<T>(
// Clears (and restores) the `in_scope_lifetimes` field. Used when
// visiting nested items, which never inherit in-scope lifetimes
// from their surrounding environment.
- fn without_in_scope_lifetime_defs<T>(
- &mut self,
- f: impl FnOnce(&mut LoweringContext<'_, '_>) -> T,
- ) -> T {
+ fn without_in_scope_lifetime_defs<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T {
let old_in_scope_lifetimes = mem::replace(&mut self.in_scope_lifetimes, vec![]);
// this vector is only used when walking over impl headers,
@@ -158,7 +154,7 @@ fn without_in_scope_lifetime_defs<T>(
pub(super) fn lower_mod(&mut self, items: &[P<Item>], inner: Span) -> hir::Mod<'hir> {
hir::Mod {
- inner,
+ inner: self.lower_span(inner),
item_ids: self.arena.alloc_from_iter(items.iter().flat_map(|x| self.lower_item_id(x))),
}
}
@@ -170,7 +166,6 @@ pub(super) fn lower_mod(&mut self, items: &[P<Item>], inner: Span) -> hir::Mod<'
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
vec
}
- ItemKind::MacroDef(..) => SmallVec::new(),
ItemKind::Fn(..) | ItemKind::Impl(box ImplKind { of_trait: None, .. }) => {
smallvec![i.id]
}
@@ -209,35 +204,19 @@ fn lower_item_id_use_tree(
}
}
- pub fn lower_item(&mut self, i: &Item) -> Option<hir::Item<'hir>> {
+ pub fn lower_item(&mut self, i: &Item) -> hir::Item<'hir> {
let mut ident = i.ident;
let mut vis = self.lower_visibility(&i.vis, None);
-
- if let ItemKind::MacroDef(MacroDef { ref body, macro_rules }) = i.kind {
- if !macro_rules || self.sess.contains_name(&i.attrs, sym::macro_export) {
- let hir_id = self.lower_node_id(i.id);
- self.lower_attrs(hir_id, &i.attrs);
- let body = P(self.lower_mac_args(body));
- self.insert_macro_def(hir::MacroDef {
- ident,
- vis,
- def_id: hir_id.expect_owner(),
- span: i.span,
- ast: MacroDef { body, macro_rules },
- });
- } else {
- for a in i.attrs.iter() {
- let a = self.lower_attr(a);
- self.non_exported_macro_attrs.push(a);
- }
- }
- return None;
- }
-
let hir_id = self.lower_node_id(i.id);
let attrs = self.lower_attrs(hir_id, &i.attrs);
let kind = self.lower_item_kind(i.span, i.id, hir_id, &mut ident, attrs, &mut vis, &i.kind);
- Some(hir::Item { def_id: hir_id.expect_owner(), ident, kind, vis, span: i.span })
+ hir::Item {
+ def_id: hir_id.expect_owner(),
+ ident: self.lower_ident(ident),
+ kind,
+ vis,
+ span: self.lower_span(i.span),
+ }
}
fn lower_item_kind(
@@ -301,7 +280,7 @@ fn lower_item_kind(
let sig = hir::FnSig {
decl,
header: this.lower_fn_header(header, fn_sig_span, id),
- span: fn_sig_span,
+ span: this.lower_span(fn_sig_span),
};
hir::ItemKind::Fn(sig, generics, body_id)
})
@@ -430,6 +409,10 @@ fn lower_item_kind(
// to not cause an assertion failure inside the `lower_defaultness` function.
let has_val = true;
let (defaultness, defaultness_span) = self.lower_defaultness(defaultness, has_val);
+ let polarity = match polarity {
+ ImplPolarity::Positive => ImplPolarity::Positive,
+ ImplPolarity::Negative(s) => ImplPolarity::Negative(self.lower_span(s)),
+ };
hir::ItemKind::Impl(hir::Impl {
unsafety: self.lower_unsafety(unsafety),
polarity,
@@ -465,7 +448,12 @@ fn lower_item_kind(
self.lower_generics(generics, ImplTraitContext::disallowed()),
self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
),
- ItemKind::MacroDef(..) | ItemKind::MacCall(..) => {
+ ItemKind::MacroDef(MacroDef { ref body, macro_rules }) => {
+ let body = P(self.lower_mac_args(body));
+
+ hir::ItemKind::Macro(ast::MacroDef { body, macro_rules })
+ }
+ ItemKind::MacCall(..) => {
panic!("`TyMac` should have been expanded by now")
}
}
@@ -543,10 +531,10 @@ fn lower_use_tree(
this.insert_item(hir::Item {
def_id: new_id.expect_owner(),
- ident,
+ ident: this.lower_ident(ident),
kind,
vis,
- span,
+ span: this.lower_span(span),
});
});
}
@@ -617,10 +605,10 @@ fn lower_use_tree(
this.insert_item(hir::Item {
def_id: new_hir_id.expect_owner(),
- ident,
+ ident: this.lower_ident(ident),
kind,
vis,
- span: use_tree.span,
+ span: this.lower_span(use_tree.span),
});
});
}
@@ -639,7 +627,10 @@ fn lower_use_tree(
hir::VisibilityKind::Public
| hir::VisibilityKind::Crate(_)
| hir::VisibilityKind::Inherited => {
- *vis = respan(prefix.span.shrink_to_lo(), hir::VisibilityKind::Inherited);
+ *vis = respan(
+ self.lower_span(prefix.span.shrink_to_lo()),
+ hir::VisibilityKind::Inherited,
+ );
}
hir::VisibilityKind::Restricted { .. } => {
// Do nothing here, as described in the comment on the match.
@@ -682,7 +673,7 @@ fn rebuild_vis(&mut self, vis: &hir::Visibility<'hir>) -> hir::Visibility<'hir>
}
}
};
- respan(vis.span, vis_kind)
+ respan(self.lower_span(vis.span), vis_kind)
}
fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
@@ -691,7 +682,7 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
self.lower_attrs(hir_id, &i.attrs);
hir::ForeignItem {
def_id,
- ident: i.ident,
+ ident: self.lower_ident(i.ident),
kind: match i.kind {
ForeignItemKind::Fn(box FnKind(_, ref sig, ref generics, _)) => {
let fdec = &sig.decl;
@@ -718,15 +709,15 @@ fn lower_foreign_item(&mut self, i: &ForeignItem) -> hir::ForeignItem<'hir> {
ForeignItemKind::MacCall(_) => panic!("macro shouldn't exist here"),
},
vis: self.lower_visibility(&i.vis, None),
- span: i.span,
+ span: self.lower_span(i.span),
}
}
fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef<'hir> {
hir::ForeignItemRef {
id: hir::ForeignItemId { def_id: self.lower_node_id(i.id).expect_owner() },
- ident: i.ident,
- span: i.span,
+ ident: self.lower_ident(i.ident),
+ span: self.lower_span(i.span),
vis: self.lower_visibility(&i.vis, Some(i.id)),
}
}
@@ -738,8 +729,8 @@ fn lower_variant(&mut self, v: &Variant) -> hir::Variant<'hir> {
id,
data: self.lower_variant_data(id, &v.data),
disr_expr: v.disr_expr.as_ref().map(|e| self.lower_anon_const(e)),
- ident: v.ident,
- span: v.span,
+ ident: self.lower_ident(v.ident),
+ span: self.lower_span(v.span),
}
}
@@ -791,12 +782,12 @@ pub(super) fn lower_field_def(
let hir_id = self.lower_node_id(f.id);
self.lower_attrs(hir_id, &f.attrs);
hir::FieldDef {
- span: f.span,
+ span: self.lower_span(f.span),
hir_id,
ident: match f.ident {
- Some(ident) => ident,
+ Some(ident) => self.lower_ident(ident),
// FIXME(jseyfried): positional field hygiene.
- None => Ident::new(sym::integer(index), f.span),
+ None => Ident::new(sym::integer(index), self.lower_span(f.span)),
},
vis: self.lower_visibility(&f.vis, None),
ty,
@@ -847,7 +838,13 @@ fn lower_trait_item(&mut self, i: &AssocItem) -> hir::TraitItem<'hir> {
};
self.lower_attrs(hir_id, &i.attrs);
- hir::TraitItem { def_id: trait_item_def_id, ident: i.ident, generics, kind, span: i.span }
+ hir::TraitItem {
+ def_id: trait_item_def_id,
+ ident: self.lower_ident(i.ident),
+ generics,
+ kind,
+ span: self.lower_span(i.span),
+ }
}
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
@@ -863,7 +860,13 @@ fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
};
let id = hir::TraitItemId { def_id: self.lower_node_id(i.id).expect_owner() };
let defaultness = hir::Defaultness::Default { has_value: has_default };
- hir::TraitItemRef { id, ident: i.ident, span: i.span, defaultness, kind }
+ hir::TraitItemRef {
+ id,
+ ident: self.lower_ident(i.ident),
+ span: self.lower_span(i.span),
+ defaultness,
+ kind,
+ }
}
/// Construct `ExprKind::Err` for the given `span`.
@@ -928,12 +931,12 @@ fn lower_impl_item(&mut self, i: &AssocItem) -> hir::ImplItem<'hir> {
self.lower_attrs(hir_id, &i.attrs);
hir::ImplItem {
def_id: hir_id.expect_owner(),
- ident: i.ident,
+ ident: self.lower_ident(i.ident),
generics,
vis: self.lower_visibility(&i.vis, None),
defaultness,
kind,
- span: i.span,
+ span: self.lower_span(i.span),
}
}
@@ -943,8 +946,8 @@ fn lower_impl_item_ref(&mut self, i: &AssocItem) -> hir::ImplItemRef<'hir> {
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
hir::ImplItemRef {
id: hir::ImplItemId { def_id: self.lower_node_id(i.id).expect_owner() },
- ident: i.ident,
- span: i.span,
+ ident: self.lower_ident(i.ident),
+ span: self.lower_span(i.span),
vis: self.lower_visibility(&i.vis, Some(i.id)),
defaultness,
kind: match &i.kind {
@@ -987,7 +990,7 @@ fn lower_visibility(
}
VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
};
- respan(v.span, node)
+ respan(self.lower_span(v.span), node)
}
fn lower_defaultness(
@@ -996,7 +999,9 @@ fn lower_defaultness(
has_value: bool,
) -> (hir::Defaultness, Option<Span>) {
match d {
- Defaultness::Default(sp) => (hir::Defaultness::Default { has_value }, Some(sp)),
+ Defaultness::Default(sp) => {
+ (hir::Defaultness::Default { has_value }, Some(self.lower_span(sp)))
+ }
Defaultness::Final => {
assert!(has_value);
(hir::Defaultness::Final, None)
@@ -1034,8 +1039,8 @@ fn lower_param(&mut self, param: &Param) -> hir::Param<'hir> {
hir::Param {
hir_id,
pat: self.lower_pat(¶m.pat),
- ty_span: param.ty.span,
- span: param.span,
+ ty_span: self.lower_span(param.ty.span),
+ span: self.lower_span(param.span),
}
}
@@ -1169,8 +1174,8 @@ fn lower_maybe_async_body(
let new_parameter = hir::Param {
hir_id: parameter.hir_id,
pat: new_parameter_pat,
- ty_span: parameter.ty_span,
- span: parameter.span,
+ ty_span: this.lower_span(parameter.ty_span),
+ span: this.lower_span(parameter.span),
};
if is_simple_parameter {
@@ -1303,7 +1308,7 @@ fn lower_method_sig(
)
},
);
- (generics, hir::FnSig { header, decl, span: sig.span })
+ (generics, hir::FnSig { header, decl, span: self.lower_span(sig.span) })
}
fn lower_fn_header(&mut self, h: FnHeader, span: Span, id: NodeId) -> hir::FnHeader {
@@ -1403,7 +1408,7 @@ pub(super) fn lower_generics_mut(
GenericsCtor {
params: self.lower_generic_params_mut(&generics.params, &add_bounds, itctx).collect(),
where_clause: self.lower_where_clause(&generics.where_clause),
- span: generics.span,
+ span: self.lower_span(generics.span),
}
}
@@ -1422,7 +1427,7 @@ fn lower_where_clause(&mut self, wc: &WhereClause) -> hir::WhereClause<'hir> {
predicates: this.arena.alloc_from_iter(
wc.predicates.iter().map(|predicate| this.lower_where_predicate(predicate)),
),
- span: wc.span,
+ span: this.lower_span(wc.span),
}
})
}
@@ -1451,12 +1456,12 @@ fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicat
// `suggest_constraining_type_param`. This will need to change if
// we ever allow something *other* than `?Sized`.
GenericBound::Trait(p, TraitBoundModifier::Maybe) => {
- hir::GenericBound::Unsized(p.span)
+ hir::GenericBound::Unsized(this.lower_span(p.span))
}
_ => this.lower_param_bound(bound, ImplTraitContext::disallowed()),
},
)),
- span,
+ span: this.lower_span(span),
})
})
}
@@ -1465,7 +1470,7 @@ fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicat
ref bounds,
span,
}) => hir::WherePredicate::RegionPredicate(hir::WhereRegionPredicate {
- span,
+ span: self.lower_span(span),
lifetime: self.lower_lifetime(lifetime),
bounds: self.lower_param_bounds(bounds, ImplTraitContext::disallowed()),
}),
@@ -1474,7 +1479,7 @@ fn lower_where_predicate(&mut self, pred: &WherePredicate) -> hir::WherePredicat
hir_id: self.lower_node_id(id),
lhs_ty: self.lower_ty(lhs_ty, ImplTraitContext::disallowed()),
rhs_ty: self.lower_ty(rhs_ty, ImplTraitContext::disallowed()),
- span,
+ span: self.lower_span(span),
})
}
}
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs
index 7b01887..deb7e74 100644
--- a/compiler/rustc_ast_lowering/src/lib.rs
+++ b/compiler/rustc_ast_lowering/src/lib.rs
@@ -64,7 +64,7 @@
use rustc_span::{Span, DUMMY_SP};
use rustc_target::spec::abi::Abi;
-use smallvec::{smallvec, SmallVec};
+use smallvec::SmallVec;
use std::collections::BTreeMap;
use std::mem;
use tracing::{debug, trace};
@@ -77,6 +77,7 @@ macro_rules! arena_vec {
}
mod asm;
+mod block;
mod expr;
mod item;
mod pat;
@@ -84,7 +85,7 @@ macro_rules! arena_vec {
const HIR_ID_COUNTER_LOCKED: u32 = 0xFFFFFFFF;
-rustc_hir::arena_types!(rustc_arena::declare_arena, [], 'tcx);
+rustc_hir::arena_types!(rustc_arena::declare_arena, 'tcx);
struct LoweringContext<'a, 'hir: 'a> {
/// Used to assign IDs to HIR nodes that do not directly correspond to AST nodes.
@@ -103,7 +104,6 @@ struct LoweringContext<'a, 'hir: 'a> {
/// The items being lowered are collected here.
owners: IndexVec<LocalDefId, Option<hir::OwnerNode<'hir>>>,
bodies: BTreeMap<hir::BodyId, hir::Body<'hir>>,
- non_exported_macro_attrs: Vec<ast::Attribute>,
trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
@@ -330,7 +330,6 @@ pub fn lower_crate<'a, 'hir>(
trait_impls: BTreeMap::new(),
modules: BTreeMap::new(),
attrs: BTreeMap::default(),
- non_exported_macro_attrs: Vec::new(),
catch_scopes: Vec::new(),
loop_scopes: Vec::new(),
is_in_loop_condition: false,
@@ -551,7 +550,6 @@ fn visit_ty(&mut self, t: &'tcx Ty) {
}
let krate = hir::Crate {
- non_exported_macro_attrs: self.arena.alloc_from_iter(self.non_exported_macro_attrs),
owners: self.owners,
bodies: self.bodies,
body_ids,
@@ -600,13 +598,6 @@ fn insert_trait_item(&mut self, item: hir::TraitItem<'hir>) -> hir::TraitItemId
id
}
- fn insert_macro_def(&mut self, item: hir::MacroDef<'hir>) {
- let def_id = item.def_id;
- let item = self.arena.alloc(item);
- self.owners.ensure_contains_elem(def_id, || None);
- self.owners[def_id] = Some(hir::OwnerNode::MacroDef(item));
- }
-
fn allocate_hir_id_counter(&mut self, owner: NodeId) -> hir::HirId {
// Set up the counter if needed.
self.item_local_id_counters.entry(owner).or_insert(0);
@@ -770,6 +761,16 @@ fn with_anonymous_lifetime_mode<R>(
result
}
+ /// Intercept all spans entering HIR.
+ /// For now we are not doing anything with the intercepted spans.
+ fn lower_span(&self, span: Span) -> Span {
+ span
+ }
+
+ fn lower_ident(&self, ident: Ident) -> Ident {
+ Ident::new(ident.name, self.lower_span(ident.span))
+ }
+
/// Creates a new `hir::GenericParam` for every new lifetime and
/// type parameter encountered while evaluating `f`. Definitions
/// are created with the parent provided. If no `parent_id` is
@@ -838,7 +839,7 @@ fn lifetime_to_generic_param(
hir_id: self.lower_node_id(node_id),
name: hir_name,
bounds: &[],
- span,
+ span: self.lower_span(span),
pure_wrt_drop: false,
kind: hir::GenericParamKind::Lifetime { kind },
}
@@ -999,7 +1000,7 @@ fn lower_attr(&self, attr: &Attribute) -> Attribute {
AttrKind::DocComment(comment_kind, data) => AttrKind::DocComment(comment_kind, data),
};
- Attribute { kind, id: attr.id, style: attr.style, span: attr.span }
+ Attribute { kind, id: attr.id, style: attr.style, span: self.lower_span(attr.span) }
}
fn alias_attrs(&mut self, id: hir::HirId, target_id: hir::HirId) {
@@ -1127,7 +1128,7 @@ fn lower_assoc_ty_constraint(
.0
}
};
- self.arena.alloc(gen_args_ctor.into_generic_args(&self.arena))
+ gen_args_ctor.into_generic_args(self)
} else {
self.arena.alloc(hir::GenericArgs::none())
};
@@ -1208,7 +1209,7 @@ fn lower_assoc_ty_constraint(
&Ty {
id: node_id,
kind: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
- span: constraint.span,
+ span: this.lower_span(constraint.span),
tokens: None,
},
itctx,
@@ -1228,10 +1229,10 @@ fn lower_assoc_ty_constraint(
hir::TypeBinding {
hir_id: self.lower_node_id(constraint.id),
- ident: constraint.ident,
+ ident: self.lower_ident(constraint.ident),
gen_args,
kind,
- span: constraint.span,
+ span: self.lower_span(constraint.span),
}
}
@@ -1245,10 +1246,9 @@ fn lower_generic_arg(
ast::GenericArg::Type(ty) => {
match ty.kind {
TyKind::Infer if self.sess.features_untracked().generic_arg_infer => {
- let hir_id = self.lower_node_id(ty.id);
return GenericArg::Infer(hir::InferArg {
- hir_id,
- span: ty.span,
+ hir_id: self.lower_node_id(ty.id),
+ span: self.lower_span(ty.span),
kind: InferKind::Type,
});
}
@@ -1279,10 +1279,11 @@ fn lower_generic_arg(
ty.span,
);
+ let span = self.lower_span(ty.span);
let path_expr = Expr {
id: ty.id,
kind: ExprKind::Path(qself.clone(), path.clone()),
- span: ty.span,
+ span,
attrs: AttrVec::new(),
tokens: None,
};
@@ -1291,7 +1292,7 @@ fn lower_generic_arg(
hir_id: this.lower_node_id(node_id),
body: this.lower_const_body(path_expr.span, Some(&path_expr)),
});
- return GenericArg::Const(ConstArg { value: ct, span: ty.span });
+ return GenericArg::Const(ConstArg { value: ct, span });
}
}
}
@@ -1301,7 +1302,7 @@ fn lower_generic_arg(
}
ast::GenericArg::Const(ct) => GenericArg::Const(ConstArg {
value: self.lower_anon_const(&ct),
- span: ct.value.span,
+ span: self.lower_span(ct.value.span),
}),
}
}
@@ -1328,7 +1329,7 @@ fn lower_path_ty(
}
fn ty(&mut self, span: Span, kind: hir::TyKind<'hir>) -> hir::Ty<'hir> {
- hir::Ty { hir_id: self.next_id(), kind, span }
+ hir::Ty { hir_id: self.next_id(), kind, span: self.lower_span(span) }
}
fn ty_tup(&mut self, span: Span, tys: &'hir [hir::Ty<'hir>]) -> hir::Ty<'hir> {
@@ -1396,7 +1397,7 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
segments: arena_vec![self; hir::PathSegment::from_ident(
Ident::with_dummy_span(kw::SelfUpper)
)],
- span: t.span,
+ span: self.lower_span(t.span),
}),
))
}
@@ -1414,7 +1415,7 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
ref ty,
TraitBoundModifier::None | TraitBoundModifier::MaybeConst,
) => Some(this.lower_poly_trait_ref(ty, itctx.reborrow())),
- // `?const ?Bound` will cause an error during AST validation
+ // `~const ?Bound` will cause an error during AST validation
// anyways, so treat it like `?Bound` as compilation proceeds.
GenericBound::Trait(
_,
@@ -1477,10 +1478,10 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
in_band_ty_params.push(hir::GenericParam {
hir_id: self.lower_node_id(def_node_id),
- name: ParamName::Plain(ident),
+ name: ParamName::Plain(self.lower_ident(ident)),
pure_wrt_drop: false,
bounds: hir_bounds,
- span,
+ span: self.lower_span(span),
kind: hir::GenericParamKind::Type {
default: None,
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
@@ -1490,9 +1491,9 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
hir::TyKind::Path(hir::QPath::Resolved(
None,
self.arena.alloc(hir::Path {
- span,
+ span: self.lower_span(span),
res: Res::Def(DefKind::TyParam, def_id.to_def_id()),
- segments: arena_vec![self; hir::PathSegment::from_ident(ident)],
+ segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident))],
}),
))
}
@@ -1519,7 +1520,7 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_, 'hir>) ->
}
};
- hir::Ty { kind, span: t.span, hir_id: self.lower_node_id(t.id) }
+ hir::Ty { kind, span: self.lower_span(t.span), hir_id: self.lower_node_id(t.id) }
}
fn lower_opaque_impl_trait(
@@ -1564,8 +1565,8 @@ fn lower_opaque_impl_trait(
let opaque_ty_item = hir::OpaqueTy {
generics: hir::Generics {
params: lifetime_defs,
- where_clause: hir::WhereClause { predicates: &[], span },
- span,
+ where_clause: hir::WhereClause { predicates: &[], span: lctx.lower_span(span) },
+ span: lctx.lower_span(span),
},
bounds: hir_bounds,
impl_trait_fn: fn_def_id,
@@ -1596,8 +1597,8 @@ fn generate_opaque_type(
def_id: opaque_ty_id,
ident: Ident::invalid(),
kind: opaque_ty_item_kind,
- vis: respan(span.shrink_to_lo(), hir::VisibilityKind::Inherited),
- span: opaque_ty_span,
+ vis: respan(self.lower_span(span.shrink_to_lo()), hir::VisibilityKind::Inherited),
+ span: self.lower_span(opaque_ty_span),
};
// Insert the item into the global item list. This usually happens
@@ -1724,7 +1725,7 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
self.output_lifetimes.push(hir::GenericArg::Lifetime(hir::Lifetime {
hir_id: self.context.next_id(),
- span: lifetime.span,
+ span: self.context.lower_span(lifetime.span),
name,
}));
@@ -1749,11 +1750,17 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
}
_ => panic!("expected `LifetimeName::Param` or `ParamName::Plain`"),
};
+ let name = match name {
+ hir::ParamName::Plain(ident) => {
+ hir::ParamName::Plain(self.context.lower_ident(ident))
+ }
+ name => name,
+ };
self.output_lifetime_params.push(hir::GenericParam {
hir_id,
name,
- span: lifetime.span,
+ span: self.context.lower_span(lifetime.span),
pure_wrt_drop: false,
bounds: &[],
kind: hir::GenericParamKind::Lifetime { kind },
@@ -1787,24 +1794,6 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
)
}
- fn lower_local(&mut self, l: &Local) -> hir::Local<'hir> {
- let ty = l
- .ty
- .as_ref()
- .map(|t| self.lower_ty(t, ImplTraitContext::Disallowed(ImplTraitPosition::Binding)));
- let init = l.init.as_ref().map(|e| self.lower_expr(e));
- let hir_id = self.lower_node_id(l.id);
- self.lower_attrs(hir_id, &l.attrs);
- hir::Local {
- hir_id,
- ty,
- pat: self.lower_pat(&l.pat),
- init,
- span: l.span,
- source: hir::LocalSource::Normal,
- }
- }
-
fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> &'hir [Ident] {
// Skip the `...` (`CVarArgs`) trailing arguments from the AST,
// as they are not explicit in HIR/Ty function signatures.
@@ -1814,8 +1803,8 @@ fn lower_fn_params_to_names(&mut self, decl: &FnDecl) -> &'hir [Ident] {
inputs = &inputs[..inputs.len() - 1];
}
self.arena.alloc_from_iter(inputs.iter().map(|param| match param.pat.kind {
- PatKind::Ident(_, ident, _) => ident,
- _ => Ident::new(kw::Empty, param.pat.span),
+ PatKind::Ident(_, ident, _) => self.lower_ident(ident),
+ _ => Ident::new(kw::Empty, self.lower_span(param.pat.span)),
}))
}
@@ -1899,7 +1888,7 @@ fn lower_fn_decl(
};
hir::FnRetTy::Return(self.lower_ty(ty, context))
}
- FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(span),
+ FnRetTy::Default(span) => hir::FnRetTy::DefaultReturn(self.lower_span(span)),
}
};
@@ -2056,8 +2045,8 @@ fn lower_async_fn_ret_ty(
let opaque_ty_item = hir::OpaqueTy {
generics: hir::Generics {
params: generic_params,
- where_clause: hir::WhereClause { predicates: &[], span },
- span,
+ where_clause: hir::WhereClause { predicates: &[], span: this.lower_span(span) },
+ span: this.lower_span(span),
},
bounds: arena_vec![this; future_bound],
impl_trait_fn: Some(fn_def_id),
@@ -2092,7 +2081,7 @@ fn lower_async_fn_ret_ty(
// Input lifetime like `'a` or `'1`:
GenericArg::Lifetime(hir::Lifetime {
hir_id: self.next_id(),
- span,
+ span: self.lower_span(span),
name: hir::LifetimeName::Param(hir_name),
})
},
@@ -2101,7 +2090,7 @@ fn lower_async_fn_ret_ty(
// Output lifetime like `'_`.
GenericArg::Lifetime(hir::Lifetime {
hir_id: self.next_id(),
- span,
+ span: self.lower_span(span),
name: hir::LifetimeName::Implicit,
})));
let generic_args = self.arena.alloc_from_iter(generic_args);
@@ -2149,7 +2138,7 @@ fn lower_async_fn_output_type_to_future_bound(
hir::GenericBound::LangItemTrait(
// ::std::future::Future<future_params>
hir::LangItem::Future,
- span,
+ self.lower_span(span),
self.next_id(),
future_args,
)
@@ -2172,7 +2161,7 @@ fn lower_param_bound(
}
fn lower_lifetime(&mut self, l: &Lifetime) -> hir::Lifetime {
- let span = l.ident.span;
+ let span = self.lower_span(l.ident.span);
match l.ident {
ident if ident.name == kw::StaticLifetime => {
self.new_named_lifetime(l.id, span, hir::LifetimeName::Static)
@@ -2191,7 +2180,7 @@ fn lower_lifetime(&mut self, l: &Lifetime) -> hir::Lifetime {
},
ident => {
self.maybe_collect_in_band_lifetime(ident);
- let param_name = ParamName::Plain(ident);
+ let param_name = ParamName::Plain(self.lower_ident(ident));
self.new_named_lifetime(l.id, span, hir::LifetimeName::Param(param_name))
}
}
@@ -2203,7 +2192,7 @@ fn new_named_lifetime(
span: Span,
name: hir::LifetimeName,
) -> hir::Lifetime {
- hir::Lifetime { hir_id: self.lower_node_id(id), span, name }
+ hir::Lifetime { hir_id: self.lower_node_id(id), span: self.lower_span(span), name }
}
fn lower_generic_params_mut<'s>(
@@ -2286,7 +2275,7 @@ fn lower_generic_param(
.next(),
};
- (hir::ParamName::Plain(param.ident), kind)
+ (hir::ParamName::Plain(self.lower_ident(param.ident)), kind)
}
GenericParamKind::Const { ref ty, kw_span: _, ref default } => {
let ty = self
@@ -2294,16 +2283,23 @@ fn lower_generic_param(
this.lower_ty(&ty, ImplTraitContext::disallowed())
});
let default = default.as_ref().map(|def| self.lower_anon_const(def));
- (hir::ParamName::Plain(param.ident), hir::GenericParamKind::Const { ty, default })
+ (
+ hir::ParamName::Plain(self.lower_ident(param.ident)),
+ hir::GenericParamKind::Const { ty, default },
+ )
}
};
+ let name = match name {
+ hir::ParamName::Plain(ident) => hir::ParamName::Plain(self.lower_ident(ident)),
+ name => name,
+ };
let hir_id = self.lower_node_id(param.id);
self.lower_attrs(hir_id, ¶m.attrs);
hir::GenericParam {
hir_id,
name,
- span: param.ident.span,
+ span: self.lower_span(param.ident.span),
pure_wrt_drop: self.sess.contains_name(¶m.attrs, sym::may_dangle),
bounds: self.arena.alloc_from_iter(bounds),
kind,
@@ -2360,7 +2356,7 @@ fn lower_poly_trait_ref(
res
});
- hir::PolyTraitRef { bound_generic_params, trait_ref, span: p.span }
+ hir::PolyTraitRef { bound_generic_params, trait_ref, span: self.lower_span(p.span) }
}
fn lower_mt(&mut self, mt: &MutTy, itctx: ImplTraitContext<'_, 'hir>) -> hir::MutTy<'hir> {
@@ -2383,23 +2379,6 @@ fn lower_param_bounds_mut<'s>(
bounds.iter().map(move |bound| self.lower_param_bound(bound, itctx.reborrow()))
}
- fn lower_block(&mut self, b: &Block, targeted_by_break: bool) -> &'hir hir::Block<'hir> {
- self.arena.alloc(self.lower_block_noalloc(b, targeted_by_break))
- }
-
- fn lower_block_noalloc(&mut self, b: &Block, targeted_by_break: bool) -> hir::Block<'hir> {
- let (stmts, expr) = match &*b.stmts {
- [stmts @ .., Stmt { kind: StmtKind::Expr(e), .. }] => (stmts, Some(&*e)),
- stmts => (stmts, None),
- };
- let stmts = self.arena.alloc_from_iter(stmts.iter().flat_map(|stmt| self.lower_stmt(stmt)));
- let expr = expr.map(|e| self.lower_expr(e));
- let rules = self.lower_block_check_mode(&b.rules);
- let hir_id = self.lower_node_id(b.id);
-
- hir::Block { hir_id, stmts, expr, rules, span: b.span, targeted_by_break }
- }
-
/// Lowers a block directly to an expression, presuming that it
/// has no attributes and is not targeted by a `break`.
fn lower_block_expr(&mut self, b: &Block) -> hir::Expr<'hir> {
@@ -2414,61 +2393,6 @@ fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
})
}
- fn lower_stmt(&mut self, s: &Stmt) -> SmallVec<[hir::Stmt<'hir>; 1]> {
- let (hir_id, kind) = match s.kind {
- StmtKind::Local(ref l) => {
- let l = self.lower_local(l);
- let hir_id = self.lower_node_id(s.id);
- self.alias_attrs(hir_id, l.hir_id);
- return smallvec![hir::Stmt {
- hir_id,
- kind: hir::StmtKind::Local(self.arena.alloc(l)),
- span: s.span,
- }];
- }
- StmtKind::Item(ref it) => {
- // Can only use the ID once.
- let mut id = Some(s.id);
- return self
- .lower_item_id(it)
- .into_iter()
- .map(|item_id| {
- let hir_id = id
- .take()
- .map(|id| self.lower_node_id(id))
- .unwrap_or_else(|| self.next_id());
-
- hir::Stmt { hir_id, kind: hir::StmtKind::Item(item_id), span: s.span }
- })
- .collect();
- }
- StmtKind::Expr(ref e) => {
- let e = self.lower_expr(e);
- let hir_id = self.lower_node_id(s.id);
- self.alias_attrs(hir_id, e.hir_id);
- (hir_id, hir::StmtKind::Expr(e))
- }
- StmtKind::Semi(ref e) => {
- let e = self.lower_expr(e);
- let hir_id = self.lower_node_id(s.id);
- self.alias_attrs(hir_id, e.hir_id);
- (hir_id, hir::StmtKind::Semi(e))
- }
- StmtKind::Empty => return smallvec![],
- StmtKind::MacCall(..) => panic!("shouldn't exist here"),
- };
- smallvec![hir::Stmt { hir_id, kind, span: s.span }]
- }
-
- fn lower_block_check_mode(&mut self, b: &BlockCheckMode) -> hir::BlockCheckMode {
- match *b {
- BlockCheckMode::Default => hir::BlockCheckMode::DefaultBlock,
- BlockCheckMode::Unsafe(u) => {
- hir::BlockCheckMode::UnsafeBlock(self.lower_unsafe_source(u))
- }
- }
- }
-
fn lower_unsafe_source(&mut self, u: UnsafeSource) -> hir::UnsafeSource {
match u {
CompilerGenerated => hir::UnsafeSource::CompilerGenerated,
@@ -2492,7 +2416,7 @@ fn lower_trait_bound_modifier(&mut self, f: TraitBoundModifier) -> hir::TraitBou
// Helper methods for building HIR.
fn stmt(&mut self, span: Span, kind: hir::StmtKind<'hir>) -> hir::Stmt<'hir> {
- hir::Stmt { span, kind, hir_id: self.next_id() }
+ hir::Stmt { span: self.lower_span(span), kind, hir_id: self.next_id() }
}
fn stmt_expr(&mut self, span: Span, expr: hir::Expr<'hir>) -> hir::Stmt<'hir> {
@@ -2512,7 +2436,7 @@ fn stmt_let_pat(
debug_assert!(!a.is_empty());
self.attrs.insert(hir_id, a);
}
- let local = hir::Local { hir_id, init, pat, source, span, ty: None };
+ let local = hir::Local { hir_id, init, pat, source, span: self.lower_span(span), ty: None };
self.stmt(span, hir::StmtKind::Local(self.arena.alloc(local)))
}
@@ -2531,7 +2455,7 @@ fn block_all(
expr,
hir_id: self.next_id(),
rules: hir::BlockCheckMode::DefaultBlock,
- span,
+ span: self.lower_span(span),
targeted_by_break: false,
};
self.arena.alloc(blk)
@@ -2563,10 +2487,10 @@ fn single_pat_field(
) -> &'hir [hir::PatField<'hir>] {
let field = hir::PatField {
hir_id: self.next_id(),
- ident: Ident::new(sym::integer(0), span),
+ ident: Ident::new(sym::integer(0), self.lower_span(span)),
is_shorthand: false,
pat,
- span,
+ span: self.lower_span(span),
};
arena_vec![self; field]
}
@@ -2577,7 +2501,7 @@ fn pat_lang_item_variant(
lang_item: hir::LangItem,
fields: &'hir [hir::PatField<'hir>],
) -> &'hir hir::Pat<'hir> {
- let qpath = hir::QPath::LangItem(lang_item, span);
+ let qpath = hir::QPath::LangItem(lang_item, self.lower_span(span));
self.pat(span, hir::PatKind::Struct(qpath, fields, false))
}
@@ -2610,8 +2534,8 @@ fn pat_ident_binding_mode_mut(
(
hir::Pat {
hir_id,
- kind: hir::PatKind::Binding(bm, hir_id, ident.with_span_pos(span), None),
- span,
+ kind: hir::PatKind::Binding(bm, hir_id, self.lower_ident(ident), None),
+ span: self.lower_span(span),
default_binding_modes: true,
},
hir_id,
@@ -2622,13 +2546,18 @@ fn pat(&mut self, span: Span, kind: hir::PatKind<'hir>) -> &'hir hir::Pat<'hir>
self.arena.alloc(hir::Pat {
hir_id: self.next_id(),
kind,
- span,
+ span: self.lower_span(span),
default_binding_modes: true,
})
}
fn pat_without_dbm(&mut self, span: Span, kind: hir::PatKind<'hir>) -> hir::Pat<'hir> {
- hir::Pat { hir_id: self.next_id(), kind, span, default_binding_modes: false }
+ hir::Pat {
+ hir_id: self.next_id(),
+ kind,
+ span: self.lower_span(span),
+ default_binding_modes: false,
+ }
}
fn ty_path(
@@ -2645,7 +2574,7 @@ fn ty_path(
let principal = hir::PolyTraitRef {
bound_generic_params: &[],
trait_ref: hir::TraitRef { path, hir_ref_id: hir_id },
- span,
+ span: self.lower_span(span),
};
// The original ID is taken by the `PolyTraitRef`,
@@ -2663,7 +2592,7 @@ fn ty_path(
_ => hir::TyKind::Path(qpath),
};
- hir::Ty { hir_id, kind, span }
+ hir::Ty { hir_id, kind, span: self.lower_span(span) }
}
/// Invoked to create the lifetime argument for a type `&T`
@@ -2678,7 +2607,7 @@ fn elided_ref_lifetime(&mut self, span: Span) -> hir::Lifetime {
let fresh_name = self.collect_fresh_in_band_lifetime(span);
hir::Lifetime {
hir_id: self.next_id(),
- span,
+ span: self.lower_span(span),
name: hir::LifetimeName::Param(fresh_name),
}
}
@@ -2773,7 +2702,7 @@ fn elided_dyn_bound(&mut self, span: Span) -> hir::Lifetime {
let r = hir::Lifetime {
hir_id: self.next_id(),
- span,
+ span: self.lower_span(span),
name: hir::LifetimeName::ImplicitObjectLifetimeDefault,
};
debug!("elided_dyn_bound: r={:?}", r);
@@ -2781,7 +2710,11 @@ fn elided_dyn_bound(&mut self, span: Span) -> hir::Lifetime {
}
fn new_implicit_lifetime(&mut self, span: Span) -> hir::Lifetime {
- hir::Lifetime { hir_id: self.next_id(), span, name: hir::LifetimeName::Implicit }
+ hir::Lifetime {
+ hir_id: self.next_id(),
+ span: self.lower_span(span),
+ name: hir::LifetimeName::Implicit,
+ }
}
fn maybe_lint_bare_trait(&mut self, span: Span, id: NodeId, is_global: bool) {
@@ -2859,12 +2792,13 @@ fn is_empty(&self) -> bool {
self.args.is_empty() && self.bindings.is_empty() && !self.parenthesized
}
- fn into_generic_args(self, arena: &'hir Arena<'hir>) -> hir::GenericArgs<'hir> {
- hir::GenericArgs {
- args: arena.alloc_from_iter(self.args),
+ fn into_generic_args(self, this: &LoweringContext<'_, 'hir>) -> &'hir hir::GenericArgs<'hir> {
+ let ga = hir::GenericArgs {
+ args: this.arena.alloc_from_iter(self.args),
bindings: self.bindings,
parenthesized: self.parenthesized,
- span_ext: self.span,
- }
+ span_ext: this.lower_span(self.span),
+ };
+ this.arena.alloc(ga)
}
}
diff --git a/compiler/rustc_ast_lowering/src/pat.rs b/compiler/rustc_ast_lowering/src/pat.rs
index d81ddd2..0a9b264 100644
--- a/compiler/rustc_ast_lowering/src/pat.rs
+++ b/compiler/rustc_ast_lowering/src/pat.rs
@@ -62,10 +62,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
let fs = self.arena.alloc_from_iter(fields.iter().map(|f| hir::PatField {
hir_id: self.next_id(),
- ident: f.ident,
+ ident: self.lower_ident(f.ident),
pat: self.lower_pat(&f.pat),
is_shorthand: f.is_shorthand,
- span: f.span,
+ span: self.lower_span(f.span),
}));
break hir::PatKind::Struct(qpath, fs, etc);
}
@@ -247,16 +247,16 @@ fn lower_pat_ident(
hir::PatKind::Binding(
self.lower_binding_mode(binding_mode),
self.lower_node_id(canonical_id),
- ident,
+ self.lower_ident(ident),
lower_sub(self),
)
}
Some(res) => hir::PatKind::Path(hir::QPath::Resolved(
None,
self.arena.alloc(hir::Path {
- span: ident.span,
+ span: self.lower_span(ident.span),
res: self.lower_res(res),
- segments: arena_vec![self; hir::PathSegment::from_ident(ident)],
+ segments: arena_vec![self; hir::PathSegment::from_ident(self.lower_ident(ident))],
}),
)),
}
@@ -280,7 +280,7 @@ fn pat_with_node_id_of(&mut self, p: &Pat, kind: hir::PatKind<'hir>) -> hir::Pat
hir::Pat {
hir_id: self.lower_node_id(p.id),
kind,
- span: p.span,
+ span: self.lower_span(p.span),
default_binding_modes: true,
}
}
diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs
index 55173c6..a11d020 100644
--- a/compiler/rustc_ast_lowering/src/path.rs
+++ b/compiler/rustc_ast_lowering/src/path.rs
@@ -110,9 +110,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
)
},
)),
- span: p.segments[..proj_start]
- .last()
- .map_or(path_span_lo, |segment| path_span_lo.to(segment.span())),
+ span: self.lower_span(
+ p.segments[..proj_start]
+ .last()
+ .map_or(path_span_lo, |segment| path_span_lo.to(segment.span())),
+ ),
});
// Simple case, either no projections, or only fully-qualified.
@@ -198,7 +200,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
explicit_owner,
)
})),
- span: p.span,
+ span: self.lower_span(p.span),
})
}
@@ -370,14 +372,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
);
hir::PathSegment {
- ident: segment.ident,
+ ident: self.lower_ident(segment.ident),
hir_id: Some(id),
res: Some(self.lower_res(res)),
infer_args,
args: if generic_args.is_empty() && generic_args.span.is_empty() {
None
} else {
- Some(self.arena.alloc(generic_args.into_generic_args(self.arena)))
+ Some(generic_args.into_generic_args(self))
},
}
}
@@ -459,6 +461,12 @@ fn lower_parenthesized_parameter_data(
parenthesized: false,
span_ext: DUMMY_SP,
});
- hir::TypeBinding { hir_id: self.next_id(), gen_args, span, ident, kind }
+ hir::TypeBinding {
+ hir_id: self.next_id(),
+ gen_args,
+ span: self.lower_span(span),
+ ident,
+ kind,
+ }
}
}
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs
index cff1b70d..a243300 100644
--- a/compiler/rustc_ast_passes/src/ast_validation.rs
+++ b/compiler/rustc_ast_passes/src/ast_validation.rs
@@ -33,24 +33,6 @@ enum SelfSemantic {
No,
}
-/// A syntactic context that disallows certain kinds of bounds (e.g., `?Trait` or `?const Trait`).
-#[derive(Clone, Copy)]
-enum BoundContext {
- ImplTrait,
- TraitBounds,
- TraitObject,
-}
-
-impl BoundContext {
- fn description(&self) -> &'static str {
- match self {
- Self::ImplTrait => "`impl Trait`",
- Self::TraitBounds => "supertraits",
- Self::TraitObject => "trait objects",
- }
- }
-}
-
struct AstValidator<'a> {
session: &'a Session,
@@ -60,6 +42,8 @@ struct AstValidator<'a> {
/// Are we inside a trait impl?
in_trait_impl: bool,
+ in_const_trait_impl: bool,
+
has_proc_macro_decls: bool,
/// Used to ban nested `impl Trait`, e.g., `impl Into<impl Debug>`.
@@ -67,11 +51,7 @@ struct AstValidator<'a> {
/// e.g., `impl Iterator<Item = impl Debug>`.
outer_impl_trait: Option<Span>,
- /// Keeps track of the `BoundContext` as we recurse.
- ///
- /// This is used to forbid `?const Trait` bounds in, e.g.,
- /// `impl Iterator<Item = Box<dyn ?const Trait>`.
- bound_context: Option<BoundContext>,
+ is_tilde_const_allowed: bool,
/// Used to ban `impl Trait` in path projections like `<impl Iterator>::Item`
/// or `Foo::Bar<impl Trait>`
@@ -88,10 +68,18 @@ struct AstValidator<'a> {
}
impl<'a> AstValidator<'a> {
- fn with_in_trait_impl(&mut self, is_in: bool, f: impl FnOnce(&mut Self)) {
+ fn with_in_trait_impl(
+ &mut self,
+ is_in: bool,
+ constness: Option<Const>,
+ f: impl FnOnce(&mut Self),
+ ) {
let old = mem::replace(&mut self.in_trait_impl, is_in);
+ let old_const =
+ mem::replace(&mut self.in_const_trait_impl, matches!(constness, Some(Const::Yes(_))));
f(self);
self.in_trait_impl = old;
+ self.in_const_trait_impl = old_const;
}
fn with_banned_impl_trait(&mut self, f: impl FnOnce(&mut Self)) {
@@ -100,6 +88,18 @@ fn with_banned_impl_trait(&mut self, f: impl FnOnce(&mut Self)) {
self.is_impl_trait_banned = old;
}
+ fn with_tilde_const_allowed(&mut self, f: impl FnOnce(&mut Self)) {
+ let old = mem::replace(&mut self.is_tilde_const_allowed, true);
+ f(self);
+ self.is_tilde_const_allowed = old;
+ }
+
+ fn with_banned_tilde_const(&mut self, f: impl FnOnce(&mut Self)) {
+ let old = mem::replace(&mut self.is_tilde_const_allowed, false);
+ f(self);
+ self.is_tilde_const_allowed = old;
+ }
+
fn with_let_allowed(&mut self, allowed: bool, f: impl FnOnce(&mut Self, bool)) {
let old = mem::replace(&mut self.is_let_allowed, allowed);
f(self, old);
@@ -130,19 +130,13 @@ fn with_banned_assoc_ty_bound(&mut self, f: impl FnOnce(&mut Self)) {
fn with_impl_trait(&mut self, outer: Option<Span>, f: impl FnOnce(&mut Self)) {
let old = mem::replace(&mut self.outer_impl_trait, outer);
if outer.is_some() {
- self.with_bound_context(BoundContext::ImplTrait, |this| f(this));
+ self.with_banned_tilde_const(f);
} else {
- f(self)
+ f(self);
}
self.outer_impl_trait = old;
}
- fn with_bound_context(&mut self, ctx: BoundContext, f: impl FnOnce(&mut Self)) {
- let old = self.bound_context.replace(ctx);
- f(self);
- self.bound_context = old;
- }
-
fn visit_assoc_ty_constraint_from_generic_args(&mut self, constraint: &'a AssocTyConstraint) {
match constraint.kind {
AssocTyConstraintKind::Equality { .. } => {}
@@ -164,9 +158,7 @@ fn walk_ty(&mut self, t: &'a Ty) {
TyKind::ImplTrait(..) => {
self.with_impl_trait(Some(t.span), |this| visit::walk_ty(this, t))
}
- TyKind::TraitObject(..) => {
- self.with_bound_context(BoundContext::TraitObject, |this| visit::walk_ty(this, t));
- }
+ TyKind::TraitObject(..) => self.with_banned_tilde_const(|this| visit::walk_ty(this, t)),
TyKind::Path(ref qself, ref path) => {
// We allow these:
// - `Option<impl Trait>`
@@ -1083,13 +1075,13 @@ fn visit_item(&mut self, item: &'a Item) {
unsafety,
polarity,
defaultness: _,
- constness: _,
- generics: _,
+ constness,
+ ref generics,
of_trait: Some(ref t),
ref self_ty,
- items: _,
+ ref items,
}) => {
- self.with_in_trait_impl(true, |this| {
+ self.with_in_trait_impl(true, Some(constness), |this| {
this.invalid_visibility(&item.vis, None);
if let TyKind::Err = self_ty.kind {
this.err_handler()
@@ -1112,7 +1104,17 @@ fn visit_item(&mut self, item: &'a Item) {
.emit();
}
- visit::walk_item(this, item);
+ this.visit_vis(&item.vis);
+ this.visit_ident(item.ident);
+ if let Const::Yes(_) = constness {
+ this.with_tilde_const_allowed(|this| this.visit_generics(generics));
+ } else {
+ this.visit_generics(generics);
+ }
+ this.visit_trait_ref(t);
+ this.visit_ty(self_ty);
+
+ walk_list!(this, visit_assoc_item, items, AssocCtxt::Impl);
});
return; // Avoid visiting again.
}
@@ -1157,13 +1159,24 @@ fn visit_item(&mut self, item: &'a Item) {
.emit();
}
}
- ItemKind::Fn(box FnKind(def, _, _, ref body)) => {
+ ItemKind::Fn(box FnKind(def, ref sig, ref generics, ref body)) => {
self.check_defaultness(item.span, def);
if body.is_none() {
let msg = "free function without a body";
self.error_item_without_body(item.span, "function", msg, " { <body> }");
}
+ self.visit_vis(&item.vis);
+ self.visit_ident(item.ident);
+ if let Const::Yes(_) = sig.header.constness {
+ self.with_tilde_const_allowed(|this| this.visit_generics(generics));
+ } else {
+ self.visit_generics(generics);
+ }
+ let kind = FnKind::Fn(FnCtxt::Free, item.ident, sig, &item.vis, body.as_deref());
+ self.visit_fn(kind, item.span, item.id);
+ walk_list!(self, visit_attribute, &item.attrs);
+ return; // Avoid visiting again.
}
ItemKind::ForeignMod(ForeignMod { unsafety, .. }) => {
let old_item = mem::replace(&mut self.extern_mod, Some(item));
@@ -1206,9 +1219,7 @@ fn visit_item(&mut self, item: &'a Item) {
self.visit_vis(&item.vis);
self.visit_ident(item.ident);
self.visit_generics(generics);
- self.with_bound_context(BoundContext::TraitBounds, |this| {
- walk_list!(this, visit_param_bound, bounds);
- });
+ self.with_banned_tilde_const(|this| walk_list!(this, visit_param_bound, bounds));
walk_list!(self, visit_assoc_item, trait_items, AssocCtxt::Trait);
walk_list!(self, visit_attribute, &item.attrs);
return;
@@ -1281,7 +1292,7 @@ fn visit_item(&mut self, item: &'a Item) {
_ => {}
}
- visit::walk_item(self, item)
+ visit::walk_item(self, item);
}
fn visit_foreign_item(&mut self, fi: &'a ForeignItem) {
@@ -1340,7 +1351,7 @@ fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) {
}
fn visit_generics(&mut self, generics: &'a Generics) {
- let cg_defaults = self.session.features_untracked().const_generics_defaults;
+ let cg_defaults = self.session.features_untracked().unordered_const_ty_params();
let mut prev_param_default = None;
for param in &generics.params {
@@ -1428,15 +1439,17 @@ fn visit_generic_param(&mut self, param: &'a GenericParam) {
fn visit_param_bound(&mut self, bound: &'a GenericBound) {
match bound {
GenericBound::Trait(_, TraitBoundModifier::MaybeConst) => {
- if let Some(ctx) = self.bound_context {
- let msg = format!("`?const` is not permitted in {}", ctx.description());
- self.err_handler().span_err(bound.span(), &msg);
+ if !self.is_tilde_const_allowed {
+ self.err_handler()
+ .struct_span_err(bound.span(), "`~const` is not allowed here")
+ .note("only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions")
+ .emit();
}
}
GenericBound::Trait(_, TraitBoundModifier::MaybeConstMaybe) => {
self.err_handler()
- .span_err(bound.span(), "`?const` and `?` are mutually exclusive");
+ .span_err(bound.span(), "`~const` and `?` are mutually exclusive");
}
_ => {}
@@ -1589,7 +1602,32 @@ fn visit_assoc_item(&mut self, item: &'a AssocItem, ctxt: AssocCtxt) {
self.check_item_named(item.ident, "const");
}
- self.with_in_trait_impl(false, |this| visit::walk_assoc_item(this, item, ctxt));
+ match item.kind {
+ AssocItemKind::TyAlias(box TyAliasKind(_, ref generics, ref bounds, ref ty))
+ if ctxt == AssocCtxt::Trait =>
+ {
+ self.visit_vis(&item.vis);
+ self.visit_ident(item.ident);
+ walk_list!(self, visit_attribute, &item.attrs);
+ self.with_tilde_const_allowed(|this| {
+ this.visit_generics(generics);
+ walk_list!(this, visit_param_bound, bounds);
+ });
+ walk_list!(self, visit_ty, ty);
+ }
+ AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, ref body))
+ if self.in_const_trait_impl || ctxt == AssocCtxt::Trait =>
+ {
+ self.visit_vis(&item.vis);
+ self.visit_ident(item.ident);
+ self.with_tilde_const_allowed(|this| this.visit_generics(generics));
+ let kind =
+ FnKind::Fn(FnCtxt::Assoc(ctxt), item.ident, sig, &item.vis, body.as_deref());
+ self.visit_fn(kind, item.span, item.id);
+ }
+ _ => self
+ .with_in_trait_impl(false, None, |this| visit::walk_assoc_item(this, item, ctxt)),
+ }
}
}
@@ -1683,9 +1721,10 @@ pub fn check_crate(session: &Session, krate: &Crate, lints: &mut LintBuffer) ->
session,
extern_mod: None,
in_trait_impl: false,
+ in_const_trait_impl: false,
has_proc_macro_decls: false,
outer_impl_trait: None,
- bound_context: None,
+ is_tilde_const_allowed: false,
is_impl_trait_banned: false,
is_assoc_ty_bound_banned: false,
is_let_allowed: false,
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index 0be26b6..1defb65 100644
--- a/compiler/rustc_ast_passes/src/feature_gate.rs
+++ b/compiler/rustc_ast_passes/src/feature_gate.rs
@@ -656,7 +656,6 @@ macro_rules! gate_all {
gate_all!(more_qualified_paths, "usage of qualified paths in this context is experimental");
gate_all!(generators, "yield syntax is experimental");
gate_all!(raw_ref_op, "raw address of syntax is experimental");
- gate_all!(const_trait_bound_opt_out, "`?const` on trait bounds is experimental");
gate_all!(const_trait_impl, "const trait impls are experimental");
gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
gate_all!(inline_const, "inline-const is experimental");
@@ -688,7 +687,6 @@ macro_rules! gate_all {
gate_all!(trait_alias, "trait aliases are experimental");
gate_all!(associated_type_bounds, "associated type bounds are unstable");
gate_all!(crate_visibility_modifier, "`crate` visibility modifier is experimental");
- gate_all!(const_generics, "const generics are unstable");
gate_all!(decl_macro, "`macro` is experimental");
gate_all!(box_patterns, "box pattern syntax is experimental");
gate_all!(exclusive_range_pattern, "exclusive range pattern syntax is experimental");
diff --git a/compiler/rustc_ast_pretty/src/pprust/mod.rs b/compiler/rustc_ast_pretty/src/pprust/mod.rs
index 976725b..e74f38d 100644
--- a/compiler/rustc_ast_pretty/src/pprust/mod.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/mod.rs
@@ -8,17 +8,19 @@
use rustc_ast::token::{Nonterminal, Token, TokenKind};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
+use std::borrow::Cow;
+
pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
State::new().nonterminal_to_string(nt)
}
/// Print the token kind precisely, without converting `$crate` into its respective crate name.
-pub fn token_kind_to_string(tok: &TokenKind) -> String {
+pub fn token_kind_to_string(tok: &TokenKind) -> Cow<'static, str> {
State::new().token_kind_to_string(tok)
}
/// Print the token precisely, without converting `$crate` into its respective crate name.
-pub fn token_to_string(token: &Token) -> String {
+pub fn token_to_string(token: &Token) -> Cow<'static, str> {
State::new().token_to_string(token)
}
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs
index b09c668..3cf04be 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state.rs
@@ -578,6 +578,33 @@ fn print_mac_common(
}
}
+ fn print_mac_def(
+ &mut self,
+ macro_def: &ast::MacroDef,
+ ident: &Ident,
+ sp: &Span,
+ print_visibility: impl FnOnce(&mut Self),
+ ) {
+ let (kw, has_bang) = if macro_def.macro_rules {
+ ("macro_rules", true)
+ } else {
+ print_visibility(self);
+ ("macro", false)
+ };
+ self.print_mac_common(
+ Some(MacHeader::Keyword(kw)),
+ has_bang,
+ Some(*ident),
+ macro_def.body.delim(),
+ ¯o_def.body.inner_tokens(),
+ true,
+ *sp,
+ );
+ if macro_def.body.need_semicolon() {
+ self.word(";");
+ }
+ }
+
fn print_path(&mut self, path: &ast::Path, colons_before_params: bool, depth: usize) {
self.maybe_print_comment(path.span.lo());
@@ -658,7 +685,7 @@ fn nonterminal_to_string(&self, nt: &Nonterminal) -> String {
}
/// Print the token kind precisely, without converting `$crate` into its respective crate name.
- fn token_kind_to_string(&self, tok: &TokenKind) -> String {
+ fn token_kind_to_string(&self, tok: &TokenKind) -> Cow<'static, str> {
self.token_kind_to_string_ext(tok, None)
}
@@ -666,72 +693,72 @@ fn token_kind_to_string_ext(
&self,
tok: &TokenKind,
convert_dollar_crate: Option<Span>,
- ) -> String {
+ ) -> Cow<'static, str> {
match *tok {
- token::Eq => "=".to_string(),
- token::Lt => "<".to_string(),
- token::Le => "<=".to_string(),
- token::EqEq => "==".to_string(),
- token::Ne => "!=".to_string(),
- token::Ge => ">=".to_string(),
- token::Gt => ">".to_string(),
- token::Not => "!".to_string(),
- token::Tilde => "~".to_string(),
- token::OrOr => "||".to_string(),
- token::AndAnd => "&&".to_string(),
- token::BinOp(op) => binop_to_string(op).to_string(),
- token::BinOpEq(op) => format!("{}=", binop_to_string(op)),
+ token::Eq => "=".into(),
+ token::Lt => "<".into(),
+ token::Le => "<=".into(),
+ token::EqEq => "==".into(),
+ token::Ne => "!=".into(),
+ token::Ge => ">=".into(),
+ token::Gt => ">".into(),
+ token::Not => "!".into(),
+ token::Tilde => "~".into(),
+ token::OrOr => "||".into(),
+ token::AndAnd => "&&".into(),
+ token::BinOp(op) => binop_to_string(op).into(),
+ token::BinOpEq(op) => format!("{}=", binop_to_string(op)).into(),
/* Structural symbols */
- token::At => "@".to_string(),
- token::Dot => ".".to_string(),
- token::DotDot => "..".to_string(),
- token::DotDotDot => "...".to_string(),
- token::DotDotEq => "..=".to_string(),
- token::Comma => ",".to_string(),
- token::Semi => ";".to_string(),
- token::Colon => ":".to_string(),
- token::ModSep => "::".to_string(),
- token::RArrow => "->".to_string(),
- token::LArrow => "<-".to_string(),
- token::FatArrow => "=>".to_string(),
- token::OpenDelim(token::Paren) => "(".to_string(),
- token::CloseDelim(token::Paren) => ")".to_string(),
- token::OpenDelim(token::Bracket) => "[".to_string(),
- token::CloseDelim(token::Bracket) => "]".to_string(),
- token::OpenDelim(token::Brace) => "{".to_string(),
- token::CloseDelim(token::Brace) => "}".to_string(),
- token::OpenDelim(token::NoDelim) | token::CloseDelim(token::NoDelim) => "".to_string(),
- token::Pound => "#".to_string(),
- token::Dollar => "$".to_string(),
- token::Question => "?".to_string(),
- token::SingleQuote => "'".to_string(),
+ token::At => "@".into(),
+ token::Dot => ".".into(),
+ token::DotDot => "..".into(),
+ token::DotDotDot => "...".into(),
+ token::DotDotEq => "..=".into(),
+ token::Comma => ",".into(),
+ token::Semi => ";".into(),
+ token::Colon => ":".into(),
+ token::ModSep => "::".into(),
+ token::RArrow => "->".into(),
+ token::LArrow => "<-".into(),
+ token::FatArrow => "=>".into(),
+ token::OpenDelim(token::Paren) => "(".into(),
+ token::CloseDelim(token::Paren) => ")".into(),
+ token::OpenDelim(token::Bracket) => "[".into(),
+ token::CloseDelim(token::Bracket) => "]".into(),
+ token::OpenDelim(token::Brace) => "{".into(),
+ token::CloseDelim(token::Brace) => "}".into(),
+ token::OpenDelim(token::NoDelim) | token::CloseDelim(token::NoDelim) => "".into(),
+ token::Pound => "#".into(),
+ token::Dollar => "$".into(),
+ token::Question => "?".into(),
+ token::SingleQuote => "'".into(),
/* Literals */
- token::Literal(lit) => literal_to_string(lit),
+ token::Literal(lit) => literal_to_string(lit).into(),
/* Name components */
token::Ident(s, is_raw) => {
- IdentPrinter::new(s, is_raw, convert_dollar_crate).to_string()
+ IdentPrinter::new(s, is_raw, convert_dollar_crate).to_string().into()
}
- token::Lifetime(s) => s.to_string(),
+ token::Lifetime(s) => s.to_string().into(),
/* Other */
token::DocComment(comment_kind, attr_style, data) => {
- doc_comment_to_string(comment_kind, attr_style, data)
+ doc_comment_to_string(comment_kind, attr_style, data).into()
}
- token::Eof => "<eof>".to_string(),
+ token::Eof => "<eof>".into(),
- token::Interpolated(ref nt) => self.nonterminal_to_string(nt),
+ token::Interpolated(ref nt) => self.nonterminal_to_string(nt).into(),
}
}
/// Print the token precisely, without converting `$crate` into its respective crate name.
- fn token_to_string(&self, token: &Token) -> String {
+ fn token_to_string(&self, token: &Token) -> Cow<'static, str> {
self.token_to_string_ext(token, false)
}
- fn token_to_string_ext(&self, token: &Token, convert_dollar_crate: bool) -> String {
+ fn token_to_string_ext(&self, token: &Token, convert_dollar_crate: bool) -> Cow<'static, str> {
let convert_dollar_crate = convert_dollar_crate.then_some(token.span);
self.token_kind_to_string_ext(&token.kind, convert_dollar_crate)
}
@@ -1305,24 +1332,9 @@ fn print_associated_type(
}
}
ast::ItemKind::MacroDef(ref macro_def) => {
- let (kw, has_bang) = if macro_def.macro_rules {
- ("macro_rules", true)
- } else {
- self.print_visibility(&item.vis);
- ("macro", false)
- };
- self.print_mac_common(
- Some(MacHeader::Keyword(kw)),
- has_bang,
- Some(item.ident),
- macro_def.body.delim(),
- ¯o_def.body.inner_tokens(),
- true,
- item.span,
- );
- if macro_def.body.need_semicolon() {
- self.word(";");
- }
+ self.print_mac_def(macro_def, &item.ident, &item.span, |state| {
+ state.print_visibility(&item.vis)
+ });
}
}
self.ann.post(self, AnnNode::Item(item))
@@ -1506,13 +1518,19 @@ fn print_poly_trait_ref(&mut self, t: &ast::PolyTraitRef) {
self.ibox(INDENT_UNIT);
self.print_local_decl(loc);
self.end();
- if let Some(ref init) = loc.init {
+ if let Some((init, els)) = loc.kind.init_else_opt() {
self.nbsp();
self.word_space("=");
self.print_expr(init);
+ if let Some(els) = els {
+ self.cbox(INDENT_UNIT);
+ self.ibox(INDENT_UNIT);
+ self.s.word(" else ");
+ self.print_block(els);
+ }
}
self.s.word(";");
- self.end();
+ self.end(); // `let` ibox
}
ast::StmtKind::Item(ref item) => self.print_item(item),
ast::StmtKind::Expr(ref expr) => {
diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs
index cc6dac5..14506f2 100644
--- a/compiler/rustc_builtin_macros/src/deriving/debug.rs
+++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs
@@ -3,7 +3,7 @@
use crate::deriving::path_std;
use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, Expr, MetaItem};
+use rustc_ast::{self as ast, Expr, LocalKind, MetaItem};
use rustc_expand::base::{Annotatable, ExtCtxt};
use rustc_span::symbol::{sym, Ident};
use rustc_span::{Span, DUMMY_SP};
@@ -135,8 +135,8 @@ fn stmt_let_underscore(cx: &mut ExtCtxt<'_>, sp: Span, expr: P<ast::Expr>) -> as
let local = P(ast::Local {
pat: cx.pat_wild(sp),
ty: None,
- init: Some(expr),
id: ast::DUMMY_NODE_ID,
+ kind: LocalKind::Init(expr),
span: sp,
attrs: ast::AttrVec::new(),
tokens: None,
diff --git a/compiler/rustc_codegen_cranelift/src/common.rs b/compiler/rustc_codegen_cranelift/src/common.rs
index 892ccf2..03f462a 100644
--- a/compiler/rustc_codegen_cranelift/src/common.rs
+++ b/compiler/rustc_codegen_cranelift/src/common.rs
@@ -256,7 +256,7 @@ pub(crate) struct FunctionCx<'m, 'clif, 'tcx: 'm> {
pub(crate) inline_asm_index: u32,
}
-impl<'tcx> LayoutOf for FunctionCx<'_, '_, 'tcx> {
+impl<'tcx> LayoutOf<'tcx> for FunctionCx<'_, '_, 'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = TyAndLayout<'tcx>;
@@ -364,7 +364,7 @@ pub(crate) fn anonymous_str(&mut self, msg: &str) -> Value {
pub(crate) struct RevealAllLayoutCx<'tcx>(pub(crate) TyCtxt<'tcx>);
-impl<'tcx> LayoutOf for RevealAllLayoutCx<'tcx> {
+impl<'tcx> LayoutOf<'tcx> for RevealAllLayoutCx<'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = TyAndLayout<'tcx>;
diff --git a/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs b/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
index c471da8..95216f1 100644
--- a/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
@@ -160,12 +160,10 @@ fn dwarf_ty(&mut self, ty: Ty<'tcx>) -> UnitEntryId {
for (field_idx, field_def) in variant.fields.iter().enumerate() {
let field_offset = layout.fields.offset(field_idx);
- let field_layout = layout
- .field(
- &layout::LayoutCx { tcx: self.tcx, param_env: ParamEnv::reveal_all() },
- field_idx,
- )
- .unwrap();
+ let field_layout = layout.field(
+ &layout::LayoutCx { tcx: self.tcx, param_env: ParamEnv::reveal_all() },
+ field_idx,
+ );
let field_type = self.dwarf_ty(field_layout.ty);
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
index 1c4d307..12f61e0 100644
--- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
@@ -789,7 +789,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value {
return;
}
- if intrinsic == sym::assert_zero_valid && !layout.might_permit_raw_init(fx, /*zero:*/ true).unwrap() {
+ if intrinsic == sym::assert_zero_valid && !layout.might_permit_raw_init(fx, /*zero:*/ true) {
with_no_trimmed_paths(|| crate::base::codegen_panic(
fx,
&format!("attempted to zero-initialize type `{}`, which is invalid", T),
@@ -798,7 +798,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value {
return;
}
- if intrinsic == sym::assert_uninit_valid && !layout.might_permit_raw_init(fx, /*zero:*/ false).unwrap() {
+ if intrinsic == sym::assert_uninit_valid && !layout.might_permit_raw_init(fx, /*zero:*/ false) {
with_no_trimmed_paths(|| crate::base::codegen_panic(
fx,
&format!("attempted to leave type `{}` uninitialized, which is invalid", T),
diff --git a/compiler/rustc_codegen_llvm/src/asm.rs b/compiler/rustc_codegen_llvm/src/asm.rs
index 4387f53..e0d3127 100644
--- a/compiler/rustc_codegen_llvm/src/asm.rs
+++ b/compiler/rustc_codegen_llvm/src/asm.rs
@@ -314,6 +314,7 @@ fn codegen_inline_asm(
InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => {}
InlineAsmArch::Hexagon => {}
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
+ InlineAsmArch::S390x => {}
InlineAsmArch::SpirV => {}
InlineAsmArch::Wasm32 => {}
InlineAsmArch::Bpf => {}
@@ -615,6 +616,10 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>)
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b",
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f",
+ InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr)
+ | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => {
+ unreachable!("clobber-only")
+ }
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => "f",
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::vreg) => {
@@ -633,6 +638,8 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>)
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r",
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => "w",
+ InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => "r",
+ InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => "f",
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
@@ -711,6 +718,7 @@ fn modifier_to_llvm(
}
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => None,
InlineAsmRegClass::Bpf(_) => None,
+ InlineAsmRegClass::S390x(_) => None,
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
@@ -751,6 +759,10 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(),
InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(),
+ InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::cr)
+ | InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::xer) => {
+ unreachable!("clobber-only")
+ }
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(),
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => cx.type_f32(),
InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::vreg) => {
@@ -769,6 +781,8 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => cx.type_i32(),
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::reg) => cx.type_i64(),
InlineAsmRegClass::Bpf(BpfInlineAsmRegClass::wreg) => cx.type_i32(),
+ InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => cx.type_i32(),
+ InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => cx.type_f64(),
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V")
}
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index 1353868..47529f7 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -88,7 +88,7 @@ fn target_spec(&self) -> &Target {
}
}
-impl abi::LayoutOf for Builder<'_, '_, 'tcx> {
+impl abi::LayoutOf<'tcx> for Builder<'_, '_, 'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = TyAndLayout<'tcx>;
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index 35c866d..45da18d 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -835,7 +835,7 @@ fn tcx(&self) -> TyCtxt<'tcx> {
}
}
-impl LayoutOf for CodegenCx<'ll, 'tcx> {
+impl LayoutOf<'tcx> for CodegenCx<'ll, 'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = TyAndLayout<'tcx>;
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index 0ca51bd..3b64ec1 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -89,13 +89,14 @@ fn llvm_arg_to_arg_name(full_arg: &str) -> &str {
add("-generate-arange-section", false);
}
- // FIXME(nagisa): disable the machine outliner by default in LLVM versions 11, where it was
- // introduced and up.
+ // Disable the machine outliner by default in LLVM versions 11 and LLVM
+ // version 12, where it leads to miscompilation.
//
- // This should remain in place until https://reviews.llvm.org/D103167 is fixed. If LLVM
- // has been upgraded since, consider adjusting the version check below to contain an upper
- // bound.
- if llvm_util::get_version() >= (11, 0, 0) {
+ // Ref:
+ // - https://github.com/rust-lang/rust/issues/85351
+ // - https://reviews.llvm.org/D103167
+ let llvm_version = llvm_util::get_version();
+ if llvm_version >= (11, 0, 0) && llvm_version < (13, 0, 0) {
add("-enable-machine-outliner=never", false);
}
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs
index 85efe3e..9818905 100644
--- a/compiler/rustc_codegen_llvm/src/type_of.rs
+++ b/compiler/rustc_codegen_llvm/src/type_of.rs
@@ -9,7 +9,7 @@
use rustc_middle::ty::{self, Ty, TypeFoldable};
use rustc_target::abi::{Abi, AddressSpace, Align, FieldsShape};
use rustc_target::abi::{Int, Pointer, F32, F64};
-use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAndLayoutMethods, Variants};
+use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAbiInterface, Variants};
use smallvec::{smallvec, SmallVec};
use tracing::debug;
@@ -393,12 +393,15 @@ fn llvm_field_index<'a>(&self, cx: &CodegenCx<'a, 'tcx>, index: usize) -> u64 {
}
}
+ // FIXME(eddyb) this having the same name as `TyAndLayout::pointee_info_at`
+ // (the inherent method, which is lacking this caching logic) can result in
+ // the uncached version being called - not wrong, but potentially inefficient.
fn pointee_info_at<'a>(&self, cx: &CodegenCx<'a, 'tcx>, offset: Size) -> Option<PointeeInfo> {
if let Some(&pointee) = cx.pointee_infos.borrow().get(&(self.ty, offset)) {
return pointee;
}
- let result = Ty::pointee_info_at(*self, cx, offset);
+ let result = Ty::ty_and_layout_pointee_info_at(*self, cx, offset);
cx.pointee_infos.borrow_mut().insert((self.ty, offset), result);
result
diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml
index 930b4dc..1446624 100644
--- a/compiler/rustc_codegen_ssa/Cargo.toml
+++ b/compiler/rustc_codegen_ssa/Cargo.toml
@@ -36,6 +36,6 @@
rustc_session = { path = "../rustc_session" }
[dependencies.object]
-version = "0.26.1"
+version = "0.26.2"
default-features = false
features = ["read_core", "elf", "macho", "pe", "unaligned", "archive", "write"]
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
index e51d6ff..f5463bc 100644
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
@@ -2482,20 +2482,39 @@ fn add_gcc_ld_path(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
if let LinkerFlavor::Gcc = flavor {
match ld_impl {
LdImpl::Lld => {
- let tools_path =
- sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
- let lld_path = tools_path
- .into_iter()
- .map(|p| p.join("gcc-ld"))
- .find(|p| {
- p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" }).exists()
- })
- .unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
- cmd.cmd().arg({
- let mut arg = OsString::from("-B");
- arg.push(lld_path);
- arg
- });
+ if sess.target.lld_flavor == LldFlavor::Ld64 {
+ let tools_path =
+ sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
+ let ld64_exe = tools_path
+ .into_iter()
+ .map(|p| p.join("gcc-ld"))
+ .map(|p| {
+ p.join(if sess.host.is_like_windows { "ld64.exe" } else { "ld64" })
+ })
+ .find(|p| p.exists())
+ .unwrap_or_else(|| sess.fatal("rust-lld (as ld64) not found"));
+ cmd.cmd().arg({
+ let mut arg = OsString::from("-fuse-ld=");
+ arg.push(ld64_exe);
+ arg
+ });
+ } else {
+ let tools_path =
+ sess.host_filesearch(PathKind::All).get_tools_search_paths(false);
+ let lld_path = tools_path
+ .into_iter()
+ .map(|p| p.join("gcc-ld"))
+ .find(|p| {
+ p.join(if sess.host.is_like_windows { "ld.exe" } else { "ld" })
+ .exists()
+ })
+ .unwrap_or_else(|| sess.fatal("rust-lld (as ld) not found"));
+ cmd.cmd().arg({
+ let mut arg = OsString::from("-B");
+ arg.push(lld_path);
+ arg
+ });
+ }
}
}
} else {
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs
index 673d348..2a76ad0 100644
--- a/compiler/rustc_codegen_ssa/src/mir/block.rs
+++ b/compiler/rustc_codegen_ssa/src/mir/block.rs
@@ -472,10 +472,8 @@ enum AssertIntrinsic {
let layout = bx.layout_of(ty);
let do_panic = match intrinsic {
Inhabited => layout.abi.is_uninhabited(),
- // We unwrap as the error type is `!`.
- ZeroValid => !layout.might_permit_raw_init(bx, /*zero:*/ true).unwrap(),
- // We unwrap as the error type is `!`.
- UninitValid => !layout.might_permit_raw_init(bx, /*zero:*/ false).unwrap(),
+ ZeroValid => !layout.might_permit_raw_init(bx, /*zero:*/ true),
+ UninitValid => !layout.might_permit_raw_init(bx, /*zero:*/ false),
};
if do_panic {
let msg_str = with_no_trimmed_paths(|| {
diff --git a/compiler/rustc_codegen_ssa/src/traits/backend.rs b/compiler/rustc_codegen_ssa/src/traits/backend.rs
index dc4146e..1393fc7 100644
--- a/compiler/rustc_codegen_ssa/src/traits/backend.rs
+++ b/compiler/rustc_codegen_ssa/src/traits/backend.rs
@@ -39,12 +39,17 @@ pub trait BackendTypes {
}
pub trait Backend<'tcx>:
- Sized + BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
+ Sized
+ + BackendTypes
+ + HasTyCtxt<'tcx>
+ + LayoutOf<'tcx, Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
{
}
impl<'tcx, T> Backend<'tcx> for T where
- Self: BackendTypes + HasTyCtxt<'tcx> + LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
+ Self: BackendTypes
+ + HasTyCtxt<'tcx>
+ + LayoutOf<'tcx, Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
{
}
diff --git a/compiler/rustc_data_structures/Cargo.toml b/compiler/rustc_data_structures/Cargo.toml
index 2063cb8..bc13ca2 100644
--- a/compiler/rustc_data_structures/Cargo.toml
+++ b/compiler/rustc_data_structures/Cargo.toml
@@ -25,7 +25,7 @@
bitflags = "1.2.1"
measureme = "9.1.0"
libc = "0.2"
-stacker = "0.1.12"
+stacker = "0.1.14"
tempfile = "3.2"
[dependencies.parking_lot]
diff --git a/compiler/rustc_data_structures/src/flock.rs b/compiler/rustc_data_structures/src/flock.rs
index 4f5d8d7..293ef4c 100644
--- a/compiler/rustc_data_structures/src/flock.rs
+++ b/compiler/rustc_data_structures/src/flock.rs
@@ -222,6 +222,10 @@ pub fn new(_p: &Path, _wait: bool, _create: bool, _exclusive: bool)
let msg = "file locks not supported on this platform";
Err(io::Error::new(io::ErrorKind::Other, msg))
}
+
+ pub fn error_unsupported(_err: &io::Error) -> bool {
+ true
+ }
}
}
}
diff --git a/compiler/rustc_data_structures/src/functor.rs b/compiler/rustc_data_structures/src/functor.rs
index fe7a256..5b83ae3 100644
--- a/compiler/rustc_data_structures/src/functor.rs
+++ b/compiler/rustc_data_structures/src/functor.rs
@@ -26,7 +26,7 @@ fn map_id<F>(self, mut f: F) -> Self
// inverse of `Box::assume_init()` and should be safe.
let mut raw: Box<mem::MaybeUninit<T>> = Box::from_raw(raw.cast());
// SAFETY: Write the mapped value back into the `Box`.
- ptr::write(raw.as_mut_ptr(), f(value));
+ raw.write(f(value));
// SAFETY: We just initialized `raw`.
raw.assume_init()
}
diff --git a/compiler/rustc_error_codes/src/error_codes/E0671.md b/compiler/rustc_error_codes/src/error_codes/E0671.md
index a993ce8..d4dbfb7 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0671.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0671.md
@@ -4,8 +4,6 @@
The following is therefore invalid:
```compile_fail,E0770
-#![feature(const_generics)]
-
fn const_id<T, const N: T>() -> T { // error
N
}
diff --git a/compiler/rustc_error_codes/src/error_codes/E0741.md b/compiler/rustc_error_codes/src/error_codes/E0741.md
index 91379bf..70d963c 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0741.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0741.md
@@ -3,7 +3,7 @@
Erroneous code example:
```compile_fail,E0741
-#![feature(const_generics)]
+#![feature(adt_const_params)]
struct A;
@@ -16,7 +16,7 @@
To fix the previous code example, we derive `PartialEq` and `Eq`:
```
-#![feature(const_generics)]
+#![feature(adt_const_params)]
#[derive(PartialEq, Eq)] // We derive both traits here.
struct A;
diff --git a/compiler/rustc_error_codes/src/error_codes/E0770.md b/compiler/rustc_error_codes/src/error_codes/E0770.md
index b39163a..cd8fc48 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0770.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0770.md
@@ -3,7 +3,6 @@
Erroneous code example:
```compile_fail,E0770
-#![feature(const_generics)]
fn foo<T, const N: T>() {} // error!
```
diff --git a/compiler/rustc_error_codes/src/error_codes/E0771.md b/compiler/rustc_error_codes/src/error_codes/E0771.md
index 824a955..a2a1a20 100644
--- a/compiler/rustc_error_codes/src/error_codes/E0771.md
+++ b/compiler/rustc_error_codes/src/error_codes/E0771.md
@@ -4,7 +4,7 @@
Erroneous code example:
```compile_fail,E0771
-#![feature(const_generics)]
+#![feature(adt_const_params)]
fn function_with_str<'a, const STRING: &'a str>() {} // error!
```
@@ -13,7 +13,7 @@
`'static`:
```
-#![feature(const_generics)]
+#![feature(adt_const_params)]
fn function_with_str<const STRING: &'static str>() {} // ok!
```
diff --git a/compiler/rustc_expand/src/build.rs b/compiler/rustc_expand/src/build.rs
index 824df27..1d83ecb 100644
--- a/compiler/rustc_expand/src/build.rs
+++ b/compiler/rustc_expand/src/build.rs
@@ -2,7 +2,7 @@
use rustc_ast::attr;
use rustc_ast::ptr::P;
-use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, PatKind, UnOp};
+use rustc_ast::{self as ast, AttrVec, BlockCheckMode, Expr, LocalKind, PatKind, UnOp};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Ident, Symbol};
@@ -153,8 +153,8 @@ pub fn stmt_let(&self, sp: Span, mutbl: bool, ident: Ident, ex: P<ast::Expr>) ->
let local = P(ast::Local {
pat,
ty: None,
- init: Some(ex),
id: ast::DUMMY_NODE_ID,
+ kind: LocalKind::Init(ex),
span: sp,
attrs: AttrVec::new(),
tokens: None,
@@ -167,8 +167,8 @@ pub fn stmt_let_type_only(&self, span: Span, ty: P<ast::Ty>) -> ast::Stmt {
let local = P(ast::Local {
pat: self.pat_wild(span),
ty: Some(ty),
- init: None,
id: ast::DUMMY_NODE_ID,
+ kind: LocalKind::Decl,
span,
attrs: AttrVec::new(),
tokens: None,
diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs
index e0c6238..f849165 100644
--- a/compiler/rustc_expand/src/mbe/macro_rules.rs
+++ b/compiler/rustc_expand/src/mbe/macro_rules.rs
@@ -1221,7 +1221,7 @@ fn is_in_follow(tok: &mbe::TokenTree, kind: NonterminalKind) -> IsInFollow {
fn quoted_tt_to_string(tt: &mbe::TokenTree) -> String {
match *tt {
- mbe::TokenTree::Token(ref token) => pprust::token_to_string(&token),
+ mbe::TokenTree::Token(ref token) => pprust::token_to_string(&token).into(),
mbe::TokenTree::MetaVar(_, name) => format!("${}", name),
mbe::TokenTree::MetaVarDecl(_, name, Some(kind)) => format!("${}:{}", name, kind),
mbe::TokenTree::MetaVarDecl(_, name, None) => format!("${}:", name),
diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs
index 18294df..725f8b8 100644
--- a/compiler/rustc_feature/src/accepted.rs
+++ b/compiler/rustc_feature/src/accepted.rs
@@ -273,7 +273,7 @@ macro_rules! declare_features {
/// Allows patterns with concurrent by-move and by-ref bindings.
/// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
(accepted, move_ref_pattern, "1.49.0", Some(68354), None),
- /// The smallest useful subset of `const_generics`.
+ /// The smallest useful subset of const generics.
(accepted, min_const_generics, "1.51.0", Some(74878), None),
/// The `unsafe_op_in_unsafe_fn` lint (allowed by default): no longer treat an unsafe function as an unsafe block.
(accepted, unsafe_block_in_unsafe_fn, "1.52.0", Some(71668), None),
diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs
index 4f4baf2..a3807a2 100644
--- a/compiler/rustc_feature/src/active.rs
+++ b/compiler/rustc_feature/src/active.rs
@@ -71,7 +71,7 @@ pub fn enabled(&self, feature: Symbol) -> bool {
}
pub fn unordered_const_ty_params(&self) -> bool {
- self.const_generics || self.const_generics_defaults
+ self.const_generics_defaults || self.generic_const_exprs || self.adt_const_params
}
/// Some features are known to be incomplete and using them is likely to have
@@ -453,9 +453,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows using `#[ffi_returns_twice]` on foreign functions.
(active, ffi_returns_twice, "1.34.0", Some(58314), None),
- /// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
- (incomplete, const_generics, "1.34.0", Some(44580), None),
-
/// Allows using `#[optimize(X)]`.
(active, optimize_attribute, "1.34.0", Some(54882), None),
@@ -515,9 +512,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows `impl const Trait for T` syntax.
(active, const_trait_impl, "1.42.0", Some(67792), None),
- /// Allows `T: ?const Trait` syntax in bounds.
- (incomplete, const_trait_bound_opt_out, "1.42.0", Some(67794), None),
-
/// Allows the use of `no_sanitize` attribute.
(active, no_sanitize, "1.42.0", Some(39699), None),
@@ -548,15 +542,9 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows capturing variables in scope using format_args!
(active, format_args_capture, "1.46.0", Some(67984), None),
- /// Lazily evaluate constants. This allows constants to depend on type parameters.
- (incomplete, lazy_normalization_consts, "1.46.0", Some(72219), None),
-
/// Allows `if let` guard in match arms.
(active, if_let_guard, "1.47.0", Some(51114), None),
- /// Allows non-trivial generic constants which have to be manually propagated upwards.
- (incomplete, const_evaluatable_checked, "1.48.0", Some(76560), None),
-
/// Allows basic arithmetic on floating point types in a `const fn`.
(active, const_fn_floating_point_arithmetic, "1.48.0", Some(57241), None),
@@ -682,6 +670,15 @@ pub fn set(&self, features: &mut Features, span: Span) {
/// Allows using doc(primitive) without a future-incompat warning
(active, doc_primitive, "1.56.0", Some(88070), None),
+ /// Allows non-trivial generic constants which have to have wfness manually propagated to callers
+ (incomplete, generic_const_exprs, "1.56.0", Some(76560), None),
+
+ /// Allows additional const parameter types, such as `&'static str` or user defined types
+ (incomplete, adt_const_params, "1.56.0", Some(44580), None),
+
+ /// Allows `let...else` statements.
+ (active, let_else, "1.56.0", Some(87335), None),
+
// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs
index 5cadbd9..8e498a5 100644
--- a/compiler/rustc_feature/src/removed.rs
+++ b/compiler/rustc_feature/src/removed.rs
@@ -102,6 +102,9 @@ macro_rules! declare_features {
(removed, extern_in_paths, "1.33.0", Some(55600), None,
Some("subsumed by `::foo::bar` paths")),
(removed, quote, "1.33.0", Some(29601), None, None),
+ /// Allows const generic types (e.g. `struct Foo<const N: usize>(...);`).
+ (removed, const_generics, "1.34.0", Some(44580), None,
+ Some("removed in favor of `#![feature(adt_const_params]` and `#![feature(generic_const_exprs)]`")),
/// Allows `[x; N]` where `x` is a constant (RFC 2203).
(removed, const_in_array_repeat_expressions, "1.37.0", Some(49147), None,
Some("removed due to causing promotable bugs")),
@@ -123,11 +126,18 @@ macro_rules! declare_features {
/// Allows overlapping impls of marker traits.
(removed, overlapping_marker_traits, "1.42.0", Some(29864), None,
Some("removed in favor of `#![feature(marker_trait_attr)]`")),
+ /// Allows `T: ?const Trait` syntax in bounds.
+ (removed, const_trait_bound_opt_out, "1.42.0", Some(67794), None,
+ Some("Removed in favor of `~const` bound in #![feature(const_trait_impl)]")),
/// Allows `#[no_debug]`.
(removed, no_debug, "1.43.0", Some(29721), None, Some("removed due to lack of demand")),
+ /// Lazily evaluate constants. This allows constants to depend on type parameters.
+ (removed, lazy_normalization_consts, "1.46.0", Some(72219), None, Some("superseded by `generic_const_exprs`")),
/// Allows comparing raw pointers during const eval.
(removed, const_compare_raw_pointers, "1.46.0", Some(53020), None,
Some("cannot be allowed in const eval in any meaningful way")),
+ /// Allows non-trivial generic constants which have to be manually propagated upwards.
+ (removed, const_evaluatable_checked, "1.48.0", Some(76560), None, Some("renamed to `generic_const_exprs`")),
/// Allows using the `#[link_args]` attribute.
(removed, link_args, "1.53.0", Some(29596), None,
Some("removed in favor of using `-C link-arg=ARG` on command line, \
diff --git a/compiler/rustc_hir/src/arena.rs b/compiler/rustc_hir/src/arena.rs
index c4cff79..3e8b98e 100644
--- a/compiler/rustc_hir/src/arena.rs
+++ b/compiler/rustc_hir/src/arena.rs
@@ -9,8 +9,8 @@
/// where `T` is the type listed. These impls will appear in the implement_ty_decoder! macro.
#[macro_export]
macro_rules! arena_types {
- ($macro:path, $args:tt, $tcx:lifetime) => (
- $macro!($args, [
+ ($macro:path, $tcx:lifetime) => (
+ $macro!([
// HIR types
[few] hir_krate: rustc_hir::Crate<$tcx>,
[] arm: rustc_hir::Arm<$tcx>,
@@ -35,7 +35,6 @@ macro_rules! arena_types {
[few] inline_asm: rustc_hir::InlineAsm<$tcx>,
[few] llvm_inline_asm: rustc_hir::LlvmInlineAsm<$tcx>,
[] local: rustc_hir::Local<$tcx>,
- [few] macro_def: rustc_hir::MacroDef<$tcx>,
[few] mod_: rustc_hir::Mod<$tcx>,
[] param: rustc_hir::Param<$tcx>,
[] pat: rustc_hir::Pat<$tcx>,
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs
index 3816888..853415c 100644
--- a/compiler/rustc_hir/src/def.rs
+++ b/compiler/rustc_hir/src/def.rs
@@ -307,7 +307,7 @@ pub enum Res<Id = hir::HirId> {
/// We do however allow `Self` in repeat expression even if it is generic to not break code
/// which already works on stable while causing the `const_evaluatable_unchecked` future compat lint.
///
- /// FIXME(lazy_normalization_consts): Remove this bodge once that feature is stable.
+ /// FIXME(generic_const_exprs): Remove this bodge once that feature is stable.
SelfTy(
/// Optionally, the trait associated with this `Self` type.
Option<DefId>,
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index 551e6a5..a9bd83a 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -670,9 +670,6 @@ pub struct ModuleItems {
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/hir.html
#[derive(Debug)]
pub struct Crate<'hir> {
- // Attributes from non-exported macros, kept only for collecting the library feature list.
- pub non_exported_macro_attrs: &'hir [Attribute],
-
pub owners: IndexVec<LocalDefId, Option<OwnerNode<'hir>>>,
pub bodies: BTreeMap<BodyId, Body<'hir>>,
pub trait_impls: BTreeMap<DefId, Vec<LocalDefId>>,
@@ -743,7 +740,7 @@ pub fn visit_all_item_likes<'hir, V>(&'hir self, visitor: &mut V)
OwnerNode::ForeignItem(item) => visitor.visit_foreign_item(item),
OwnerNode::ImplItem(item) => visitor.visit_impl_item(item),
OwnerNode::TraitItem(item) => visitor.visit_trait_item(item),
- OwnerNode::MacroDef(_) | OwnerNode::Crate(_) => {}
+ OwnerNode::Crate(_) => {}
}
}
}
@@ -758,7 +755,7 @@ pub fn par_visit_all_item_likes<'hir, V>(&'hir self, visitor: &V)
Some(OwnerNode::ForeignItem(item)) => visitor.visit_foreign_item(item),
Some(OwnerNode::ImplItem(item)) => visitor.visit_impl_item(item),
Some(OwnerNode::TraitItem(item)) => visitor.visit_trait_item(item),
- Some(OwnerNode::MacroDef(_)) | Some(OwnerNode::Crate(_)) | None => {}
+ Some(OwnerNode::Crate(_)) | None => {}
})
}
@@ -768,32 +765,6 @@ pub fn items<'hir>(&'hir self) -> impl Iterator<Item = &'hir Item<'hir>> + 'hir
_ => None,
})
}
-
- pub fn exported_macros<'hir>(&'hir self) -> impl Iterator<Item = &'hir MacroDef<'hir>> + 'hir {
- self.owners.iter().filter_map(|owner| match owner {
- Some(OwnerNode::MacroDef(macro_def)) => Some(*macro_def),
- _ => None,
- })
- }
-}
-
-/// A macro definition, in this crate or imported from another.
-///
-/// Not parsed directly, but created on macro import or `macro_rules!` expansion.
-#[derive(Debug)]
-pub struct MacroDef<'hir> {
- pub ident: Ident,
- pub vis: Visibility<'hir>,
- pub def_id: LocalDefId,
- pub span: Span,
- pub ast: ast::MacroDef,
-}
-
-impl MacroDef<'_> {
- #[inline]
- pub fn hir_id(&self) -> HirId {
- HirId::make_owner(self.def_id)
- }
}
/// A block of statements `{ .. }`, which may have a label (in this case the
@@ -2602,7 +2573,7 @@ pub struct PolyTraitRef<'hir> {
pub type Visibility<'hir> = Spanned<VisibilityKind<'hir>>;
-#[derive(Debug)]
+#[derive(Copy, Clone, Debug)]
pub enum VisibilityKind<'hir> {
Public,
Crate(CrateSugar),
@@ -2791,6 +2762,8 @@ pub enum ItemKind<'hir> {
Const(&'hir Ty<'hir>, BodyId),
/// A function declaration.
Fn(FnSig<'hir>, Generics<'hir>, BodyId),
+ /// A MBE macro definition (`macro_rules!` or `macro`).
+ Macro(ast::MacroDef),
/// A module.
Mod(Mod<'hir>),
/// An external module, e.g. `extern { .. }`.
@@ -2856,6 +2829,7 @@ pub fn descr(&self) -> &'static str {
ItemKind::Static(..) => "static item",
ItemKind::Const(..) => "constant item",
ItemKind::Fn(..) => "function",
+ ItemKind::Macro(..) => "macro",
ItemKind::Mod(..) => "module",
ItemKind::ForeignMod { .. } => "extern block",
ItemKind::GlobalAsm(..) => "global asm item",
@@ -2996,7 +2970,6 @@ pub enum OwnerNode<'hir> {
ForeignItem(&'hir ForeignItem<'hir>),
TraitItem(&'hir TraitItem<'hir>),
ImplItem(&'hir ImplItem<'hir>),
- MacroDef(&'hir MacroDef<'hir>),
Crate(&'hir Mod<'hir>),
}
@@ -3006,8 +2979,7 @@ pub fn ident(&self) -> Option<Ident> {
OwnerNode::Item(Item { ident, .. })
| OwnerNode::ForeignItem(ForeignItem { ident, .. })
| OwnerNode::ImplItem(ImplItem { ident, .. })
- | OwnerNode::TraitItem(TraitItem { ident, .. })
- | OwnerNode::MacroDef(MacroDef { ident, .. }) => Some(*ident),
+ | OwnerNode::TraitItem(TraitItem { ident, .. }) => Some(*ident),
OwnerNode::Crate(..) => None,
}
}
@@ -3018,7 +2990,6 @@ pub fn span(&self) -> Span {
| OwnerNode::ForeignItem(ForeignItem { span, .. })
| OwnerNode::ImplItem(ImplItem { span, .. })
| OwnerNode::TraitItem(TraitItem { span, .. })
- | OwnerNode::MacroDef(MacroDef { span, .. })
| OwnerNode::Crate(Mod { inner: span, .. }) => *span,
}
}
@@ -3062,8 +3033,7 @@ pub fn def_id(self) -> LocalDefId {
OwnerNode::Item(Item { def_id, .. })
| OwnerNode::TraitItem(TraitItem { def_id, .. })
| OwnerNode::ImplItem(ImplItem { def_id, .. })
- | OwnerNode::ForeignItem(ForeignItem { def_id, .. })
- | OwnerNode::MacroDef(MacroDef { def_id, .. }) => *def_id,
+ | OwnerNode::ForeignItem(ForeignItem { def_id, .. }) => *def_id,
OwnerNode::Crate(..) => crate::CRATE_HIR_ID.owner,
}
}
@@ -3095,13 +3065,6 @@ pub fn expect_trait_item(self) -> &'hir TraitItem<'hir> {
_ => panic!(),
}
}
-
- pub fn expect_macro_def(self) -> &'hir MacroDef<'hir> {
- match self {
- OwnerNode::MacroDef(n) => n,
- _ => panic!(),
- }
- }
}
impl<'hir> Into<OwnerNode<'hir>> for &'hir Item<'hir> {
@@ -3128,12 +3091,6 @@ fn into(self) -> OwnerNode<'hir> {
}
}
-impl<'hir> Into<OwnerNode<'hir>> for &'hir MacroDef<'hir> {
- fn into(self) -> OwnerNode<'hir> {
- OwnerNode::MacroDef(self)
- }
-}
-
impl<'hir> Into<Node<'hir>> for OwnerNode<'hir> {
fn into(self) -> Node<'hir> {
match self {
@@ -3141,7 +3098,6 @@ fn into(self) -> Node<'hir> {
OwnerNode::ForeignItem(n) => Node::ForeignItem(n),
OwnerNode::ImplItem(n) => Node::ImplItem(n),
OwnerNode::TraitItem(n) => Node::TraitItem(n),
- OwnerNode::MacroDef(n) => Node::MacroDef(n),
OwnerNode::Crate(n) => Node::Crate(n),
}
}
@@ -3167,7 +3123,6 @@ pub enum Node<'hir> {
Arm(&'hir Arm<'hir>),
Block(&'hir Block<'hir>),
Local(&'hir Local<'hir>),
- MacroDef(&'hir MacroDef<'hir>),
/// `Ctor` refers to the constructor of an enum variant or struct. Only tuple or unit variants
/// with synthesized constructors.
@@ -3204,7 +3159,6 @@ pub fn ident(&self) -> Option<Ident> {
| Node::ForeignItem(ForeignItem { ident, .. })
| Node::Field(FieldDef { ident, .. })
| Node::Variant(Variant { ident, .. })
- | Node::MacroDef(MacroDef { ident, .. })
| Node::Item(Item { ident, .. })
| Node::PathSegment(PathSegment { ident, .. }) => Some(*ident),
Node::Lifetime(lt) => Some(lt.name.ident()),
@@ -3265,8 +3219,7 @@ pub fn hir_id(&self) -> Option<HirId> {
Node::Item(Item { def_id, .. })
| Node::TraitItem(TraitItem { def_id, .. })
| Node::ImplItem(ImplItem { def_id, .. })
- | Node::ForeignItem(ForeignItem { def_id, .. })
- | Node::MacroDef(MacroDef { def_id, .. }) => Some(HirId::make_owner(*def_id)),
+ | Node::ForeignItem(ForeignItem { def_id, .. }) => Some(HirId::make_owner(*def_id)),
Node::Field(FieldDef { hir_id, .. })
| Node::AnonConst(AnonConst { hir_id, .. })
| Node::Expr(Expr { hir_id, .. })
@@ -3326,7 +3279,6 @@ pub fn as_owner(self) -> Option<OwnerNode<'hir>> {
Node::ForeignItem(i) => Some(OwnerNode::ForeignItem(i)),
Node::TraitItem(i) => Some(OwnerNode::TraitItem(i)),
Node::ImplItem(i) => Some(OwnerNode::ImplItem(i)),
- Node::MacroDef(i) => Some(OwnerNode::MacroDef(i)),
Node::Crate(i) => Some(OwnerNode::Crate(i)),
_ => None,
}
diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs
index 7f15386..f4fbfd2 100644
--- a/compiler/rustc_hir/src/intravisit.rs
+++ b/compiler/rustc_hir/src/intravisit.rs
@@ -466,9 +466,6 @@ fn visit_assoc_type_binding(&mut self, type_binding: &'v TypeBinding<'v>) {
walk_assoc_type_binding(self, type_binding)
}
fn visit_attribute(&mut self, _id: HirId, _attr: &'v Attribute) {}
- fn visit_macro_def(&mut self, macro_def: &'v MacroDef<'v>) {
- walk_macro_def(self, macro_def)
- }
fn visit_vis(&mut self, vis: &'v Visibility<'v>) {
walk_vis(self, vis)
}
@@ -484,7 +481,6 @@ fn visit_defaultness(&mut self, defaultness: &'v Defaultness) {
pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate<'v>) {
let top_mod = krate.module();
visitor.visit_mod(top_mod, top_mod.inner, CRATE_HIR_ID);
- walk_list!(visitor, visit_macro_def, krate.exported_macros());
for (&id, attrs) in krate.attrs.iter() {
for a in *attrs {
visitor.visit_attribute(id, a)
@@ -492,11 +488,6 @@ pub fn walk_crate<'v, V: Visitor<'v>>(visitor: &mut V, krate: &'v Crate<'v>) {
}
}
-pub fn walk_macro_def<'v, V: Visitor<'v>>(visitor: &mut V, macro_def: &'v MacroDef<'v>) {
- visitor.visit_id(macro_def.hir_id());
- visitor.visit_ident(macro_def.ident);
-}
-
pub fn walk_mod<'v, V: Visitor<'v>>(visitor: &mut V, module: &'v Mod<'v>, mod_hir_id: HirId) {
visitor.visit_id(mod_hir_id);
for &item_id in module.item_ids {
@@ -586,6 +577,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
item.span,
item.hir_id(),
),
+ ItemKind::Macro(_) => {
+ visitor.visit_id(item.hir_id());
+ }
ItemKind::Mod(ref module) => {
// `visit_mod()` takes care of visiting the `Item`'s `HirId`.
visitor.visit_mod(module, item.span, item.hir_id())
diff --git a/compiler/rustc_hir/src/stable_hash_impls.rs b/compiler/rustc_hir/src/stable_hash_impls.rs
index 5606075..422a106 100644
--- a/compiler/rustc_hir/src/stable_hash_impls.rs
+++ b/compiler/rustc_hir/src/stable_hash_impls.rs
@@ -1,8 +1,8 @@
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
use crate::hir::{
- BodyId, Expr, ForeignItem, ForeignItemId, ImplItem, ImplItemId, Item, ItemId, MacroDef, Mod,
- TraitItem, TraitItemId, Ty, VisibilityKind,
+ BodyId, Expr, ForeignItem, ForeignItemId, ImplItem, ImplItemId, Item, ItemId, Mod, TraitItem,
+ TraitItemId, Ty, VisibilityKind,
};
use crate::hir_id::{HirId, ItemLocalId};
use rustc_span::def_id::DefPathHash;
@@ -190,16 +190,3 @@ fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
});
}
}
-
-impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for MacroDef<'_> {
- fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
- let MacroDef { ident, def_id: _, ref ast, ref vis, span } = *self;
-
- hcx.hash_hir_item_like(|hcx| {
- ident.name.hash_stable(hcx, hasher);
- ast.hash_stable(hcx, hasher);
- vis.hash_stable(hcx, hasher);
- span.hash_stable(hcx, hasher);
- });
- }
-}
diff --git a/compiler/rustc_hir/src/target.rs b/compiler/rustc_hir/src/target.rs
index 473477b..29c948f 100644
--- a/compiler/rustc_hir/src/target.rs
+++ b/compiler/rustc_hir/src/target.rs
@@ -111,6 +111,7 @@ pub fn from_item(item: &Item<'_>) -> Target {
ItemKind::Static(..) => Target::Static,
ItemKind::Const(..) => Target::Const,
ItemKind::Fn(..) => Target::Fn,
+ ItemKind::Macro(..) => Target::MacroDef,
ItemKind::Mod(..) => Target::Mod,
ItemKind::ForeignMod { .. } => Target::ForeignMod,
ItemKind::GlobalAsm(..) => Target::GlobalAsm,
diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs
index 9c286ad..42e51f4 100644
--- a/compiler/rustc_hir_pretty/src/lib.rs
+++ b/compiler/rustc_hir_pretty/src/lib.rs
@@ -120,7 +120,6 @@ pub fn print_node(&mut self, node: Node<'_>) {
// printing.
Node::Ctor(..) => panic!("cannot print isolated Ctor"),
Node::Local(a) => self.print_local_decl(&a),
- Node::MacroDef(_) => panic!("cannot print MacroDef"),
Node::Crate(..) => panic!("cannot print Crate"),
}
}
@@ -642,6 +641,11 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
self.end(); // need to close a box
self.ann.nested(self, Nested::Body(body));
}
+ hir::ItemKind::Macro(ref macro_def) => {
+ self.print_mac_def(macro_def, &item.ident, &item.span, |state| {
+ state.print_visibility(&item.vis)
+ });
+ }
hir::ItemKind::Mod(ref _mod) => {
self.head(visibility_qualified(&item.vis, "mod"));
self.print_ident(item.ident);
diff --git a/compiler/rustc_infer/src/infer/canonical/query_response.rs b/compiler/rustc_infer/src/infer/canonical/query_response.rs
index c3c28d7..6a97a6c 100644
--- a/compiler/rustc_infer/src/infer/canonical/query_response.rs
+++ b/compiler/rustc_infer/src/infer/canonical/query_response.rs
@@ -678,7 +678,7 @@ fn push_outlives(
fn const_equate(&mut self, _a: &'tcx Const<'tcx>, _b: &'tcx Const<'tcx>) {
span_bug!(
self.cause.span(self.infcx.tcx),
- "lazy_normalization_consts: unreachable `const_equate`"
+ "generic_const_exprs: unreachable `const_equate`"
);
}
diff --git a/compiler/rustc_infer/src/infer/combine.rs b/compiler/rustc_infer/src/infer/combine.rs
index 3230891..a0ee212 100644
--- a/compiler/rustc_infer/src/infer/combine.rs
+++ b/compiler/rustc_infer/src/infer/combine.rs
@@ -202,7 +202,7 @@ pub fn super_combine_consts<R>(
/// A good example of this is the following:
///
/// ```rust
- /// #![feature(const_generics)]
+ /// #![feature(generic_const_exprs)]
///
/// fn bind<const N: usize>(value: [u8; N]) -> [u8; 3 + 4] {
/// todo!()
diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
index 299dcf5..d549338 100644
--- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs
+++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs
@@ -781,6 +781,10 @@ fn note_error_origin(
);
}
}
+ ObligationCauseCode::LetElse => {
+ err.help("try adding a diverging expression, such as `return` or `panic!(..)`");
+ err.help("...or use `match` instead of `let...else`");
+ }
_ => (),
}
}
@@ -2592,6 +2596,7 @@ fn as_failure_code(&self, terr: &TypeError<'tcx>) -> FailureCode {
}
IfExpression { .. } => Error0308("`if` and `else` have incompatible types"),
IfExpressionWithNoElse => Error0317("`if` may be missing an `else` clause"),
+ LetElse => Error0308("`else` clause of `let...else` does not diverge"),
MainFunctionType => Error0580("`main` function has wrong type"),
StartFunctionType => Error0308("`#[start]` function has wrong type"),
IntrinsicType => Error0308("intrinsic has wrong type"),
diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs
index 8f848f5..88b9e92 100644
--- a/compiler/rustc_lint/src/builtin.rs
+++ b/compiler/rustc_lint/src/builtin.rs
@@ -585,24 +585,6 @@ fn exit_lint_attrs(&mut self, _: &LateContext<'_>, _attrs: &[ast::Attribute]) {
fn check_crate(&mut self, cx: &LateContext<'_>, krate: &hir::Crate<'_>) {
self.check_missing_docs_attrs(cx, CRATE_DEF_ID, krate.module().inner, "the", "crate");
-
- for macro_def in krate.exported_macros() {
- // Non exported macros should be skipped, since `missing_docs` only
- // applies to externally visible items.
- if !cx.access_levels.is_exported(macro_def.def_id) {
- continue;
- }
-
- let attrs = cx.tcx.hir().attrs(macro_def.hir_id());
- let has_doc = attrs.iter().any(has_doc);
- if !has_doc {
- cx.struct_span_lint(
- MISSING_DOCS,
- cx.tcx.sess.source_map().guess_head_span(macro_def.span),
- |lint| lint.build("missing documentation for macro").emit(),
- );
- }
- }
}
fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
@@ -636,6 +618,7 @@ fn check_item(&mut self, cx: &LateContext<'_>, it: &hir::Item<'_>) {
hir::ItemKind::TyAlias(..)
| hir::ItemKind::Fn(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Enum(..)
| hir::ItemKind::Struct(..)
@@ -2357,7 +2340,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
/// ### Example
///
/// ```rust
- /// #![feature(const_generics)]
+ /// #![feature(generic_const_exprs)]
/// ```
///
/// {{produces}}
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index c2a46e9..7dbc3d6 100644
--- a/compiler/rustc_lint/src/context.rs
+++ b/compiler/rustc_lint/src/context.rs
@@ -41,7 +41,7 @@
use rustc_session::SessionLintStore;
use rustc_span::lev_distance::find_best_match_for_name;
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
-use rustc_target::abi::LayoutOf;
+use rustc_target::abi::{self, LayoutOf};
use tracing::debug;
use std::cell::Cell;
@@ -1059,7 +1059,28 @@ fn path_generic_args(
}
}
-impl<'tcx> LayoutOf for LateContext<'tcx> {
+impl<'tcx> abi::HasDataLayout for LateContext<'tcx> {
+ #[inline]
+ fn data_layout(&self) -> &abi::TargetDataLayout {
+ &self.tcx.data_layout
+ }
+}
+
+impl<'tcx> ty::layout::HasTyCtxt<'tcx> for LateContext<'tcx> {
+ #[inline]
+ fn tcx(&self) -> TyCtxt<'tcx> {
+ self.tcx
+ }
+}
+
+impl<'tcx> ty::layout::HasParamEnv<'tcx> for LateContext<'tcx> {
+ #[inline]
+ fn param_env(&self) -> ty::ParamEnv<'tcx> {
+ self.param_env
+ }
+}
+
+impl<'tcx> LayoutOf<'tcx> for LateContext<'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
diff --git a/compiler/rustc_lint/src/late.rs b/compiler/rustc_lint/src/late.rs
index 052efa8..30400da 100644
--- a/compiler/rustc_lint/src/late.rs
+++ b/compiler/rustc_lint/src/late.rs
@@ -453,10 +453,6 @@ fn late_lint_pass_crate<'tcx, T: LateLintPass<'tcx>>(tcx: TyCtxt<'tcx>, pass: T)
lint_callback!(cx, check_crate, krate);
hir_visit::walk_crate(cx, krate);
- for attr in krate.non_exported_macro_attrs {
- // This HIR ID is a lie, since the macro ID isn't available.
- cx.visit_attribute(hir::CRATE_HIR_ID, attr);
- }
lint_callback!(cx, check_crate_post, krate);
})
diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs
index e6cbfa0..90bf34e 100644
--- a/compiler/rustc_lint/src/levels.rs
+++ b/compiler/rustc_lint/src/levels.rs
@@ -37,9 +37,6 @@ fn lint_levels(tcx: TyCtxt<'_>, (): ()) -> LintLevelMap {
let push = builder.levels.push(tcx.hir().attrs(hir::CRATE_HIR_ID), &store, true);
builder.levels.register_id(hir::CRATE_HIR_ID);
- for macro_def in krate.exported_macros() {
- builder.levels.register_id(macro_def.hir_id());
- }
intravisit::walk_crate(&mut builder, krate);
builder.levels.pop(push);
diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs
index 24ac723..ef4bda6 100644
--- a/compiler/rustc_lint/src/lib.rs
+++ b/compiler/rustc_lint/src/lib.rs
@@ -62,6 +62,8 @@
mod types;
mod unused;
+pub use array_into_iter::ARRAY_INTO_ITER;
+
use rustc_ast as ast;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
diff --git a/compiler/rustc_lint/src/unused.rs b/compiler/rustc_lint/src/unused.rs
index be13788..f04ac8d 100644
--- a/compiler/rustc_lint/src/unused.rs
+++ b/compiler/rustc_lint/src/unused.rs
@@ -1,7 +1,7 @@
use crate::Lint;
use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext};
use rustc_ast as ast;
-use rustc_ast::util::parser;
+use rustc_ast::util::{classify, parser};
use rustc_ast::{ExprKind, StmtKind};
use rustc_ast_pretty::pprust;
use rustc_errors::{pluralize, Applicability};
@@ -382,6 +382,7 @@ enum UnusedDelimsCtx {
FunctionArg,
MethodArg,
AssignedValue,
+ AssignedValueLetElse,
IfCond,
WhileCond,
ForIterExpr,
@@ -398,7 +399,9 @@ fn from(ctx: UnusedDelimsCtx) -> &'static str {
match ctx {
UnusedDelimsCtx::FunctionArg => "function argument",
UnusedDelimsCtx::MethodArg => "method argument",
- UnusedDelimsCtx::AssignedValue => "assigned value",
+ UnusedDelimsCtx::AssignedValue | UnusedDelimsCtx::AssignedValueLetElse => {
+ "assigned value"
+ }
UnusedDelimsCtx::IfCond => "`if` condition",
UnusedDelimsCtx::WhileCond => "`while` condition",
UnusedDelimsCtx::ForIterExpr => "`for` iterator expression",
@@ -441,14 +444,26 @@ fn check_unused_delims_expr(
right_pos: Option<BytePos>,
);
- fn is_expr_delims_necessary(inner: &ast::Expr, followed_by_block: bool) -> bool {
+ fn is_expr_delims_necessary(
+ inner: &ast::Expr,
+ followed_by_block: bool,
+ followed_by_else: bool,
+ ) -> bool {
+ if followed_by_else {
+ match inner.kind {
+ ast::ExprKind::Binary(op, ..) if op.node.lazy() => return true,
+ _ if classify::expr_trailing_brace(inner).is_some() => return true,
+ _ => {}
+ }
+ }
+
// Prevent false-positives in cases like `fn x() -> u8 { ({ 0 } + 1) }`
let lhs_needs_parens = {
let mut innermost = inner;
loop {
if let ExprKind::Binary(_, lhs, _rhs) = &innermost.kind {
innermost = lhs;
- if !rustc_ast::util::classify::expr_requires_semi_to_be_stmt(innermost) {
+ if !classify::expr_requires_semi_to_be_stmt(innermost) {
break true;
}
} else {
@@ -618,15 +633,12 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
match s.kind {
StmtKind::Local(ref local) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
- if let Some(ref value) = local.init {
- self.check_unused_delims_expr(
- cx,
- &value,
- UnusedDelimsCtx::AssignedValue,
- false,
- None,
- None,
- );
+ if let Some((init, els)) = local.kind.init_else_opt() {
+ let ctx = match els {
+ None => UnusedDelimsCtx::AssignedValue,
+ Some(_) => UnusedDelimsCtx::AssignedValueLetElse,
+ };
+ self.check_unused_delims_expr(cx, init, ctx, false, None, None);
}
}
StmtKind::Expr(ref expr) => {
@@ -702,7 +714,8 @@ fn check_unused_delims_expr(
) {
match value.kind {
ast::ExprKind::Paren(ref inner) => {
- if !Self::is_expr_delims_necessary(inner, followed_by_block)
+ let followed_by_else = ctx == UnusedDelimsCtx::AssignedValueLetElse;
+ if !Self::is_expr_delims_necessary(inner, followed_by_block, followed_by_else)
&& value.attrs.is_empty()
&& !value.span.from_expansion()
&& (ctx != UnusedDelimsCtx::LetScrutineeExpr
@@ -941,7 +954,7 @@ fn check_unused_delims_expr(
// FIXME(const_generics): handle paths when #67075 is fixed.
if let [stmt] = inner.stmts.as_slice() {
if let ast::StmtKind::Expr(ref expr) = stmt.kind {
- if !Self::is_expr_delims_necessary(expr, followed_by_block)
+ if !Self::is_expr_delims_necessary(expr, followed_by_block, false)
&& (ctx != UnusedDelimsCtx::AnonConst
|| matches!(expr.kind, ast::ExprKind::Lit(_)))
&& !cx.sess().source_map().is_multiline(value.span)
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs
index 4e591b2..dd44e0c 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder.rs
@@ -1100,7 +1100,13 @@ fn each_child_of_item<F>(&self, id: DefIndex, mut callback: F, sess: &Session)
let vis = self.get_visibility(child_index);
let def_id = self.local_def_id(child_index);
let res = Res::Def(kind, def_id);
- callback(Export { res, ident, vis, span });
+
+ // FIXME: Macros are currently encoded twice, once as items and once as
+ // reexports. We ignore the items here and only use the reexports.
+ if !matches!(kind, DefKind::Macro(..)) {
+ callback(Export { res, ident, vis, span });
+ }
+
// For non-re-export structs and variants add their constructors to children.
// Re-export lists automatically contain constructors when necessary.
match kind {
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs
index 1c243f8..2cd4fe3 100644
--- a/compiler/rustc_metadata/src/rmeta/encoder.rs
+++ b/compiler/rustc_metadata/src/rmeta/encoder.rs
@@ -448,9 +448,6 @@ fn encode_info_for_items(&mut self) {
}
krate.visit_all_item_likes(&mut self.as_deep_visitor());
- for macro_def in krate.exported_macros() {
- self.visit_macro_def(macro_def);
- }
}
fn encode_def_path_table(&mut self) {
@@ -1385,6 +1382,9 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
EntryKind::Fn(self.lazy(data))
}
+ hir::ItemKind::Macro(ref macro_def) => {
+ EntryKind::MacroDef(self.lazy(macro_def.clone()))
+ }
hir::ItemKind::Mod(ref m) => {
return self.encode_info_for_mod(item.def_id, m);
}
@@ -1539,13 +1539,6 @@ fn encode_info_for_item(&mut self, def_id: DefId, item: &'tcx hir::Item<'tcx>) {
}
}
- /// Serialize the text of exported macros
- fn encode_info_for_macro_def(&mut self, macro_def: &hir::MacroDef<'_>) {
- let def_id = macro_def.def_id.to_def_id();
- record!(self.tables.kind[def_id] <- EntryKind::MacroDef(self.lazy(macro_def.ast.clone())));
- self.encode_ident_span(def_id, macro_def.ident);
- }
-
fn encode_info_for_generic_param(&mut self, def_id: DefId, kind: EntryKind, encode_type: bool) {
record!(self.tables.kind[def_id] <- kind);
if encode_type {
@@ -1915,9 +1908,6 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
intravisit::walk_generics(self, generics);
self.encode_info_for_generics(generics);
}
- fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
- self.encode_info_for_macro_def(macro_def);
- }
}
impl EncodeContext<'a, 'tcx> {
@@ -1972,6 +1962,7 @@ fn encode_addl_info_for_item(&mut self, item: &hir::Item<'_>) {
hir::ItemKind::Static(..)
| hir::ItemKind::Const(..)
| hir::ItemKind::Fn(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::ForeignMod { .. }
| hir::ItemKind::GlobalAsm(..)
diff --git a/compiler/rustc_middle/src/arena.rs b/compiler/rustc_middle/src/arena.rs
index a89d00e..59db2c6 100644
--- a/compiler/rustc_middle/src/arena.rs
+++ b/compiler/rustc_middle/src/arena.rs
@@ -9,8 +9,8 @@
/// listed. These impls will appear in the implement_ty_decoder! macro.
#[macro_export]
macro_rules! arena_types {
- ($macro:path, $args:tt, $tcx:lifetime) => (
- $macro!($args, [
+ ($macro:path, $tcx:lifetime) => (
+ $macro!([
[] layouts: rustc_target::abi::Layout,
// AdtDef are interned and compared by address
[] adt_def: rustc_middle::ty::AdtDef,
@@ -109,4 +109,4 @@ macro_rules! arena_types {
)
}
-arena_types!(rustc_arena::declare_arena, [], 'tcx);
+arena_types!(rustc_arena::declare_arena, 'tcx);
diff --git a/compiler/rustc_middle/src/hir/map/collector.rs b/compiler/rustc_middle/src/hir/map/collector.rs
index 5c166c7..1351b49 100644
--- a/compiler/rustc_middle/src/hir/map/collector.rs
+++ b/compiler/rustc_middle/src/hir/map/collector.rs
@@ -394,20 +394,6 @@ fn visit_vis(&mut self, visibility: &'hir Visibility<'hir>) {
}
}
- fn visit_macro_def(&mut self, macro_def: &'hir MacroDef<'hir>) {
- // Exported macros are visited directly from the crate root,
- // so they do not have `parent_node` set.
- // Find the correct enclosing module from their DefKey.
- let def_key = self.definitions.def_key(macro_def.def_id);
- let parent = def_key.parent.map_or(hir::CRATE_HIR_ID, |local_def_index| {
- self.definitions.local_def_id_to_hir_id(LocalDefId { local_def_index })
- });
- self.insert_owner(macro_def.def_id, OwnerNode::MacroDef(macro_def));
- self.with_parent(parent, |this| {
- this.insert_nested(macro_def.def_id);
- });
- }
-
fn visit_variant(&mut self, v: &'hir Variant<'hir>, g: &'hir Generics<'hir>, item_id: HirId) {
self.insert(v.span, v.id, Node::Variant(v));
self.with_parent(v.id, |this| {
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs
index c313146..62d0374 100644
--- a/compiler/rustc_middle/src/hir/map/mod.rs
+++ b/compiler/rustc_middle/src/hir/map/mod.rs
@@ -10,7 +10,6 @@
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
use rustc_hir::intravisit;
-use rustc_hir::intravisit::Visitor;
use rustc_hir::itemlikevisit::ItemLikeVisitor;
use rustc_hir::*;
use rustc_index::vec::Idx;
@@ -218,6 +217,7 @@ pub fn opt_def_kind(&self, local_def_id: LocalDefId) -> Option<DefKind> {
ItemKind::Static(..) => DefKind::Static,
ItemKind::Const(..) => DefKind::Const,
ItemKind::Fn(..) => DefKind::Fn,
+ ItemKind::Macro(..) => DefKind::Macro(MacroKind::Bang),
ItemKind::Mod(..) => DefKind::Mod,
ItemKind::OpaqueTy(..) => DefKind::OpaqueTy,
ItemKind::TyAlias(..) => DefKind::TyAlias,
@@ -266,7 +266,6 @@ pub fn opt_def_kind(&self, local_def_id: LocalDefId) -> Option<DefKind> {
ExprKind::Closure(.., Some(_)) => DefKind::Generator,
_ => bug!("def_kind: unsupported node: {}", self.node_to_string(hir_id)),
},
- Node::MacroDef(_) => DefKind::Macro(MacroKind::Bang),
Node::GenericParam(param) => match param.kind {
GenericParamKind::Lifetime { .. } => DefKind::LifetimeParam,
GenericParamKind::Type { .. } => DefKind::TyParam,
@@ -543,15 +542,6 @@ pub fn visit_item_likes_in_module<V>(&self, module: LocalDefId, visitor: &mut V)
}
}
- pub fn visit_exported_macros_in_krate<V>(&self, visitor: &mut V)
- where
- V: Visitor<'hir>,
- {
- for macro_def in self.krate().exported_macros() {
- visitor.visit_macro_def(macro_def);
- }
- }
-
/// Returns an iterator for the nodes in the ancestor tree of the `current_id`
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`.
pub fn parent_iter(&self, current_id: HirId) -> ParentHirIterator<'_, 'hir> {
@@ -645,8 +635,6 @@ pub fn get_return_block(&self, id: HirId) -> Option<HirId> {
/// in a module, trait, or impl.
pub fn get_parent_item(&self, hir_id: HirId) -> HirId {
if let Some((hir_id, _node)) = self.parent_owner_iter(hir_id).next() {
- // A MacroDef does not have children.
- debug_assert!(!matches!(_node, OwnerNode::MacroDef(_)));
hir_id
} else {
CRATE_HIR_ID
@@ -774,13 +762,6 @@ pub fn expect_foreign_item(&self, id: HirId) -> &'hir ForeignItem<'hir> {
}
}
- pub fn expect_macro_def(&self, id: HirId) -> &'hir MacroDef<'hir> {
- match self.tcx.hir_owner(id.expect_owner()) {
- Some(Owner { node: OwnerNode::MacroDef(macro_def) }) => macro_def,
- _ => bug!("expected macro def, found {}", self.node_to_string(id)),
- }
- }
-
pub fn expect_expr(&self, id: HirId) -> &'hir Expr<'hir> {
match self.find(id) {
Some(Node::Expr(expr)) => expr,
@@ -800,7 +781,6 @@ pub fn opt_name(&self, id: HirId) -> Option<Symbol> {
Node::GenericParam(param) => param.name.ident().name,
Node::Binding(&Pat { kind: PatKind::Binding(_, _, l, _), .. }) => l.name,
Node::Ctor(..) => self.name(self.get_parent_item(id)),
- Node::MacroDef(md) => md.ident.name,
_ => return None,
})
}
@@ -867,7 +847,6 @@ pub fn opt_span(&self, hir_id: HirId) -> Option<Span> {
Node::Infer(i) => i.span,
Node::Visibility(v) => bug!("unexpected Visibility {:?}", v),
Node::Local(local) => local.span,
- Node::MacroDef(macro_def) => macro_def.span,
Node::Crate(item) => item.inner,
};
Some(span)
@@ -1013,7 +992,6 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher);
tcx.sess.local_stable_crate_id().hash_stable(&mut hcx, &mut stable_hasher);
- tcx.untracked_crate.non_exported_macro_attrs.hash_stable(&mut hcx, &mut stable_hasher);
let crate_hash: Fingerprint = stable_hasher.finish();
Svh::new(crate_hash.to_smaller_hash())
@@ -1062,6 +1040,7 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
ItemKind::Static(..) => "static",
ItemKind::Const(..) => "const",
ItemKind::Fn(..) => "fn",
+ ItemKind::Macro(..) => "macro",
ItemKind::Mod(..) => "mod",
ItemKind::ForeignMod { .. } => "foreign mod",
ItemKind::GlobalAsm(..) => "global asm",
@@ -1118,7 +1097,6 @@ fn hir_id_to_string(map: &Map<'_>, id: HirId) -> String {
Some(Node::Lifetime(_)) => node_str("lifetime"),
Some(Node::GenericParam(ref param)) => format!("generic_param {:?}{}", param, id_str),
Some(Node::Visibility(ref vis)) => format!("visibility {:?}{}", vis, id_str),
- Some(Node::MacroDef(_)) => format!("macro {}{}", path_str(), id_str),
Some(Node::Crate(..)) => String::from("root_crate"),
None => format!("unknown node{}", id_str),
}
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs
index 8e2917e..346a9e8 100644
--- a/compiler/rustc_middle/src/mir/mod.rs
+++ b/compiler/rustc_middle/src/mir/mod.rs
@@ -426,6 +426,11 @@ pub fn vars_and_temps_iter(
(arg_count + 1..local_count).map(Local::new)
}
+ #[inline]
+ pub fn drain_vars_and_temps<'a>(&'a mut self) -> impl Iterator<Item = LocalDecl<'tcx>> + 'a {
+ self.local_decls.drain(self.arg_count + 1..)
+ }
+
/// Changes a statement to a nop. This is both faster than deleting instructions and avoids
/// invalidating statement indices in `Location`s.
pub fn make_statement_nop(&mut self, location: Location) {
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 0740754..dada94e 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -120,7 +120,18 @@
/// Records the type of every item.
query type_of(key: DefId) -> Ty<'tcx> {
- desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) }
+ desc { |tcx|
+ "{action} `{path}`",
+ action = {
+ use rustc_hir::def::DefKind;
+ match tcx.def_kind(key) {
+ DefKind::TyAlias => "expanding type alias",
+ DefKind::TraitAlias => "expanding trait alias",
+ _ => "computing type of",
+ }
+ },
+ path = tcx.def_path_str(key),
+ }
cache_on_disk_if { key.is_local() }
}
diff --git a/compiler/rustc_middle/src/traits/mod.rs b/compiler/rustc_middle/src/traits/mod.rs
index 457e80c..74edb17 100644
--- a/compiler/rustc_middle/src/traits/mod.rs
+++ b/compiler/rustc_middle/src/traits/mod.rs
@@ -17,7 +17,6 @@
use rustc_errors::{Applicability, DiagnosticBuilder};
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
-use rustc_hir::Constness;
use rustc_span::symbol::Symbol;
use rustc_span::{Span, DUMMY_SP};
use smallvec::SmallVec;
@@ -306,6 +305,9 @@ pub enum ObligationCauseCode<'tcx> {
/// Intrinsic has wrong type
IntrinsicType,
+ /// A let else block does not diverge
+ LetElse,
+
/// Method receiver
MethodReceiver,
@@ -497,7 +499,7 @@ pub enum ImplSource<'tcx, N> {
/// for some type parameter. The `Vec<N>` represents the
/// obligations incurred from normalizing the where-clause (if
/// any).
- Param(Vec<N>, Constness),
+ Param(Vec<N>, ty::BoundConstness),
/// Virtual calls through an object.
Object(ImplSourceObjectData<'tcx, N>),
diff --git a/compiler/rustc_middle/src/ty/codec.rs b/compiler/rustc_middle/src/ty/codec.rs
index 36db258..4edb6a3 100644
--- a/compiler/rustc_middle/src/ty/codec.rs
+++ b/compiler/rustc_middle/src/ty/codec.rs
@@ -437,15 +437,15 @@ fn decode(decoder: &mut D) -> Result<&$tcx Self, D::Error> {
}
macro_rules! impl_arena_allocatable_decoders {
- ([], [$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => {
+ ([$($a:tt $name:ident: $ty:ty,)*], $tcx:lifetime) => {
$(
impl_arena_allocatable_decoder!($a [[$name: $ty], $tcx]);
)*
}
}
-rustc_hir::arena_types!(impl_arena_allocatable_decoders, [], 'tcx);
-arena_types!(impl_arena_allocatable_decoders, [], 'tcx);
+rustc_hir::arena_types!(impl_arena_allocatable_decoders, 'tcx);
+arena_types!(impl_arena_allocatable_decoders, 'tcx);
#[macro_export]
macro_rules! implement_ty_decoder {
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs
index 89542a1..de7c6d9 100644
--- a/compiler/rustc_middle/src/ty/context.rs
+++ b/compiler/rustc_middle/src/ty/context.rs
@@ -1420,8 +1420,8 @@ pub fn borrowck_mode(self) -> BorrowckMode {
#[inline]
pub fn lazy_normalization(self) -> bool {
let features = self.features();
- // Note: We do not enable lazy normalization for `min_const_generics`.
- features.const_generics || features.lazy_normalization_consts
+ // Note: We only use lazy normalization for generic const expressions.
+ features.generic_const_exprs
}
#[inline]
diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs
index ecbe9ca..796ca65 100644
--- a/compiler/rustc_middle/src/ty/error.rs
+++ b/compiler/rustc_middle/src/ty/error.rs
@@ -33,7 +33,7 @@ pub fn new(a_is_expected: bool, a: T, b: T) -> Self {
#[derive(Clone, Debug, TypeFoldable)]
pub enum TypeError<'tcx> {
Mismatch,
- ConstnessMismatch(ExpectedFound<hir::Constness>),
+ ConstnessMismatch(ExpectedFound<ty::BoundConstness>),
UnsafetyMismatch(ExpectedFound<hir::Unsafety>),
AbiMismatch(ExpectedFound<abi::Abi>),
Mutability,
@@ -102,7 +102,7 @@ fn report_maybe_different(
CyclicConst(_) => write!(f, "encountered a self-referencing constant"),
Mismatch => write!(f, "types differ"),
ConstnessMismatch(values) => {
- write!(f, "expected {} fn, found {} fn", values.expected, values.found)
+ write!(f, "expected {} bound, found {} bound", values.expected, values.found)
}
UnsafetyMismatch(values) => {
write!(f, "expected {} fn, found {} fn", values.expected, values.found)
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index 5068ace..5e5902a 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -1788,22 +1788,18 @@ fn record_layout_for_printing_outlined(&self, layout: TyAndLayout<'tcx>) {
let field_info: Vec<_> = flds
.iter()
.enumerate()
- .map(|(i, &name)| match layout.field(self, i) {
- Err(err) => {
- bug!("no layout found for field {}: `{:?}`", name, err);
+ .map(|(i, &name)| {
+ let field_layout = layout.field(self, i);
+ let offset = layout.fields.offset(i);
+ let field_end = offset + field_layout.size;
+ if min_size < field_end {
+ min_size = field_end;
}
- Ok(field_layout) => {
- let offset = layout.fields.offset(i);
- let field_end = offset + field_layout.size;
- if min_size < field_end {
- min_size = field_end;
- }
- FieldInfo {
- name: name.to_string(),
- offset: offset.bytes(),
- size: field_layout.size.bytes(),
- align: field_layout.align.abi.bytes(),
- }
+ FieldInfo {
+ name: name.to_string(),
+ offset: offset.bytes(),
+ size: field_layout.size.bytes(),
+ align: field_layout.align.abi.bytes(),
}
})
.collect();
@@ -2034,6 +2030,20 @@ fn tcx(&self) -> TyCtxt<'tcx> {
}
}
+impl<'tcx> HasDataLayout for ty::query::TyCtxtAt<'tcx> {
+ #[inline]
+ fn data_layout(&self) -> &TargetDataLayout {
+ &self.data_layout
+ }
+}
+
+impl<'tcx> HasTyCtxt<'tcx> for ty::query::TyCtxtAt<'tcx> {
+ #[inline]
+ fn tcx(&self) -> TyCtxt<'tcx> {
+ **self
+ }
+}
+
impl<'tcx, C> HasParamEnv<'tcx> for LayoutCx<'tcx, C> {
fn param_env(&self) -> ty::ParamEnv<'tcx> {
self.param_env
@@ -2054,7 +2064,7 @@ fn tcx(&self) -> TyCtxt<'tcx> {
pub type TyAndLayout<'tcx> = rustc_target::abi::TyAndLayout<'tcx, Ty<'tcx>>;
-impl<'tcx> LayoutOf for LayoutCx<'tcx, TyCtxt<'tcx>> {
+impl LayoutOf<'tcx> for LayoutCx<'tcx, TyCtxt<'tcx>> {
type Ty = Ty<'tcx>;
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
@@ -2066,7 +2076,7 @@ fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
}
}
-impl LayoutOf for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
+impl LayoutOf<'tcx> for LayoutCx<'tcx, ty::query::TyCtxtAt<'tcx>> {
type Ty = Ty<'tcx>;
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
@@ -2078,13 +2088,11 @@ fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyAndLayout {
}
}
-impl<'tcx, C> TyAndLayoutMethods<'tcx, C> for Ty<'tcx>
+impl<'tcx, C> TyAbiInterface<'tcx, C> for Ty<'tcx>
where
- C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout: MaybeResult<TyAndLayout<'tcx>>>
- + HasTyCtxt<'tcx>
- + HasParamEnv<'tcx>,
+ C: HasTyCtxt<'tcx> + HasParamEnv<'tcx>,
{
- fn for_variant(
+ fn ty_and_layout_for_variant(
this: TyAndLayout<'tcx>,
cx: &C,
variant_index: VariantIdx,
@@ -2101,8 +2109,11 @@ fn for_variant(
}
Variants::Single { index } => {
+ let tcx = cx.tcx();
+ let param_env = cx.param_env();
+
// Deny calling for_variant more than once for non-Single enums.
- if let Ok(original_layout) = cx.layout_of(this.ty).to_result() {
+ if let Ok(original_layout) = tcx.layout_of(param_env.and(this.ty)) {
assert_eq!(original_layout.variants, Variants::Single { index });
}
@@ -2112,7 +2123,6 @@ fn for_variant(
ty::Adt(def, _) => def.variants[variant_index].fields.len(),
_ => bug!(),
};
- let tcx = cx.tcx();
tcx.intern_layout(Layout {
variants: Variants::Single { index: variant_index },
fields: match NonZeroUsize::new(fields) {
@@ -2134,32 +2144,24 @@ fn for_variant(
TyAndLayout { ty: this.ty, layout }
}
- fn field(this: TyAndLayout<'tcx>, cx: &C, i: usize) -> C::TyAndLayout {
- enum TyMaybeWithLayout<C: LayoutOf> {
- Ty(C::Ty),
- TyAndLayout(C::TyAndLayout),
+ fn ty_and_layout_field(this: TyAndLayout<'tcx>, cx: &C, i: usize) -> TyAndLayout<'tcx> {
+ enum TyMaybeWithLayout<'tcx> {
+ Ty(Ty<'tcx>),
+ TyAndLayout(TyAndLayout<'tcx>),
}
- fn ty_and_layout_kind<
- C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout: MaybeResult<TyAndLayout<'tcx>>>
- + HasTyCtxt<'tcx>
- + HasParamEnv<'tcx>,
- >(
+ fn field_ty_or_layout(
this: TyAndLayout<'tcx>,
- cx: &C,
+ cx: &(impl HasTyCtxt<'tcx> + HasParamEnv<'tcx>),
i: usize,
- ty: C::Ty,
- ) -> TyMaybeWithLayout<C> {
+ ) -> TyMaybeWithLayout<'tcx> {
let tcx = cx.tcx();
- let tag_layout = |tag: &Scalar| -> C::TyAndLayout {
+ let tag_layout = |tag: &Scalar| -> TyAndLayout<'tcx> {
let layout = Layout::scalar(cx, tag.clone());
- MaybeResult::from(Ok(TyAndLayout {
- layout: tcx.intern_layout(layout),
- ty: tag.value.to_ty(tcx),
- }))
+ TyAndLayout { layout: tcx.intern_layout(layout), ty: tag.value.to_ty(tcx) }
};
- match *ty.kind() {
+ match *this.ty.kind() {
ty::Bool
| ty::Char
| ty::Int(_)
@@ -2170,7 +2172,7 @@ fn ty_and_layout_kind<
| ty::FnDef(..)
| ty::GeneratorWitness(..)
| ty::Foreign(..)
- | ty::Dynamic(..) => bug!("TyAndLayout::field_type({:?}): not applicable", this),
+ | ty::Dynamic(..) => bug!("TyAndLayout::field({:?}): not applicable", this),
// Potentially-fat pointers.
ty::Ref(_, pointee, _) | ty::RawPtr(ty::TypeAndMut { ty: pointee, .. }) => {
@@ -2182,17 +2184,19 @@ fn ty_and_layout_kind<
// as the `Abi` or `FieldsShape` is checked by users.
if i == 0 {
let nil = tcx.mk_unit();
- let ptr_ty = if ty.is_unsafe_ptr() {
+ let unit_ptr_ty = if this.ty.is_unsafe_ptr() {
tcx.mk_mut_ptr(nil)
} else {
tcx.mk_mut_ref(tcx.lifetimes.re_static, nil)
};
- return TyMaybeWithLayout::TyAndLayout(MaybeResult::from(
- cx.layout_of(ptr_ty).to_result().map(|mut ptr_layout| {
- ptr_layout.ty = ty;
- ptr_layout
- }),
- ));
+
+ // NOTE(eddyb) using an empty `ParamEnv`, and `unwrap`-ing
+ // the `Result` should always work because the type is
+ // always either `*mut ()` or `&'static mut ()`.
+ return TyMaybeWithLayout::TyAndLayout(TyAndLayout {
+ ty: this.ty,
+ ..tcx.layout_of(ty::ParamEnv::reveal_all().and(unit_ptr_ty)).unwrap()
+ });
}
match tcx.struct_tail_erasing_lifetimes(pointee, cx.param_env()).kind() {
@@ -2216,7 +2220,7 @@ fn ty_and_layout_kind<
])
*/
}
- _ => bug!("TyAndLayout::field_type({:?}): not applicable", this),
+ _ => bug!("TyAndLayout::field({:?}): not applicable", this),
}
}
@@ -2225,9 +2229,11 @@ fn ty_and_layout_kind<
ty::Str => TyMaybeWithLayout::Ty(tcx.types.u8),
// Tuples, generators and closures.
- ty::Closure(_, ref substs) => {
- ty_and_layout_kind(this, cx, i, substs.as_closure().tupled_upvars_ty())
- }
+ ty::Closure(_, ref substs) => field_ty_or_layout(
+ TyAndLayout { ty: substs.as_closure().tupled_upvars_ty(), ..this },
+ cx,
+ i,
+ ),
ty::Generator(def_id, ref substs, _) => match this.variants {
Variants::Single { index } => TyMaybeWithLayout::Ty(
@@ -2270,24 +2276,42 @@ fn ty_and_layout_kind<
| ty::Opaque(..)
| ty::Param(_)
| ty::Infer(_)
- | ty::Error(_) => bug!("TyAndLayout::field_type: unexpected type `{}`", this.ty),
+ | ty::Error(_) => bug!("TyAndLayout::field: unexpected type `{}`", this.ty),
}
}
- cx.layout_of(match ty_and_layout_kind(this, cx, i, this.ty) {
- TyMaybeWithLayout::Ty(result) => result,
- TyMaybeWithLayout::TyAndLayout(result) => return result,
- })
+ match field_ty_or_layout(this, cx, i) {
+ TyMaybeWithLayout::Ty(field_ty) => {
+ cx.tcx().layout_of(cx.param_env().and(field_ty)).unwrap_or_else(|e| {
+ bug!(
+ "failed to get layout for `{}`: {},\n\
+ despite it being a field (#{}) of an existing layout: {:#?}",
+ field_ty,
+ e,
+ i,
+ this
+ )
+ })
+ }
+ TyMaybeWithLayout::TyAndLayout(field_layout) => field_layout,
+ }
}
- fn pointee_info_at(this: TyAndLayout<'tcx>, cx: &C, offset: Size) -> Option<PointeeInfo> {
+ fn ty_and_layout_pointee_info_at(
+ this: TyAndLayout<'tcx>,
+ cx: &C,
+ offset: Size,
+ ) -> Option<PointeeInfo> {
+ let tcx = cx.tcx();
+ let param_env = cx.param_env();
+
let addr_space_of_ty = |ty: Ty<'tcx>| {
if ty.is_fn() { cx.data_layout().instruction_address_space } else { AddressSpace::DATA }
};
let pointee_info = match *this.ty.kind() {
ty::RawPtr(mt) if offset.bytes() == 0 => {
- cx.layout_of(mt.ty).to_result().ok().map(|layout| PointeeInfo {
+ tcx.layout_of(param_env.and(mt.ty)).ok().map(|layout| PointeeInfo {
size: layout.size,
align: layout.align.abi,
safe: None,
@@ -2295,18 +2319,15 @@ fn pointee_info_at(this: TyAndLayout<'tcx>, cx: &C, offset: Size) -> Option<Poin
})
}
ty::FnPtr(fn_sig) if offset.bytes() == 0 => {
- cx.layout_of(cx.tcx().mk_fn_ptr(fn_sig)).to_result().ok().map(|layout| {
- PointeeInfo {
- size: layout.size,
- align: layout.align.abi,
- safe: None,
- address_space: cx.data_layout().instruction_address_space,
- }
+ tcx.layout_of(param_env.and(tcx.mk_fn_ptr(fn_sig))).ok().map(|layout| PointeeInfo {
+ size: layout.size,
+ align: layout.align.abi,
+ safe: None,
+ address_space: cx.data_layout().instruction_address_space,
})
}
ty::Ref(_, ty, mt) if offset.bytes() == 0 => {
let address_space = addr_space_of_ty(ty);
- let tcx = cx.tcx();
let kind = if tcx.sess.opts.optimize == OptLevel::No {
// Use conservative pointer kind if not optimizing. This saves us the
// Freeze/Unpin queries, and can save time in the codegen backend (noalias
@@ -2335,7 +2356,7 @@ fn pointee_info_at(this: TyAndLayout<'tcx>, cx: &C, offset: Size) -> Option<Poin
}
};
- cx.layout_of(ty).to_result().ok().map(|layout| PointeeInfo {
+ tcx.layout_of(param_env.and(ty)).ok().map(|layout| PointeeInfo {
size: layout.size,
align: layout.align.abi,
safe: Some(kind),
@@ -2538,7 +2559,7 @@ fn fn_sig_for_fn_abi(&self, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
pub trait FnAbiExt<'tcx, C>
where
- C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
+ C: LayoutOf<'tcx, Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
+ HasDataLayout
+ HasTargetSpec
+ HasTyCtxt<'tcx>
@@ -2725,7 +2746,7 @@ pub fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
impl<'tcx, C> FnAbiExt<'tcx, C> for call::FnAbi<'tcx, Ty<'tcx>>
where
- C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
+ C: LayoutOf<'tcx, Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
+ HasDataLayout
+ HasTargetSpec
+ HasTyCtxt<'tcx>
@@ -3004,16 +3025,15 @@ fn adjust_for_abi(&mut self, cx: &C, abi: SpecAbi) {
}
}
-fn make_thin_self_ptr<'tcx, C>(cx: &C, mut layout: TyAndLayout<'tcx>) -> TyAndLayout<'tcx>
-where
- C: LayoutOf<Ty = Ty<'tcx>, TyAndLayout = TyAndLayout<'tcx>>
- + HasTyCtxt<'tcx>
- + HasParamEnv<'tcx>,
-{
+fn make_thin_self_ptr<'tcx>(
+ cx: &(impl HasTyCtxt<'tcx> + HasParamEnv<'tcx>),
+ layout: TyAndLayout<'tcx>,
+) -> TyAndLayout<'tcx> {
+ let tcx = cx.tcx();
let fat_pointer_ty = if layout.is_unsized() {
// unsized `self` is passed as a pointer to `self`
// FIXME (mikeyhew) change this to use &own if it is ever added to the language
- cx.tcx().mk_mut_ptr(layout.ty)
+ tcx.mk_mut_ptr(layout.ty)
} else {
match layout.abi {
Abi::ScalarPair(..) => (),
@@ -3047,8 +3067,13 @@ fn make_thin_self_ptr<'tcx, C>(cx: &C, mut layout: TyAndLayout<'tcx>) -> TyAndLa
// we now have a type like `*mut RcBox<dyn Trait>`
// change its layout to that of `*mut ()`, a thin pointer, but keep the same type
// this is understood as a special case elsewhere in the compiler
- let unit_pointer_ty = cx.tcx().mk_mut_ptr(cx.tcx().mk_unit());
- layout = cx.layout_of(unit_pointer_ty);
- layout.ty = fat_pointer_ty;
- layout
+ let unit_ptr_ty = tcx.mk_mut_ptr(tcx.mk_unit());
+
+ TyAndLayout {
+ ty: fat_pointer_ty,
+
+ // NOTE(eddyb) using an empty `ParamEnv`, and `unwrap`-ing the `Result`
+ // should always work because the type is always `*mut ()`.
+ ..tcx.layout_of(ty::ParamEnv::reveal_all().and(unit_ptr_ty)).unwrap()
+ }
}
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 8f814a8..8aa27d4 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -37,7 +37,7 @@
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind, Res};
use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalDefIdMap, CRATE_DEF_INDEX};
-use rustc_hir::{Constness, Node};
+use rustc_hir::Node;
use rustc_macros::HashStable;
use rustc_span::symbol::{kw, Ident, Symbol};
use rustc_span::Span;
@@ -181,6 +181,25 @@ pub enum Visibility {
Invisible,
}
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, HashStable, TyEncodable, TyDecodable)]
+pub enum BoundConstness {
+ /// `T: Trait`
+ NotConst,
+ /// `T: ~const Trait`
+ ///
+ /// Requires resolving to const only when we are in a const context.
+ ConstIfConst,
+}
+
+impl fmt::Display for BoundConstness {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ match self {
+ Self::NotConst => f.write_str("normal"),
+ Self::ConstIfConst => f.write_str("`~const`"),
+ }
+ }
+}
+
#[derive(
Clone,
Debug,
@@ -457,10 +476,6 @@ pub enum PredicateKind<'tcx> {
/// Corresponds to `where Foo: Bar<A, B, C>`. `Foo` here would be
/// the `Self` type of the trait reference and `A`, `B`, and `C`
/// would be the type parameters.
- ///
- /// A trait predicate will have `Constness::Const` if it originates
- /// from a bound on a `const fn` without the `?const` opt-out (e.g.,
- /// `const fn foobar<Foo: Bar>() {}`).
Trait(TraitPredicate<'tcx>),
/// `where 'a: 'b`
@@ -632,10 +647,7 @@ pub fn subst_supertrait(
pub struct TraitPredicate<'tcx> {
pub trait_ref: TraitRef<'tcx>,
- /// A trait predicate will have `Constness::Const` if it originates
- /// from a bound on a `const fn` without the `?const` opt-out (e.g.,
- /// `const fn foobar<Foo: Bar>() {}`).
- pub constness: hir::Constness,
+ pub constness: BoundConstness,
}
pub type PolyTraitPredicate<'tcx> = ty::Binder<'tcx, TraitPredicate<'tcx>>;
@@ -1304,7 +1316,7 @@ pub fn and<T: TypeFoldable<'tcx>>(self, value: T) -> ParamEnvAnd<'tcx, T> {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, TypeFoldable)]
pub struct ConstnessAnd<T> {
- pub constness: Constness,
+ pub constness: BoundConstness,
pub value: T,
}
@@ -1312,18 +1324,18 @@ pub struct ConstnessAnd<T> {
// the constness of trait bounds is being propagated correctly.
pub trait WithConstness: Sized {
#[inline]
- fn with_constness(self, constness: Constness) -> ConstnessAnd<Self> {
+ fn with_constness(self, constness: BoundConstness) -> ConstnessAnd<Self> {
ConstnessAnd { constness, value: self }
}
#[inline]
- fn with_const(self) -> ConstnessAnd<Self> {
- self.with_constness(Constness::Const)
+ fn with_const_if_const(self) -> ConstnessAnd<Self> {
+ self.with_constness(BoundConstness::ConstIfConst)
}
#[inline]
fn without_const(self) -> ConstnessAnd<Self> {
- self.with_constness(Constness::NotConst)
+ self.with_constness(BoundConstness::NotConst)
}
}
diff --git a/compiler/rustc_middle/src/ty/relate.rs b/compiler/rustc_middle/src/ty/relate.rs
index 4a2c834..9d1be21 100644
--- a/compiler/rustc_middle/src/ty/relate.rs
+++ b/compiler/rustc_middle/src/ty/relate.rs
@@ -200,12 +200,12 @@ fn relate<R: TypeRelation<'tcx>>(
}
}
-impl<'tcx> Relate<'tcx> for ast::Constness {
+impl<'tcx> Relate<'tcx> for ty::BoundConstness {
fn relate<R: TypeRelation<'tcx>>(
relation: &mut R,
- a: ast::Constness,
- b: ast::Constness,
- ) -> RelateResult<'tcx, ast::Constness> {
+ a: ty::BoundConstness,
+ b: ty::BoundConstness,
+ ) -> RelateResult<'tcx, ty::BoundConstness> {
if a != b {
Err(TypeError::ConstnessMismatch(expected_found(relation, a, b)))
} else {
@@ -577,13 +577,13 @@ pub fn super_relate_consts<R: TypeRelation<'tcx>>(
}
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu))
- if tcx.features().const_evaluatable_checked =>
+ if tcx.features().generic_const_exprs =>
{
tcx.try_unify_abstract_consts((au.shrink(), bu.shrink()))
}
// While this is slightly incorrect, it shouldn't matter for `min_const_generics`
- // and is the better alternative to waiting until `const_evaluatable_checked` can
+ // and is the better alternative to waiting until `generic_const_exprs` can
// be stabilized.
(ty::ConstKind::Unevaluated(au), ty::ConstKind::Unevaluated(bu))
if au.def == bu.def && au.promoted == bu.promoted =>
diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs
index 2ab25c8..89ad99d 100644
--- a/compiler/rustc_middle/src/ty/structural_impls.rs
+++ b/compiler/rustc_middle/src/ty/structural_impls.rs
@@ -8,7 +8,6 @@
use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer};
use crate::ty::{self, InferConst, Lift, Ty, TyCtxt};
use rustc_data_structures::functor::IdFunctor;
-use rustc_hir as hir;
use rustc_hir::def::Namespace;
use rustc_hir::def_id::CRATE_DEF_INDEX;
use rustc_index::vec::{Idx, IndexVec};
@@ -155,8 +154,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
impl fmt::Debug for ty::TraitPredicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- if let hir::Constness::Const = self.constness {
- write!(f, "const ")?;
+ if let ty::BoundConstness::ConstIfConst = self.constness {
+ write!(f, "~const ")?;
}
write!(f, "TraitPredicate({:?})", self.trait_ref)
}
@@ -241,6 +240,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
crate::traits::Reveal,
crate::ty::adjustment::AutoBorrowMutability,
crate::ty::AdtKind,
+ crate::ty::BoundConstness,
// Including `BoundRegionKind` is a *bit* dubious, but direct
// references to bound region appear in `ty::Error`, and aren't
// really meant to be folded. In general, we can only fold a fully
diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs
index 8b893b7..65dd61b 100644
--- a/compiler/rustc_middle/src/ty/sty.rs
+++ b/compiler/rustc_middle/src/ty/sty.rs
@@ -878,7 +878,7 @@ pub fn def_id(&self) -> DefId {
pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
self.map_bound(|trait_ref| ty::TraitPredicate {
trait_ref,
- constness: hir::Constness::NotConst,
+ constness: ty::BoundConstness::NotConst,
})
}
}
diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
index 7be3f54..4e079ed 100644
--- a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
+++ b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
@@ -5,11 +5,14 @@
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_middle::{
hir::place::PlaceBase,
- mir::{self, ClearCrossCrate, Local, LocalDecl, LocalInfo, LocalKind, Location},
+ mir::{
+ self, BindingForm, ClearCrossCrate, ImplicitSelfKind, Local, LocalDecl, LocalInfo,
+ LocalKind, Location,
+ },
};
use rustc_span::source_map::DesugaringKind;
use rustc_span::symbol::{kw, Symbol};
-use rustc_span::Span;
+use rustc_span::{BytePos, Span};
use crate::borrow_check::diagnostics::BorrowedContentSource;
use crate::borrow_check::MirBorrowckCtxt;
@@ -241,13 +244,74 @@ pub(crate) fn report_mutability_error(
.map(|l| mut_borrow_of_mutable_ref(l, self.local_names[local]))
.unwrap_or(false) =>
{
+ let decl = &self.body.local_decls[local];
err.span_label(span, format!("cannot {ACT}", ACT = act));
- err.span_suggestion(
- span,
- "try removing `&mut` here",
- String::new(),
- Applicability::MaybeIncorrect,
- );
+ if let Some(mir::Statement {
+ source_info,
+ kind:
+ mir::StatementKind::Assign(box (
+ _,
+ mir::Rvalue::Ref(
+ _,
+ mir::BorrowKind::Mut { allow_two_phase_borrow: false },
+ _,
+ ),
+ )),
+ ..
+ }) = &self.body[location.block].statements.get(location.statement_index)
+ {
+ match decl.local_info {
+ Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::Var(
+ mir::VarBindingForm {
+ binding_mode: ty::BindingMode::BindByValue(Mutability::Not),
+ opt_ty_info: Some(sp),
+ opt_match_place: _,
+ pat_span: _,
+ },
+ )))) => {
+ err.span_note(sp, "the binding is already a mutable borrow");
+ }
+ _ => {
+ err.span_note(
+ decl.source_info.span,
+ "the binding is already a mutable borrow",
+ );
+ }
+ }
+ if let Ok(snippet) =
+ self.infcx.tcx.sess.source_map().span_to_snippet(source_info.span)
+ {
+ if snippet.starts_with("&mut ") {
+ // We don't have access to the HIR to get accurate spans, but we can
+ // give a best effort structured suggestion.
+ err.span_suggestion_verbose(
+ source_info.span.with_hi(source_info.span.lo() + BytePos(5)),
+ "try removing `&mut` here",
+ String::new(),
+ Applicability::MachineApplicable,
+ );
+ } else {
+ // This can occur with things like `(&mut self).foo()`.
+ err.span_help(source_info.span, "try removing `&mut` here");
+ }
+ } else {
+ err.span_help(source_info.span, "try removing `&mut` here");
+ }
+ } else if decl.mutability == Mutability::Not
+ && !matches!(
+ decl.local_info,
+ Some(box LocalInfo::User(ClearCrossCrate::Set(BindingForm::ImplicitSelf(
+ ImplicitSelfKind::MutRef
+ ))))
+ )
+ {
+ err.span_suggestion_verbose(
+ decl.source_info.span.shrink_to_lo(),
+ "consider making the binding mutable",
+ "mut ".to_string(),
+ Applicability::MachineApplicable,
+ );
+ }
}
// We want to suggest users use `let mut` for local (user
diff --git a/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs b/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs
index e9ab62e..12fceef 100644
--- a/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs
+++ b/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs
@@ -82,15 +82,7 @@ pub(in crate::borrow_check) fn infer_opaque_types(
.find(|ur_vid| self.eval_equal(vid, **ur_vid))
.and_then(|ur_vid| self.definitions[*ur_vid].external_name)
.unwrap_or(infcx.tcx.lifetimes.re_root_empty),
- ty::ReLateBound(..) => region,
- ty::ReStatic => region,
- _ => {
- infcx.tcx.sess.delay_span_bug(
- span,
- &format!("unexpected concrete region in borrowck: {:?}", region),
- );
- region
- }
+ _ => region,
});
debug!(?universal_concrete_type, ?universal_substs);
diff --git a/compiler/rustc_mir/src/borrow_check/type_check/canonical.rs b/compiler/rustc_mir/src/borrow_check/type_check/canonical.rs
index 9fafcfa..b501716 100644
--- a/compiler/rustc_mir/src/borrow_check/type_check/canonical.rs
+++ b/compiler/rustc_mir/src/borrow_check/type_check/canonical.rs
@@ -1,6 +1,5 @@
use std::fmt;
-use rustc_hir as hir;
use rustc_infer::infer::canonical::Canonical;
use rustc_infer::traits::query::NoSolution;
use rustc_middle::mir::ConstraintCategory;
@@ -88,7 +87,7 @@ pub(super) fn prove_trait_ref(
self.prove_predicates(
Some(ty::PredicateKind::Trait(ty::TraitPredicate {
trait_ref,
- constness: hir::Constness::NotConst,
+ constness: ty::BoundConstness::NotConst,
})),
locations,
category,
diff --git a/compiler/rustc_mir/src/borrow_check/type_check/free_region_relations.rs b/compiler/rustc_mir/src/borrow_check/type_check/free_region_relations.rs
index 012d672..6426098 100644
--- a/compiler/rustc_mir/src/borrow_check/type_check/free_region_relations.rs
+++ b/compiler/rustc_mir/src/borrow_check/type_check/free_region_relations.rs
@@ -256,6 +256,9 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
let constraint_sets: Vec<_> = unnormalized_input_output_tys
.flat_map(|ty| {
debug!("build: input_or_output={:?}", ty);
+ // We add implied bounds from both the unnormalized and normalized ty
+ // See issue #87748
+ let constraints_implied_1 = self.add_implied_bounds(ty);
let TypeOpOutput { output: ty, constraints: constraints1, .. } = self
.param_env
.and(type_op::normalize::Normalize::new(ty))
@@ -271,9 +274,21 @@ impl UniversalRegionRelationsBuilder<'cx, 'tcx> {
canonicalized_query: None,
}
});
- let constraints2 = self.add_implied_bounds(ty);
+ // Note: we need this in examples like
+ // ```
+ // trait Foo {
+ // type Bar;
+ // fn foo(&self) -> &Self::Bar;
+ // }
+ // impl Foo for () {
+ // type Bar = ();
+ // fn foo(&self) ->&() {}
+ // }
+ // ```
+ // Both &Self::Bar and &() are WF
+ let constraints_implied_2 = self.add_implied_bounds(ty);
normalized_inputs_and_output.push(ty);
- constraints1.into_iter().chain(constraints2)
+ constraints1.into_iter().chain(constraints_implied_1).chain(constraints_implied_2)
})
.collect();
diff --git a/compiler/rustc_mir/src/interpret/cast.rs b/compiler/rustc_mir/src/interpret/cast.rs
index 697e983..6f18009 100644
--- a/compiler/rustc_mir/src/interpret/cast.rs
+++ b/compiler/rustc_mir/src/interpret/cast.rs
@@ -340,7 +340,7 @@ fn unsize_into(
// Example: `Arc<T>` -> `Arc<Trait>`
// here we need to increase the size of every &T thin ptr field to a fat ptr
for i in 0..src.layout.fields.count() {
- let cast_ty_field = cast_ty.field(self, i)?;
+ let cast_ty_field = cast_ty.field(self, i);
if cast_ty_field.is_zst() {
continue;
}
diff --git a/compiler/rustc_mir/src/interpret/eval_context.rs b/compiler/rustc_mir/src/interpret/eval_context.rs
index 516ef4f..bfb3de0 100644
--- a/compiler/rustc_mir/src/interpret/eval_context.rs
+++ b/compiler/rustc_mir/src/interpret/eval_context.rs
@@ -312,7 +312,7 @@ fn param_env(&self) -> ty::ParamEnv<'tcx> {
}
}
-impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> LayoutOf for InterpCx<'mir, 'tcx, M> {
+impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> LayoutOf<'tcx> for InterpCx<'mir, 'tcx, M> {
type Ty = Ty<'tcx>;
type TyAndLayout = InterpResult<'tcx, TyAndLayout<'tcx>>;
@@ -592,7 +592,7 @@ pub(super) fn size_and_align_of(
// Recurse to get the size of the dynamically sized field (must be
// the last field). Can't have foreign types here, how would we
// adjust alignment and size for them?
- let field = layout.field(self, layout.fields.count() - 1)?;
+ let field = layout.field(self, layout.fields.count() - 1);
let (unsized_size, unsized_align) =
match self.size_and_align_of(metadata, &field)? {
Some(size_and_align) => size_and_align,
@@ -645,7 +645,7 @@ pub(super) fn size_and_align_of(
ty::Slice(_) | ty::Str => {
let len = metadata.unwrap_meta().to_machine_usize(self)?;
- let elem = layout.field(self, 0)?;
+ let elem = layout.field(self, 0);
// Make sure the slice is not too big.
let size = elem.size.checked_mul(len, self).ok_or_else(|| {
diff --git a/compiler/rustc_mir/src/interpret/operand.rs b/compiler/rustc_mir/src/interpret/operand.rs
index 403dc1b..4afce2b 100644
--- a/compiler/rustc_mir/src/interpret/operand.rs
+++ b/compiler/rustc_mir/src/interpret/operand.rs
@@ -364,7 +364,7 @@ pub fn operand_field(
Err(value) => value,
};
- let field_layout = op.layout.field(self, field)?;
+ let field_layout = op.layout.field(self, field);
if field_layout.is_zst() {
let immediate = Scalar::ZST.into();
return Ok(OpTy { op: Operand::Immediate(immediate), layout: field_layout });
diff --git a/compiler/rustc_mir/src/interpret/place.rs b/compiler/rustc_mir/src/interpret/place.rs
index 91fcc34..afad971 100644
--- a/compiler/rustc_mir/src/interpret/place.rs
+++ b/compiler/rustc_mir/src/interpret/place.rs
@@ -355,7 +355,7 @@ pub fn mplace_field(
field: usize,
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
let offset = base.layout.fields.offset(field);
- let field_layout = base.layout.field(self, field)?;
+ let field_layout = base.layout.field(self, field);
// Offset may need adjustment for unsized fields.
let (meta, offset) = if field_layout.is_unsized() {
@@ -405,7 +405,7 @@ pub fn mplace_index(
}
let offset = stride * index; // `Size` multiplication
// All fields have the same layout.
- let field_layout = base.layout.field(self, 0)?;
+ let field_layout = base.layout.field(self, 0);
assert!(!field_layout.is_unsized());
base.offset(offset, MemPlaceMeta::None, field_layout, self)
@@ -430,7 +430,7 @@ pub(super) fn mplace_array_fields(
FieldsShape::Array { stride, .. } => stride,
_ => span_bug!(self.cur_span(), "mplace_array_fields: expected an array layout"),
};
- let layout = base.layout.field(self, 0)?;
+ let layout = base.layout.field(self, 0);
let dl = &self.tcx.data_layout;
// `Size` multiplication
Ok((0..len).map(move |i| base.offset(stride * i, MemPlaceMeta::None, layout, dl)))
diff --git a/compiler/rustc_mir/src/interpret/terminator.rs b/compiler/rustc_mir/src/interpret/terminator.rs
index d87aa4a..6349604 100644
--- a/compiler/rustc_mir/src/interpret/terminator.rs
+++ b/compiler/rustc_mir/src/interpret/terminator.rs
@@ -461,7 +461,7 @@ fn eval_fn_call(
// a thin pointer.
assert!(receiver_place.layout.is_unsized());
let receiver_ptr_ty = self.tcx.mk_mut_ptr(receiver_place.layout.ty);
- let this_receiver_ptr = self.layout_of(receiver_ptr_ty)?.field(self, 0)?;
+ let this_receiver_ptr = self.layout_of(receiver_ptr_ty)?.field(self, 0);
// Adjust receiver argument.
args[0] = OpTy::from(ImmTy::from_immediate(
Scalar::from_maybe_pointer(receiver_place.ptr, self).into(),
diff --git a/compiler/rustc_mir/src/monomorphize/collector.rs b/compiler/rustc_mir/src/monomorphize/collector.rs
index f030362..4cb3622 100644
--- a/compiler/rustc_mir/src/monomorphize/collector.rs
+++ b/compiler/rustc_mir/src/monomorphize/collector.rs
@@ -1149,6 +1149,7 @@ fn visit_item(&mut self, item: &'v hir::Item<'v>) {
match item.kind {
hir::ItemKind::ExternCrate(..)
| hir::ItemKind::Use(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::ForeignMod { .. }
| hir::ItemKind::TyAlias(..)
| hir::ItemKind::Trait(..)
diff --git a/compiler/rustc_mir/src/transform/check_consts/check.rs b/compiler/rustc_mir/src/transform/check_consts/check.rs
index 0361ddc..2b74806 100644
--- a/compiler/rustc_mir/src/transform/check_consts/check.rs
+++ b/compiler/rustc_mir/src/transform/check_consts/check.rs
@@ -805,6 +805,8 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
}
};
+ let mut nonconst_call_permission = false;
+
// Attempting to call a trait method?
if let Some(trait_id) = tcx.trait_of_item(callee) {
trace!("attempting to call a trait method");
@@ -819,23 +821,54 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
param_env,
Binder::dummy(TraitPredicate {
trait_ref,
- constness: hir::Constness::Const,
+ constness: ty::BoundConstness::ConstIfConst,
}),
);
let implsrc = tcx.infer_ctxt().enter(|infcx| {
- let mut selcx = SelectionContext::new(&infcx);
- selcx.select(&obligation).unwrap()
+ let mut selcx =
+ SelectionContext::with_constness(&infcx, hir::Constness::Const);
+ selcx.select(&obligation)
});
- // If the method is provided via a where-clause that does not use the `?const`
- // opt-out, the call is allowed.
- if let Some(ImplSource::Param(_, hir::Constness::Const)) = implsrc {
- debug!(
- "const_trait_impl: provided {:?} via where-clause in {:?}",
- trait_ref, param_env
- );
- return;
+ match implsrc {
+ Ok(Some(ImplSource::Param(_, ty::BoundConstness::ConstIfConst))) => {
+ debug!(
+ "const_trait_impl: provided {:?} via where-clause in {:?}",
+ trait_ref, param_env
+ );
+ return;
+ }
+ Ok(Some(ImplSource::UserDefined(data))) => {
+ let callee_name = tcx.item_name(callee);
+ if let Some(&did) = tcx
+ .associated_item_def_ids(data.impl_def_id)
+ .iter()
+ .find(|did| tcx.item_name(**did) == callee_name)
+ {
+ callee = did;
+ }
+ }
+ _ => {
+ if !tcx.is_const_fn_raw(callee) {
+ // At this point, it is only legal when the caller is marked with
+ // #[default_method_body_is_const], and the callee is in the same
+ // trait.
+ let callee_trait = tcx.trait_of_item(callee);
+ if callee_trait.is_some() {
+ if tcx.has_attr(caller, sym::default_method_body_is_const) {
+ if tcx.trait_of_item(caller) == callee_trait {
+ nonconst_call_permission = true;
+ }
+ }
+ }
+
+ if !nonconst_call_permission {
+ self.check_op(ops::FnCallNonConst);
+ return;
+ }
+ }
+ }
}
// Resolve a trait method call to its concrete implementation, which may be in a
@@ -875,34 +908,16 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
let is_intrinsic = tcx.fn_sig(callee).abi() == RustIntrinsic;
if !tcx.is_const_fn_raw(callee) {
- let mut permitted = false;
-
- let callee_trait = tcx.trait_of_item(callee);
- if let Some(trait_id) = callee_trait {
- if tcx.has_attr(caller, sym::default_method_body_is_const) {
- // permit call to non-const fn when caller has default_method_body_is_const..
- if tcx.trait_of_item(caller) == callee_trait {
- // ..and caller and callee are in the same trait.
- permitted = true;
- }
- }
- if !permitted {
- // if trait's impls are all const, permit the call.
- let mut const_impls = true;
- tcx.for_each_relevant_impl(trait_id, substs.type_at(0), |imp| {
- if const_impls {
- if let hir::Constness::NotConst = tcx.impl_constness(imp) {
- const_impls = false;
- }
- }
- });
- if const_impls {
- permitted = true;
- }
+ if tcx.trait_of_item(callee).is_some() {
+ if tcx.has_attr(callee, sym::default_method_body_is_const) {
+ // To get to here we must have already found a const impl for the
+ // trait, but for it to still be non-const can be that the impl is
+ // using default method bodies.
+ nonconst_call_permission = true;
}
}
- if !permitted {
+ if !nonconst_call_permission {
self.check_op(ops::FnCallNonConst);
return;
}
diff --git a/compiler/rustc_mir/src/transform/const_prop.rs b/compiler/rustc_mir/src/transform/const_prop.rs
index 1932cd5..5c51aa4 100644
--- a/compiler/rustc_mir/src/transform/const_prop.rs
+++ b/compiler/rustc_mir/src/transform/const_prop.rs
@@ -17,7 +17,7 @@
Location, Operand, Place, Rvalue, SourceInfo, SourceScope, SourceScopeData, Statement,
StatementKind, Terminator, TerminatorKind, UnOp, RETURN_PLACE,
};
-use rustc_middle::ty::layout::{HasTyCtxt, LayoutError, TyAndLayout};
+use rustc_middle::ty::layout::{LayoutError, TyAndLayout};
use rustc_middle::ty::subst::{InternalSubsts, Subst};
use rustc_middle::ty::{
self, ConstInt, ConstKind, Instance, ParamEnv, ScalarInt, Ty, TyCtxt, TypeFoldable,
@@ -330,7 +330,7 @@ struct ConstPropagator<'mir, 'tcx> {
source_info: Option<SourceInfo>,
}
-impl<'mir, 'tcx> LayoutOf for ConstPropagator<'mir, 'tcx> {
+impl<'mir, 'tcx> LayoutOf<'tcx> for ConstPropagator<'mir, 'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = Result<TyAndLayout<'tcx>, LayoutError<'tcx>>;
@@ -346,13 +346,20 @@ fn data_layout(&self) -> &TargetDataLayout {
}
}
-impl<'mir, 'tcx> HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
+impl<'mir, 'tcx> ty::layout::HasTyCtxt<'tcx> for ConstPropagator<'mir, 'tcx> {
#[inline]
fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
}
+impl<'mir, 'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'mir, 'tcx> {
+ #[inline]
+ fn param_env(&self) -> ty::ParamEnv<'tcx> {
+ self.param_env
+ }
+}
+
impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
fn new(
body: &Body<'tcx>,
diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs
index c333667..8e9da31 100644
--- a/compiler/rustc_mir/src/transform/inline.rs
+++ b/compiler/rustc_mir/src/transform/inline.rs
@@ -607,13 +607,7 @@ fn dest_needs_borrow(place: Place<'_>) -> bool {
}
// Insert all of the (mapped) parts of the callee body into the caller.
- caller_body.local_decls.extend(
- // FIXME(eddyb) make `Range<Local>` iterable so that we can use
- // `callee_body.local_decls.drain(callee_body.vars_and_temps())`
- callee_body
- .vars_and_temps_iter()
- .map(|local| callee_body.local_decls[local].clone()),
- );
+ caller_body.local_decls.extend(callee_body.drain_vars_and_temps());
caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..));
caller_body.var_debug_info.append(&mut callee_body.var_debug_info);
caller_body.basic_blocks_mut().extend(callee_body.basic_blocks_mut().drain(..));
diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
index 50cbe0f..b34c1e0 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs
@@ -17,7 +17,7 @@
use rustc_session::lint::builtin::BINDINGS_WITH_VARIANT_NAME;
use rustc_session::lint::builtin::{IRREFUTABLE_LET_PATTERNS, UNREACHABLE_PATTERNS};
use rustc_session::Session;
-use rustc_span::Span;
+use rustc_span::{DesugaringKind, ExpnKind, Span};
use std::slice;
crate fn check_match(tcx: TyCtxt<'_>, def_id: DefId) {
@@ -118,31 +118,6 @@ fn check_patterns(&self, pat: &Pat<'_>) {
check_for_bindings_named_same_as_variants(self, pat);
}
- fn let_source(&mut self, pat: &'tcx hir::Pat<'tcx>, _expr: &hir::Expr<'_>) -> LetSource {
- let hir = self.tcx.hir();
- let parent = hir.get_parent_node(pat.hir_id);
- let parent_parent = hir.get_parent_node(parent);
- let parent_parent_node = hir.get(parent_parent);
-
- let parent_parent_parent = hir.get_parent_node(parent_parent);
- let parent_parent_parent_parent = hir.get_parent_node(parent_parent_parent);
- let parent_parent_parent_parent_node = hir.get(parent_parent_parent_parent);
-
- if let hir::Node::Expr(hir::Expr {
- kind: hir::ExprKind::Loop(_, _, hir::LoopSource::While, _),
- ..
- }) = parent_parent_parent_parent_node
- {
- LetSource::WhileLet
- } else if let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::If { .. }, .. }) =
- parent_parent_node
- {
- LetSource::IfLet
- } else {
- LetSource::GenericLet
- }
- }
-
fn lower_pattern<'p>(
&self,
cx: &mut MatchCheckCtxt<'p, 'tcx>,
@@ -172,10 +147,9 @@ fn new_cx(&self, hir_id: HirId) -> MatchCheckCtxt<'_, 'tcx> {
fn check_let(&mut self, pat: &'tcx hir::Pat<'tcx>, expr: &hir::Expr<'_>, span: Span) {
self.check_patterns(pat);
- let ls = self.let_source(pat, expr);
let mut cx = self.new_cx(expr.hir_id);
let tpat = self.lower_pattern(&mut cx, pat, &mut false).0;
- check_let_reachability(&mut cx, ls, pat.hir_id, &tpat, span);
+ check_let_reachability(&mut cx, pat.hir_id, &tpat, span);
}
fn check_match(
@@ -192,13 +166,7 @@ fn check_match(
if let Some(hir::Guard::IfLet(ref pat, _)) = arm.guard {
self.check_patterns(pat);
let tpat = self.lower_pattern(&mut cx, pat, &mut false).0;
- check_let_reachability(
- &mut cx,
- LetSource::IfLetGuard,
- pat.hir_id,
- &tpat,
- tpat.span,
- );
+ check_let_reachability(&mut cx, pat.hir_id, &tpat, tpat.span);
}
}
@@ -397,7 +365,7 @@ fn unreachable_pattern(tcx: TyCtxt<'_>, span: Span, id: HirId, catchall: Option<
});
}
-fn irrefutable_let_pattern(id: HirId, ls: LetSource, span: Span, tcx: TyCtxt<'_>) {
+fn irrefutable_let_pattern(tcx: TyCtxt<'_>, id: HirId, span: Span) {
macro_rules! emit_diag {
(
$lint:expr,
@@ -412,7 +380,12 @@ macro_rules! emit_diag {
}};
}
- tcx.struct_span_lint_hir(IRREFUTABLE_LET_PATTERNS, id, span, |lint| match ls {
+ let source = let_source(tcx, id);
+ let span = match source {
+ LetSource::LetElse(span) => span,
+ _ => span,
+ };
+ tcx.struct_span_lint_hir(IRREFUTABLE_LET_PATTERNS, id, span, |lint| match source {
LetSource::GenericLet => {
emit_diag!(lint, "`let`", "`let` is useless", "removing `let`");
}
@@ -432,6 +405,14 @@ macro_rules! emit_diag {
"removing the guard and adding a `let` inside the match arm"
);
}
+ LetSource::LetElse(..) => {
+ emit_diag!(
+ lint,
+ "`let...else`",
+ "`else` clause is useless",
+ "removing the `else` clause"
+ );
+ }
LetSource::WhileLet => {
emit_diag!(
lint,
@@ -445,7 +426,6 @@ macro_rules! emit_diag {
fn check_let_reachability<'p, 'tcx>(
cx: &mut MatchCheckCtxt<'p, 'tcx>,
- ls: LetSource,
pat_id: HirId,
pat: &'p super::Pat<'tcx>,
span: Span,
@@ -454,13 +434,13 @@ fn check_let_reachability<'p, 'tcx>(
let report = compute_match_usefulness(&cx, &arms, pat_id, pat.ty);
report_arm_reachability(&cx, &report, |arm_index, arm_span, arm_hir_id, _| {
- match ls {
+ match let_source(cx.tcx, pat_id) {
LetSource::IfLet | LetSource::WhileLet => {
match arm_index {
// The arm with the user-specified pattern.
0 => unreachable_pattern(cx.tcx, arm_span, arm_hir_id, None),
// The arm with the wildcard pattern.
- 1 => irrefutable_let_pattern(pat_id, ls, arm_span, cx.tcx),
+ 1 => irrefutable_let_pattern(cx.tcx, pat_id, arm_span),
_ => bug!(),
}
}
@@ -473,7 +453,7 @@ fn check_let_reachability<'p, 'tcx>(
if report.non_exhaustiveness_witnesses.is_empty() {
// The match is exhaustive, i.e. the `if let` pattern is irrefutable.
- irrefutable_let_pattern(pat_id, ls, span, cx.tcx);
+ irrefutable_let_pattern(cx.tcx, pat_id, span);
}
}
@@ -787,5 +767,46 @@ pub enum LetSource {
GenericLet,
IfLet,
IfLetGuard,
+ LetElse(Span),
WhileLet,
}
+
+fn let_source(tcx: TyCtxt<'_>, pat_id: HirId) -> LetSource {
+ let hir = tcx.hir();
+ let parent = hir.get_parent_node(pat_id);
+ match hir.get(parent) {
+ hir::Node::Arm(hir::Arm {
+ guard: Some(hir::Guard::IfLet(&hir::Pat { hir_id, .. }, _)),
+ ..
+ }) if hir_id == pat_id => {
+ return LetSource::IfLetGuard;
+ }
+ hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Let(..), span, .. }) => {
+ let expn_data = span.ctxt().outer_expn_data();
+ if let ExpnKind::Desugaring(DesugaringKind::LetElse) = expn_data.kind {
+ return LetSource::LetElse(expn_data.call_site);
+ }
+ }
+ _ => {}
+ }
+ let parent_parent = hir.get_parent_node(parent);
+ let parent_parent_node = hir.get(parent_parent);
+
+ let parent_parent_parent = hir.get_parent_node(parent_parent);
+ let parent_parent_parent_parent = hir.get_parent_node(parent_parent_parent);
+ let parent_parent_parent_parent_node = hir.get(parent_parent_parent_parent);
+
+ if let hir::Node::Expr(hir::Expr {
+ kind: hir::ExprKind::Loop(_, _, hir::LoopSource::While, _),
+ ..
+ }) = parent_parent_parent_parent_node
+ {
+ LetSource::WhileLet
+ } else if let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::If { .. }, .. }) =
+ parent_parent_node
+ {
+ LetSource::IfLet
+ } else {
+ LetSource::GenericLet
+ }
+}
diff --git a/compiler/rustc_mir_build/src/thir/pattern/mod.rs b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
index 5221ced..cb74ae4 100644
--- a/compiler/rustc_mir_build/src/thir/pattern/mod.rs
+++ b/compiler/rustc_mir_build/src/thir/pattern/mod.rs
@@ -21,7 +21,7 @@
use rustc_middle::mir::{BorrowKind, Field, Mutability};
use rustc_middle::thir::{Ascription, BindingMode, FieldPat, Pat, PatKind, PatRange, PatTyProj};
use rustc_middle::ty::subst::{GenericArg, SubstsRef};
-use rustc_middle::ty::{self, AdtDef, DefIdTree, Region, Ty, TyCtxt, UserType};
+use rustc_middle::ty::{self, AdtDef, ConstKind, DefIdTree, Region, Ty, TyCtxt, UserType};
use rustc_span::{Span, Symbol};
use std::cmp::Ordering;
@@ -545,6 +545,11 @@ fn lower_lit(&mut self, expr: &'tcx hir::Expr<'tcx>) -> PatKind<'tcx> {
hir::ExprKind::ConstBlock(ref anon_const) => {
let anon_const_def_id = self.tcx.hir().local_def_id(anon_const.hir_id);
let value = ty::Const::from_anon_const(self.tcx, anon_const_def_id);
+ if matches!(value.val, ConstKind::Param(_)) {
+ let span = self.tcx.hir().span(anon_const.hir_id);
+ self.errors.push(PatternError::ConstParamInPattern(span));
+ return PatKind::Wild;
+ }
return *self.const_to_pat(value, expr.hir_id, expr.span, false).kind;
}
hir::ExprKind::Lit(ref lit) => (lit, false),
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 326c8f8..a1d3e9a 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -41,7 +41,7 @@ macro_rules! maybe_whole_expr {
let path = path.clone();
$p.bump();
return Ok($p.mk_expr(
- $p.token.span,
+ $p.prev_token.span,
ExprKind::Path(None, path),
AttrVec::new(),
));
@@ -50,7 +50,7 @@ macro_rules! maybe_whole_expr {
let block = block.clone();
$p.bump();
return Ok($p.mk_expr(
- $p.token.span,
+ $p.prev_token.span,
ExprKind::Block(block, None),
AttrVec::new(),
));
@@ -1528,7 +1528,7 @@ fn error_float_lits_must_have_int_part(&self, token: &Token) {
.span_suggestion(
token.span,
"must have an integer part",
- pprust::token_to_string(token),
+ pprust::token_to_string(token).into(),
Applicability::MachineApplicable,
)
.emit();
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs
index 4c3c140d..c34fd02 100644
--- a/compiler/rustc_parse/src/parser/mod.rs
+++ b/compiler/rustc_parse/src/parser/mod.rs
@@ -806,7 +806,7 @@ fn parse_seq_to_before_tokens<T>(
.span_suggestion_short(
sp,
&format!("missing `{}`", token_str),
- token_str,
+ token_str.into(),
Applicability::MaybeIncorrect,
)
.emit();
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs
index 85515bd..068bd36 100644
--- a/compiler/rustc_parse/src/parser/stmt.rs
+++ b/compiler/rustc_parse/src/parser/stmt.rs
@@ -11,8 +11,9 @@
use rustc_ast::ptr::P;
use rustc_ast::token::{self, TokenKind};
use rustc_ast::util::classify;
-use rustc_ast::AstLike;
-use rustc_ast::{AttrStyle, AttrVec, Attribute, MacCall, MacCallStmt, MacStmtStyle};
+use rustc_ast::{
+ AstLike, AttrStyle, AttrVec, Attribute, LocalKind, MacCall, MacCallStmt, MacStmtStyle,
+};
use rustc_ast::{Block, BlockCheckMode, Expr, ExprKind, Local, Stmt};
use rustc_ast::{StmtKind, DUMMY_NODE_ID};
use rustc_errors::{Applicability, PResult};
@@ -292,8 +293,65 @@ fn parse_local(&mut self, attrs: AttrVec) -> PResult<'a, P<Local>> {
return Err(err);
}
};
+ let kind = match init {
+ None => LocalKind::Decl,
+ Some(init) => {
+ if self.eat_keyword(kw::Else) {
+ let els = self.parse_block()?;
+ self.check_let_else_init_bool_expr(&init);
+ self.check_let_else_init_trailing_brace(&init);
+ LocalKind::InitElse(init, els)
+ } else {
+ LocalKind::Init(init)
+ }
+ }
+ };
let hi = if self.token == token::Semi { self.token.span } else { self.prev_token.span };
- Ok(P(ast::Local { ty, pat, init, id: DUMMY_NODE_ID, span: lo.to(hi), attrs, tokens: None }))
+ Ok(P(ast::Local { ty, pat, kind, id: DUMMY_NODE_ID, span: lo.to(hi), attrs, tokens: None }))
+ }
+
+ fn check_let_else_init_bool_expr(&self, init: &ast::Expr) {
+ if let ast::ExprKind::Binary(op, ..) = init.kind {
+ if op.node.lazy() {
+ let suggs = vec![
+ (init.span.shrink_to_lo(), "(".to_string()),
+ (init.span.shrink_to_hi(), ")".to_string()),
+ ];
+ self.struct_span_err(
+ init.span,
+ &format!(
+ "a `{}` expression cannot be directly assigned in `let...else`",
+ op.node.to_string()
+ ),
+ )
+ .multipart_suggestion(
+ "wrap the expression in parenthesis",
+ suggs,
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ }
+ }
+ }
+
+ fn check_let_else_init_trailing_brace(&self, init: &ast::Expr) {
+ if let Some(trailing) = classify::expr_trailing_brace(init) {
+ let err_span = trailing.span.with_lo(trailing.span.hi() - BytePos(1));
+ let suggs = vec![
+ (trailing.span.shrink_to_lo(), "(".to_string()),
+ (trailing.span.shrink_to_hi(), ")".to_string()),
+ ];
+ self.struct_span_err(
+ err_span,
+ "right curly brace `}` before `else` in a `let...else` statement not allowed",
+ )
+ .multipart_suggestion(
+ "try wrapping the expression in parenthesis",
+ suggs,
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ }
}
/// Parses the RHS of a local variable declaration (e.g., `= 14;`).
@@ -495,13 +553,13 @@ pub fn parse_full_stmt(
StmtKind::Expr(_) | StmtKind::MacCall(_) => {}
StmtKind::Local(ref mut local) if let Err(e) = self.expect_semi() => {
// We might be at the `,` in `let x = foo<bar, baz>;`. Try to recover.
- match &mut local.init {
- Some(ref mut expr) => {
- self.check_mistyped_turbofish_with_multiple_type_params(e, expr)?;
- // We found `foo<bar, baz>`, have we fully recovered?
- self.expect_semi()?;
- }
- None => return Err(e),
+ match &mut local.kind {
+ LocalKind::Init(expr) | LocalKind::InitElse(expr, _) => {
+ self.check_mistyped_turbofish_with_multiple_type_params(e, expr)?;
+ // We found `foo<bar, baz>`, have we fully recovered?
+ self.expect_semi()?;
+ }
+ LocalKind::Decl => return Err(e),
}
eat_semi = false;
}
diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs
index 1fbf01b..299fc91 100644
--- a/compiler/rustc_parse/src/parser/ty.rs
+++ b/compiler/rustc_parse/src/parser/ty.rs
@@ -11,12 +11,12 @@
use rustc_span::source_map::Span;
use rustc_span::symbol::{kw, sym};
-/// Any `?` or `?const` modifiers that appear at the start of a bound.
+/// Any `?` or `~const` modifiers that appear at the start of a bound.
struct BoundModifiers {
/// `?Trait`.
maybe: Option<Span>,
- /// `?const Trait`.
+ /// `~const Trait`.
maybe_const: Option<Span>,
}
@@ -609,6 +609,7 @@ fn can_begin_bound(&mut self) -> bool {
|| self.check_lifetime()
|| self.check(&token::Not) // Used for error reporting only.
|| self.check(&token::Question)
+ || self.check(&token::Tilde)
|| self.check_keyword(kw::For)
|| self.check(&token::OpenDelim(token::Paren))
}
@@ -655,7 +656,7 @@ fn parse_generic_bound(&mut self) -> PResult<'a, Result<GenericBound, Span>> {
let inner_lo = self.token.span;
let is_negative = self.eat(&token::Not);
- let modifiers = self.parse_ty_bound_modifiers();
+ let modifiers = self.parse_ty_bound_modifiers()?;
let bound = if self.token.is_lifetime() {
self.error_lt_bound_with_modifiers(modifiers);
self.parse_generic_lt_bound(lo, inner_lo, has_parens)?
@@ -690,7 +691,7 @@ fn error_lt_bound_with_modifiers(&self, modifiers: BoundModifiers) {
if let Some(span) = modifiers.maybe_const {
self.struct_span_err(
span,
- "`?const` may only modify trait bounds, not lifetime bounds",
+ "`~const` may only modify trait bounds, not lifetime bounds",
)
.emit();
}
@@ -721,34 +722,27 @@ fn recover_paren_lifetime(&mut self, lo: Span, inner_lo: Span) -> PResult<'a, ()
Ok(())
}
- /// Parses the modifiers that may precede a trait in a bound, e.g. `?Trait` or `?const Trait`.
+ /// Parses the modifiers that may precede a trait in a bound, e.g. `?Trait` or `~const Trait`.
///
/// If no modifiers are present, this does not consume any tokens.
///
/// ```
- /// TY_BOUND_MODIFIERS = "?" ["const" ["?"]]
+ /// TY_BOUND_MODIFIERS = ["~const"] ["?"]
/// ```
- fn parse_ty_bound_modifiers(&mut self) -> BoundModifiers {
- if !self.eat(&token::Question) {
- return BoundModifiers { maybe: None, maybe_const: None };
- }
+ fn parse_ty_bound_modifiers(&mut self) -> PResult<'a, BoundModifiers> {
+ let maybe_const = if self.eat(&token::Tilde) {
+ let tilde = self.prev_token.span;
+ self.expect_keyword(kw::Const)?;
+ let span = tilde.to(self.prev_token.span);
+ self.sess.gated_spans.gate(sym::const_trait_impl, span);
+ Some(span)
+ } else {
+ None
+ };
- // `? ...`
- let first_question = self.prev_token.span;
- if !self.eat_keyword(kw::Const) {
- return BoundModifiers { maybe: Some(first_question), maybe_const: None };
- }
+ let maybe = if self.eat(&token::Question) { Some(self.prev_token.span) } else { None };
- // `?const ...`
- let maybe_const = first_question.to(self.prev_token.span);
- self.sess.gated_spans.gate(sym::const_trait_bound_opt_out, maybe_const);
- if !self.eat(&token::Question) {
- return BoundModifiers { maybe: None, maybe_const: Some(maybe_const) };
- }
-
- // `?const ? ...`
- let second_question = self.prev_token.span;
- BoundModifiers { maybe: Some(second_question), maybe_const: Some(maybe_const) }
+ Ok(BoundModifiers { maybe, maybe_const })
}
/// Parses a type bound according to:
@@ -757,7 +751,7 @@ fn parse_ty_bound_modifiers(&mut self) -> BoundModifiers {
/// TY_BOUND_NOPAREN = [TY_BOUND_MODIFIERS] [for<LT_PARAM_DEFS>] SIMPLE_PATH
/// ```
///
- /// For example, this grammar accepts `?const ?for<'a: 'b> m::Trait<'a>`.
+ /// For example, this grammar accepts `~const ?for<'a: 'b> m::Trait<'a>`.
fn parse_generic_ty_bound(
&mut self,
lo: Span,
diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs
index d0ddad1..fd438bd 100644
--- a/compiler/rustc_passes/src/check_attr.rs
+++ b/compiler/rustc_passes/src/check_attr.rs
@@ -1331,6 +1331,36 @@ fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: &Span, target:
Target::Field | Target::Arm | Target::MacroDef => {
self.inline_attr_str_error_with_macro_def(hir_id, attr, "no_mangle");
}
+ // FIXME: #[no_mangle] was previously allowed on non-functions/statics, this should be an error
+ // The error should specify that the item that is wrong is specifically a *foreign* fn/static
+ // otherwise the error seems odd
+ Target::ForeignFn | Target::ForeignStatic => {
+ let foreign_item_kind = match target {
+ Target::ForeignFn => "function",
+ Target::ForeignStatic => "static",
+ _ => unreachable!(),
+ };
+ self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
+ lint.build(&format!(
+ "`#[no_mangle]` has no effect on a foreign {}",
+ foreign_item_kind
+ ))
+ .warn(
+ "this was previously accepted by the compiler but is \
+ being phased out; it will become a hard error in \
+ a future release!",
+ )
+ .span_label(*span, format!("foreign {}", foreign_item_kind))
+ .note("symbol names in extern blocks are not mangled")
+ .span_suggestion(
+ attr.span,
+ "remove this attribute",
+ String::new(),
+ Applicability::MachineApplicable,
+ )
+ .emit();
+ });
+ }
_ => {
// FIXME: #[no_mangle] was previously allowed on non-functions/statics and some
// crates used this, so only emit a warning.
@@ -1723,6 +1753,16 @@ fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
}
fn visit_item(&mut self, item: &'tcx Item<'tcx>) {
+ // Historically we've run more checks on non-exported than exported macros,
+ // so this lets us continue to run them while maintaining backwards compatibility.
+ // In the long run, the checks should be harmonized.
+ if let ItemKind::Macro(ref macro_def) = item.kind {
+ let def_id = item.def_id.to_def_id();
+ if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) {
+ check_non_exported_macro_for_invalid_attrs(self.tcx, item);
+ }
+ }
+
let target = Target::from_item(item);
self.check_attributes(item.hir_id(), &item.span, target, Some(ItemLike::Item(item)));
intravisit::walk_item(self, item)
@@ -1795,11 +1835,6 @@ fn visit_variant(
intravisit::walk_variant(self, variant, generics, item_id)
}
- fn visit_macro_def(&mut self, macro_def: &'tcx hir::MacroDef<'tcx>) {
- self.check_attributes(macro_def.hir_id(), ¯o_def.span, Target::MacroDef, None);
- intravisit::walk_macro_def(self, macro_def);
- }
-
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
self.check_attributes(param.hir_id, ¶m.span, Target::Param, None);
@@ -1848,7 +1883,9 @@ fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
}
}
-fn check_invalid_macro_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
+fn check_non_exported_macro_for_invalid_attrs(tcx: TyCtxt<'_>, item: &Item<'_>) {
+ let attrs = tcx.hir().attrs(item.hir_id());
+
for attr in attrs {
if attr.has_name(sym::inline) {
struct_span_err!(
@@ -1869,8 +1906,6 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
if module_def_id.is_top_level_module() {
check_attr_visitor.check_attributes(CRATE_HIR_ID, &DUMMY_SP, Target::Mod, None);
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
- tcx.hir().visit_exported_macros_in_krate(check_attr_visitor);
- check_invalid_macro_level_attr(tcx, tcx.hir().krate().non_exported_macro_attrs);
}
}
diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs
index e43abda..3f12a74 100644
--- a/compiler/rustc_passes/src/diagnostic_items.rs
+++ b/compiler/rustc_passes/src/diagnostic_items.rs
@@ -107,10 +107,6 @@ fn diagnostic_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> FxHashMap<Symbol
// Collect diagnostic items in this crate.
tcx.hir().krate().visit_all_item_likes(&mut collector);
- for m in tcx.hir().krate().exported_macros() {
- collector.observe_item(m.def_id);
- }
-
collector.items
}
diff --git a/compiler/rustc_passes/src/hir_stats.rs b/compiler/rustc_passes/src/hir_stats.rs
index 2bed8ca..b8ce973 100644
--- a/compiler/rustc_passes/src/hir_stats.rs
+++ b/compiler/rustc_passes/src/hir_stats.rs
@@ -244,11 +244,6 @@ fn visit_assoc_type_binding(&mut self, type_binding: &'v hir::TypeBinding<'v>) {
fn visit_attribute(&mut self, _: hir::HirId, attr: &'v ast::Attribute) {
self.record("Attribute", Id::Attr(attr.id), attr);
}
-
- fn visit_macro_def(&mut self, macro_def: &'v hir::MacroDef<'v>) {
- self.record("MacroDef", Id::Node(macro_def.hir_id()), macro_def);
- hir_visit::walk_macro_def(self, macro_def)
- }
}
impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs
index 43a3a30..64ea4ee 100644
--- a/compiler/rustc_passes/src/layout_test.rs
+++ b/compiler/rustc_passes/src/layout_test.rs
@@ -113,7 +113,7 @@ struct UnwrapLayoutCx<'tcx> {
param_env: ParamEnv<'tcx>,
}
-impl LayoutOf for UnwrapLayoutCx<'tcx> {
+impl LayoutOf<'tcx> for UnwrapLayoutCx<'tcx> {
type Ty = Ty<'tcx>;
type TyAndLayout = TyAndLayout<'tcx>;
diff --git a/compiler/rustc_passes/src/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs
index 605b52f..7d15ca1 100644
--- a/compiler/rustc_passes/src/lib_features.rs
+++ b/compiler/rustc_passes/src/lib_features.rs
@@ -127,9 +127,7 @@ fn visit_attribute(&mut self, _: rustc_hir::HirId, attr: &'tcx Attribute) {
fn get_lib_features(tcx: TyCtxt<'_>, (): ()) -> LibFeatures {
let mut collector = LibFeatureCollector::new(tcx);
let krate = tcx.hir().krate();
- for attr in krate.non_exported_macro_attrs {
- collector.visit_attribute(rustc_hir::CRATE_HIR_ID, attr);
- }
+
intravisit::walk_crate(&mut collector, krate);
collector.lib_features
}
diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs
index 5ca098c..23f4323 100644
--- a/compiler/rustc_passes/src/reachable.rs
+++ b/compiler/rustc_passes/src/reachable.rs
@@ -263,6 +263,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>, search_item: LocalDefId) {
| hir::ItemKind::Use(..)
| hir::ItemKind::OpaqueTy(..)
| hir::ItemKind::TyAlias(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::ForeignMod { .. }
| hir::ItemKind::Impl { .. }
@@ -309,8 +310,7 @@ fn propagate_node(&mut self, node: &Node<'tcx>, search_item: LocalDefId) {
| Node::Ctor(..)
| Node::Field(_)
| Node::Ty(_)
- | Node::Crate(_)
- | Node::MacroDef(_) => {}
+ | Node::Crate(_) => {}
_ => {
bug!(
"found unexpected node kind in worklist: {} ({:?})",
diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs
index b64dcb0..a88393c 100644
--- a/compiler/rustc_passes/src/stability.rs
+++ b/compiler/rustc_passes/src/stability.rs
@@ -538,19 +538,6 @@ fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) {
);
}
- fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
- self.annotate(
- md.def_id,
- md.span,
- None,
- AnnotationKind::Required,
- InheritDeprecation::Yes,
- InheritConstStability::No,
- InheritStability::No,
- |_| {},
- );
- }
-
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {
let kind = match &p.kind {
// Allow stability attributes on default generic arguments.
@@ -662,11 +649,6 @@ fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem<'tcx>) {
self.check_missing_stability(i.def_id, i.span);
intravisit::walk_foreign_item(self, i);
}
-
- fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
- self.check_missing_stability(md.def_id, md.span);
- }
-
// Note that we don't need to `check_missing_stability` for default generic parameters,
// as we assume that any default generic parameters without attributes are automatically
// stable (assuming they have not inherited instability from their parent).
diff --git a/compiler/rustc_privacy/Cargo.toml b/compiler/rustc_privacy/Cargo.toml
index 85a53b1..6ac2915 100644
--- a/compiler/rustc_privacy/Cargo.toml
+++ b/compiler/rustc_privacy/Cargo.toml
@@ -5,6 +5,7 @@
[dependencies]
rustc_middle = { path = "../rustc_middle" }
+rustc_ast = { path = "../rustc_ast" }
rustc_attr = { path = "../rustc_attr" }
rustc_errors = { path = "../rustc_errors" }
rustc_hir = { path = "../rustc_hir" }
diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs
index 6fe68a0..9c376c6 100644
--- a/compiler/rustc_privacy/src/lib.rs
+++ b/compiler/rustc_privacy/src/lib.rs
@@ -6,6 +6,7 @@
#![feature(associated_type_defaults)]
#![recursion_limit = "256"]
+use rustc_ast::MacroDef;
use rustc_attr as attr;
use rustc_data_structures::fx::FxHashSet;
use rustc_errors::struct_span_err;
@@ -26,7 +27,7 @@
use rustc_middle::ty::{self, Const, GenericParamDefKind, TraitRef, Ty, TyCtxt, TypeFoldable};
use rustc_session::lint;
use rustc_span::hygiene::Transparency;
-use rustc_span::symbol::{kw, Ident};
+use rustc_span::symbol::{kw, sym, Ident};
use rustc_span::Span;
use rustc_trait_selection::traits::const_evaluatable::{self, AbstractConst};
@@ -135,7 +136,7 @@ fn visit_predicate(&mut self, predicate: ty::Predicate<'tcx>) -> ControlFlow<V::
}
ty::PredicateKind::RegionOutlives(..) => ControlFlow::CONTINUE,
ty::PredicateKind::ConstEvaluatable(uv)
- if self.def_id_visitor.tcx().features().const_evaluatable_checked =>
+ if self.def_id_visitor.tcx().features().generic_const_exprs =>
{
let tcx = self.def_id_visitor.tcx();
if let Ok(Some(ct)) = AbstractConst::new(tcx, uv) {
@@ -462,6 +463,43 @@ fn reach(
}
}
+ // We have to make sure that the items that macros might reference
+ // are reachable, since they might be exported transitively.
+ fn update_reachability_from_macro(&mut self, local_def_id: LocalDefId, md: &MacroDef) {
+ // Non-opaque macros cannot make other items more accessible than they already are.
+
+ let hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
+ let attrs = self.tcx.hir().attrs(hir_id);
+ if attr::find_transparency(&attrs, md.macro_rules).0 != Transparency::Opaque {
+ return;
+ }
+
+ let item_def_id = local_def_id.to_def_id();
+ let macro_module_def_id =
+ ty::DefIdTree::parent(self.tcx, item_def_id).unwrap().expect_local();
+ if self.tcx.hir().opt_def_kind(macro_module_def_id) != Some(DefKind::Mod) {
+ // The macro's parent doesn't correspond to a `mod`, return early (#63164, #65252).
+ return;
+ }
+
+ if self.get(local_def_id).is_none() {
+ return;
+ }
+
+ // Since we are starting from an externally visible module,
+ // all the parents in the loop below are also guaranteed to be modules.
+ let mut module_def_id = macro_module_def_id;
+ loop {
+ let changed_reachability =
+ self.update_macro_reachable(module_def_id, macro_module_def_id);
+ if changed_reachability || module_def_id == CRATE_DEF_ID {
+ break;
+ }
+ module_def_id =
+ ty::DefIdTree::parent(self.tcx, module_def_id.to_def_id()).unwrap().expect_local();
+ }
+ }
+
/// Updates the item as being reachable through a macro defined in the given
/// module. Returns `true` if the level has changed.
fn update_macro_reachable(
@@ -511,16 +549,26 @@ fn update_macro_reachable_def(
}
match def_kind {
// No type privacy, so can be directly marked as reachable.
- DefKind::Const
- | DefKind::Macro(_)
- | DefKind::Static
- | DefKind::TraitAlias
- | DefKind::TyAlias => {
+ DefKind::Const | DefKind::Static | DefKind::TraitAlias | DefKind::TyAlias => {
if vis.is_accessible_from(module.to_def_id(), self.tcx) {
self.update(def_id, level);
}
}
+ // Hygine isn't really implemented for `macro_rules!` macros at the
+ // moment. Accordingly, marking them as reachable is unwise. `macro` macros
+ // have normal hygine, so we can treat them like other items without type
+ // privacy and mark them reachable.
+ DefKind::Macro(_) => {
+ let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
+ let item = self.tcx.hir().expect_item(hir_id);
+ if let hir::ItemKind::Macro(MacroDef { macro_rules: false, .. }) = item.kind {
+ if vis.is_accessible_from(module.to_def_id(), self.tcx) {
+ self.update(def_id, level);
+ }
+ }
+ }
+
// We can't use a module name as the final segment of a path, except
// in use statements. Since re-export checking doesn't consider
// hygiene these don't need to be marked reachable. The contents of
@@ -644,6 +692,12 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
hir::ItemKind::Impl { .. } => {
Option::<AccessLevel>::of_impl(item.def_id, self.tcx, &self.access_levels)
}
+ // Only exported `macro_rules!` items are public, but they always are.
+ hir::ItemKind::Macro(MacroDef { macro_rules: true, .. }) => {
+ let def_id = item.def_id.to_def_id();
+ let is_macro_export = self.tcx.has_attr(def_id, sym::macro_export);
+ if is_macro_export { Some(AccessLevel::Public) } else { None }
+ }
// Foreign modules inherit level from parents.
hir::ItemKind::ForeignMod { .. } => self.prev_level,
// Other `pub` items inherit levels from parents.
@@ -652,6 +706,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
| hir::ItemKind::ExternCrate(..)
| hir::ItemKind::GlobalAsm(..)
| hir::ItemKind::Fn(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::Struct(..)
@@ -708,6 +763,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
}
}
+ hir::ItemKind::Macro(ref macro_def) => {
+ self.update_reachability_from_macro(item.def_id, macro_def);
+ }
hir::ItemKind::ForeignMod { items, .. } => {
for foreign_item in items {
if foreign_item.vis.node.is_pub() {
@@ -715,6 +773,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
}
}
}
+
hir::ItemKind::OpaqueTy(..)
| hir::ItemKind::Use(..)
| hir::ItemKind::Static(..)
@@ -730,7 +789,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
// Mark all items in interfaces of reachable items as reachable.
match item.kind {
// The interface is empty.
- hir::ItemKind::ExternCrate(..) => {}
+ hir::ItemKind::Macro(..) | hir::ItemKind::ExternCrate(..) => {}
// All nested items are checked by `visit_item`.
hir::ItemKind::Mod(..) => {}
// Re-exports are handled in `visit_mod`. However, in order to avoid looping over
@@ -885,45 +944,6 @@ fn visit_mod(&mut self, m: &'tcx hir::Mod<'tcx>, _sp: Span, id: hir::HirId) {
intravisit::walk_mod(self, m, id);
}
-
- fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
- // Non-opaque macros cannot make other items more accessible than they already are.
- let attrs = self.tcx.hir().attrs(md.hir_id());
- if attr::find_transparency(&attrs, md.ast.macro_rules).0 != Transparency::Opaque {
- // `#[macro_export]`-ed `macro_rules!` are `Public` since they
- // ignore their containing path to always appear at the crate root.
- if md.ast.macro_rules {
- self.update(md.def_id, Some(AccessLevel::Public));
- }
- return;
- }
-
- let macro_module_def_id =
- ty::DefIdTree::parent(self.tcx, md.def_id.to_def_id()).unwrap().expect_local();
- if self.tcx.hir().opt_def_kind(macro_module_def_id) != Some(DefKind::Mod) {
- // The macro's parent doesn't correspond to a `mod`, return early (#63164, #65252).
- return;
- }
-
- let level = if md.vis.node.is_pub() { self.get(macro_module_def_id) } else { None };
- let new_level = self.update(md.def_id, level);
- if new_level.is_none() {
- return;
- }
-
- // Since we are starting from an externally visible module,
- // all the parents in the loop below are also guaranteed to be modules.
- let mut module_def_id = macro_module_def_id;
- loop {
- let changed_reachability =
- self.update_macro_reachable(module_def_id, macro_module_def_id);
- if changed_reachability || module_def_id == CRATE_DEF_ID {
- break;
- }
- module_def_id =
- ty::DefIdTree::parent(self.tcx, module_def_id.to_def_id()).unwrap().expect_local();
- }
- }
}
impl ReachEverythingInTheInterfaceVisitor<'_, 'tcx> {
@@ -1789,7 +1809,7 @@ fn generics(&mut self) -> &mut Self {
self.visit(self.tcx.type_of(param.def_id));
}
}
- // FIXME(const_evaluatable_checked): May want to look inside const here
+ // FIXME(generic_const_exprs): May want to look inside const here
GenericParamDefKind::Const { .. } => {
self.visit(self.tcx.type_of(param.def_id));
}
@@ -1981,7 +2001,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
// Checked in resolve.
hir::ItemKind::Use(..) => {}
// No subitems.
- hir::ItemKind::GlobalAsm(..) => {}
+ hir::ItemKind::Macro(..) | hir::ItemKind::GlobalAsm(..) => {}
// Subitems of these items have inherited publicity.
hir::ItemKind::Const(..)
| hir::ItemKind::Static(..)
diff --git a/compiler/rustc_query_impl/src/keys.rs b/compiler/rustc_query_impl/src/keys.rs
index d85f1c0..c973eae 100644
--- a/compiler/rustc_query_impl/src/keys.rs
+++ b/compiler/rustc_query_impl/src/keys.rs
@@ -20,6 +20,12 @@ pub trait Key {
/// In the event that a cycle occurs, if no explicit span has been
/// given for a query with key `self`, what span should we use?
fn default_span(&self, tcx: TyCtxt<'_>) -> Span;
+
+ /// If the key is a [`DefId`] or `DefId`--equivalent, return that `DefId`.
+ /// Otherwise, return `None`.
+ fn key_as_def_id(&self) -> Option<DefId> {
+ None
+ }
}
impl Key for () {
@@ -95,6 +101,9 @@ fn query_crate_is_local(&self) -> bool {
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
self.to_def_id().default_span(tcx)
}
+ fn key_as_def_id(&self) -> Option<DefId> {
+ Some(self.to_def_id())
+ }
}
impl Key for DefId {
@@ -105,6 +114,10 @@ fn query_crate_is_local(&self) -> bool {
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(*self)
}
+ #[inline(always)]
+ fn key_as_def_id(&self) -> Option<DefId> {
+ Some(*self)
+ }
}
impl Key for ty::WithOptConstParam<LocalDefId> {
@@ -165,6 +178,10 @@ fn query_crate_is_local(&self) -> bool {
fn default_span(&self, tcx: TyCtxt<'_>) -> Span {
tcx.def_span(self.0)
}
+ #[inline(always)]
+ fn key_as_def_id(&self) -> Option<DefId> {
+ Some(self.0)
+ }
}
impl Key for (DefId, LocalDefId, Ident) {
diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs
index 5022bf2..bb0e651 100644
--- a/compiler/rustc_query_impl/src/lib.rs
+++ b/compiler/rustc_query_impl/src/lib.rs
@@ -51,6 +51,8 @@
mod profiling_support;
pub use self::profiling_support::alloc_self_profile_query_strings;
+mod util;
+
rustc_query_append! { [define_queries!][<'tcx>] }
impl<'tcx> Queries<'tcx> {
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs
index 5774d02..90a6ba4 100644
--- a/compiler/rustc_query_impl/src/plumbing.rs
+++ b/compiler/rustc_query_impl/src/plumbing.rs
@@ -337,6 +337,13 @@ pub fn $name<$tcx>(tcx: QueryCtxt<$tcx>, key: query_keys::$name<$tcx>) -> QueryS
} else {
Some(key.default_span(*tcx))
};
+ let def_id = key.key_as_def_id();
+ let def_kind = def_id
+ .and_then(|def_id| def_id.as_local())
+ // Use `tcx.hir().opt_def_kind()` to reduce the chance of
+ // accidentally triggering an infinite query loop.
+ .and_then(|def_id| tcx.hir().opt_def_kind(def_id))
+ .map(|def_kind| $crate::util::def_kind_to_simple_def_kind(def_kind));
let hash = || {
let mut hcx = tcx.create_stable_hashing_context();
let mut hasher = StableHasher::new();
@@ -345,7 +352,7 @@ pub fn $name<$tcx>(tcx: QueryCtxt<$tcx>, key: query_keys::$name<$tcx>) -> QueryS
hasher.finish::<u64>()
};
- QueryStackFrame::new(name, description, span, hash)
+ QueryStackFrame::new(name, description, span, def_kind, hash)
})*
}
diff --git a/compiler/rustc_query_impl/src/util.rs b/compiler/rustc_query_impl/src/util.rs
new file mode 100644
index 0000000..517c107
--- /dev/null
+++ b/compiler/rustc_query_impl/src/util.rs
@@ -0,0 +1,18 @@
+use rustc_hir::def::DefKind;
+use rustc_query_system::query::SimpleDefKind;
+
+/// Convert a [`DefKind`] to a [`SimpleDefKind`].
+///
+/// *See [`SimpleDefKind`]'s docs for more information.*
+pub(crate) fn def_kind_to_simple_def_kind(def_kind: DefKind) -> SimpleDefKind {
+ match def_kind {
+ DefKind::Struct => SimpleDefKind::Struct,
+ DefKind::Enum => SimpleDefKind::Enum,
+ DefKind::Union => SimpleDefKind::Union,
+ DefKind::Trait => SimpleDefKind::Trait,
+ DefKind::TyAlias => SimpleDefKind::TyAlias,
+ DefKind::TraitAlias => SimpleDefKind::TraitAlias,
+
+ _ => SimpleDefKind::Other,
+ }
+}
diff --git a/compiler/rustc_query_system/src/query/job.rs b/compiler/rustc_query_system/src/query/job.rs
index a967670..63a8f06 100644
--- a/compiler/rustc_query_system/src/query/job.rs
+++ b/compiler/rustc_query_system/src/query/job.rs
@@ -1,6 +1,6 @@
use crate::dep_graph::DepContext;
use crate::query::plumbing::CycleError;
-use crate::query::{QueryContext, QueryStackFrame};
+use crate::query::{QueryContext, QueryStackFrame, SimpleDefKind};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::{struct_span_err, Diagnostic, DiagnosticBuilder, Handler, Level};
@@ -591,10 +591,33 @@ pub(crate) fn report_cycle<'a>(
err.span_note(span, &format!("...which requires {}...", query.description));
}
- err.note(&format!(
- "...which again requires {}, completing the cycle",
- stack[0].query.description
- ));
+ if stack.len() == 1 {
+ err.note(&format!("...which immediately requires {} again", stack[0].query.description));
+ } else {
+ err.note(&format!(
+ "...which again requires {}, completing the cycle",
+ stack[0].query.description
+ ));
+ }
+
+ if stack.iter().all(|entry| {
+ entry.query.def_kind.map_or(false, |def_kind| {
+ matches!(def_kind, SimpleDefKind::TyAlias | SimpleDefKind::TraitAlias)
+ })
+ }) {
+ if stack.iter().all(|entry| {
+ entry
+ .query
+ .def_kind
+ .map_or(false, |def_kind| matches!(def_kind, SimpleDefKind::TyAlias))
+ }) {
+ err.note("type aliases cannot be recursive");
+ err.help("consider using a struct, enum, or union instead to break the cycle");
+ err.help("see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information");
+ } else {
+ err.note("trait aliases cannot be recursive");
+ }
+ }
if let Some((span, query)) = usage {
err.span_note(fix_span(span, &query), &format!("cycle used when {}", query.description));
diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs
index 7288aae..dffe7f3 100644
--- a/compiler/rustc_query_system/src/query/mod.rs
+++ b/compiler/rustc_query_system/src/query/mod.rs
@@ -29,24 +29,53 @@ pub struct QueryStackFrame {
pub name: &'static str,
pub description: String,
span: Option<Span>,
+ /// The `DefKind` this query frame is associated with, if applicable.
+ ///
+ /// We can't use `rustc_hir::def::DefKind` because `rustc_hir` is not
+ /// available in `rustc_query_system`. Instead, we have a simplified
+ /// custom version of it, called [`SimpleDefKind`].
+ def_kind: Option<SimpleDefKind>,
/// This hash is used to deterministically pick
/// a query to remove cycles in the parallel compiler.
#[cfg(parallel_compiler)]
hash: u64,
}
+/// A simplified version of `rustc_hir::def::DefKind`.
+///
+/// It was added to help improve cycle errors caused by recursive type aliases.
+/// As of August 2021, `rustc_query_system` cannot depend on `rustc_hir`
+/// because it would create a dependency cycle. So, instead, a simplified
+/// version of `DefKind` was added to `rustc_query_system`.
+///
+/// `DefKind`s are converted to `SimpleDefKind`s in `rustc_query_impl`.
+#[derive(Debug, Copy, Clone)]
+pub enum SimpleDefKind {
+ Struct,
+ Enum,
+ Union,
+ Trait,
+ TyAlias,
+ TraitAlias,
+
+ // FIXME: add more from `rustc_hir::def::DefKind` and then remove `Other`
+ Other,
+}
+
impl QueryStackFrame {
#[inline]
pub fn new(
name: &'static str,
description: String,
span: Option<Span>,
+ def_kind: Option<SimpleDefKind>,
_hash: impl FnOnce() -> u64,
) -> Self {
Self {
name,
description,
span,
+ def_kind,
#[cfg(parallel_compiler)]
hash: _hash(),
}
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index ca2c228..0b1687d 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -506,8 +506,7 @@ impl<'a> Resolver<'a> {
if self.session.is_nightly_build() {
err.help(
- "use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` \
- to allow generic const expressions"
+ "use `#![feature(generic_const_exprs)]` to allow generic const expressions",
);
}
diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs
index 0b552aa..5c7b4b0 100644
--- a/compiler/rustc_resolve/src/late.rs
+++ b/compiler/rustc_resolve/src/late.rs
@@ -454,7 +454,7 @@ fn visit_local(&mut self, local: &'ast Local) {
_ => Some((
local.pat.span,
local.ty.as_ref().map(|ty| ty.span),
- local.init.as_ref().map(|init| init.span),
+ local.kind.init().map(|init| init.span),
)),
};
let original = replace(&mut self.diagnostic_metadata.current_let_binding, local_spans);
@@ -1426,7 +1426,14 @@ fn resolve_local(&mut self, local: &'ast Local) {
walk_list!(self, visit_ty, &local.ty);
// Resolve the initializer.
- walk_list!(self, visit_expr, &local.init);
+ if let Some((init, els)) = local.kind.init_else_opt() {
+ self.visit_expr(init);
+
+ // Resolve the `else` block
+ if let Some(els) = els {
+ self.visit_block(els);
+ }
+ }
// Resolve the pattern.
self.resolve_pattern_top(&local.pat, PatternSource::Let);
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index 9d92359..45657f2 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -215,7 +215,6 @@ pub(crate) fn smart_resolve_report_errors(
"let ".to_string(),
Applicability::MaybeIncorrect,
);
- self.r.session.if_let_suggestions.borrow_mut().insert(*span);
}
_ => {}
}
@@ -2246,7 +2245,7 @@ fn span_underscore_borrow(&self) -> Span {
}
/// Non-static lifetimes are prohibited in anonymous constants under `min_const_generics`.
- /// This function will emit an error if `const_generics` is not enabled, the body identified by
+ /// This function will emit an error if `generic_const_exprs` is not enabled, the body identified by
/// `body_id` is an anonymous constant and `lifetime_ref` is non-static.
crate fn maybe_emit_forbidden_non_static_lifetime_error(
&self,
@@ -2265,7 +2264,7 @@ fn span_underscore_borrow(&self) -> Span {
if !self.tcx.lazy_normalization() && is_anon_const && !is_allowed_lifetime {
feature_err(
&self.tcx.sess.parse_sess,
- sym::const_generics,
+ sym::generic_const_exprs,
lifetime_ref.span,
"a non-static lifetime is not allowed in a `const`",
)
diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs
index 882d15c..e901d4c 100644
--- a/compiler/rustc_resolve/src/late/lifetimes.rs
+++ b/compiler/rustc_resolve/src/late/lifetimes.rs
@@ -740,6 +740,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
hir::ItemKind::ExternCrate(_)
| hir::ItemKind::Use(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::ForeignMod { .. }
| hir::ItemKind::GlobalAsm(..) => {
@@ -2300,7 +2301,7 @@ fn resolve_lifetime_ref(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
match *scope {
Scope::Body { id, s } => {
// Non-static lifetimes are prohibited in anonymous constants without
- // `const_generics`.
+ // `generic_const_exprs`.
self.maybe_emit_forbidden_non_static_lifetime_error(id, lifetime_ref);
outermost_body = Some(id);
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index e308ea1..da3beac 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -2734,10 +2734,7 @@ fn validate_res_from_ribs(
ConstantItemRibKind(trivial, _) => {
let features = self.session.features_untracked();
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
- if !(trivial
- || features.const_generics
- || features.lazy_normalization_consts)
- {
+ if !(trivial || features.generic_const_exprs) {
// HACK(min_const_generics): If we encounter `Self` in an anonymous constant
// we can't easily tell if it's generic at this stage, so we instead remember
// this and then enforce the self type to be concrete later on.
@@ -2809,10 +2806,7 @@ fn validate_res_from_ribs(
ConstantItemRibKind(trivial, _) => {
let features = self.session.features_untracked();
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
- if !(trivial
- || features.const_generics
- || features.lazy_normalization_consts)
- {
+ if !(trivial || features.generic_const_exprs) {
if record_used {
self.report_error(
span,
diff --git a/compiler/rustc_save_analysis/src/sig.rs b/compiler/rustc_save_analysis/src/sig.rs
index c3bc1c1..7864b47 100644
--- a/compiler/rustc_save_analysis/src/sig.rs
+++ b/compiler/rustc_save_analysis/src/sig.rs
@@ -416,6 +416,14 @@ fn make(&self, offset: usize, _parent_id: Option<hir::HirId>, scx: &SaveContext<
Ok(sig)
}
+ hir::ItemKind::Macro(_) => {
+ let mut text = "macro".to_owned();
+ let name = self.ident.to_string();
+ text.push_str(&name);
+ text.push_str(&"! {}");
+
+ Ok(text_sig(text))
+ }
hir::ItemKind::Mod(ref _mod) => {
let mut text = "mod ".to_owned();
let name = self.ident.to_string();
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs
index 20e94e3..18b9339 100644
--- a/compiler/rustc_session/src/session.rs
+++ b/compiler/rustc_session/src/session.rs
@@ -209,9 +209,6 @@ pub struct Session {
/// Set of enabled features for the current target.
pub target_features: FxHashSet<Symbol>,
-
- /// `Span`s for `if` conditions that we have suggested turning into `if let`.
- pub if_let_suggestions: Lock<FxHashSet<Span>>,
}
pub struct PerfStats {
@@ -1328,7 +1325,6 @@ pub fn build_session(
miri_unleashed_features: Lock::new(Default::default()),
asm_arch,
target_features: FxHashSet::default(),
- if_let_suggestions: Default::default(),
};
validate_commandline_args_with_session_available(&sess);
diff --git a/compiler/rustc_span/src/edition.rs b/compiler/rustc_span/src/edition.rs
index 8544acd..511c2e8 100644
--- a/compiler/rustc_span/src/edition.rs
+++ b/compiler/rustc_span/src/edition.rs
@@ -32,7 +32,7 @@ pub enum Edition {
pub const DEFAULT_EDITION: Edition = Edition::Edition2015;
-pub const LATEST_STABLE_EDITION: Edition = Edition::Edition2018;
+pub const LATEST_STABLE_EDITION: Edition = Edition::Edition2021;
impl fmt::Display for Edition {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -66,7 +66,7 @@ pub fn is_stable(&self) -> bool {
match *self {
Edition::Edition2015 => true,
Edition::Edition2018 => true,
- Edition::Edition2021 => false,
+ Edition::Edition2021 => true,
}
}
}
diff --git a/compiler/rustc_span/src/hygiene.rs b/compiler/rustc_span/src/hygiene.rs
index e44a2e9..c22093c 100644
--- a/compiler/rustc_span/src/hygiene.rs
+++ b/compiler/rustc_span/src/hygiene.rs
@@ -1097,6 +1097,7 @@ pub enum DesugaringKind {
Async,
Await,
ForLoop(ForLoopLoc),
+ LetElse,
}
/// A location in the desugaring of a `for` loop
@@ -1117,6 +1118,7 @@ pub fn descr(self) -> &'static str {
DesugaringKind::TryBlock => "`try` block",
DesugaringKind::OpaqueTy => "`impl Trait`",
DesugaringKind::ForLoop(_) => "`for` loop",
+ DesugaringKind::LetElse => "`let...else`",
}
}
}
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index 89e032b..10e9bde 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -597,6 +597,14 @@ pub fn parent(self) -> Option<Span> {
if !expn_data.is_root() { Some(expn_data.call_site) } else { None }
}
+ /// Walk down the expansion ancestors to find a span that's contained within `outer`.
+ pub fn find_ancestor_inside(mut self, outer: Span) -> Option<Span> {
+ while !outer.contains(self) {
+ self = self.parent()?;
+ }
+ Some(self)
+ }
+
/// Edition of the crate from which this span came.
pub fn edition(self) -> edition::Edition {
self.ctxt().edition()
diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs
index 2c3af80..c2de5ed 100644
--- a/compiler/rustc_span/src/source_map.rs
+++ b/compiler/rustc_span/src/source_map.rs
@@ -567,6 +567,17 @@ fn span_to_source<F, T>(&self, sp: Span, extract_source: F) -> Result<T, SpanSni
}
}
+ /// Returns whether or not this span points into a file
+ /// in the current crate. This may be `false` for spans
+ /// produced by a macro expansion, or for spans associated
+ /// with the definition of an item in a foreign crate
+ pub fn is_local_span(&self, sp: Span) -> bool {
+ let local_begin = self.lookup_byte_offset(sp.lo());
+ let local_end = self.lookup_byte_offset(sp.hi());
+ // This might be a weird span that covers multiple files
+ local_begin.sf.src.is_some() && local_end.sf.src.is_some()
+ }
+
/// Returns the source snippet as `String` corresponding to the given `Span`.
pub fn span_to_snippet(&self, sp: Span) -> Result<String, SpanSnippetError> {
self.span_to_source(sp, |src, start_index, end_index| {
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs
index f788eb7..2402316 100644
--- a/compiler/rustc_span/src/symbol.rs
+++ b/compiler/rustc_span/src/symbol.rs
@@ -284,6 +284,7 @@
add_assign,
add_with_overflow,
address,
+ adt_const_params,
advanced_slice_patterns,
adx_target_feature,
alias,
@@ -478,6 +479,7 @@
core_panic_macro,
cosf32,
cosf64,
+ cr,
crate_id,
crate_in_paths,
crate_local,
@@ -662,6 +664,7 @@
generators,
generic_arg_infer,
generic_associated_types,
+ generic_const_exprs,
generic_param_attrs,
get_context,
global_allocator,
@@ -742,6 +745,7 @@
le,
len,
let_chains,
+ let_else,
lhs,
lib,
libc,
@@ -1415,6 +1419,7 @@
wreg,
write_bytes,
x87_reg,
+ xer,
xmm_reg,
ymm_reg,
zmm_reg,
diff --git a/compiler/rustc_symbol_mangling/src/lib.rs b/compiler/rustc_symbol_mangling/src/lib.rs
index 551309f..220c9f7 100644
--- a/compiler/rustc_symbol_mangling/src/lib.rs
+++ b/compiler/rustc_symbol_mangling/src/lib.rs
@@ -246,10 +246,18 @@ fn compute_symbol_name(
tcx.symbol_mangling_version(mangling_version_crate)
};
- match mangling_version {
+ let symbol = match mangling_version {
SymbolManglingVersion::Legacy => legacy::mangle(tcx, instance, instantiating_crate),
SymbolManglingVersion::V0 => v0::mangle(tcx, instance, instantiating_crate),
- }
+ };
+
+ debug_assert!(
+ rustc_demangle::try_demangle(&symbol).is_ok(),
+ "compute_symbol_name: `{}` cannot be demangled",
+ symbol
+ );
+
+ symbol
}
fn is_generic(substs: SubstsRef<'_>) -> bool {
diff --git a/compiler/rustc_target/src/abi/call/aarch64.rs b/compiler/rustc_target/src/abi/call/aarch64.rs
index a5e985d..4613a45 100644
--- a/compiler/rustc_target/src/abi/call/aarch64.rs
+++ b/compiler/rustc_target/src/abi/call/aarch64.rs
@@ -1,10 +1,10 @@
use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
-use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, TyAbiInterface};
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
let size = arg.layout.size;
@@ -26,8 +26,8 @@ fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Opti
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(32);
@@ -48,8 +48,8 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(32);
@@ -70,8 +70,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !fn_abi.ret.is_ignore() {
classify_ret(cx, &mut fn_abi.ret);
diff --git a/compiler/rustc_target/src/abi/call/amdgpu.rs b/compiler/rustc_target/src/abi/call/amdgpu.rs
index 0b4f279..9be9747 100644
--- a/compiler/rustc_target/src/abi/call/amdgpu.rs
+++ b/compiler/rustc_target/src/abi/call/amdgpu.rs
@@ -1,26 +1,26 @@
use crate::abi::call::{ArgAbi, FnAbi};
-use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, TyAbiInterface};
fn classify_ret<'a, Ty, C>(_cx: &C, ret: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
ret.extend_integer_width_to(32);
}
fn classify_arg<'a, Ty, C>(_cx: &C, arg: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
arg.extend_integer_width_to(32);
}
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !fn_abi.ret.is_ignore() {
classify_ret(cx, &mut fn_abi.ret);
diff --git a/compiler/rustc_target/src/abi/call/arm.rs b/compiler/rustc_target/src/abi/call/arm.rs
index b560e11..e66c213 100644
--- a/compiler/rustc_target/src/abi/call/arm.rs
+++ b/compiler/rustc_target/src/abi/call/arm.rs
@@ -1,11 +1,11 @@
use crate::abi::call::{ArgAbi, Conv, FnAbi, Reg, RegKind, Uniform};
-use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, TyAbiInterface};
use crate::spec::HasTargetSpec;
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
let size = arg.layout.size;
@@ -27,8 +27,8 @@ fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Opti
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, vfp: bool)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(32);
@@ -53,8 +53,8 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, vfp: bool)
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, vfp: bool)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(32);
@@ -75,8 +75,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, vfp: bool)
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout + HasTargetSpec,
{
// If this is a target with a hard-float ABI, and the function is not explicitly
// `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
diff --git a/compiler/rustc_target/src/abi/call/mips.rs b/compiler/rustc_target/src/abi/call/mips.rs
index 733a732..cc44319 100644
--- a/compiler/rustc_target/src/abi/call/mips.rs
+++ b/compiler/rustc_target/src/abi/call/mips.rs
@@ -1,10 +1,9 @@
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
-use crate::abi::{HasDataLayout, LayoutOf, Size, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, Size};
-fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
+fn classify_ret<Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(32);
@@ -14,10 +13,9 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
}
}
-fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
+fn classify_arg<Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
+ C: HasDataLayout,
{
let dl = cx.data_layout();
let size = arg.layout.size;
@@ -35,10 +33,9 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
*offset = offset.align_to(align) + size.align_to(align);
}
-pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
+pub fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
+ C: HasDataLayout,
{
let mut offset = Size::ZERO;
if !fn_abi.ret.is_ignore() {
diff --git a/compiler/rustc_target/src/abi/call/mips64.rs b/compiler/rustc_target/src/abi/call/mips64.rs
index a630c84..28ca93c 100644
--- a/compiler/rustc_target/src/abi/call/mips64.rs
+++ b/compiler/rustc_target/src/abi/call/mips64.rs
@@ -1,5 +1,5 @@
use crate::abi::call::{ArgAbi, ArgExtension, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
-use crate::abi::{self, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{self, HasDataLayout, Size, TyAbiInterface};
fn extend_integer_width_mips<Ty>(arg: &mut ArgAbi<'_, Ty>, bits: u64) {
// Always sign extend u32 values on 64-bit mips
@@ -19,8 +19,8 @@ fn extend_integer_width_mips<Ty>(arg: &mut ArgAbi<'_, Ty>, bits: u64) {
fn float_reg<'a, Ty, C>(cx: &C, ret: &ArgAbi<'a, Ty>, i: usize) -> Option<Reg>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
match ret.layout.field(cx, i).abi {
abi::Abi::Scalar(ref scalar) => match scalar.value {
@@ -34,8 +34,8 @@ fn float_reg<'a, Ty, C>(cx: &C, ret: &ArgAbi<'a, Ty>, i: usize) -> Option<Reg>
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
extend_integer_width_mips(ret, 64);
@@ -74,8 +74,8 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !arg.layout.is_aggregate() {
extend_integer_width_mips(arg, 64);
@@ -144,8 +144,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !fn_abi.ret.is_ignore() {
classify_ret(cx, &mut fn_abi.ret);
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index 6e0e140..6d3c731 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -1,5 +1,5 @@
use crate::abi::{self, Abi, Align, FieldsShape, Size};
-use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, TyAbiInterface, TyAndLayout};
use crate::spec::{self, HasTargetSpec};
mod aarch64;
@@ -316,8 +316,7 @@ fn is_aggregate(&self) -> bool {
/// specific targets.
pub fn homogeneous_aggregate<C>(&self, cx: &C) -> Result<HomogeneousAggregate, Heterogeneous>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = Self>,
+ Ty: TyAbiInterface<'a, C> + Copy,
{
match self.abi {
Abi::Uninhabited => Err(Heterogeneous),
@@ -603,8 +602,8 @@ pub struct FnAbi<'a, Ty> {
impl<'a, Ty> FnAbi<'a, Ty> {
pub fn adjust_for_cabi<C>(&mut self, cx: &C, abi: spec::abi::Abi) -> Result<(), String>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout + HasTargetSpec,
{
if abi == spec::abi::Abi::X86Interrupt {
if let Some(arg) = self.args.first_mut() {
diff --git a/compiler/rustc_target/src/abi/call/powerpc64.rs b/compiler/rustc_target/src/abi/call/powerpc64.rs
index 8c2a9d0..c22ef9c 100644
--- a/compiler/rustc_target/src/abi/call/powerpc64.rs
+++ b/compiler/rustc_target/src/abi/call/powerpc64.rs
@@ -3,7 +3,7 @@
// need to be fixed when PowerPC vector support is added.
use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
-use crate::abi::{Endian, HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{Endian, HasDataLayout, TyAbiInterface};
use crate::spec::HasTargetSpec;
#[derive(Debug, Clone, Copy, PartialEq)]
@@ -19,8 +19,8 @@ fn is_homogeneous_aggregate<'a, Ty, C>(
abi: ABI,
) -> Option<Uniform>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
// ELFv1 only passes one-member aggregates transparently.
@@ -43,8 +43,8 @@ fn is_homogeneous_aggregate<'a, Ty, C>(
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, abi: ABI)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(64);
@@ -86,8 +86,8 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, abi: ABI)
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, abi: ABI)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(64);
@@ -116,8 +116,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, abi: ABI)
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout + HasTargetSpec,
{
let abi = if cx.target_spec().env == "musl" {
ELFv2
diff --git a/compiler/rustc_target/src/abi/call/riscv.rs b/compiler/rustc_target/src/abi/call/riscv.rs
index 1ab881d..8c2ef8c 100644
--- a/compiler/rustc_target/src/abi/call/riscv.rs
+++ b/compiler/rustc_target/src/abi/call/riscv.rs
@@ -5,9 +5,7 @@
// https://github.com/llvm/llvm-project/blob/8e780252a7284be45cf1ba224cabd884847e8e92/clang/lib/CodeGen/TargetInfo.cpp#L9311-L9773
use crate::abi::call::{ArgAbi, ArgExtension, CastTarget, FnAbi, PassMode, Reg, RegKind, Uniform};
-use crate::abi::{
- self, Abi, FieldsShape, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods,
-};
+use crate::abi::{self, Abi, FieldsShape, HasDataLayout, Size, TyAbiInterface, TyAndLayout};
use crate::spec::HasTargetSpec;
#[derive(Copy, Clone)]
@@ -43,8 +41,7 @@ fn should_use_fp_conv_helper<'a, Ty, C>(
field2_kind: &mut RegPassKind,
) -> Result<(), CannotUseFpConv>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
+ Ty: TyAbiInterface<'a, C> + Copy,
{
match arg_layout.abi {
Abi::Scalar(ref scalar) => match scalar.value {
@@ -130,8 +127,7 @@ fn should_use_fp_conv<'a, Ty, C>(
flen: u64,
) -> Option<FloatConv>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
+ Ty: TyAbiInterface<'a, C> + Copy,
{
let mut field1_kind = RegPassKind::Unknown;
let mut field2_kind = RegPassKind::Unknown;
@@ -149,8 +145,7 @@ fn should_use_fp_conv<'a, Ty, C>(
fn classify_ret<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, xlen: u64, flen: u64) -> bool
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
+ Ty: TyAbiInterface<'a, C> + Copy,
{
if let Some(conv) = should_use_fp_conv(cx, &arg.layout, xlen, flen) {
match conv {
@@ -212,8 +207,7 @@ fn classify_arg<'a, Ty, C>(
avail_gprs: &mut u64,
avail_fprs: &mut u64,
) where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>>,
+ Ty: TyAbiInterface<'a, C> + Copy,
{
if !is_vararg {
match should_use_fp_conv(cx, &arg.layout, xlen, flen) {
@@ -320,8 +314,8 @@ fn extend_integer_width<'a, Ty>(arg: &mut ArgAbi<'a, Ty>, xlen: u64) {
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout + HasTargetSpec,
{
let flen = match &cx.target_spec().llvm_abiname[..] {
"ilp32f" | "lp64f" => 32,
diff --git a/compiler/rustc_target/src/abi/call/s390x.rs b/compiler/rustc_target/src/abi/call/s390x.rs
index 005dcc6..5941089 100644
--- a/compiler/rustc_target/src/abi/call/s390x.rs
+++ b/compiler/rustc_target/src/abi/call/s390x.rs
@@ -2,13 +2,9 @@
// for a pre-z13 machine or using -mno-vx.
use crate::abi::call::{ArgAbi, FnAbi, Reg};
-use crate::abi::{self, HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{self, HasDataLayout, TyAbiInterface, TyAndLayout};
-fn classify_ret<'a, Ty, C>(ret: &mut ArgAbi<'_, Ty>)
-where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
-{
+fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
if !ret.layout.is_aggregate() && ret.layout.size.bits() <= 64 {
ret.extend_integer_width_to(64);
} else {
@@ -18,8 +14,8 @@ fn classify_ret<'a, Ty, C>(ret: &mut ArgAbi<'_, Ty>)
fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyAndLayout<'a, Ty>) -> bool
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C>,
+ C: HasDataLayout,
{
match layout.abi {
abi::Abi::Scalar(ref scalar) => scalar.value.is_float(),
@@ -36,8 +32,8 @@ fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyAndLayout<'a, Ty>) -> bool
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !arg.layout.is_aggregate() && arg.layout.size.bits() <= 64 {
arg.extend_integer_width_to(64);
@@ -63,8 +59,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !fn_abi.ret.is_ignore() {
classify_ret(&mut fn_abi.ret);
diff --git a/compiler/rustc_target/src/abi/call/sparc.rs b/compiler/rustc_target/src/abi/call/sparc.rs
index 733a732..cc44319 100644
--- a/compiler/rustc_target/src/abi/call/sparc.rs
+++ b/compiler/rustc_target/src/abi/call/sparc.rs
@@ -1,10 +1,9 @@
use crate::abi::call::{ArgAbi, FnAbi, Reg, Uniform};
-use crate::abi::{HasDataLayout, LayoutOf, Size, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, Size};
-fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
+fn classify_ret<Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(32);
@@ -14,10 +13,9 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'_, Ty>, offset: &mut Size)
}
}
-fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
+fn classify_arg<Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
+ C: HasDataLayout,
{
let dl = cx.data_layout();
let size = arg.layout.size;
@@ -35,10 +33,9 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'_, Ty>, offset: &mut Size)
*offset = offset.align_to(align) + size.align_to(align);
}
-pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
+pub fn compute_abi_info<Ty, C>(cx: &C, fn_abi: &mut FnAbi<'_, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty> + HasDataLayout,
+ C: HasDataLayout,
{
let mut offset = Size::ZERO;
if !fn_abi.ret.is_ignore() {
diff --git a/compiler/rustc_target/src/abi/call/sparc64.rs b/compiler/rustc_target/src/abi/call/sparc64.rs
index a647675..5d74c94 100644
--- a/compiler/rustc_target/src/abi/call/sparc64.rs
+++ b/compiler/rustc_target/src/abi/call/sparc64.rs
@@ -1,12 +1,12 @@
// FIXME: This needs an audit for correctness and completeness.
use crate::abi::call::{ArgAbi, FnAbi, Reg, RegKind, Uniform};
-use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, TyAbiInterface};
fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Option<Uniform>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
arg.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()).and_then(|unit| {
// Ensure we have at most eight uniquely addressable members.
@@ -26,8 +26,8 @@ fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) -> Opti
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !ret.layout.is_aggregate() {
ret.extend_integer_width_to(64);
@@ -52,8 +52,8 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !arg.layout.is_aggregate() {
arg.extend_integer_width_to(64);
@@ -76,8 +76,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !fn_abi.ret.is_ignore() {
classify_ret(cx, &mut fn_abi.ret);
diff --git a/compiler/rustc_target/src/abi/call/wasm.rs b/compiler/rustc_target/src/abi/call/wasm.rs
index bf2c08b..3237cde 100644
--- a/compiler/rustc_target/src/abi/call/wasm.rs
+++ b/compiler/rustc_target/src/abi/call/wasm.rs
@@ -1,10 +1,10 @@
use crate::abi::call::{ArgAbi, FnAbi, Uniform};
-use crate::abi::{HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{HasDataLayout, TyAbiInterface};
fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgAbi<'a, Ty>) -> bool
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if val.layout.is_aggregate() {
if let Some(unit) = val.layout.homogeneous_aggregate(cx).ok().and_then(|ha| ha.unit()) {
@@ -20,8 +20,8 @@ fn unwrap_trivial_aggregate<'a, Ty, C>(cx: &C, val: &mut ArgAbi<'a, Ty>) -> bool
fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
ret.extend_integer_width_to(32);
if ret.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, ret) {
@@ -31,8 +31,8 @@ fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>)
fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
arg.extend_integer_width_to(32);
if arg.layout.is_aggregate() && !unwrap_trivial_aggregate(cx, arg) {
@@ -43,8 +43,8 @@ fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
/// The purpose of this ABI is to match the C ABI (aka clang) exactly.
pub fn compute_c_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !fn_abi.ret.is_ignore() {
classify_ret(cx, &mut fn_abi.ret);
diff --git a/compiler/rustc_target/src/abi/call/x86.rs b/compiler/rustc_target/src/abi/call/x86.rs
index ff8849e..3fc197b 100644
--- a/compiler/rustc_target/src/abi/call/x86.rs
+++ b/compiler/rustc_target/src/abi/call/x86.rs
@@ -1,5 +1,5 @@
use crate::abi::call::{ArgAttribute, FnAbi, PassMode, Reg, RegKind};
-use crate::abi::{self, HasDataLayout, LayoutOf, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{self, HasDataLayout, TyAbiInterface, TyAndLayout};
use crate::spec::HasTargetSpec;
#[derive(PartialEq)]
@@ -10,8 +10,8 @@ pub enum Flavor {
fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyAndLayout<'a, Ty>) -> bool
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
match layout.abi {
abi::Abi::Scalar(ref scalar) => scalar.value.is_float(),
@@ -28,8 +28,8 @@ fn is_single_fp_element<'a, Ty, C>(cx: &C, layout: TyAndLayout<'a, Ty>) -> bool
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>, flavor: Flavor)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout + HasTargetSpec,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout + HasTargetSpec,
{
if !fn_abi.ret.is_ignore() {
if fn_abi.ret.layout.is_aggregate() {
diff --git a/compiler/rustc_target/src/abi/call/x86_64.rs b/compiler/rustc_target/src/abi/call/x86_64.rs
index a55658b..08f0aab 100644
--- a/compiler/rustc_target/src/abi/call/x86_64.rs
+++ b/compiler/rustc_target/src/abi/call/x86_64.rs
@@ -2,7 +2,7 @@
// https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
use crate::abi::call::{ArgAbi, CastTarget, FnAbi, Reg, RegKind};
-use crate::abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyAndLayout, TyAndLayoutMethods};
+use crate::abi::{self, Abi, HasDataLayout, Size, TyAbiInterface, TyAndLayout};
/// Classification of "eightbyte" components.
// N.B., the order of the variants is from general to specific,
@@ -26,8 +26,8 @@ fn classify_arg<'a, Ty, C>(
arg: &ArgAbi<'a, Ty>,
) -> Result<[Option<Class>; MAX_EIGHTBYTES], Memory>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
fn classify<'a, Ty, C>(
cx: &C,
@@ -36,8 +36,8 @@ fn classify<'a, Ty, C>(
off: Size,
) -> Result<(), Memory>
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
if !off.is_aligned(layout.align.abi) {
if !layout.is_zst() {
@@ -172,8 +172,8 @@ fn cast_target(cls: &[Option<Class>], size: Size) -> CastTarget {
pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
where
- Ty: TyAndLayoutMethods<'a, C> + Copy,
- C: LayoutOf<Ty = Ty, TyAndLayout = TyAndLayout<'a, Ty>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C> + Copy,
+ C: HasDataLayout,
{
let mut int_regs = MAX_INT_REGS;
let mut sse_regs = MAX_SSE_REGS;
diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs
index 2820a48..8203999 100644
--- a/compiler/rustc_target/src/abi/mod.rs
+++ b/compiler/rustc_target/src/abi/mod.rs
@@ -1174,9 +1174,9 @@ fn deref(&self) -> &&'a Layout {
}
/// Trait for context types that can compute layouts of things.
-pub trait LayoutOf {
- type Ty;
- type TyAndLayout;
+pub trait LayoutOf<'a>: Sized {
+ type Ty: TyAbiInterface<'a, Self>;
+ type TyAndLayout: MaybeResult<TyAndLayout<'a, Self::Ty>>;
fn layout_of(&self, ty: Self::Ty) -> Self::TyAndLayout;
fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyAndLayout {
@@ -1184,9 +1184,6 @@ fn spanned_layout_of(&self, ty: Self::Ty, _span: Span) -> Self::TyAndLayout {
}
}
-/// The `TyAndLayout` above will always be a `MaybeResult<TyAndLayout<'_, Self>>`.
-/// We can't add the bound due to the lifetime, but this trait is still useful when
-/// writing code that's generic over the `LayoutOf` impl.
pub trait MaybeResult<T> {
type Error;
@@ -1239,41 +1236,42 @@ pub struct PointeeInfo {
pub address_space: AddressSpace,
}
-pub trait TyAndLayoutMethods<'a, C: LayoutOf<Ty = Self>>: Sized {
- fn for_variant(
+/// Trait that needs to be implemented by the higher-level type representation
+/// (e.g. `rustc_middle::ty::Ty`), to provide `rustc_target::abi` functionality.
+pub trait TyAbiInterface<'a, C>: Sized {
+ fn ty_and_layout_for_variant(
this: TyAndLayout<'a, Self>,
cx: &C,
variant_index: VariantIdx,
) -> TyAndLayout<'a, Self>;
- fn field(this: TyAndLayout<'a, Self>, cx: &C, i: usize) -> C::TyAndLayout;
- fn pointee_info_at(this: TyAndLayout<'a, Self>, cx: &C, offset: Size) -> Option<PointeeInfo>;
+ fn ty_and_layout_field(this: TyAndLayout<'a, Self>, cx: &C, i: usize) -> TyAndLayout<'a, Self>;
+ fn ty_and_layout_pointee_info_at(
+ this: TyAndLayout<'a, Self>,
+ cx: &C,
+ offset: Size,
+ ) -> Option<PointeeInfo>;
}
impl<'a, Ty> TyAndLayout<'a, Ty> {
pub fn for_variant<C>(self, cx: &C, variant_index: VariantIdx) -> Self
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty>,
+ Ty: TyAbiInterface<'a, C>,
{
- Ty::for_variant(self, cx, variant_index)
+ Ty::ty_and_layout_for_variant(self, cx, variant_index)
}
- /// Callers might want to use `C: LayoutOf<Ty=Ty, TyAndLayout: MaybeResult<Self>>`
- /// to allow recursion (see `might_permit_zero_init` below for an example).
- pub fn field<C>(self, cx: &C, i: usize) -> C::TyAndLayout
+ pub fn field<C>(self, cx: &C, i: usize) -> Self
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty>,
+ Ty: TyAbiInterface<'a, C>,
{
- Ty::field(self, cx, i)
+ Ty::ty_and_layout_field(self, cx, i)
}
pub fn pointee_info_at<C>(self, cx: &C, offset: Size) -> Option<PointeeInfo>
where
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty>,
+ Ty: TyAbiInterface<'a, C>,
{
- Ty::pointee_info_at(self, cx, offset)
+ Ty::ty_and_layout_pointee_info_at(self, cx, offset)
}
}
@@ -1301,11 +1299,11 @@ pub fn is_zst(&self) -> bool {
/// FIXME: Once we removed all the conservatism, we could alternatively
/// create an all-0/all-undef constant and run the const value validator to see if
/// this is a valid value for the given type.
- pub fn might_permit_raw_init<C, E>(self, cx: &C, zero: bool) -> Result<bool, E>
+ pub fn might_permit_raw_init<C>(self, cx: &C, zero: bool) -> bool
where
Self: Copy,
- Ty: TyAndLayoutMethods<'a, C>,
- C: LayoutOf<Ty = Ty, TyAndLayout: MaybeResult<Self, Error = E>> + HasDataLayout,
+ Ty: TyAbiInterface<'a, C>,
+ C: HasDataLayout,
{
let scalar_allows_raw_init = move |s: &Scalar| -> bool {
if zero {
@@ -1330,7 +1328,7 @@ pub fn might_permit_raw_init<C, E>(self, cx: &C, zero: bool) -> Result<bool, E>
};
if !valid {
// This is definitely not okay.
- return Ok(false);
+ return false;
}
// If we have not found an error yet, we need to recursively descend into fields.
@@ -1341,16 +1339,15 @@ pub fn might_permit_raw_init<C, E>(self, cx: &C, zero: bool) -> Result<bool, E>
}
FieldsShape::Arbitrary { offsets, .. } => {
for idx in 0..offsets.len() {
- let field = self.field(cx, idx).to_result()?;
- if !field.might_permit_raw_init(cx, zero)? {
+ if !self.field(cx, idx).might_permit_raw_init(cx, zero) {
// We found a field that is unhappy with this kind of initialization.
- return Ok(false);
+ return false;
}
}
}
}
// FIXME(#66151): For now, we are conservative and do not check `self.variants`.
- Ok(true)
+ true
}
}
diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs
index bb24f7b..99699c5 100644
--- a/compiler/rustc_target/src/asm/mod.rs
+++ b/compiler/rustc_target/src/asm/mod.rs
@@ -154,6 +154,7 @@ macro_rules! types {
mod nvptx;
mod powerpc;
mod riscv;
+mod s390x;
mod spirv;
mod wasm;
mod x86;
@@ -166,6 +167,7 @@ macro_rules! types {
pub use nvptx::{NvptxInlineAsmReg, NvptxInlineAsmRegClass};
pub use powerpc::{PowerPCInlineAsmReg, PowerPCInlineAsmRegClass};
pub use riscv::{RiscVInlineAsmReg, RiscVInlineAsmRegClass};
+pub use s390x::{S390xInlineAsmReg, S390xInlineAsmRegClass};
pub use spirv::{SpirVInlineAsmReg, SpirVInlineAsmRegClass};
pub use wasm::{WasmInlineAsmReg, WasmInlineAsmRegClass};
pub use x86::{X86InlineAsmReg, X86InlineAsmRegClass};
@@ -184,6 +186,7 @@ pub enum InlineAsmArch {
Mips64,
PowerPC,
PowerPC64,
+ S390x,
SpirV,
Wasm32,
Bpf,
@@ -206,6 +209,7 @@ fn from_str(s: &str) -> Result<InlineAsmArch, ()> {
"hexagon" => Ok(Self::Hexagon),
"mips" => Ok(Self::Mips),
"mips64" => Ok(Self::Mips64),
+ "s390x" => Ok(Self::S390x),
"spirv" => Ok(Self::SpirV),
"wasm32" => Ok(Self::Wasm32),
"bpf" => Ok(Self::Bpf),
@@ -235,6 +239,7 @@ pub enum InlineAsmReg {
PowerPC(PowerPCInlineAsmReg),
Hexagon(HexagonInlineAsmReg),
Mips(MipsInlineAsmReg),
+ S390x(S390xInlineAsmReg),
SpirV(SpirVInlineAsmReg),
Wasm(WasmInlineAsmReg),
Bpf(BpfInlineAsmReg),
@@ -252,6 +257,7 @@ pub fn name(self) -> &'static str {
Self::PowerPC(r) => r.name(),
Self::Hexagon(r) => r.name(),
Self::Mips(r) => r.name(),
+ Self::S390x(r) => r.name(),
Self::Bpf(r) => r.name(),
Self::Err => "<reg>",
}
@@ -266,6 +272,7 @@ pub fn reg_class(self) -> InlineAsmRegClass {
Self::PowerPC(r) => InlineAsmRegClass::PowerPC(r.reg_class()),
Self::Hexagon(r) => InlineAsmRegClass::Hexagon(r.reg_class()),
Self::Mips(r) => InlineAsmRegClass::Mips(r.reg_class()),
+ Self::S390x(r) => InlineAsmRegClass::S390x(r.reg_class()),
Self::Bpf(r) => InlineAsmRegClass::Bpf(r.reg_class()),
Self::Err => InlineAsmRegClass::Err,
}
@@ -305,6 +312,9 @@ pub fn parse(
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
Self::Mips(MipsInlineAsmReg::parse(arch, has_feature, target, &name)?)
}
+ InlineAsmArch::S390x => {
+ Self::S390x(S390xInlineAsmReg::parse(arch, has_feature, target, &name)?)
+ }
InlineAsmArch::SpirV => {
Self::SpirV(SpirVInlineAsmReg::parse(arch, has_feature, target, &name)?)
}
@@ -333,6 +343,7 @@ pub fn emit(
Self::PowerPC(r) => r.emit(out, arch, modifier),
Self::Hexagon(r) => r.emit(out, arch, modifier),
Self::Mips(r) => r.emit(out, arch, modifier),
+ Self::S390x(r) => r.emit(out, arch, modifier),
Self::Bpf(r) => r.emit(out, arch, modifier),
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
}
@@ -344,9 +355,10 @@ pub fn overlapping_regs(self, mut cb: impl FnMut(InlineAsmReg)) {
Self::Arm(r) => r.overlapping_regs(|r| cb(Self::Arm(r))),
Self::AArch64(_) => cb(self),
Self::RiscV(_) => cb(self),
- Self::PowerPC(_) => cb(self),
+ Self::PowerPC(r) => r.overlapping_regs(|r| cb(Self::PowerPC(r))),
Self::Hexagon(r) => r.overlapping_regs(|r| cb(Self::Hexagon(r))),
Self::Mips(_) => cb(self),
+ Self::S390x(_) => cb(self),
Self::Bpf(r) => r.overlapping_regs(|r| cb(Self::Bpf(r))),
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
}
@@ -374,6 +386,7 @@ pub enum InlineAsmRegClass {
PowerPC(PowerPCInlineAsmRegClass),
Hexagon(HexagonInlineAsmRegClass),
Mips(MipsInlineAsmRegClass),
+ S390x(S390xInlineAsmRegClass),
SpirV(SpirVInlineAsmRegClass),
Wasm(WasmInlineAsmRegClass),
Bpf(BpfInlineAsmRegClass),
@@ -392,6 +405,7 @@ pub fn name(self) -> Symbol {
Self::PowerPC(r) => r.name(),
Self::Hexagon(r) => r.name(),
Self::Mips(r) => r.name(),
+ Self::S390x(r) => r.name(),
Self::SpirV(r) => r.name(),
Self::Wasm(r) => r.name(),
Self::Bpf(r) => r.name(),
@@ -412,6 +426,7 @@ pub fn suggest_class(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<Sel
Self::PowerPC(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::PowerPC),
Self::Hexagon(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Hexagon),
Self::Mips(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Mips),
+ Self::S390x(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::S390x),
Self::SpirV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::SpirV),
Self::Wasm(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Wasm),
Self::Bpf(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Bpf),
@@ -439,6 +454,7 @@ pub fn suggest_modifier(
Self::PowerPC(r) => r.suggest_modifier(arch, ty),
Self::Hexagon(r) => r.suggest_modifier(arch, ty),
Self::Mips(r) => r.suggest_modifier(arch, ty),
+ Self::S390x(r) => r.suggest_modifier(arch, ty),
Self::SpirV(r) => r.suggest_modifier(arch, ty),
Self::Wasm(r) => r.suggest_modifier(arch, ty),
Self::Bpf(r) => r.suggest_modifier(arch, ty),
@@ -462,6 +478,7 @@ pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str
Self::PowerPC(r) => r.default_modifier(arch),
Self::Hexagon(r) => r.default_modifier(arch),
Self::Mips(r) => r.default_modifier(arch),
+ Self::S390x(r) => r.default_modifier(arch),
Self::SpirV(r) => r.default_modifier(arch),
Self::Wasm(r) => r.default_modifier(arch),
Self::Bpf(r) => r.default_modifier(arch),
@@ -484,6 +501,7 @@ pub fn supported_types(
Self::PowerPC(r) => r.supported_types(arch),
Self::Hexagon(r) => r.supported_types(arch),
Self::Mips(r) => r.supported_types(arch),
+ Self::S390x(r) => r.supported_types(arch),
Self::SpirV(r) => r.supported_types(arch),
Self::Wasm(r) => r.supported_types(arch),
Self::Bpf(r) => r.supported_types(arch),
@@ -509,6 +527,7 @@ pub fn parse(arch: InlineAsmArch, name: Symbol) -> Result<Self, &'static str> {
InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
Self::Mips(MipsInlineAsmRegClass::parse(arch, name)?)
}
+ InlineAsmArch::S390x => Self::S390x(S390xInlineAsmRegClass::parse(arch, name)?),
InlineAsmArch::SpirV => Self::SpirV(SpirVInlineAsmRegClass::parse(arch, name)?),
InlineAsmArch::Wasm32 => Self::Wasm(WasmInlineAsmRegClass::parse(arch, name)?),
InlineAsmArch::Bpf => Self::Bpf(BpfInlineAsmRegClass::parse(arch, name)?),
@@ -527,6 +546,7 @@ pub fn valid_modifiers(self, arch: InlineAsmArch) -> &'static [char] {
Self::PowerPC(r) => r.valid_modifiers(arch),
Self::Hexagon(r) => r.valid_modifiers(arch),
Self::Mips(r) => r.valid_modifiers(arch),
+ Self::S390x(r) => r.valid_modifiers(arch),
Self::SpirV(r) => r.valid_modifiers(arch),
Self::Wasm(r) => r.valid_modifiers(arch),
Self::Bpf(r) => r.valid_modifiers(arch),
@@ -695,6 +715,11 @@ pub fn allocatable_registers(
mips::fill_reg_map(arch, has_feature, target, &mut map);
map
}
+ InlineAsmArch::S390x => {
+ let mut map = s390x::regclass_map();
+ s390x::fill_reg_map(arch, has_feature, target, &mut map);
+ map
+ }
InlineAsmArch::SpirV => {
let mut map = spirv::regclass_map();
spirv::fill_reg_map(arch, has_feature, target, &mut map);
diff --git a/compiler/rustc_target/src/asm/powerpc.rs b/compiler/rustc_target/src/asm/powerpc.rs
index 42fc25c..51a4303 100644
--- a/compiler/rustc_target/src/asm/powerpc.rs
+++ b/compiler/rustc_target/src/asm/powerpc.rs
@@ -7,6 +7,8 @@
reg,
reg_nonzero,
freg,
+ cr,
+ xer,
}
}
@@ -44,6 +46,7 @@ pub fn supported_types(
}
}
Self::freg => types! { _: F32, F64; },
+ Self::cr | Self::xer => &[],
}
}
}
@@ -108,6 +111,16 @@ pub fn supported_types(
f29: freg = ["f29", "fr29"],
f30: freg = ["f30", "fr30"],
f31: freg = ["f31", "fr31"],
+ cr: cr = ["cr"],
+ cr0: cr = ["cr0"],
+ cr1: cr = ["cr1"],
+ cr2: cr = ["cr2"],
+ cr3: cr = ["cr3"],
+ cr4: cr = ["cr4"],
+ cr5: cr = ["cr5"],
+ cr6: cr = ["cr6"],
+ cr7: cr = ["cr7"],
+ xer: xer = ["xer"],
#error = ["r1", "1", "sp"] =>
"the stack pointer cannot be used as an operand for inline asm",
#error = ["r2", "2"] =>
@@ -136,17 +149,55 @@ pub fn emit(
_arch: InlineAsmArch,
_modifier: Option<char>,
) -> fmt::Result {
+ macro_rules! do_emit {
+ (
+ $($(($reg:ident, $value:literal)),*;)*
+ ) => {
+ out.write_str(match self {
+ $($(Self::$reg => $value,)*)*
+ })
+ };
+ }
// Strip off the leading prefix.
- if self as u32 <= Self::r28 as u32 {
- let index = self as u32 - Self::r28 as u32;
- write!(out, "{}", index)
- } else if self as u32 >= Self::f0 as u32 && self as u32 <= Self::f31 as u32 {
- let index = self as u32 - Self::f31 as u32;
- write!(out, "{}", index)
- } else {
- unreachable!()
+ do_emit! {
+ (r0, "0"), (r3, "3"), (r4, "4"), (r5, "5"), (r6, "6"), (r7, "7");
+ (r8, "8"), (r9, "9"), (r10, "10"), (r11, "11"), (r12, "12"), (r14, "14"), (r15, "15");
+ (r16, "16"), (r17, "17"), (r18, "18"), (r19, "19"), (r20, "20"), (r21, "21"), (r22, "22"), (r23, "23");
+ (r24, "24"), (r25, "25"), (r26, "26"), (r27, "27"), (r28, "28");
+ (f0, "0"), (f1, "1"), (f2, "2"), (f3, "3"), (f4, "4"), (f5, "5"), (f6, "6"), (f7, "7");
+ (f8, "8"), (f9, "9"), (f10, "10"), (f11, "11"), (f12, "12"), (f13, "13"), (f14, "14"), (f15, "15");
+ (f16, "16"), (f17, "17"), (f18, "18"), (f19, "19"), (f20, "20"), (f21, "21"), (f22, "22"), (f23, "23");
+ (f24, "24"), (f25, "25"), (f26, "26"), (f27, "27"), (f28, "28"), (f29, "29"), (f30, "30"), (f31, "31");
+ (cr, "cr");
+ (cr0, "0"), (cr1, "1"), (cr2, "2"), (cr3, "3"), (cr4, "4"), (cr5, "5"), (cr6, "6"), (cr7, "7");
+ (xer, "xer");
}
}
- pub fn overlapping_regs(self, mut _cb: impl FnMut(PowerPCInlineAsmReg)) {}
+ pub fn overlapping_regs(self, mut cb: impl FnMut(PowerPCInlineAsmReg)) {
+ macro_rules! reg_conflicts {
+ (
+ $(
+ $full:ident : $($field:ident)*
+ ),*;
+ ) => {
+ match self {
+ $(
+ Self::$full => {
+ cb(Self::$full);
+ $(cb(Self::$field);)*
+ }
+ $(Self::$field)|* => {
+ cb(Self::$full);
+ cb(self);
+ }
+ )*
+ r => cb(r),
+ }
+ };
+ }
+ reg_conflicts! {
+ cr : cr0 cr1 cr2 cr3 cr4 cr5 cr6 cr7;
+ }
+ }
}
diff --git a/compiler/rustc_target/src/asm/s390x.rs b/compiler/rustc_target/src/asm/s390x.rs
new file mode 100644
index 0000000..a74873f
--- /dev/null
+++ b/compiler/rustc_target/src/asm/s390x.rs
@@ -0,0 +1,106 @@
+use super::{InlineAsmArch, InlineAsmType};
+use rustc_macros::HashStable_Generic;
+use std::fmt;
+
+def_reg_class! {
+ S390x S390xInlineAsmRegClass {
+ reg,
+ freg,
+ }
+}
+
+impl S390xInlineAsmRegClass {
+ pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] {
+ &[]
+ }
+
+ pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> {
+ None
+ }
+
+ pub fn suggest_modifier(
+ self,
+ _arch: InlineAsmArch,
+ _ty: InlineAsmType,
+ ) -> Option<(char, &'static str)> {
+ None
+ }
+
+ pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
+ None
+ }
+
+ pub fn supported_types(
+ self,
+ arch: InlineAsmArch,
+ ) -> &'static [(InlineAsmType, Option<&'static str>)] {
+ match (self, arch) {
+ (Self::reg, _) => types! { _: I8, I16, I32, I64; },
+ (Self::freg, _) => types! { _: F32, F64; },
+ }
+ }
+}
+
+def_regs! {
+ S390x S390xInlineAsmReg S390xInlineAsmRegClass {
+ r0: reg = ["r0"],
+ r1: reg = ["r1"],
+ r2: reg = ["r2"],
+ r3: reg = ["r3"],
+ r4: reg = ["r4"],
+ r5: reg = ["r5"],
+ r6: reg = ["r6"],
+ r7: reg = ["r7"],
+ r8: reg = ["r8"],
+ r9: reg = ["r9"],
+ r10: reg = ["r10"],
+ r12: reg = ["r12"],
+ r13: reg = ["r13"],
+ r14: reg = ["r14"],
+ f0: freg = ["f0"],
+ f1: freg = ["f1"],
+ f2: freg = ["f2"],
+ f3: freg = ["f3"],
+ f4: freg = ["f4"],
+ f5: freg = ["f5"],
+ f6: freg = ["f6"],
+ f7: freg = ["f7"],
+ f8: freg = ["f8"],
+ f9: freg = ["f9"],
+ f10: freg = ["f10"],
+ f11: freg = ["f11"],
+ f12: freg = ["f12"],
+ f13: freg = ["f13"],
+ f14: freg = ["f14"],
+ f15: freg = ["f15"],
+ #error = ["r11"] =>
+ "The frame pointer cannot be used as an operand for inline asm",
+ #error = ["r15"] =>
+ "The stack pointer cannot be used as an operand for inline asm",
+ #error = [
+ "c0", "c1", "c2", "c3",
+ "c4", "c5", "c6", "c7",
+ "c8", "c9", "c10", "c11",
+ "c12", "c13", "c14", "c15"
+ ] =>
+ "control registers are reserved by the kernel and cannot be used as operands for inline asm",
+ #error = [
+ "a0", "a1", "a2", "a3",
+ "a4", "a5", "a6", "a7",
+ "a8", "a9", "a10", "a11",
+ "a12", "a13", "a14", "a15"
+ ] =>
+ "access registers are not supported and cannot be used as operands for inline asm",
+ }
+}
+
+impl S390xInlineAsmReg {
+ pub fn emit(
+ self,
+ out: &mut dyn fmt::Write,
+ _arch: InlineAsmArch,
+ _modifier: Option<char>,
+ ) -> fmt::Result {
+ write!(out, "%{}", self.name())
+ }
+}
diff --git a/compiler/rustc_target/src/spec/apple_base.rs b/compiler/rustc_target/src/spec/apple_base.rs
index 5d75f6a..a21b784 100644
--- a/compiler/rustc_target/src/spec/apple_base.rs
+++ b/compiler/rustc_target/src/spec/apple_base.rs
@@ -1,6 +1,6 @@
use std::env;
-use crate::spec::{FramePointer, SplitDebuginfo, TargetOptions};
+use crate::spec::{FramePointer, LldFlavor, SplitDebuginfo, TargetOptions};
pub fn opts(os: &str) -> TargetOptions {
// ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6
@@ -35,6 +35,7 @@ pub fn opts(os: &str) -> TargetOptions {
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
eh_frame_header: false,
+ lld_flavor: LldFlavor::Ld64,
// The historical default for macOS targets is to run `dsymutil` which
// generates a packed version of debuginfo split from the main file.
diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs
index 9119568..4d0cad8 100644
--- a/compiler/rustc_target/src/spec/mod.rs
+++ b/compiler/rustc_target/src/spec/mod.rs
@@ -1501,7 +1501,8 @@ pub fn is_abi_supported(&self, abi: Abi) -> Option<bool> {
| Cdecl
| EfiApi => true,
X86Interrupt => ["x86", "x86_64"].contains(&&self.arch[..]),
- Aapcs | CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
+ Aapcs => "arm" == self.arch,
+ CCmseNonSecureCall => ["arm", "aarch64"].contains(&&self.arch[..]),
Win64 | SysV64 => self.arch == "x86_64",
PtxKernel => self.arch == "nvptx64",
Msp430Interrupt => self.arch == "msp430",
diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
index 282502c..622c9ed 100644
--- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs
+++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs
@@ -285,7 +285,7 @@ fn evaluate_predicates(
def_id: trait_did,
substs: infcx.tcx.mk_substs_trait(ty, &[]),
},
- constness: hir::Constness::NotConst,
+ constness: ty::BoundConstness::NotConst,
}));
let computed_preds = param_env.caller_bounds().iter();
diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
index 5c0bd1d..ddabe59 100644
--- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
+++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs
@@ -34,7 +34,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>(
span: Span,
) -> Result<(), NotConstEvaluatable> {
debug!("is_const_evaluatable({:?})", uv);
- if infcx.tcx.features().const_evaluatable_checked {
+ if infcx.tcx.features().generic_const_exprs {
let tcx = infcx.tcx;
match AbstractConst::new(tcx, uv)? {
// We are looking at a generic abstract constant.
@@ -537,9 +537,9 @@ pub(super) fn mir_abstract_const<'tcx>(
tcx: TyCtxt<'tcx>,
def: ty::WithOptConstParam<LocalDefId>,
) -> Result<Option<&'tcx [mir::abstract_const::Node<'tcx>]>, ErrorReported> {
- if tcx.features().const_evaluatable_checked {
+ if tcx.features().generic_const_exprs {
match tcx.def_kind(def.did) {
- // FIXME(const_evaluatable_checked): We currently only do this for anonymous constants,
+ // FIXME(generic_const_exprs): We currently only do this for anonymous constants,
// meaning that we do not look into associated constants. I(@lcnr) am not yet sure whether
// we want to look into them or treat them as opaque projections.
//
@@ -568,7 +568,7 @@ pub(super) fn try_unify_abstract_consts<'tcx>(
Ok(false)
})()
.unwrap_or_else(|ErrorReported| true)
- // FIXME(const_evaluatable_checked): We should instead have this
+ // FIXME(generic_const_exprs): We should instead have this
// method return the resulting `ty::Const` and return `ConstKind::Error`
// on `ErrorReported`.
}
@@ -656,13 +656,13 @@ pub(super) fn try_unify<'tcx>(
// branch should only be taking when dealing with associated constants, at
// which point directly comparing them seems like the desired behavior.
//
- // FIXME(const_evaluatable_checked): This isn't actually the case.
+ // FIXME(generic_const_exprs): This isn't actually the case.
// We also take this branch for concrete anonymous constants and
// expand generic anonymous constants with concrete substs.
(ty::ConstKind::Unevaluated(a_uv), ty::ConstKind::Unevaluated(b_uv)) => {
a_uv == b_uv
}
- // FIXME(const_evaluatable_checked): We may want to either actually try
+ // FIXME(generic_const_exprs): We may want to either actually try
// to evaluate `a_ct` and `b_ct` if they are are fully concrete or something like
// this, for now we just return false here.
_ => false,
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
index 6a7aafc..9fd5cb2 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs
@@ -794,7 +794,7 @@ fn report_selection_error(
)
}
SelectionError::NotConstEvaluatable(NotConstEvaluatable::MentionsParam) => {
- if !self.tcx.features().const_evaluatable_checked {
+ if !self.tcx.features().generic_const_exprs {
let mut err = self.tcx.sess.struct_span_err(
span,
"constant expression depends on a generic parameter",
@@ -803,7 +803,7 @@ fn report_selection_error(
// issue. However, this is currently not actually possible
// (see https://github.com/rust-lang/rust/issues/66962#issuecomment-575907083).
//
- // Note that with `feature(const_evaluatable_checked)` this case should not
+ // Note that with `feature(generic_const_exprs)` this case should not
// be reachable.
err.note("this may fail depending on what value the parameter takes");
err.emit();
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
index 40841a6..db3432b 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -1928,7 +1928,11 @@ fn note_obligation_cause_code<T>(
| ObligationCauseCode::OpaqueType
| ObligationCauseCode::MiscObligation
| ObligationCauseCode::WellFormed(..)
- | ObligationCauseCode::MatchImpl(..) => {}
+ | ObligationCauseCode::MatchImpl(..)
+ | ObligationCauseCode::ReturnType
+ | ObligationCauseCode::ReturnValue(_)
+ | ObligationCauseCode::BlockTailExpression(_)
+ | ObligationCauseCode::LetElse => {}
ObligationCauseCode::SliceOrArrayElem => {
err.note("slice and array elements must have `Sized` type");
}
@@ -2338,9 +2342,6 @@ fn note_obligation_cause_code<T>(
predicate
));
}
- ObligationCauseCode::ReturnType
- | ObligationCauseCode::ReturnValue(_)
- | ObligationCauseCode::BlockTailExpression(_) => (),
ObligationCauseCode::TrivialBound => {
err.help("see issue #48214");
if tcx.sess.opts.unstable_features.is_nightly_build() {
diff --git a/compiler/rustc_trait_selection/src/traits/fulfill.rs b/compiler/rustc_trait_selection/src/traits/fulfill.rs
index f214930..18abcc7 100644
--- a/compiler/rustc_trait_selection/src/traits/fulfill.rs
+++ b/compiler/rustc_trait_selection/src/traits/fulfill.rs
@@ -572,7 +572,7 @@ fn progress_changed_obligations(
ty::PredicateKind::ConstEquate(c1, c2) => {
debug!(?c1, ?c2, "equating consts");
let tcx = self.selcx.tcx();
- if tcx.features().const_evaluatable_checked {
+ if tcx.features().generic_const_exprs {
// FIXME: we probably should only try to unify abstract constants
// if the constants depend on generic parameters.
//
diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs
index 554b295..17a4184 100644
--- a/compiler/rustc_trait_selection/src/traits/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/mod.rs
@@ -778,7 +778,10 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot(
let obligation = Obligation::new(
ObligationCause::dummy(),
ty::ParamEnv::reveal_all(),
- ty::Binder::dummy(ty::TraitPredicate { trait_ref, constness: hir::Constness::NotConst }),
+ ty::Binder::dummy(ty::TraitPredicate {
+ trait_ref,
+ constness: ty::BoundConstness::NotConst,
+ }),
);
let implsrc = tcx.infer_ctxt().enter(|infcx| {
diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs
index dd974e6..041fd65 100644
--- a/compiler/rustc_trait_selection/src/traits/object_safety.rs
+++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs
@@ -855,7 +855,7 @@ fn visit_const(&mut self, ct: &ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
fn visit_predicate(&mut self, pred: ty::Predicate<'tcx>) -> ControlFlow<Self::BreakTy> {
if let ty::PredicateKind::ConstEvaluatable(ct) = pred.kind().skip_binder() {
- // FIXME(const_evaluatable_checked): We should probably deduplicate the logic for
+ // FIXME(generic_const_exprs): We should probably deduplicate the logic for
// `AbstractConst`s here, it might make sense to change `ConstEvaluatable` to
// take a `ty::Const` instead.
use rustc_middle::mir::abstract_const::Node;
diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
index c571a1d..6fae817 100644
--- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs
@@ -8,7 +8,6 @@
//! https://rustc-dev-guide.rust-lang.org/traits/resolution.html#confirmation
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir::lang_items::LangItem;
-use rustc_hir::Constness;
use rustc_index::bit_set::GrowableBitSet;
use rustc_infer::infer::InferOk;
use rustc_infer::infer::LateBoundRegionConversionTime::HigherRankedType;
@@ -75,7 +74,7 @@ pub(super) fn confirm_candidate(
ProjectionCandidate(idx) => {
let obligations = self.confirm_projection_candidate(obligation, idx)?;
// FIXME(jschievink): constness
- Ok(ImplSource::Param(obligations, Constness::NotConst))
+ Ok(ImplSource::Param(obligations, ty::BoundConstness::NotConst))
}
ObjectCandidate(idx) => {
@@ -113,7 +112,7 @@ pub(super) fn confirm_candidate(
// This indicates something like `Trait + Send: Send`. In this case, we know that
// this holds because that's what the object type is telling us, and there's really
// no additional obligations to prove and no types in particular to unify, etc.
- Ok(ImplSource::Param(Vec::new(), Constness::NotConst))
+ Ok(ImplSource::Param(Vec::new(), ty::BoundConstness::NotConst))
}
BuiltinUnsizeCandidate => {
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index 1580562..5214277 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -32,7 +32,6 @@
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
-use rustc_hir::Constness;
use rustc_infer::infer::LateBoundRegionConversionTime;
use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
use rustc_middle::mir::abstract_const::NotConstEvaluatable;
@@ -130,8 +129,8 @@ pub struct SelectionContext<'cx, 'tcx> {
/// and a negative impl
allow_negative_impls: bool,
- /// Do we only want const impls when we have a const trait predicate?
- const_impls_required: bool,
+ /// Are we in a const context that needs `~const` bounds to be const?
+ is_in_const_context: bool,
/// The mode that trait queries run in, which informs our error handling
/// policy. In essence, canonicalized queries need their errors propagated
@@ -224,7 +223,7 @@ pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> {
intercrate: false,
intercrate_ambiguity_causes: None,
allow_negative_impls: false,
- const_impls_required: false,
+ is_in_const_context: false,
query_mode: TraitQueryMode::Standard,
}
}
@@ -236,7 +235,7 @@ pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tc
intercrate: true,
intercrate_ambiguity_causes: None,
allow_negative_impls: false,
- const_impls_required: false,
+ is_in_const_context: false,
query_mode: TraitQueryMode::Standard,
}
}
@@ -252,7 +251,7 @@ pub fn with_negative(
intercrate: false,
intercrate_ambiguity_causes: None,
allow_negative_impls,
- const_impls_required: false,
+ is_in_const_context: false,
query_mode: TraitQueryMode::Standard,
}
}
@@ -268,7 +267,7 @@ pub fn with_query_mode(
intercrate: false,
intercrate_ambiguity_causes: None,
allow_negative_impls: false,
- const_impls_required: false,
+ is_in_const_context: false,
query_mode,
}
}
@@ -283,7 +282,7 @@ pub fn with_constness(
intercrate: false,
intercrate_ambiguity_causes: None,
allow_negative_impls: false,
- const_impls_required: matches!(constness, hir::Constness::Const),
+ is_in_const_context: matches!(constness, hir::Constness::Const),
query_mode: TraitQueryMode::Standard,
}
}
@@ -316,14 +315,19 @@ pub fn tcx(&self) -> TyCtxt<'tcx> {
self.infcx.tcx
}
+ /// Returns `true` if the trait predicate is considerd `const` to this selection context.
+ pub fn is_trait_predicate_const(&self, pred: ty::TraitPredicate<'_>) -> bool {
+ match pred.constness {
+ ty::BoundConstness::ConstIfConst if self.is_in_const_context => true,
+ _ => false,
+ }
+ }
+
/// Returns `true` if the predicate is considered `const` to
/// this selection context.
pub fn is_predicate_const(&self, pred: ty::Predicate<'_>) -> bool {
match pred.kind().skip_binder() {
- ty::PredicateKind::Trait(ty::TraitPredicate {
- constness: hir::Constness::Const,
- ..
- }) if self.const_impls_required => true,
+ ty::PredicateKind::Trait(pred) => self.is_trait_predicate_const(pred),
_ => false,
}
}
@@ -615,7 +619,7 @@ fn evaluate_predicate_recursively<'o>(
ty::PredicateKind::ConstEquate(c1, c2) => {
debug!(?c1, ?c2, "evaluate_predicate_recursively: equating consts");
- if self.tcx().features().const_evaluatable_checked {
+ if self.tcx().features().generic_const_exprs {
// FIXME: we probably should only try to unify abstract constants
// if the constants depend on generic parameters.
//
@@ -1074,30 +1078,28 @@ fn filter_impls(
) -> SelectionResult<'tcx, SelectionCandidate<'tcx>> {
let tcx = self.tcx();
// Respect const trait obligations
- if self.const_impls_required {
- if let hir::Constness::Const = obligation.predicate.skip_binder().constness {
- if Some(obligation.predicate.skip_binder().trait_ref.def_id)
- != tcx.lang_items().sized_trait()
- // const Sized bounds are skipped
- {
- match candidate {
- // const impl
- ImplCandidate(def_id)
- if tcx.impl_constness(def_id) == hir::Constness::Const => {}
- // const param
- ParamCandidate(ty::ConstnessAnd {
- constness: hir::Constness::Const,
- ..
- }) => {}
- // auto trait impl
- AutoImplCandidate(..) => {}
- // generator, this will raise error in other places
- // or ignore error with const_async_blocks feature
- GeneratorCandidate => {}
- _ => {
- // reject all other types of candidates
- return Err(Unimplemented);
- }
+ if self.is_trait_predicate_const(obligation.predicate.skip_binder()) {
+ if Some(obligation.predicate.skip_binder().trait_ref.def_id)
+ != tcx.lang_items().sized_trait()
+ // const Sized bounds are skipped
+ {
+ match candidate {
+ // const impl
+ ImplCandidate(def_id)
+ if tcx.impl_constness(def_id) == hir::Constness::Const => {}
+ // const param
+ ParamCandidate(ty::ConstnessAnd {
+ constness: ty::BoundConstness::ConstIfConst,
+ ..
+ }) => {}
+ // auto trait impl
+ AutoImplCandidate(..) => {}
+ // generator, this will raise error in other places
+ // or ignore error with const_async_blocks feature
+ GeneratorCandidate => {}
+ _ => {
+ // reject all other types of candidates
+ return Err(Unimplemented);
}
}
}
@@ -1495,7 +1497,9 @@ fn candidate_should_be_dropped_in_favor_of(
// probably best characterized as a "hack", since we might prefer to just do our
// best to *not* create essentially duplicate candidates in the first place.
other.value.bound_vars().len() <= victim.value.bound_vars().len()
- } else if other.value == victim.value && victim.constness == Constness::NotConst {
+ } else if other.value == victim.value
+ && victim.constness == ty::BoundConstness::NotConst
+ {
// Drop otherwise equivalent non-const candidates in favor of const candidates.
true
} else {
diff --git a/compiler/rustc_typeck/Cargo.toml b/compiler/rustc_typeck/Cargo.toml
index fa5ef63..dd76a5e 100644
--- a/compiler/rustc_typeck/Cargo.toml
+++ b/compiler/rustc_typeck/Cargo.toml
@@ -26,3 +26,4 @@
rustc_infer = { path = "../rustc_infer" }
rustc_trait_selection = { path = "../rustc_trait_selection" }
rustc_ty_utils = { path = "../rustc_ty_utils" }
+rustc_lint = { path = "../rustc_lint" }
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index d916ff7..059e0ca 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -20,7 +20,7 @@
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::{walk_generics, Visitor as _};
use rustc_hir::lang_items::LangItem;
-use rustc_hir::{Constness, GenericArg, GenericArgs};
+use rustc_hir::{GenericArg, GenericArgs};
use rustc_middle::ty::subst::{self, GenericArgKind, InternalSubsts, Subst, SubstsRef};
use rustc_middle::ty::GenericParamDefKind;
use rustc_middle::ty::{self, Const, DefIdTree, Ty, TyCtxt, TypeFoldable};
@@ -47,8 +47,6 @@ pub trait AstConv<'tcx> {
fn item_def_id(&self) -> Option<DefId>;
- fn default_constness_for_trait_bounds(&self) -> Constness;
-
/// Returns predicates in scope of the form `X: Foo<T>`, where `X`
/// is a type parameter `X` with the given id `def_id` and T
/// matches `assoc_name`. This is a subset of the full set of
@@ -724,7 +722,7 @@ pub fn instantiate_poly_trait_ref(
&self,
trait_ref: &hir::TraitRef<'_>,
span: Span,
- constness: Constness,
+ constness: ty::BoundConstness,
self_ty: Ty<'tcx>,
bounds: &mut Bounds<'tcx>,
speculative: bool,
@@ -795,7 +793,7 @@ pub fn instantiate_lang_item_trait_ref(
let bound_vars = tcx.late_bound_vars(hir_id);
let poly_trait_ref =
ty::Binder::bind_with_vars(ty::TraitRef::new(trait_def_id, substs), bound_vars);
- bounds.trait_bounds.push((poly_trait_ref, span, Constness::NotConst));
+ bounds.trait_bounds.push((poly_trait_ref, span, ty::BoundConstness::NotConst));
let mut dup_bindings = FxHashMap::default();
for binding in assoc_bindings {
@@ -920,14 +918,13 @@ fn add_bounds(
bounds: &mut Bounds<'tcx>,
bound_vars: &'tcx ty::List<ty::BoundVariableKind>,
) {
- let constness = self.default_constness_for_trait_bounds();
for ast_bound in ast_bounds {
match *ast_bound {
hir::GenericBound::Trait(ref b, hir::TraitBoundModifier::None) => {
self.instantiate_poly_trait_ref(
&b.trait_ref,
b.span,
- constness,
+ ty::BoundConstness::NotConst,
param_ty,
bounds,
false,
@@ -937,7 +934,7 @@ fn add_bounds(
self.instantiate_poly_trait_ref(
&b.trait_ref,
b.span,
- Constness::NotConst,
+ ty::BoundConstness::ConstIfConst,
param_ty,
bounds,
false,
@@ -1251,7 +1248,7 @@ fn conv_object_ty_poly_trait_ref(
} = self.instantiate_poly_trait_ref(
&trait_bound.trait_ref,
trait_bound.span,
- Constness::NotConst,
+ ty::BoundConstness::NotConst,
dummy_self,
&mut bounds,
false,
@@ -1330,7 +1327,7 @@ trait here instead: `trait NewTrait: {} {{}}`",
.filter(|(trait_ref, _, _)| !tcx.trait_is_auto(trait_ref.def_id()));
for (base_trait_ref, span, constness) in regular_traits_refs_spans {
- assert_eq!(constness, Constness::NotConst);
+ assert_eq!(constness, ty::BoundConstness::NotConst);
for obligation in traits::elaborate_trait_ref(tcx, base_trait_ref) {
debug!(
diff --git a/compiler/rustc_typeck/src/bounds.rs b/compiler/rustc_typeck/src/bounds.rs
index 5d20064..24474e1 100644
--- a/compiler/rustc_typeck/src/bounds.rs
+++ b/compiler/rustc_typeck/src/bounds.rs
@@ -1,7 +1,6 @@
//! Bounds are restrictions applied to some types after they've been converted into the
//! `ty` form from the HIR.
-use rustc_hir::Constness;
use rustc_middle::ty::{self, ToPredicate, Ty, TyCtxt, WithConstness};
use rustc_span::Span;
@@ -30,7 +29,7 @@ pub struct Bounds<'tcx> {
/// A list of trait bounds. So if you had `T: Debug` this would be
/// `T: Debug`. Note that the self-type is explicit here.
- pub trait_bounds: Vec<(ty::PolyTraitRef<'tcx>, Span, Constness)>,
+ pub trait_bounds: Vec<(ty::PolyTraitRef<'tcx>, Span, ty::BoundConstness)>,
/// A list of projection equality bounds. So if you had `T:
/// Iterator<Item = u32>` this would include `<T as
diff --git a/compiler/rustc_typeck/src/check/compare_method.rs b/compiler/rustc_typeck/src/check/compare_method.rs
index c384e0d..d59291b 100644
--- a/compiler/rustc_typeck/src/check/compare_method.rs
+++ b/compiler/rustc_typeck/src/check/compare_method.rs
@@ -250,6 +250,8 @@ fn compare_predicate_entailment<'tcx>(
// Compute placeholder form of impl and trait method tys.
let tcx = infcx.tcx;
+ let mut wf_tys = vec![];
+
let (impl_sig, _) = infcx.replace_bound_vars_with_fresh_vars(
impl_m_span,
infer::HigherRankedType,
@@ -260,10 +262,18 @@ fn compare_predicate_entailment<'tcx>(
let impl_fty = tcx.mk_fn_ptr(ty::Binder::dummy(impl_sig));
debug!("compare_impl_method: impl_fty={:?}", impl_fty);
+ // First liberate late bound regions and subst placeholders
let trait_sig = tcx.liberate_late_bound_regions(impl_m.def_id, tcx.fn_sig(trait_m.def_id));
let trait_sig = trait_sig.subst(tcx, trait_to_placeholder_substs);
+ // Next, add all inputs and output as well-formed tys. Importantly,
+ // we have to do this before normalization, since the normalized ty may
+ // not contain the input parameters. See issue #87748.
+ wf_tys.extend(trait_sig.inputs_and_output.iter());
let trait_sig =
inh.normalize_associated_types_in(impl_m_span, impl_m_hir_id, param_env, trait_sig);
+ // Also add the resulting inputs and output as well-formed.
+ // This probably isn't strictly necessary.
+ wf_tys.extend(trait_sig.inputs_and_output.iter());
let trait_fty = tcx.mk_fn_ptr(ty::Binder::dummy(trait_sig));
debug!("compare_impl_method: trait_fty={:?}", trait_fty);
@@ -388,7 +398,7 @@ fn compare_predicate_entailment<'tcx>(
// Finally, resolve all regions. This catches wily misuses of
// lifetime parameters.
let fcx = FnCtxt::new(&inh, param_env, impl_m_hir_id);
- fcx.regionck_item(impl_m_hir_id, impl_m_span, trait_sig.inputs_and_output);
+ fcx.regionck_item(impl_m_hir_id, impl_m_span, &wf_tys);
Ok(())
})
diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs
index ab927b7..10f5b00 100644
--- a/compiler/rustc_typeck/src/check/expr.rs
+++ b/compiler/rustc_typeck/src/check/expr.rs
@@ -849,7 +849,26 @@ fn check_then_else(
coerce.coerce(self, &self.misc(sp), then_expr, then_ty);
if let Some(else_expr) = opt_else_expr {
- let else_ty = self.check_expr_with_expectation(else_expr, expected);
+ let else_ty = if sp.desugaring_kind() == Some(DesugaringKind::LetElse) {
+ // todo introduce `check_expr_with_expectation(.., Expectation::LetElse)`
+ // for errors that point to the offending expression rather than the entire block.
+ // We could use `check_expr_eq_type(.., tcx.types.never)`, but then there is no
+ // way to detect that the expected type originated from let-else and provide
+ // a customized error.
+ let else_ty = self.check_expr(else_expr);
+ let cause = self.cause(else_expr.span, ObligationCauseCode::LetElse);
+
+ if let Some(mut err) =
+ self.demand_eqtype_with_origin(&cause, self.tcx.types.never, else_ty)
+ {
+ err.emit();
+ self.tcx.ty_error()
+ } else {
+ else_ty
+ }
+ } else {
+ self.check_expr_with_expectation(else_expr, expected)
+ };
let else_diverges = self.diverges.get();
let opt_suggest_box_span =
@@ -919,9 +938,10 @@ fn check_expr_assign(
);
}
- if self.sess().if_let_suggestions.borrow().get(&expr.span).is_some() {
- // We already emitted an `if let` suggestion due to an identifier not found.
- err.delay_as_bug();
+ // If the assignment expression itself is ill-formed, don't
+ // bother emitting another error
+ if lhs_ty.references_error() || rhs_ty.references_error() {
+ err.delay_as_bug()
} else {
err.emit();
}
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
index 25d1c87..17e0c42 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
@@ -914,7 +914,7 @@ pub fn resolve_ty_and_res_fully_qualified_call(
});
if result.is_ok() {
- self.maybe_lint_bare_trait(qpath, hir_id);
+ self.maybe_lint_bare_trait(qpath, hir_id, span);
self.register_wf_obligation(ty.into(), qself.span, traits::WellFormed(None));
}
@@ -927,7 +927,7 @@ pub fn resolve_ty_and_res_fully_qualified_call(
)
}
- fn maybe_lint_bare_trait(&self, qpath: &QPath<'_>, hir_id: hir::HirId) {
+ fn maybe_lint_bare_trait(&self, qpath: &QPath<'_>, hir_id: hir::HirId, span: Span) {
if let QPath::TypeRelative(self_ty, _) = qpath {
if let TyKind::TraitObject([poly_trait_ref, ..], _, TraitObjectSyntax::None) =
self_ty.kind
@@ -935,10 +935,15 @@ fn maybe_lint_bare_trait(&self, qpath: &QPath<'_>, hir_id: hir::HirId) {
let msg = "trait objects without an explicit `dyn` are deprecated";
let (sugg, app) = match self.tcx.sess.source_map().span_to_snippet(self_ty.span) {
Ok(s) if poly_trait_ref.trait_ref.path.is_global() => {
- (format!("<dyn ({})>", s), Applicability::MachineApplicable)
+ (format!("dyn ({})", s), Applicability::MachineApplicable)
}
- Ok(s) => (format!("<dyn {}>", s), Applicability::MachineApplicable),
- Err(_) => ("<dyn <type>>".to_string(), Applicability::HasPlaceholders),
+ Ok(s) => (format!("dyn {}", s), Applicability::MachineApplicable),
+ Err(_) => ("dyn <type>".to_string(), Applicability::HasPlaceholders),
+ };
+ // Wrap in `<..>` if it isn't already.
+ let sugg = match self.tcx.sess.source_map().span_to_snippet(span) {
+ Ok(s) if s.starts_with('<') => sugg,
+ _ => format!("<{}>", sugg),
};
let replace = String::from("use `dyn`");
if self.sess().edition() >= Edition::Edition2021 {
diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs b/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs
index 16f3de5..9c70d2c 100644
--- a/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs
+++ b/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs
@@ -180,10 +180,6 @@ fn item_def_id(&self) -> Option<DefId> {
None
}
- fn default_constness_for_trait_bounds(&self) -> hir::Constness {
- self.tcx.hir().get(self.body_id).constness_for_typeck()
- }
-
fn get_type_parameter_bounds(
&self,
_: Span,
diff --git a/compiler/rustc_typeck/src/check/method/prelude2021.rs b/compiler/rustc_typeck/src/check/method/prelude2021.rs
index b5bc9d3..5c8056b 100644
--- a/compiler/rustc_typeck/src/check/method/prelude2021.rs
+++ b/compiler/rustc_typeck/src/check/method/prelude2021.rs
@@ -5,9 +5,9 @@
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_middle::ty::subst::InternalSubsts;
-use rustc_middle::ty::{Adt, Ref, Ty};
+use rustc_middle::ty::{Adt, Array, Ref, Ty};
use rustc_session::lint::builtin::RUST_2021_PRELUDE_COLLISIONS;
-use rustc_span::symbol::kw::Underscore;
+use rustc_span::symbol::kw::{Empty, Underscore};
use rustc_span::symbol::{sym, Ident};
use rustc_span::Span;
use rustc_trait_selection::infer::InferCtxtExt;
@@ -38,10 +38,20 @@ pub(super) fn lint_dot_call_from_2018(
return;
}
- // These are the method names that were added to prelude in Rust 2021
- if !matches!(segment.ident.name, sym::try_into) {
- return;
- }
+ let prelude_or_array_lint = match segment.ident.name {
+ // `try_into` was added to the prelude in Rust 2021.
+ sym::try_into => RUST_2021_PRELUDE_COLLISIONS,
+ // `into_iter` wasn't added to the prelude,
+ // but `[T; N].into_iter()` doesn't resolve to IntoIterator::into_iter
+ // before Rust 2021, which results in the same problem.
+ // It is only a problem for arrays.
+ sym::into_iter if let Array(..) = self_ty.kind() => {
+ // In this case, it wasn't really a prelude addition that was the problem.
+ // Instead, the problem is that the array-into_iter hack will no longer apply in Rust 2021.
+ rustc_lint::ARRAY_INTO_ITER
+ }
+ _ => return,
+ };
// No need to lint if method came from std/core, as that will now be in the prelude
if matches!(self.tcx.crate_name(pick.item.def_id.krate), sym::std | sym::core) {
@@ -69,7 +79,7 @@ pub(super) fn lint_dot_call_from_2018(
// Inherent impls only require not relying on autoref and autoderef in order to
// ensure that the trait implementation won't be used
self.tcx.struct_span_lint_hir(
- RUST_2021_PRELUDE_COLLISIONS,
+ prelude_or_array_lint,
self_expr.hir_id,
self_expr.span,
|lint| {
@@ -130,7 +140,7 @@ pub(super) fn lint_dot_call_from_2018(
// trait implementations require full disambiguation to not clash with the new prelude
// additions (i.e. convert from dot-call to fully-qualified call)
self.tcx.struct_span_lint_hir(
- RUST_2021_PRELUDE_COLLISIONS,
+ prelude_or_array_lint,
call_expr.hir_id,
call_expr.span,
|lint| {
@@ -146,15 +156,16 @@ pub(super) fn lint_dot_call_from_2018(
segment.ident.name
));
- let (self_adjusted, precise) = self.adjust_expr(pick, self_expr);
+ let (self_adjusted, precise) = self.adjust_expr(pick, self_expr, sp);
if precise {
let args = args
.iter()
.skip(1)
.map(|arg| {
+ let span = arg.span.find_ancestor_inside(sp).unwrap_or_default();
format!(
", {}",
- self.sess().source_map().span_to_snippet(arg.span).unwrap()
+ self.sess().source_map().span_to_snippet(span).unwrap()
)
})
.collect::<String>();
@@ -163,8 +174,22 @@ pub(super) fn lint_dot_call_from_2018(
sp,
"disambiguate the associated function",
format!(
- "{}::{}({}{})",
- trait_name, segment.ident.name, self_adjusted, args
+ "{}::{}{}({}{})",
+ trait_name,
+ segment.ident.name,
+ if let Some(args) = segment.args.as_ref().and_then(|args| self
+ .sess()
+ .source_map()
+ .span_to_snippet(args.span_ext)
+ .ok())
+ {
+ // Keep turbofish.
+ format!("::{}", args)
+ } else {
+ String::new()
+ },
+ self_adjusted,
+ args,
),
Applicability::MachineApplicable,
);
@@ -239,47 +264,57 @@ pub(super) fn lint_fully_qualified_call_from_2018(
let trait_path = self.trait_path_or_bare_name(span, expr_id, pick.item.container.id());
let trait_generics = self.tcx.generics_of(pick.item.container.id());
- let parameter_count = trait_generics.count() - (trait_generics.has_self as usize);
- let trait_name = if parameter_count == 0 {
- trait_path
- } else {
- format!(
- "{}<{}>",
- trait_path,
- std::iter::repeat("_").take(parameter_count).collect::<Vec<_>>().join(", ")
- )
- };
+ let trait_name =
+ if trait_generics.params.len() <= trait_generics.has_self as usize {
+ trait_path
+ } else {
+ let counts = trait_generics.own_counts();
+ format!(
+ "{}<{}>",
+ trait_path,
+ std::iter::repeat("'_")
+ .take(counts.lifetimes)
+ .chain(std::iter::repeat("_").take(
+ counts.types + counts.consts - trait_generics.has_self as usize
+ ))
+ .collect::<Vec<_>>()
+ .join(", ")
+ )
+ };
let mut lint = lint.build(&format!(
"trait-associated function `{}` will become ambiguous in Rust 2021",
method_name.name
));
- let self_ty_name = self
- .sess()
- .source_map()
- .span_to_snippet(self_ty_span)
- .unwrap_or_else(|_| self_ty.to_string());
+ let mut self_ty_name = self_ty_span
+ .find_ancestor_inside(span)
+ .and_then(|span| self.sess().source_map().span_to_snippet(span).ok())
+ .unwrap_or_else(|| self_ty.to_string());
- let self_ty_generics_count = match self_ty.kind() {
- // Get the number of generics the self type has (if an Adt) unless we can determine that
- // the user has written the self type with generics already which we (naively) do by looking
- // for a "<" in `self_ty_name`.
- Adt(def, _) if !self_ty_name.contains('<') => self.tcx.generics_of(def.did).count(),
- _ => 0,
- };
- let self_ty_generics = if self_ty_generics_count > 0 {
- format!("<{}>", vec!["_"; self_ty_generics_count].join(", "))
- } else {
- String::new()
- };
+ // Get the number of generics the self type has (if an Adt) unless we can determine that
+ // the user has written the self type with generics already which we (naively) do by looking
+ // for a "<" in `self_ty_name`.
+ if !self_ty_name.contains('<') {
+ if let Adt(def, _) = self_ty.kind() {
+ let generics = self.tcx.generics_of(def.did);
+ if !generics.params.is_empty() {
+ let counts = generics.own_counts();
+ self_ty_name += &format!(
+ "<{}>",
+ std::iter::repeat("'_")
+ .take(counts.lifetimes)
+ .chain(std::iter::repeat("_").take(counts.types + counts.consts))
+ .collect::<Vec<_>>()
+ .join(", ")
+ );
+ }
+ }
+ }
lint.span_suggestion(
span,
"disambiguate the associated function",
- format!(
- "<{}{} as {}>::{}",
- self_ty_name, self_ty_generics, trait_name, method_name.name,
- ),
+ format!("<{} as {}>::{}", self_ty_name, trait_name, method_name.name,),
Applicability::MachineApplicable,
);
@@ -322,7 +357,12 @@ fn trait_path(&self, span: Span, expr_hir_id: HirId, trait_def_id: DefId) -> Opt
.filter_map(|item| if item.ident.name != Underscore { Some(item.ident) } else { None })
.next();
if let Some(any_id) = any_id {
- return Some(format!("{}", any_id));
+ if any_id.name == Empty {
+ // Glob import, so just use its name.
+ return None;
+ } else {
+ return Some(format!("{}", any_id));
+ }
}
// All that is left is `_`! We need to use the full path. It doesn't matter which one we pick,
@@ -344,7 +384,12 @@ fn trait_path(&self, span: Span, expr_hir_id: HirId, trait_def_id: DefId) -> Opt
/// Creates a string version of the `expr` that includes explicit adjustments.
/// Returns the string and also a bool indicating whther this is a *precise*
/// suggestion.
- fn adjust_expr(&self, pick: &Pick<'tcx>, expr: &hir::Expr<'tcx>) -> (String, bool) {
+ fn adjust_expr(
+ &self,
+ pick: &Pick<'tcx>,
+ expr: &hir::Expr<'tcx>,
+ outer: Span,
+ ) -> (String, bool) {
let derefs = "*".repeat(pick.autoderefs);
let autoref = match pick.autoref_or_ptr_adjustment {
@@ -353,12 +398,15 @@ fn adjust_expr(&self, pick: &Pick<'tcx>, expr: &hir::Expr<'tcx>) -> (String, boo
Some(probe::AutorefOrPtrAdjustment::ToConstPtr) | None => "",
};
- let (expr_text, precise) =
- if let Ok(expr_text) = self.sess().source_map().span_to_snippet(expr.span) {
- (expr_text, true)
- } else {
- ("(..)".to_string(), false)
- };
+ let (expr_text, precise) = if let Some(expr_text) = expr
+ .span
+ .find_ancestor_inside(outer)
+ .and_then(|span| self.sess().source_map().span_to_snippet(span).ok())
+ {
+ (expr_text, true)
+ } else {
+ ("(..)".to_string(), false)
+ };
let adjusted_text = if let Some(probe::AutorefOrPtrAdjustment::ToConstPtr) =
pick.autoref_or_ptr_adjustment
diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs
index a88b1c7..803c440 100644
--- a/compiler/rustc_typeck/src/check/mod.rs
+++ b/compiler/rustc_typeck/src/check/mod.rs
@@ -364,7 +364,7 @@ fn typeck_with_fallback<'tcx>(
let typeck_results = Inherited::build(tcx, def_id).enter(|inh| {
let param_env = tcx.param_env(def_id);
- let fcx = if let Some(hir::FnSig { header, decl, .. }) = fn_sig {
+ let (fcx, wf_tys) = if let Some(hir::FnSig { header, decl, .. }) = fn_sig {
let fn_sig = if crate::collect::get_infer_ret_ty(&decl.output).is_some() {
let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id);
<dyn AstConv<'_>>::ty_of_fn(
@@ -383,17 +383,25 @@ fn typeck_with_fallback<'tcx>(
check_abi(tcx, id, span, fn_sig.abi());
+ // When normalizing the function signature, we assume all types are
+ // well-formed. So, we don't need to worry about the obligations
+ // from normalization. We could just discard these, but to align with
+ // compare_method and elsewhere, we just add implied bounds for
+ // these types.
+ let mut wf_tys = vec![];
// Compute the fty from point of view of inside the fn.
let fn_sig = tcx.liberate_late_bound_regions(def_id.to_def_id(), fn_sig);
+ wf_tys.extend(fn_sig.inputs_and_output.iter());
let fn_sig = inh.normalize_associated_types_in(
body.value.span,
body_id.hir_id,
param_env,
fn_sig,
);
+ wf_tys.extend(fn_sig.inputs_and_output.iter());
let fcx = check_fn(&inh, param_env, fn_sig, decl, id, body, None, true).0;
- fcx
+ (fcx, wf_tys)
} else {
let fcx = FnCtxt::new(&inh, param_env, body.value.hir_id);
let expected_type = body_ty
@@ -443,7 +451,7 @@ fn typeck_with_fallback<'tcx>(
fcx.write_ty(id, expected_type);
- fcx
+ (fcx, vec![])
};
let fallback_has_occurred = fcx.type_inference_fallback();
@@ -467,7 +475,7 @@ fn typeck_with_fallback<'tcx>(
fcx.select_all_obligations_or_error();
if fn_sig.is_some() {
- fcx.regionck_fn(id, body);
+ fcx.regionck_fn(id, body, span, &wf_tys);
} else {
fcx.regionck_expr(body);
}
diff --git a/compiler/rustc_typeck/src/check/regionck.rs b/compiler/rustc_typeck/src/check/regionck.rs
index ca6828c..290fa5f 100644
--- a/compiler/rustc_typeck/src/check/regionck.rs
+++ b/compiler/rustc_typeck/src/check/regionck.rs
@@ -144,11 +144,20 @@ pub fn regionck_item(&self, item_id: hir::HirId, span: Span, wf_tys: &[Ty<'tcx>]
/// rest of type check and because sometimes we need type
/// inference to have completed before we can determine which
/// constraints to add.
- pub fn regionck_fn(&self, fn_id: hir::HirId, body: &'tcx hir::Body<'tcx>) {
+ pub(crate) fn regionck_fn(
+ &self,
+ fn_id: hir::HirId,
+ body: &'tcx hir::Body<'tcx>,
+ span: Span,
+ wf_tys: &[Ty<'tcx>],
+ ) {
debug!("regionck_fn(id={})", fn_id);
let subject = self.tcx.hir().body_owner_def_id(body.id());
let hir_id = body.value.hir_id;
let mut rcx = RegionCtxt::new(self, hir_id, Subject(subject), self.param_env);
+ // We need to add the implied bounds from the function signature
+ rcx.outlives_environment.add_implied_bounds(self, wf_tys, fn_id, span);
+ rcx.outlives_environment.save_implied_bounds(fn_id);
if !self.errors_reported_since_creation() {
// regionck assumes typeck succeeded
diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs
index ae6bebcf..a25d0f8 100644
--- a/compiler/rustc_typeck/src/check/upvar.rs
+++ b/compiler/rustc_typeck/src/check/upvar.rs
@@ -400,6 +400,11 @@ fn process_collected_capture_information(
};
capture_info.capture_kind = capture_kind;
+ let capture_info = if let Some(existing) = processed.get(&place) {
+ determine_capture_info(*existing, capture_info)
+ } else {
+ capture_info
+ };
processed.insert(place, capture_info);
}
@@ -675,15 +680,13 @@ fn perform_2229_migration_anaysis(
migrated_variables_concat
);
- let mut closure_body_span = self.tcx.hir().span(body_id.hir_id);
-
// If the body was entirely expanded from a macro
// invocation, i.e. the body is not contained inside the
// closure span, then we walk up the expansion until we
// find the span before the expansion.
- while !closure_body_span.is_dummy() && !closure_span.contains(closure_body_span) {
- closure_body_span = closure_body_span.parent().unwrap_or(DUMMY_SP);
- }
+ let closure_body_span = self.tcx.hir().span(body_id.hir_id)
+ .find_ancestor_inside(closure_span)
+ .unwrap_or(DUMMY_SP);
if let Ok(s) = self.tcx.sess.source_map().span_to_snippet(closure_body_span) {
let mut lines = s.lines();
@@ -1896,31 +1899,20 @@ fn restrict_capture_precision<'tcx>(
return (place, curr_mode);
}
-/// Take ownership if data being accessed is owned by the variable used to access it
-/// (or if closure attempts to move data that it doesn’t own).
-/// Note: When taking ownership, only capture data found on the stack.
+/// Truncate deref of any reference.
fn adjust_for_move_closure<'tcx>(
mut place: Place<'tcx>,
mut kind: ty::UpvarCapture<'tcx>,
) -> (Place<'tcx>, ty::UpvarCapture<'tcx>) {
- let contains_deref_of_ref = place.deref_tys().any(|ty| ty.is_ref());
let first_deref = place.projections.iter().position(|proj| proj.kind == ProjectionKind::Deref);
- match kind {
- ty::UpvarCapture::ByRef(..) if contains_deref_of_ref => (place, kind),
-
- // If there's any Deref and the data needs to be moved into the closure body,
- // or it's a Deref of a Box, truncate the path to the first deref
- _ => {
- if let Some(idx) = first_deref {
- truncate_place_to_len_and_update_capture_kind(&mut place, &mut kind, idx);
- }
-
- // AMAN: I think we don't need the span inside the ByValue anymore
- // we have more detailed span in CaptureInfo
- (place, ty::UpvarCapture::ByValue(None))
- }
+ if let Some(idx) = first_deref {
+ truncate_place_to_len_and_update_capture_kind(&mut place, &mut kind, idx);
}
+
+ // AMAN: I think we don't need the span inside the ByValue anymore
+ // we have more detailed span in CaptureInfo
+ (place, ty::UpvarCapture::ByValue(None))
}
/// Adjust closure capture just that if taking ownership of data, only move data
diff --git a/compiler/rustc_typeck/src/check/wfcheck.rs b/compiler/rustc_typeck/src/check/wfcheck.rs
index 2e01e99..17716af 100644
--- a/compiler/rustc_typeck/src/check/wfcheck.rs
+++ b/compiler/rustc_typeck/src/check/wfcheck.rs
@@ -290,7 +290,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
let err_ty_str;
let mut is_ptr = true;
- let err = if tcx.features().const_generics {
+ let err = if tcx.features().adt_const_params {
match ty.peel_refs().kind() {
ty::FnPtr(_) => Some("function pointers"),
ty::RawPtr(_) => Some("raw pointers"),
@@ -328,7 +328,7 @@ fn check_param_wf(tcx: TyCtxt<'_>, param: &hir::GenericParam<'_>) {
err.note("the only supported types are integers, `bool` and `char`");
if tcx.sess.is_nightly_build() {
err.help(
- "more complex types are supported with `#![feature(const_generics)]`",
+ "more complex types are supported with `#![feature(adt_const_params)]`",
);
}
err.emit()
@@ -911,6 +911,7 @@ fn visit_const(&mut self, c: &'tcx ty::Const<'tcx>) -> ControlFlow<Self::BreakTy
}
}
+#[tracing::instrument(level = "debug", skip(fcx, span, hir_decl))]
fn check_fn_or_method<'fcx, 'tcx>(
fcx: &FnCtxt<'fcx, 'tcx>,
span: Span,
@@ -921,6 +922,11 @@ fn check_fn_or_method<'fcx, 'tcx>(
) {
let sig = fcx.tcx.liberate_late_bound_regions(def_id, sig);
+ // Unnormalized types in signature are WF too
+ implied_bounds.extend(sig.inputs());
+ // FIXME(#27579) return types should not be implied bounds
+ implied_bounds.push(sig.output());
+
// Normalize the input and output types one at a time, using a different
// `WellFormedLoc` for each. We cannot call `normalize_associated_types`
// on the entire `FnSig`, since this would use the same `WellFormedLoc`
@@ -970,9 +976,11 @@ fn check_fn_or_method<'fcx, 'tcx>(
ObligationCauseCode::ReturnType,
);
- // FIXME(#25759) return types should not be implied bounds
+ // FIXME(#27579) return types should not be implied bounds
implied_bounds.push(sig.output());
+ debug!(?implied_bounds);
+
check_where_clauses(fcx, span, def_id, Some((sig.output(), hir_decl.output.span())));
}
@@ -1117,6 +1125,7 @@ fn check_opaque_types<'fcx, 'tcx>(
`self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one \
of the previous types except `Self`)";
+#[tracing::instrument(level = "debug", skip(fcx))]
fn check_method_receiver<'fcx, 'tcx>(
fcx: &FnCtxt<'fcx, 'tcx>,
fn_sig: &hir::FnSig<'_>,
diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs
index 75f9405..6412051 100644
--- a/compiler/rustc_typeck/src/collect.rs
+++ b/compiler/rustc_typeck/src/collect.rs
@@ -365,10 +365,6 @@ fn item_def_id(&self) -> Option<DefId> {
Some(self.item_def_id)
}
- fn default_constness_for_trait_bounds(&self) -> hir::Constness {
- self.node().constness_for_typeck()
- }
-
fn get_type_parameter_bounds(
&self,
span: Span,
@@ -664,7 +660,6 @@ fn type_parameter_bounds_in_generics(
only_self_bounds: OnlySelfBounds,
assoc_name: Option<Ident>,
) -> Vec<(ty::Predicate<'tcx>, Span)> {
- let constness = self.default_constness_for_trait_bounds();
let from_ty_params = ast_generics
.params
.iter()
@@ -677,7 +672,7 @@ fn type_parameter_bounds_in_generics(
Some(assoc_name) => self.bound_defines_assoc_item(b, assoc_name),
None => true,
})
- .flat_map(|b| predicates_from_bound(self, ty, b, constness));
+ .flat_map(|b| predicates_from_bound(self, ty, b));
let from_where_clauses = ast_generics
.where_clause
@@ -703,7 +698,7 @@ fn type_parameter_bounds_in_generics(
})
.filter_map(move |b| bt.map(|bt| (bt, b)))
})
- .flat_map(|(bt, b)| predicates_from_bound(self, bt, b, constness));
+ .flat_map(|(bt, b)| predicates_from_bound(self, bt, b));
from_ty_params.chain(from_where_clauses).collect()
}
@@ -751,6 +746,7 @@ fn convert_item(tcx: TyCtxt<'_>, item_id: hir::ItemId) {
// These don't define types.
hir::ItemKind::ExternCrate(_)
| hir::ItemKind::Use(..)
+ | hir::ItemKind::Macro(_)
| hir::ItemKind::Mod(_)
| hir::ItemKind::GlobalAsm(_) => {}
hir::ItemKind::ForeignMod { items, .. } => {
@@ -1493,7 +1489,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
}
// HACK(eddyb) this provides the correct generics when
- // `feature(const_generics)` is enabled, so that const expressions
+ // `feature(generic_const_expressions)` is enabled, so that const expressions
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
//
// Note that we do not supply the parent generics when using
@@ -2006,7 +2002,16 @@ fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredicates<'_> {
// prove that the trait applies to the types that were
// used, and adding the predicate into this list ensures
// that this is done.
- let span = tcx.sess.source_map().guess_head_span(tcx.def_span(def_id));
+ let mut span = tcx.def_span(def_id);
+ if tcx.sess.source_map().is_local_span(span) {
+ // `guess_head_span` reads the actual source file from
+ // disk to try to determine the 'head' snippet of the span.
+ // Don't do this for a span that comes from a file outside
+ // of our crate, since this would make our query output
+ // (and overall crate metadata) dependent on the
+ // *current* state of an external file.
+ span = tcx.sess.source_map().guess_head_span(span);
+ }
result.predicates =
tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(std::iter::once((
ty::TraitRef::identity(tcx, def_id).without_const().to_predicate(tcx),
@@ -2031,7 +2036,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
let mut is_default_impl_trait = None;
let icx = ItemCtxt::new(tcx, def_id);
- let constness = icx.default_constness_for_trait_bounds();
const NO_GENERICS: &hir::Generics<'_> = &hir::Generics::empty();
@@ -2227,8 +2231,10 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
match bound {
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
let constness = match modifier {
- hir::TraitBoundModifier::MaybeConst => hir::Constness::NotConst,
- hir::TraitBoundModifier::None => constness,
+ hir::TraitBoundModifier::None => ty::BoundConstness::NotConst,
+ hir::TraitBoundModifier::MaybeConst => {
+ ty::BoundConstness::ConstIfConst
+ }
// We ignore `where T: ?Sized`, it is already part of
// type parameter `T`.
hir::TraitBoundModifier::Maybe => continue,
@@ -2303,7 +2309,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
}
}
- if tcx.features().const_evaluatable_checked {
+ if tcx.features().generic_const_exprs {
predicates.extend(const_evaluatable_predicates_of(tcx, def_id.expect_local()));
}
@@ -2491,14 +2497,13 @@ fn predicates_from_bound<'tcx>(
astconv: &dyn AstConv<'tcx>,
param_ty: Ty<'tcx>,
bound: &'tcx hir::GenericBound<'tcx>,
- constness: hir::Constness,
) -> Vec<(ty::Predicate<'tcx>, Span)> {
match *bound {
hir::GenericBound::Trait(ref tr, modifier) => {
let constness = match modifier {
hir::TraitBoundModifier::Maybe => return vec![],
- hir::TraitBoundModifier::MaybeConst => hir::Constness::NotConst,
- hir::TraitBoundModifier::None => constness,
+ hir::TraitBoundModifier::MaybeConst => ty::BoundConstness::ConstIfConst,
+ hir::TraitBoundModifier::None => ty::BoundConstness::NotConst,
};
let mut bounds = Bounds::default();
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs
index 9bce5ee..41277b2 100644
--- a/compiler/rustc_typeck/src/collect/type_of.rs
+++ b/compiler/rustc_typeck/src/collect/type_of.rs
@@ -427,6 +427,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
}
ItemKind::Trait(..)
| ItemKind::TraitAlias(..)
+ | ItemKind::Macro(..)
| ItemKind::Mod(..)
| ItemKind::ForeignMod { .. }
| ItemKind::GlobalAsm(..)
diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs
index 024370f..3d483e3 100644
--- a/compiler/rustc_typeck/src/expr_use_visitor.rs
+++ b/compiler/rustc_typeck/src/expr_use_visitor.rs
@@ -2,6 +2,7 @@
//! normal visitor, which just walks the entire body in one shot, the
//! `ExprUseVisitor` determines how expressions are being used.
+use hir::def::DefKind;
// Export these here so that Clippy can use them.
pub use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection};
@@ -14,7 +15,7 @@
use rustc_infer::infer::InferCtxt;
use rustc_middle::hir::place::ProjectionKind;
use rustc_middle::mir::FakeReadCause;
-use rustc_middle::ty::{self, adjustment, TyCtxt};
+use rustc_middle::ty::{self, adjustment, AdtKind, Ty, TyCtxt};
use rustc_target::abi::VariantIdx;
use std::iter;
@@ -251,28 +252,37 @@ pub fn walk_expr(&mut self, expr: &hir::Expr<'_>) {
needs_to_be_read = true;
}
}
- PatKind::TupleStruct(..)
- | PatKind::Path(..)
- | PatKind::Struct(..)
- | PatKind::Tuple(..) => {
- // If the PatKind is a TupleStruct, Path, Struct or Tuple then we want to check
- // whether the Variant is a MultiVariant or a SingleVariant. We only want
- // to borrow discr if it is a MultiVariant.
- // If it is a SingleVariant and creates a binding we will handle that when
- // this callback gets called again.
+ PatKind::Path(qpath) => {
+ // A `Path` pattern is just a name like `Foo`. This is either a
+ // named constant or else it refers to an ADT variant
- // Get the type of the Place after all projections have been applied
- let place_ty = place.place.ty();
-
- if let ty::Adt(def, _) = place_ty.kind() {
- if def.variants.len() > 1 {
+ let res = self.mc.typeck_results.qpath_res(qpath, pat.hir_id);
+ match res {
+ Res::Def(DefKind::Const, _)
+ | Res::Def(DefKind::AssocConst, _) => {
+ // Named constants have to be equated with the value
+ // being matched, so that's a read of the value being matched.
+ //
+ // FIXME: We don't actually reads for ZSTs.
needs_to_be_read = true;
}
- } else {
- // If it is not ty::Adt, then it should be read
- needs_to_be_read = true;
+ _ => {
+ // Otherwise, this is a struct/enum variant, and so it's
+ // only a read if we need to read the discriminant.
+ needs_to_be_read |= is_multivariant_adt(place.place.ty());
+ }
}
}
+ PatKind::TupleStruct(..) | PatKind::Struct(..) | PatKind::Tuple(..) => {
+ // For `Foo(..)`, `Foo { ... }` and `(...)` patterns, check if we are matching
+ // against a multivariant enum or struct. In that case, we have to read
+ // the discriminant. Otherwise this kind of pattern doesn't actually
+ // read anything (we'll get invoked for the `...`, which may indeed
+ // perform some reads).
+
+ let place_ty = place.place.ty();
+ needs_to_be_read |= is_multivariant_adt(place_ty);
+ }
PatKind::Lit(_) | PatKind::Range(..) => {
// If the PatKind is a Lit or a Range then we want
// to borrow discr.
@@ -833,3 +843,22 @@ fn delegate_consume<'a, 'tcx>(
}
}
}
+
+fn is_multivariant_adt(ty: Ty<'tcx>) -> bool {
+ if let ty::Adt(def, _) = ty.kind() {
+ // Note that if a non-exhaustive SingleVariant is defined in another crate, we need
+ // to assume that more cases will be added to the variant in the future. This mean
+ // that we should handle non-exhaustive SingleVariant the same way we would handle
+ // a MultiVariant.
+ // If the variant is not local it must be defined in another crate.
+ let is_non_exhaustive = match def.adt_kind() {
+ AdtKind::Struct | AdtKind::Union => {
+ def.non_enum_variant().is_field_list_non_exhaustive()
+ }
+ AdtKind::Enum => def.is_variant_list_non_exhaustive(),
+ };
+ def.variants.len() > 1 || (!def.did.is_local() && is_non_exhaustive)
+ } else {
+ false
+ }
+}
diff --git a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
index d3e4be1..8ecd603 100644
--- a/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
+++ b/compiler/rustc_typeck/src/impl_wf_check/min_specialization.rs
@@ -68,7 +68,6 @@
use crate::constrained_generic_params as cgp;
use rustc_data_structures::fx::FxHashSet;
-use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::{InferCtxt, RegionckMode, TyCtxtInferExt};
@@ -368,7 +367,7 @@ fn check_specialization_on<'tcx>(tcx: TyCtxt<'tcx>, predicate: ty::Predicate<'tc
// items.
ty::PredicateKind::Trait(ty::TraitPredicate {
trait_ref,
- constness: hir::Constness::NotConst,
+ constness: ty::BoundConstness::NotConst,
}) => {
if !matches!(
trait_predicate_kind(tcx, predicate),
@@ -399,7 +398,7 @@ fn trait_predicate_kind<'tcx>(
match predicate.kind().skip_binder() {
ty::PredicateKind::Trait(ty::TraitPredicate {
trait_ref,
- constness: hir::Constness::NotConst,
+ constness: ty::BoundConstness::NotConst,
}) => Some(tcx.trait_def(trait_ref.def_id).specialization_kind),
ty::PredicateKind::Trait(_)
| ty::PredicateKind::RegionOutlives(_)
diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs
index 638a46f..749f681 100644
--- a/compiler/rustc_typeck/src/lib.rs
+++ b/compiler/rustc_typeck/src/lib.rs
@@ -548,7 +548,7 @@ pub fn hir_trait_to_predicates<'tcx>(
&item_cx,
hir_trait,
DUMMY_SP,
- hir::Constness::NotConst,
+ ty::BoundConstness::NotConst,
self_ty,
&mut bounds,
true,
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs
index 4b649e4..70a838a 100644
--- a/library/alloc/src/collections/btree/map.rs
+++ b/library/alloc/src/collections/btree/map.rs
@@ -233,9 +233,7 @@ fn clone_subtree<'a, K: Clone, V: Clone>(
}
if self.is_empty() {
- // Ideally we'd call `BTreeMap::new` here, but that has the `K:
- // Ord` constraint, which this method lacks.
- BTreeMap { root: None, length: 0 }
+ BTreeMap::new()
} else {
clone_subtree(self.root.as_ref().unwrap().reborrow()) // unwrap succeeds because not empty
}
@@ -499,10 +497,7 @@ impl<K, V> BTreeMap<K, V> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
- pub const fn new() -> BTreeMap<K, V>
- where
- K: Ord,
- {
+ pub const fn new() -> BTreeMap<K, V> {
BTreeMap { root: None, length: 0 }
}
@@ -522,7 +517,7 @@ pub const fn new() -> BTreeMap<K, V>
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self) {
- *self = BTreeMap { root: None, length: 0 };
+ *self = BTreeMap::new();
}
/// Returns a reference to the value corresponding to the key.
@@ -1957,7 +1952,7 @@ fn hash<H: Hasher>(&self, state: &mut H) {
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<K: Ord, V> Default for BTreeMap<K, V> {
+impl<K, V> Default for BTreeMap<K, V> {
/// Creates an empty `BTreeMap`.
fn default() -> BTreeMap<K, V> {
BTreeMap::new()
diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs
index 17e5384..a99d6c4 100644
--- a/library/alloc/src/collections/btree/map/tests.rs
+++ b/library/alloc/src/collections/btree/map/tests.rs
@@ -1745,7 +1745,7 @@ fn vacant_entry<T: Send + Ord + Default>(v: &mut BTreeMap<T, T>) -> impl Send +
}
}
-#[allow(dead_code)]
+#[test]
fn test_ord_absence() {
fn map<K>(mut map: BTreeMap<K, ()>) {
map.is_empty();
@@ -1784,6 +1784,12 @@ fn map_debug<K: Debug>(mut map: BTreeMap<K, ()>) {
fn map_clone<K: Clone>(mut map: BTreeMap<K, ()>) {
map.clone_from(&map.clone());
}
+
+ #[derive(Debug, Clone)]
+ struct NonOrd;
+ map(BTreeMap::<NonOrd, _>::new());
+ map_debug(BTreeMap::<NonOrd, _>::new());
+ map_clone(BTreeMap::<NonOrd, _>::default());
}
#[test]
diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs
index 0c268ad..ff0db22 100644
--- a/library/alloc/src/collections/btree/set.rs
+++ b/library/alloc/src/collections/btree/set.rs
@@ -246,10 +246,7 @@ impl<T> BTreeSet<T> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_new", issue = "71835")]
- pub const fn new() -> BTreeSet<T>
- where
- T: Ord,
- {
+ pub const fn new() -> BTreeSet<T> {
BTreeSet { map: BTreeMap::new() }
}
@@ -1192,7 +1189,7 @@ fn extend_one(&mut self, &elem: &'a T) {
}
#[stable(feature = "rust1", since = "1.0.0")]
-impl<T: Ord> Default for BTreeSet<T> {
+impl<T> Default for BTreeSet<T> {
/// Creates an empty `BTreeSet`.
fn default() -> BTreeSet<T> {
BTreeSet::new()
diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs
index 5d590a2..0a87ae1 100644
--- a/library/alloc/src/collections/btree/set/tests.rs
+++ b/library/alloc/src/collections/btree/set/tests.rs
@@ -607,7 +607,7 @@ fn union<T: Send + Sync + Ord>(v: &BTreeSet<T>) -> impl Send + '_ {
}
}
-#[allow(dead_code)]
+#[test]
fn test_ord_absence() {
fn set<K>(mut set: BTreeSet<K>) {
set.is_empty();
@@ -626,6 +626,12 @@ fn set_debug<K: Debug>(set: BTreeSet<K>) {
fn set_clone<K: Clone>(mut set: BTreeSet<K>) {
set.clone_from(&set.clone());
}
+
+ #[derive(Debug, Clone)]
+ struct NonOrd;
+ set(BTreeSet::<NonOrd>::new());
+ set_debug(BTreeSet::<NonOrd>::new());
+ set_clone(BTreeSet::<NonOrd>::default());
}
#[test]
diff --git a/library/alloc/tests/const_fns.rs b/library/alloc/tests/const_fns.rs
index da58ae9..f448b3eb 100644
--- a/library/alloc/tests/const_fns.rs
+++ b/library/alloc/tests/const_fns.rs
@@ -1,29 +1,5 @@
// Test const functions in the library
-use core::cmp::Ordering;
-
-// FIXME remove this struct once we put `K: ?const Ord` on BTreeMap::new.
-#[derive(PartialEq, Eq, PartialOrd)]
-pub struct MyType;
-
-impl const Ord for MyType {
- fn cmp(&self, _: &Self) -> Ordering {
- Ordering::Equal
- }
-
- fn max(self, _: Self) -> Self {
- Self
- }
-
- fn min(self, _: Self) -> Self {
- Self
- }
-
- fn clamp(self, _: Self, _: Self) -> Self {
- Self
- }
-}
-
pub const MY_VEC: Vec<usize> = Vec::new();
pub const MY_VEC2: Vec<usize> = Default::default();
@@ -32,13 +8,13 @@ fn clamp(self, _: Self, _: Self) -> Self {
use std::collections::{BTreeMap, BTreeSet};
-pub const MY_BTREEMAP: BTreeMap<MyType, MyType> = BTreeMap::new();
-pub const MAP: &'static BTreeMap<MyType, MyType> = &MY_BTREEMAP;
+pub const MY_BTREEMAP: BTreeMap<usize, usize> = BTreeMap::new();
+pub const MAP: &'static BTreeMap<usize, usize> = &MY_BTREEMAP;
pub const MAP_LEN: usize = MAP.len();
pub const MAP_IS_EMPTY: bool = MAP.is_empty();
-pub const MY_BTREESET: BTreeSet<MyType> = BTreeSet::new();
-pub const SET: &'static BTreeSet<MyType> = &MY_BTREESET;
+pub const MY_BTREESET: BTreeSet<usize> = BTreeSet::new();
+pub const SET: &'static BTreeSet<usize> = &MY_BTREESET;
pub const SET_LEN: usize = SET.len();
pub const SET_IS_EMPTY: bool = SET.is_empty();
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index 1a6d1ae..d667fff 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -76,6 +76,7 @@
#![feature(const_alloc_layout)]
#![feature(const_arguments_as_str)]
#![feature(const_assert_type)]
+#![feature(const_bigint_helper_methods)]
#![feature(const_caller_location)]
#![feature(const_cell_into_inner)]
#![feature(const_discriminant)]
diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs
index 0bc6469..1a31091 100644
--- a/library/core/src/num/int_macros.rs
+++ b/library/core/src/num/int_macros.rs
@@ -918,6 +918,40 @@ pub const fn saturating_mul(self, rhs: Self) -> Self {
}
}
+ /// Saturating integer division. Computes `self / rhs`, saturating at the
+ /// numeric bounds instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_div)]
+ ///
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_div(-1), ", stringify!($SelfT), "::MIN + 1);")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_div(-1), ", stringify!($SelfT), "::MAX);")]
+ ///
+ /// ```
+ ///
+ /// ```should_panic
+ /// #![feature(saturating_div)]
+ ///
+ #[doc = concat!("let _ = 1", stringify!($SelfT), ".saturating_div(0);")]
+ ///
+ /// ```
+ #[unstable(feature = "saturating_div", issue = "87920")]
+ #[rustc_const_unstable(feature = "saturating_div", issue = "87920")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn saturating_div(self, rhs: Self) -> Self {
+ match self.overflowing_div(rhs) {
+ (result, false) => result,
+ (_result, true) => Self::MAX, // MIN / -1 is the only possible saturating overflow
+ }
+ }
+
/// Saturating integer exponentiation. Computes `self.pow(exp)`,
/// saturating at the numeric bounds instead of overflowing.
///
@@ -1307,6 +1341,33 @@ pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) {
(a as Self, b)
}
+ /// Calculates `self + rhs + carry` without the ability to overflow.
+ ///
+ /// Performs "ternary addition" which takes in an extra bit to add, and may return an
+ /// additional bit of overflow. This allows for chaining together multiple additions
+ /// to create "big integers" which represent larger values.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage
+ ///
+ /// ```
+ /// #![feature(bigint_helper_methods)]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, false), (7, false));")]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, true), (8, false));")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), (", stringify!($SelfT), "::MIN, false));")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, true), (", stringify!($SelfT), "::MIN + 1, false));")]
+ /// ```
+ #[unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool) {
+ let (sum, carry) = (self as $UnsignedT).carrying_add(rhs as $UnsignedT, carry);
+ (sum as $SelfT, carry)
+ }
+
/// Calculates `self` - `rhs`
///
/// Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow
@@ -1331,6 +1392,33 @@ pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) {
(a as Self, b)
}
+ /// Calculates `self - rhs - borrow` without the ability to overflow.
+ ///
+ /// Performs "ternary subtraction" which takes in an extra bit to subtract, and may return
+ /// an additional bit of overflow. This allows for chaining together multiple subtractions
+ /// to create "big integers" which represent larger values.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage
+ ///
+ /// ```
+ /// #![feature(bigint_helper_methods)]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".borrowing_sub(2, false), (3, false));")]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".borrowing_sub(2, true), (2, false));")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.borrowing_sub(1, false), (", stringify!($SelfT), "::MAX, false));")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.borrowing_sub(1, true), (", stringify!($SelfT), "::MAX - 1, false));")]
+ /// ```
+ #[unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn borrowing_sub(self, rhs: Self, borrow: bool) -> (Self, bool) {
+ let (sum, borrow) = (self as $UnsignedT).borrowing_sub(rhs as $UnsignedT, borrow);
+ (sum as $SelfT, borrow)
+ }
+
/// Calculates the multiplication of `self` and `rhs`.
///
/// Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow
diff --git a/library/core/src/num/mod.rs b/library/core/src/num/mod.rs
index 9788404..59b68cb 100644
--- a/library/core/src/num/mod.rs
+++ b/library/core/src/num/mod.rs
@@ -43,8 +43,12 @@ macro_rules! unlikely {
mod error;
mod int_log10;
mod nonzero;
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+mod saturating;
mod wrapping;
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+pub use saturating::Saturating;
#[stable(feature = "rust1", since = "1.0.0")]
pub use wrapping::Wrapping;
@@ -89,20 +93,96 @@ macro_rules! usize_isize_from_xe_bytes_doc {
};
}
+macro_rules! widening_impl {
+ ($SelfT:ty, $WideT:ty, $BITS:literal) => {
+ /// Calculates the complete product `self * rhs` without the possibility to overflow.
+ ///
+ /// This returns the low-order (wrapping) bits and the high-order (overflow) bits
+ /// of the result as two separate values, in that order.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// Please note that this example is shared between integer types.
+ /// Which explains why `u32` is used here.
+ ///
+ /// ```
+ /// #![feature(bigint_helper_methods)]
+ /// assert_eq!(5u32.widening_mul(2), (10, 0));
+ /// assert_eq!(1_000_000_000u32.widening_mul(10), (1410065408, 2));
+ /// ```
+ #[unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn widening_mul(self, rhs: Self) -> (Self, Self) {
+ // note: longer-term this should be done via an intrinsic,
+ // but for now we can deal without an impl for u128/i128
+ // SAFETY: overflow will be contained within the wider types
+ let wide = unsafe { (self as $WideT).unchecked_mul(rhs as $WideT) };
+ (wide as $SelfT, (wide >> $BITS) as $SelfT)
+ }
+
+ /// Calculates the "full multiplication" `self * rhs + carry`
+ /// without the possibility to overflow.
+ ///
+ /// This returns the low-order (wrapping) bits and the high-order (overflow) bits
+ /// of the result as two separate values, in that order.
+ ///
+ /// Performs "long multiplication" which takes in an extra amount to add, and may return an
+ /// additional amount of overflow. This allows for chaining together multiple
+ /// multiplications to create "big integers" which represent larger values.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// Please note that this example is shared between integer types.
+ /// Which explains why `u32` is used here.
+ ///
+ /// ```
+ /// #![feature(bigint_helper_methods)]
+ /// assert_eq!(5u32.carrying_mul(2, 0), (10, 0));
+ /// assert_eq!(5u32.carrying_mul(2, 10), (20, 0));
+ /// assert_eq!(1_000_000_000u32.carrying_mul(10, 0), (1410065408, 2));
+ /// assert_eq!(1_000_000_000u32.carrying_mul(10, 10), (1410065418, 2));
+ /// ```
+ #[unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[rustc_const_unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn carrying_mul(self, rhs: Self, carry: Self) -> (Self, Self) {
+ // note: longer-term this should be done via an intrinsic,
+ // but for now we can deal without an impl for u128/i128
+ // SAFETY: overflow will be contained within the wider types
+ let wide = unsafe {
+ (self as $WideT).unchecked_mul(rhs as $WideT).unchecked_add(carry as $WideT)
+ };
+ (wide as $SelfT, (wide >> $BITS) as $SelfT)
+ }
+ };
+}
+
#[lang = "i8"]
impl i8 {
+ widening_impl! { i8, i16, 8 }
int_impl! { i8, i8, u8, 8, 7, -128, 127, 2, "-0x7e", "0xa", "0x12", "0x12", "0x48",
"[0x12]", "[0x12]", "", "" }
}
#[lang = "i16"]
impl i16 {
+ widening_impl! { i16, i32, 16 }
int_impl! { i16, i16, u16, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234", "0x3412",
"0x2c48", "[0x34, 0x12]", "[0x12, 0x34]", "", "" }
}
#[lang = "i32"]
impl i32 {
+ widening_impl! { i32, i64, 32 }
int_impl! { i32, i32, u32, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]", "", "" }
@@ -110,6 +190,7 @@ impl i32 {
#[lang = "i64"]
impl i64 {
+ widening_impl! { i64, i128, 64 }
int_impl! { i64, i64, u64, 64, 63, -9223372036854775808, 9223372036854775807, 12,
"0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
@@ -131,6 +212,7 @@ impl i128 {
#[cfg(target_pointer_width = "16")]
#[lang = "isize"]
impl isize {
+ widening_impl! { isize, i32, 16 }
int_impl! { isize, i16, usize, 16, 15, -32768, 32767, 4, "-0x5ffd", "0x3a", "0x1234",
"0x3412", "0x2c48", "[0x34, 0x12]", "[0x12, 0x34]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@@ -139,6 +221,7 @@ impl isize {
#[cfg(target_pointer_width = "32")]
#[lang = "isize"]
impl isize {
+ widening_impl! { isize, i64, 32 }
int_impl! { isize, i32, usize, 32, 31, -2147483648, 2147483647, 8, "0x10000b3", "0xb301",
"0x12345678", "0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]",
"[0x12, 0x34, 0x56, 0x78]",
@@ -148,6 +231,7 @@ impl isize {
#[cfg(target_pointer_width = "64")]
#[lang = "isize"]
impl isize {
+ widening_impl! { isize, i128, 64 }
int_impl! { isize, i64, usize, 64, 63, -9223372036854775808, 9223372036854775807,
12, "0xaa00000000006e1", "0x6e10aa", "0x1234567890123456", "0x5634129078563412",
"0x6a2c48091e6a2c48", "[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
@@ -160,6 +244,7 @@ impl isize {
#[lang = "u8"]
impl u8 {
+ widening_impl! { u8, u16, 8 }
uint_impl! { u8, u8, 8, 255, 2, "0x82", "0xa", "0x12", "0x12", "0x48", "[0x12]",
"[0x12]", "", "" }
@@ -693,18 +778,21 @@ pub fn escape_ascii(&self) -> ascii::EscapeDefault {
#[lang = "u16"]
impl u16 {
+ widening_impl! { u16, u32, 16 }
uint_impl! { u16, u16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]", "", "" }
}
#[lang = "u32"]
impl u32 {
+ widening_impl! { u32, u64, 32 }
uint_impl! { u32, u32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]", "", "" }
}
#[lang = "u64"]
impl u64 {
+ widening_impl! { u64, u128, 64 }
uint_impl! { u64, u64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
@@ -727,6 +815,7 @@ impl u128 {
#[cfg(target_pointer_width = "16")]
#[lang = "usize"]
impl usize {
+ widening_impl! { usize, u32, 16 }
uint_impl! { usize, u16, 16, 65535, 4, "0xa003", "0x3a", "0x1234", "0x3412", "0x2c48",
"[0x34, 0x12]", "[0x12, 0x34]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@@ -734,6 +823,7 @@ impl usize {
#[cfg(target_pointer_width = "32")]
#[lang = "usize"]
impl usize {
+ widening_impl! { usize, u64, 32 }
uint_impl! { usize, u32, 32, 4294967295, 8, "0x10000b3", "0xb301", "0x12345678",
"0x78563412", "0x1e6a2c48", "[0x78, 0x56, 0x34, 0x12]", "[0x12, 0x34, 0x56, 0x78]",
usize_isize_to_xe_bytes_doc!(), usize_isize_from_xe_bytes_doc!() }
@@ -742,6 +832,7 @@ impl usize {
#[cfg(target_pointer_width = "64")]
#[lang = "usize"]
impl usize {
+ widening_impl! { usize, u128, 64 }
uint_impl! { usize, u64, 64, 18446744073709551615, 12, "0xaa00000000006e1", "0x6e10aa",
"0x1234567890123456", "0x5634129078563412", "0x6a2c48091e6a2c48",
"[0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x34, 0x12]",
diff --git a/library/core/src/num/saturating.rs b/library/core/src/num/saturating.rs
new file mode 100644
index 0000000..f6dd360
--- /dev/null
+++ b/library/core/src/num/saturating.rs
@@ -0,0 +1,976 @@
+//! Definitions of `Saturating<T>`.
+
+use crate::fmt;
+use crate::ops::{Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign};
+use crate::ops::{BitXor, BitXorAssign, Div, DivAssign};
+use crate::ops::{Mul, MulAssign, Neg, Not, Rem, RemAssign};
+use crate::ops::{Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign};
+
+/// Provides intentionally-saturating arithmetic on `T`.
+///
+/// Operations like `+` on `u32` values are intended to never overflow,
+/// and in some debug configurations overflow is detected and results
+/// in a panic. While most arithmetic falls into this category, some
+/// code explicitly expects and relies upon saturating arithmetic.
+///
+/// Saturating arithmetic can be achieved either through methods like
+/// `saturating_add`, or through the `Saturating<T>` type, which says that
+/// all standard arithmetic operations on the underlying value are
+/// intended to have saturating semantics.
+///
+/// The underlying value can be retrieved through the `.0` index of the
+/// `Saturating` tuple.
+///
+/// # Examples
+///
+/// ```
+/// #![feature(saturating_int_impl)]
+/// use std::num::Saturating;
+///
+/// let max = Saturating(u32::MAX);
+/// let one = Saturating(1u32);
+///
+/// assert_eq!(u32::MAX, (max + one).0);
+/// ```
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Default, Hash)]
+#[repr(transparent)]
+pub struct Saturating<T>(#[unstable(feature = "saturating_int_impl", issue = "87920")] pub T);
+
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+impl<T: fmt::Debug> fmt::Debug for Saturating<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+impl<T: fmt::Display> fmt::Display for Saturating<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+impl<T: fmt::Binary> fmt::Binary for Saturating<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+impl<T: fmt::Octal> fmt::Octal for Saturating<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+impl<T: fmt::LowerHex> fmt::LowerHex for Saturating<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+impl<T: fmt::UpperHex> fmt::UpperHex for Saturating<T> {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+#[allow(unused_macros)]
+macro_rules! sh_impl_signed {
+ ($t:ident, $f:ident) => {
+ // FIXME what is the correct implementation here? see discussion https://github.com/rust-lang/rust/pull/87921#discussion_r695870065
+ //
+ // #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ // impl Shl<$f> for Saturating<$t> {
+ // type Output = Saturating<$t>;
+ //
+ // #[inline]
+ // fn shl(self, other: $f) -> Saturating<$t> {
+ // if other < 0 {
+ // Saturating(self.0.shr((-other & self::shift_max::$t as $f) as u32))
+ // } else {
+ // Saturating(self.0.shl((other & self::shift_max::$t as $f) as u32))
+ // }
+ // }
+ // }
+ // forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f,
+ // #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+ //
+ // #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ // impl ShlAssign<$f> for Saturating<$t> {
+ // #[inline]
+ // fn shl_assign(&mut self, other: $f) {
+ // *self = *self << other;
+ // }
+ // }
+ // forward_ref_op_assign! { impl ShlAssign, shl_assign for Saturating<$t>, $f }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Shr<$f> for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn shr(self, other: $f) -> Saturating<$t> {
+ if other < 0 {
+ Saturating(self.0.shl((-other & self::shift_max::$t as $f) as u32))
+ } else {
+ Saturating(self.0.shr((other & self::shift_max::$t as $f) as u32))
+ }
+ }
+ }
+ forward_ref_binop! { impl Shr, shr for Saturating<$t>, $f,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl ShrAssign<$f> for Saturating<$t> {
+ #[inline]
+ fn shr_assign(&mut self, other: $f) {
+ *self = *self >> other;
+ }
+ }
+ forward_ref_op_assign! { impl ShrAssign, shr_assign for Saturating<$t>, $f }
+ };
+}
+
+macro_rules! sh_impl_unsigned {
+ ($t:ident, $f:ident) => {
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Shl<$f> for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn shl(self, other: $f) -> Saturating<$t> {
+ Saturating(self.0.wrapping_shl(other as u32))
+ }
+ }
+ forward_ref_binop! { impl Shl, shl for Saturating<$t>, $f,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl ShlAssign<$f> for Saturating<$t> {
+ #[inline]
+ fn shl_assign(&mut self, other: $f) {
+ *self = *self << other;
+ }
+ }
+ forward_ref_op_assign! { impl ShlAssign, shl_assign for Saturating<$t>, $f }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Shr<$f> for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn shr(self, other: $f) -> Saturating<$t> {
+ Saturating(self.0.wrapping_shr(other as u32))
+ }
+ }
+ forward_ref_binop! { impl Shr, shr for Saturating<$t>, $f,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl ShrAssign<$f> for Saturating<$t> {
+ #[inline]
+ fn shr_assign(&mut self, other: $f) {
+ *self = *self >> other;
+ }
+ }
+ forward_ref_op_assign! { impl ShrAssign, shr_assign for Saturating<$t>, $f }
+ };
+}
+
+// FIXME (#23545): uncomment the remaining impls
+macro_rules! sh_impl_all {
+ ($($t:ident)*) => ($(
+ //sh_impl_unsigned! { $t, u8 }
+ //sh_impl_unsigned! { $t, u16 }
+ //sh_impl_unsigned! { $t, u32 }
+ //sh_impl_unsigned! { $t, u64 }
+ //sh_impl_unsigned! { $t, u128 }
+ sh_impl_unsigned! { $t, usize }
+
+ //sh_impl_signed! { $t, i8 }
+ //sh_impl_signed! { $t, i16 }
+ //sh_impl_signed! { $t, i32 }
+ //sh_impl_signed! { $t, i64 }
+ //sh_impl_signed! { $t, i128 }
+ //sh_impl_signed! { $t, isize }
+ )*)
+}
+
+sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
+
+// FIXME(30524): impl Op<T> for Saturating<T>, impl OpAssign<T> for Saturating<T>
+macro_rules! saturating_impl {
+ ($($t:ty)*) => ($(
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Add for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn add(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0.saturating_add(other.0))
+ }
+ }
+ forward_ref_binop! { impl Add, add for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl AddAssign for Saturating<$t> {
+ #[inline]
+ fn add_assign(&mut self, other: Saturating<$t>) {
+ *self = *self + other;
+ }
+ }
+ forward_ref_op_assign! { impl AddAssign, add_assign for Saturating<$t>, Saturating<$t> }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Sub for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn sub(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0.saturating_sub(other.0))
+ }
+ }
+ forward_ref_binop! { impl Sub, sub for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl SubAssign for Saturating<$t> {
+ #[inline]
+ fn sub_assign(&mut self, other: Saturating<$t>) {
+ *self = *self - other;
+ }
+ }
+ forward_ref_op_assign! { impl SubAssign, sub_assign for Saturating<$t>, Saturating<$t> }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Mul for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn mul(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0.saturating_mul(other.0))
+ }
+ }
+ forward_ref_binop! { impl Mul, mul for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl MulAssign for Saturating<$t> {
+ #[inline]
+ fn mul_assign(&mut self, other: Saturating<$t>) {
+ *self = *self * other;
+ }
+ }
+ forward_ref_op_assign! { impl MulAssign, mul_assign for Saturating<$t>, Saturating<$t> }
+
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl, saturating_div)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(Saturating(2", stringify!($t), "), Saturating(5", stringify!($t), ") / Saturating(2));")]
+ #[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MAX), Saturating(", stringify!($t), "::MAX) / Saturating(1));")]
+ #[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN), Saturating(", stringify!($t), "::MIN) / Saturating(1));")]
+ /// ```
+ ///
+ /// ```should_panic
+ /// #![feature(saturating_int_impl, saturating_div)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let _ = Saturating(0", stringify!($t), ") / Saturating(0);")]
+ /// ```
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Div for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn div(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0.saturating_div(other.0))
+ }
+ }
+ forward_ref_binop! { impl Div, div for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl DivAssign for Saturating<$t> {
+ #[inline]
+ fn div_assign(&mut self, other: Saturating<$t>) {
+ *self = *self / other;
+ }
+ }
+ forward_ref_op_assign! { impl DivAssign, div_assign for Saturating<$t>, Saturating<$t> }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Rem for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn rem(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0.rem(other.0))
+ }
+ }
+ forward_ref_binop! { impl Rem, rem for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl RemAssign for Saturating<$t> {
+ #[inline]
+ fn rem_assign(&mut self, other: Saturating<$t>) {
+ *self = *self % other;
+ }
+ }
+ forward_ref_op_assign! { impl RemAssign, rem_assign for Saturating<$t>, Saturating<$t> }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Not for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn not(self) -> Saturating<$t> {
+ Saturating(!self.0)
+ }
+ }
+ forward_ref_unop! { impl Not, not for Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl BitXor for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn bitxor(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0 ^ other.0)
+ }
+ }
+ forward_ref_binop! { impl BitXor, bitxor for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl BitXorAssign for Saturating<$t> {
+ #[inline]
+ fn bitxor_assign(&mut self, other: Saturating<$t>) {
+ *self = *self ^ other;
+ }
+ }
+ forward_ref_op_assign! { impl BitXorAssign, bitxor_assign for Saturating<$t>, Saturating<$t> }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl BitOr for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn bitor(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0 | other.0)
+ }
+ }
+ forward_ref_binop! { impl BitOr, bitor for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl BitOrAssign for Saturating<$t> {
+ #[inline]
+ fn bitor_assign(&mut self, other: Saturating<$t>) {
+ *self = *self | other;
+ }
+ }
+ forward_ref_op_assign! { impl BitOrAssign, bitor_assign for Saturating<$t>, Saturating<$t> }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl BitAnd for Saturating<$t> {
+ type Output = Saturating<$t>;
+
+ #[inline]
+ fn bitand(self, other: Saturating<$t>) -> Saturating<$t> {
+ Saturating(self.0 & other.0)
+ }
+ }
+ forward_ref_binop! { impl BitAnd, bitand for Saturating<$t>, Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl BitAndAssign for Saturating<$t> {
+ #[inline]
+ fn bitand_assign(&mut self, other: Saturating<$t>) {
+ *self = *self & other;
+ }
+ }
+ forward_ref_op_assign! { impl BitAndAssign, bitand_assign for Saturating<$t>, Saturating<$t> }
+
+ )*)
+}
+
+saturating_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+
+macro_rules! saturating_int_impl {
+ ($($t:ty)*) => ($(
+ impl Saturating<$t> {
+ /// Returns the smallest value that can be represented by this integer type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(<Saturating<", stringify!($t), ">>::MIN, Saturating(", stringify!($t), "::MIN));")]
+ /// ```
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const MIN: Self = Self(<$t>::MIN);
+
+ /// Returns the largest value that can be represented by this integer type.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(<Saturating<", stringify!($t), ">>::MAX, Saturating(", stringify!($t), "::MAX));")]
+ /// ```
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const MAX: Self = Self(<$t>::MAX);
+
+ /// Returns the size of this integer type in bits.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(<Saturating<", stringify!($t), ">>::BITS, ", stringify!($t), "::BITS);")]
+ /// ```
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const BITS: u32 = <$t>::BITS;
+
+ /// Returns the number of ones in the binary representation of `self`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(0b01001100", stringify!($t), ");")]
+ ///
+ /// assert_eq!(n.count_ones(), 3);
+ /// ```
+ #[inline]
+ #[doc(alias = "popcount")]
+ #[doc(alias = "popcnt")]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn count_ones(self) -> u32 {
+ self.0.count_ones()
+ }
+
+ /// Returns the number of zeros in the binary representation of `self`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(Saturating(!0", stringify!($t), ").count_zeros(), 0);")]
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn count_zeros(self) -> u32 {
+ self.0.count_zeros()
+ }
+
+ /// Returns the number of trailing zeros in the binary representation of `self`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(0b0101000", stringify!($t), ");")]
+ ///
+ /// assert_eq!(n.trailing_zeros(), 3);
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn trailing_zeros(self) -> u32 {
+ self.0.trailing_zeros()
+ }
+
+ /// Shifts the bits to the left by a specified amount, `n`,
+ /// saturating the truncated bits to the end of the resulting
+ /// integer.
+ ///
+ /// Please note this isn't the same operation as the `<<` shifting
+ /// operator!
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ /// let n: Saturating<i64> = Saturating(0x0123456789ABCDEF);
+ /// let m: Saturating<i64> = Saturating(-0x76543210FEDCBA99);
+ ///
+ /// assert_eq!(n.rotate_left(32), m);
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn rotate_left(self, n: u32) -> Self {
+ Saturating(self.0.rotate_left(n))
+ }
+
+ /// Shifts the bits to the right by a specified amount, `n`,
+ /// saturating the truncated bits to the beginning of the resulting
+ /// integer.
+ ///
+ /// Please note this isn't the same operation as the `>>` shifting
+ /// operator!
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ /// let n: Saturating<i64> = Saturating(0x0123456789ABCDEF);
+ /// let m: Saturating<i64> = Saturating(-0xFEDCBA987654322);
+ ///
+ /// assert_eq!(n.rotate_right(4), m);
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn rotate_right(self, n: u32) -> Self {
+ Saturating(self.0.rotate_right(n))
+ }
+
+ /// Reverses the byte order of the integer.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ /// let n: Saturating<i16> = Saturating(0b0000000_01010101);
+ /// assert_eq!(n, Saturating(85));
+ ///
+ /// let m = n.swap_bytes();
+ ///
+ /// assert_eq!(m, Saturating(0b01010101_00000000));
+ /// assert_eq!(m, Saturating(21760));
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn swap_bytes(self) -> Self {
+ Saturating(self.0.swap_bytes())
+ }
+
+ /// Reverses the bit pattern of the integer.
+ ///
+ /// # Examples
+ ///
+ /// Please note that this example is shared between integer types.
+ /// Which explains why `i16` is used here.
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ /// let n = Saturating(0b0000000_01010101i16);
+ /// assert_eq!(n, Saturating(85));
+ ///
+ /// let m = n.reverse_bits();
+ ///
+ /// assert_eq!(m.0 as u16, 0b10101010_00000000);
+ /// assert_eq!(m, Saturating(-22016));
+ /// ```
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ #[rustc_const_stable(feature = "const_reverse_bits", since = "1.37.0")]
+ #[inline]
+ #[must_use]
+ pub const fn reverse_bits(self) -> Self {
+ Saturating(self.0.reverse_bits())
+ }
+
+ /// Converts an integer from big endian to the target's endianness.
+ ///
+ /// On big endian this is a no-op. On little endian the bytes are
+ /// swapped.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(0x1A", stringify!($t), ");")]
+ ///
+ /// if cfg!(target_endian = "big") {
+ #[doc = concat!(" assert_eq!(<Saturating<", stringify!($t), ">>::from_be(n), n)")]
+ /// } else {
+ #[doc = concat!(" assert_eq!(<Saturating<", stringify!($t), ">>::from_be(n), n.swap_bytes())")]
+ /// }
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn from_be(x: Self) -> Self {
+ Saturating(<$t>::from_be(x.0))
+ }
+
+ /// Converts an integer from little endian to the target's endianness.
+ ///
+ /// On little endian this is a no-op. On big endian the bytes are
+ /// swapped.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(0x1A", stringify!($t), ");")]
+ ///
+ /// if cfg!(target_endian = "little") {
+ #[doc = concat!(" assert_eq!(<Saturating<", stringify!($t), ">>::from_le(n), n)")]
+ /// } else {
+ #[doc = concat!(" assert_eq!(<Saturating<", stringify!($t), ">>::from_le(n), n.swap_bytes())")]
+ /// }
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn from_le(x: Self) -> Self {
+ Saturating(<$t>::from_le(x.0))
+ }
+
+ /// Converts `self` to big endian from the target's endianness.
+ ///
+ /// On big endian this is a no-op. On little endian the bytes are
+ /// swapped.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(0x1A", stringify!($t), ");")]
+ ///
+ /// if cfg!(target_endian = "big") {
+ /// assert_eq!(n.to_be(), n)
+ /// } else {
+ /// assert_eq!(n.to_be(), n.swap_bytes())
+ /// }
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn to_be(self) -> Self {
+ Saturating(self.0.to_be())
+ }
+
+ /// Converts `self` to little endian from the target's endianness.
+ ///
+ /// On little endian this is a no-op. On big endian the bytes are
+ /// swapped.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(0x1A", stringify!($t), ");")]
+ ///
+ /// if cfg!(target_endian = "little") {
+ /// assert_eq!(n.to_le(), n)
+ /// } else {
+ /// assert_eq!(n.to_le(), n.swap_bytes())
+ /// }
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn to_le(self) -> Self {
+ Saturating(self.0.to_le())
+ }
+
+ /// Raises self to the power of `exp`, using exponentiation by squaring.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(Saturating(3", stringify!($t), ").pow(4), Saturating(81));")]
+ /// ```
+ ///
+ /// Results that are too large are saturated:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ /// assert_eq!(Saturating(3i8).pow(5), Saturating(127));
+ /// assert_eq!(Saturating(3i8).pow(6), Saturating(127));
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub fn pow(self, exp: u32) -> Self {
+ Saturating(self.0.saturating_pow(exp))
+ }
+ }
+ )*)
+}
+
+saturating_int_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
+
+macro_rules! saturating_int_impl_signed {
+ ($($t:ty)*) => ($(
+ impl Saturating<$t> {
+ /// Returns the number of leading zeros in the binary representation of `self`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(", stringify!($t), "::MAX >> 2);")]
+ ///
+ /// assert_eq!(n.leading_zeros(), 3);
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn leading_zeros(self) -> u32 {
+ self.0.leading_zeros()
+ }
+
+ /// Saturating absolute value. Computes `self.abs()`, returning `MAX` if `self == MIN`
+ /// instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(Saturating(100", stringify!($t), ").abs(), Saturating(100));")]
+ #[doc = concat!("assert_eq!(Saturating(-100", stringify!($t), ").abs(), Saturating(100));")]
+ #[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN).abs(), Saturating((", stringify!($t), "::MIN + 1).abs()));")]
+ #[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN).abs(), Saturating(", stringify!($t), "::MIN.saturating_abs()));")]
+ #[doc = concat!("assert_eq!(Saturating(", stringify!($t), "::MIN).abs(), Saturating(", stringify!($t), "::MAX));")]
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub fn abs(self) -> Saturating<$t> {
+ Saturating(self.0.saturating_abs())
+ }
+
+ /// Returns a number representing sign of `self`.
+ ///
+ /// - `0` if the number is zero
+ /// - `1` if the number is positive
+ /// - `-1` if the number is negative
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert_eq!(Saturating(10", stringify!($t), ").signum(), Saturating(1));")]
+ #[doc = concat!("assert_eq!(Saturating(0", stringify!($t), ").signum(), Saturating(0));")]
+ #[doc = concat!("assert_eq!(Saturating(-10", stringify!($t), ").signum(), Saturating(-1));")]
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub fn signum(self) -> Saturating<$t> {
+ Saturating(self.0.signum())
+ }
+
+ /// Returns `true` if `self` is positive and `false` if the number is zero or
+ /// negative.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert!(Saturating(10", stringify!($t), ").is_positive());")]
+ #[doc = concat!("assert!(!Saturating(-10", stringify!($t), ").is_positive());")]
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn is_positive(self) -> bool {
+ self.0.is_positive()
+ }
+
+ /// Returns `true` if `self` is negative and `false` if the number is zero or
+ /// positive.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert!(Saturating(-10", stringify!($t), ").is_negative());")]
+ #[doc = concat!("assert!(!Saturating(10", stringify!($t), ").is_negative());")]
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn is_negative(self) -> bool {
+ self.0.is_negative()
+ }
+ }
+
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ impl Neg for Saturating<$t> {
+ type Output = Self;
+ #[inline]
+ fn neg(self) -> Self {
+ Saturating(self.0.saturating_neg())
+ }
+ }
+ forward_ref_unop! { impl Neg, neg for Saturating<$t>,
+ #[unstable(feature = "saturating_int_impl", issue = "87920")] }
+ )*)
+}
+
+saturating_int_impl_signed! { isize i8 i16 i32 i64 i128 }
+
+macro_rules! saturating_int_impl_unsigned {
+ ($($t:ty)*) => ($(
+ impl Saturating<$t> {
+ /// Returns the number of leading zeros in the binary representation of `self`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("let n = Saturating(", stringify!($t), "::MAX >> 2);")]
+ ///
+ /// assert_eq!(n.leading_zeros(), 2);
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub const fn leading_zeros(self) -> u32 {
+ self.0.leading_zeros()
+ }
+
+ /// Returns `true` if and only if `self == 2^k` for some `k`.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_int_impl)]
+ /// use std::num::Saturating;
+ ///
+ #[doc = concat!("assert!(Saturating(16", stringify!($t), ").is_power_of_two());")]
+ #[doc = concat!("assert!(!Saturating(10", stringify!($t), ").is_power_of_two());")]
+ /// ```
+ #[inline]
+ #[unstable(feature = "saturating_int_impl", issue = "87920")]
+ pub fn is_power_of_two(self) -> bool {
+ self.0.is_power_of_two()
+ }
+
+ }
+ )*)
+}
+
+saturating_int_impl_unsigned! { usize u8 u16 u32 u64 u128 }
+
+// Related to potential Shl and ShlAssign implementation
+//
+// mod shift_max {
+// #![allow(non_upper_case_globals)]
+//
+// #[cfg(target_pointer_width = "16")]
+// mod platform {
+// pub const usize: u32 = super::u16;
+// pub const isize: u32 = super::i16;
+// }
+//
+// #[cfg(target_pointer_width = "32")]
+// mod platform {
+// pub const usize: u32 = super::u32;
+// pub const isize: u32 = super::i32;
+// }
+//
+// #[cfg(target_pointer_width = "64")]
+// mod platform {
+// pub const usize: u32 = super::u64;
+// pub const isize: u32 = super::i64;
+// }
+//
+// pub const i8: u32 = (1 << 3) - 1;
+// pub const i16: u32 = (1 << 4) - 1;
+// pub const i32: u32 = (1 << 5) - 1;
+// pub const i64: u32 = (1 << 6) - 1;
+// pub const i128: u32 = (1 << 7) - 1;
+// pub use self::platform::isize;
+//
+// pub const u8: u32 = i8;
+// pub const u16: u32 = i16;
+// pub const u32: u32 = i32;
+// pub const u64: u32 = i64;
+// pub const u128: u32 = i128;
+// pub use self::platform::usize;
+// }
diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs
index ae113a4..9366efb 100644
--- a/library/core/src/num/uint_macros.rs
+++ b/library/core/src/num/uint_macros.rs
@@ -1041,6 +1041,36 @@ pub const fn saturating_mul(self, rhs: Self) -> Self {
}
}
+ /// Saturating integer division. Computes `self / rhs`, saturating at the
+ /// numeric bounds instead of overflowing.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage:
+ ///
+ /// ```
+ /// #![feature(saturating_div)]
+ ///
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")]
+ ///
+ /// ```
+ ///
+ /// ```should_panic
+ /// #![feature(saturating_div)]
+ ///
+ #[doc = concat!("let _ = 1", stringify!($SelfT), ".saturating_div(0);")]
+ ///
+ /// ```
+ #[unstable(feature = "saturating_div", issue = "87920")]
+ #[rustc_const_unstable(feature = "saturating_div", issue = "87920")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn saturating_div(self, rhs: Self) -> Self {
+ // on unsigned types, there is no overflow in integer division
+ self.wrapping_div(rhs)
+ }
+
/// Saturating integer exponentiation. Computes `self.pow(exp)`,
/// saturating at the numeric bounds instead of overflowing.
///
@@ -1378,6 +1408,36 @@ pub const fn overflowing_add(self, rhs: Self) -> (Self, bool) {
(a as Self, b)
}
+ /// Calculates `self + rhs + carry` without the ability to overflow.
+ ///
+ /// Performs "ternary addition" which takes in an extra bit to add, and may return an
+ /// additional bit of overflow. This allows for chaining together multiple additions
+ /// to create "big integers" which represent larger values.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage
+ ///
+ /// ```
+ /// #![feature(bigint_helper_methods)]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, false), (7, false));")]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".carrying_add(2, true), (8, false));")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, false), (0, true));")]
+ #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.carrying_add(1, true), (1, true));")]
+ /// ```
+ #[unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn carrying_add(self, rhs: Self, carry: bool) -> (Self, bool) {
+ // note: longer-term this should be done via an intrinsic, but this has been shown
+ // to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic
+ let (a, b) = self.overflowing_add(rhs);
+ let (c, d) = a.overflowing_add(carry as $SelfT);
+ (c, b | d)
+ }
+
/// Calculates `self` - `rhs`
///
/// Returns a tuple of the subtraction along with a boolean indicating
@@ -1403,6 +1463,36 @@ pub const fn overflowing_sub(self, rhs: Self) -> (Self, bool) {
(a as Self, b)
}
+ /// Calculates `self - rhs - borrow` without the ability to overflow.
+ ///
+ /// Performs "ternary subtraction" which takes in an extra bit to subtract, and may return
+ /// an additional bit of overflow. This allows for chaining together multiple subtractions
+ /// to create "big integers" which represent larger values.
+ ///
+ /// # Examples
+ ///
+ /// Basic usage
+ ///
+ /// ```
+ /// #![feature(bigint_helper_methods)]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".borrowing_sub(2, false), (3, false));")]
+ #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".borrowing_sub(2, true), (2, false));")]
+ #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".borrowing_sub(1, false), (", stringify!($SelfT), "::MAX, true));")]
+ #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".borrowing_sub(1, true), (", stringify!($SelfT), "::MAX - 1, true));")]
+ /// ```
+ #[unstable(feature = "bigint_helper_methods", issue = "85532")]
+ #[rustc_const_unstable(feature = "const_bigint_helper_methods", issue = "85532")]
+ #[must_use = "this returns the result of the operation, \
+ without modifying the original"]
+ #[inline]
+ pub const fn borrowing_sub(self, rhs: Self, borrow: bool) -> (Self, bool) {
+ // note: longer-term this should be done via an intrinsic, but this has been shown
+ // to generate optimal code for now, and LLVM doesn't have an equivalent intrinsic
+ let (a, b) = self.overflowing_sub(rhs);
+ let (c, d) = a.overflowing_sub(borrow as $SelfT);
+ (c, b | d)
+ }
+
/// Calculates the multiplication of `self` and `rhs`.
///
/// Returns a tuple of the multiplication along with a boolean
diff --git a/library/core/src/time.rs b/library/core/src/time.rs
index 2d8a1cb..35b740c 100644
--- a/library/core/src/time.rs
+++ b/library/core/src/time.rs
@@ -2,14 +2,21 @@
//! Temporal quantification.
//!
-//! Example:
+//! # Examples:
+//!
+//! There are multiple ways to create a new [`Duration`]:
//!
//! ```
-//! use std::time::Duration;
+//! # use std::time::Duration;
+//! let five_seconds = Duration::from_secs(5);
+//! assert_eq!(five_seconds, Duration::from_millis(5_000));
+//! assert_eq!(five_seconds, Duration::from_micros(5_000_000));
+//! assert_eq!(five_seconds, Duration::from_nanos(5_000_000_000));
//!
-//! let five_seconds = Duration::new(5, 0);
-//! // both declarations are equivalent
-//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5));
+//! let ten_seconds = Duration::from_secs(10);
+//! let seven_nanos = Duration::from_nanos(7);
+//! let total = ten_seconds + seven_nanos;
+//! assert_eq!(total, Duration::new(10, 7));
//! ```
use crate::fmt;
diff --git a/library/std/src/env.rs b/library/std/src/env.rs
index a746520..e343073 100644
--- a/library/std/src/env.rs
+++ b/library/std/src/env.rs
@@ -616,6 +616,9 @@ pub fn temp_dir() -> PathBuf {
/// return the path of the symbolic link and other platforms will return the
/// path of the symbolic link’s target.
///
+/// If the executable is renamed while it is running, platforms may return the
+/// path at the time it was loaded instead of the new path.
+///
/// # Errors
///
/// Acquiring the path of the current executable is a platform-specific operation
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 5e91a0c..028a066 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -310,6 +310,8 @@
#![feature(ptr_internals)]
#![feature(rustc_attrs)]
#![feature(rustc_private)]
+#![feature(saturating_div)]
+#![feature(saturating_int_impl)]
#![feature(slice_concat_ext)]
#![feature(slice_internals)]
#![feature(slice_ptr_get)]
diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs
index 336891e..5b4a9fa 100644
--- a/library/std/src/net/tcp.rs
+++ b/library/std/src/net/tcp.rs
@@ -401,6 +401,53 @@ pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
self.0.peek(buf)
}
+ /// Sets the value of the `SO_LINGER` option on this socket.
+ ///
+ /// This value controls how the socket is closed when data remains
+ /// to be sent. If `SO_LINGER` is set, the socket will remain open
+ /// for the specified duration as the system attempts to send pending data.
+ /// Otherwise, the system may close the socket immediately, or wait for a
+ /// default timeout.
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// #![feature(tcp_linger)]
+ ///
+ /// use std::net::TcpStream;
+ /// use std::time::Duration;
+ ///
+ /// let stream = TcpStream::connect("127.0.0.1:8080")
+ /// .expect("Couldn't connect to the server...");
+ /// stream.set_linger(Some(Duration::from_secs(0))).expect("set_linger call failed");
+ /// ```
+ #[unstable(feature = "tcp_linger", issue = "88494")]
+ pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
+ self.0.set_linger(linger)
+ }
+
+ /// Gets the value of the `SO_LINGER` option on this socket.
+ ///
+ /// For more information about this option, see [`TcpStream::set_linger`].
+ ///
+ /// # Examples
+ ///
+ /// ```no_run
+ /// #![feature(tcp_linger)]
+ ///
+ /// use std::net::TcpStream;
+ /// use std::time::Duration;
+ ///
+ /// let stream = TcpStream::connect("127.0.0.1:8080")
+ /// .expect("Couldn't connect to the server...");
+ /// stream.set_linger(Some(Duration::from_secs(0))).expect("set_linger call failed");
+ /// assert_eq!(stream.linger().unwrap(), Some(Duration::from_secs(0)));
+ /// ```
+ #[unstable(feature = "tcp_linger", issue = "88494")]
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ self.0.linger()
+ }
+
/// Sets the value of the `TCP_NODELAY` option on this socket.
///
/// If set, this option disables the Nagle algorithm. This means that
diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs
index 387a361..c2061c1 100644
--- a/library/std/src/net/tcp/tests.rs
+++ b/library/std/src/net/tcp/tests.rs
@@ -769,6 +769,21 @@ fn test_timeout_zero_duration() {
#[test]
#[cfg_attr(target_env = "sgx", ignore)]
+fn linger() {
+ let addr = next_test_ip4();
+ let _listener = t!(TcpListener::bind(&addr));
+
+ let stream = t!(TcpStream::connect(&("localhost", addr.port())));
+
+ assert_eq!(None, t!(stream.linger()));
+ t!(stream.set_linger(Some(Duration::from_secs(1))));
+ assert_eq!(Some(Duration::from_secs(1)), t!(stream.linger()));
+ t!(stream.set_linger(None));
+ assert_eq!(None, t!(stream.linger()));
+}
+
+#[test]
+#[cfg_attr(target_env = "sgx", ignore)]
fn nodelay() {
let addr = next_test_ip4();
let _listener = t!(TcpListener::bind(&addr));
diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs
index 8715058..6354752 100644
--- a/library/std/src/net/udp.rs
+++ b/library/std/src/net/udp.rs
@@ -39,7 +39,7 @@
///
/// fn main() -> std::io::Result<()> {
/// {
-/// let mut socket = UdpSocket::bind("127.0.0.1:34254")?;
+/// let socket = UdpSocket::bind("127.0.0.1:34254")?;
///
/// // Receives a single datagram message on the socket. If `buf` is too small to hold
/// // the message, it will be cut off.
diff --git a/library/std/src/num.rs b/library/std/src/num.rs
index e7051f0..46064bd 100644
--- a/library/std/src/num.rs
+++ b/library/std/src/num.rs
@@ -12,6 +12,8 @@
#[cfg(test)]
mod benches;
+#[unstable(feature = "saturating_int_impl", issue = "87920")]
+pub use core::num::Saturating;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::num::Wrapping;
#[stable(feature = "rust1", since = "1.0.0")]
diff --git a/library/std/src/sys/hermit/net.rs b/library/std/src/sys/hermit/net.rs
index 3f0c99c..880ef67 100644
--- a/library/std/src/sys/hermit/net.rs
+++ b/library/std/src/sys/hermit/net.rs
@@ -182,6 +182,14 @@ pub fn duplicate(&self) -> io::Result<TcpStream> {
Ok(self.clone())
}
+ pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
+ unsupported()
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ unsupported()
+ }
+
pub fn set_nodelay(&self, mode: bool) -> io::Result<()> {
abi::tcpstream::set_nodelay(*self.0.as_inner(), mode)
.map_err(|_| io::Error::new_const(ErrorKind::Uncategorized, &"set_nodelay failed"))
diff --git a/library/std/src/sys/sgx/net.rs b/library/std/src/sys/sgx/net.rs
index 3a69aa0..89c5af6 100644
--- a/library/std/src/sys/sgx/net.rs
+++ b/library/std/src/sys/sgx/net.rs
@@ -183,6 +183,14 @@ pub fn duplicate(&self) -> io::Result<TcpStream> {
Ok(self.clone())
}
+ pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
+ sgx_ineffective(())
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ sgx_ineffective(None)
+ }
+
pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
sgx_ineffective(())
}
diff --git a/library/std/src/sys/unix/l4re.rs b/library/std/src/sys/unix/l4re.rs
index 3cf637c..ba63b41 100644
--- a/library/std/src/sys/unix/l4re.rs
+++ b/library/std/src/sys/unix/l4re.rs
@@ -98,6 +98,14 @@ pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
unimpl!();
}
+ pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
+ unimpl!();
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ unimpl!();
+ }
+
pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
unimpl!();
}
@@ -214,6 +222,14 @@ pub fn duplicate(&self) -> io::Result<TcpStream> {
unimpl!();
}
+ pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
+ unimpl!();
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ unimpl!();
+ }
+
pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
unimpl!();
}
diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs
index c2f5da1..9ae6d12d 100644
--- a/library/std/src/sys/unix/net.rs
+++ b/library/std/src/sys/unix/net.rs
@@ -12,6 +12,14 @@
use libc::{c_int, c_void, size_t, sockaddr, socklen_t, MSG_PEEK};
+cfg_if::cfg_if! {
+ if #[cfg(target_vendor = "apple")] {
+ use libc::SO_LINGER_SEC as SO_LINGER;
+ } else {
+ use libc::SO_LINGER;
+ }
+}
+
pub use crate::sys::{cvt, cvt_r};
#[allow(unused_extern_crates)]
@@ -376,6 +384,21 @@ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
Ok(())
}
+ pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
+ let linger = libc::linger {
+ l_onoff: linger.is_some() as libc::c_int,
+ l_linger: linger.unwrap_or_default().as_secs() as libc::c_int,
+ };
+
+ setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger)
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ let val: libc::linger = getsockopt(self, libc::SOL_SOCKET, SO_LINGER)?;
+
+ Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64)))
+ }
+
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
setsockopt(self, libc::IPPROTO_TCP, libc::TCP_NODELAY, nodelay as c_int)
}
diff --git a/library/std/src/sys/unix/stack_overflow.rs b/library/std/src/sys/unix/stack_overflow.rs
index 81f47a7..e8747e3 100644
--- a/library/std/src/sys/unix/stack_overflow.rs
+++ b/library/std/src/sys/unix/stack_overflow.rs
@@ -161,24 +161,10 @@ unsafe fn get_stackp() -> *mut libc::c_void {
stackp.add(page_size())
}
- #[cfg(any(
- target_os = "linux",
- target_os = "macos",
- target_os = "freebsd",
- target_os = "netbsd",
- target_os = "openbsd",
- target_os = "solaris",
- target_os = "illumos"
- ))]
unsafe fn get_stack() -> libc::stack_t {
libc::stack_t { ss_sp: get_stackp(), ss_flags: 0, ss_size: SIGSTKSZ }
}
- #[cfg(target_os = "dragonfly")]
- unsafe fn get_stack() -> libc::stack_t {
- libc::stack_t { ss_sp: get_stackp() as *mut i8, ss_flags: 0, ss_size: SIGSTKSZ }
- }
-
pub unsafe fn make_handler() -> Handler {
if !NEED_ALTSTACK.load(Ordering::Relaxed) {
return Handler::null();
diff --git a/library/std/src/sys/unsupported/net.rs b/library/std/src/sys/unsupported/net.rs
index 96203c7..dbb6ce2 100644
--- a/library/std/src/sys/unsupported/net.rs
+++ b/library/std/src/sys/unsupported/net.rs
@@ -76,6 +76,14 @@ pub fn duplicate(&self) -> io::Result<TcpStream> {
self.0
}
+ pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
+ self.0
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ self.0
+ }
+
pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
self.0
}
diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs
index c7c4a9f..a4dbb22 100644
--- a/library/std/src/sys/wasi/net.rs
+++ b/library/std/src/sys/wasi/net.rs
@@ -127,6 +127,14 @@ pub fn duplicate(&self) -> io::Result<TcpStream> {
unsupported()
}
+ pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> {
+ unsupported()
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ unsupported()
+ }
+
pub fn set_nodelay(&self, _: bool) -> io::Result<()> {
unsupported()
}
diff --git a/library/std/src/sys/windows/c.rs b/library/std/src/sys/windows/c.rs
index 63f9be7..cedf389 100644
--- a/library/std/src/sys/windows/c.rs
+++ b/library/std/src/sys/windows/c.rs
@@ -197,6 +197,7 @@ fn clone(&self) -> Self {
pub const SOCK_STREAM: c_int = 1;
pub const SOCKET_ERROR: c_int = -1;
pub const SOL_SOCKET: c_int = 0xffff;
+pub const SO_LINGER: c_int = 0x0080;
pub const SO_RCVTIMEO: c_int = 0x1006;
pub const SO_SNDTIMEO: c_int = 0x1005;
pub const IPPROTO_IP: c_int = 0;
@@ -217,6 +218,13 @@ fn clone(&self) -> Self {
pub const MSG_PEEK: c_int = 0x2;
#[repr(C)]
+#[derive(Copy, Clone)]
+pub struct linger {
+ pub l_onoff: c_ushort,
+ pub l_linger: c_ushort,
+}
+
+#[repr(C)]
pub struct ip_mreq {
pub imr_multiaddr: in_addr,
pub imr_interface: in_addr,
diff --git a/library/std/src/sys/windows/net.rs b/library/std/src/sys/windows/net.rs
index 55aacb3..33152cc 100644
--- a/library/std/src/sys/windows/net.rs
+++ b/library/std/src/sys/windows/net.rs
@@ -15,7 +15,7 @@
use crate::sys_common::{AsInner, FromInner, IntoInner};
use crate::time::Duration;
-use libc::{c_int, c_long, c_ulong};
+use libc::{c_int, c_long, c_ulong, c_ushort};
pub type wrlen_t = i32;
@@ -446,6 +446,21 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
cvt(result).map(drop)
}
+ pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
+ let linger = c::linger {
+ l_onoff: linger.is_some() as c_ushort,
+ l_linger: linger.unwrap_or_default().as_secs() as c_ushort,
+ };
+
+ net::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger)
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ let val: c::linger = net::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?;
+
+ Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64)))
+ }
+
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
net::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BYTE)
}
diff --git a/library/std/src/sys_common/net.rs b/library/std/src/sys_common/net.rs
index 0ffa5c0..c5c3df3 100644
--- a/library/std/src/sys_common/net.rs
+++ b/library/std/src/sys_common/net.rs
@@ -297,6 +297,14 @@ pub fn duplicate(&self) -> io::Result<TcpStream> {
self.inner.duplicate().map(|s| TcpStream { inner: s })
}
+ pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
+ self.inner.set_linger(linger)
+ }
+
+ pub fn linger(&self) -> io::Result<Option<Duration>> {
+ self.inner.linger()
+ }
+
pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> {
self.inner.set_nodelay(nodelay)
}
diff --git a/library/std/src/time.rs b/library/std/src/time.rs
index ec105f2..e9207ee 100644
--- a/library/std/src/time.rs
+++ b/library/std/src/time.rs
@@ -1,13 +1,32 @@
//! Temporal quantification.
//!
-//! Example:
+//! # Examples:
+//!
+//! There are multiple ways to create a new [`Duration`]:
//!
//! ```
-//! use std::time::Duration;
+//! # use std::time::Duration;
+//! let five_seconds = Duration::from_secs(5);
+//! assert_eq!(five_seconds, Duration::from_millis(5_000));
+//! assert_eq!(five_seconds, Duration::from_micros(5_000_000));
+//! assert_eq!(five_seconds, Duration::from_nanos(5_000_000_000));
//!
-//! let five_seconds = Duration::new(5, 0);
-//! // both declarations are equivalent
-//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5));
+//! let ten_seconds = Duration::from_secs(10);
+//! let seven_nanos = Duration::from_nanos(7);
+//! let total = ten_seconds + seven_nanos;
+//! assert_eq!(total, Duration::new(10, 7));
+//! ```
+//!
+//! Using [`Instant`] to calculate how long a function took to run:
+//!
+//! ```ignore (incomplete)
+//! let now = Instant::now();
+//!
+//! // Calling a slow function, it may take a while
+//! slow_function();
+//!
+//! let elapsed_time = now.elapsed();
+//! println!("Running slow_function() took {} seconds.", elapsed_time.as_secs());
//! ```
#![stable(feature = "time", since = "1.3.0")]
@@ -26,7 +45,7 @@
pub use core::time::Duration;
/// A measurement of a monotonically nondecreasing clock.
-/// Opaque and useful only with `Duration`.
+/// Opaque and useful only with [`Duration`].
///
/// Instants are always guaranteed to be no less than any previously measured
/// instant when created, and are often useful for tasks such as measuring
diff --git a/library/stdarch b/library/stdarch
index c158cfd..89b0e35 160000
--- a/library/stdarch
+++ b/library/stdarch
@@ -1 +1 @@
-Subproject commit c158cfd38e20d855f5d6ca8a5a101eefb82604a8
+Subproject commit 89b0e355bc3cff5cddec2290c84f36eb3a026aad
diff --git a/library/unwind/build.rs b/library/unwind/build.rs
index 0529d24..1d0b4a5 100644
--- a/library/unwind/build.rs
+++ b/library/unwind/build.rs
@@ -4,36 +4,18 @@ fn main() {
println!("cargo:rerun-if-changed=build.rs");
let target = env::var("TARGET").expect("TARGET was not set");
- if cfg!(target_os = "linux") && cfg!(feature = "system-llvm-libunwind") {
- // linking for Linux is handled in lib.rs
- return;
- }
+ if target.contains("android") {
+ let build = cc::Build::new();
- if cfg!(feature = "llvm-libunwind")
- && ((target.contains("linux") && !target.contains("musl")) || target.contains("fuchsia"))
- {
- // Build the unwinding from libunwind C/C++ source code.
- llvm_libunwind::compile();
- } else if target.contains("x86_64-fortanix-unknown-sgx") {
- llvm_libunwind::compile();
- } else if target.contains("linux") {
- // linking for Linux is handled in lib.rs
- if target.contains("musl") {
- llvm_libunwind::compile();
- } else if target.contains("android") {
- let build = cc::Build::new();
+ // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
+ // check if we have `libunwind` available and if so use it. Otherwise
+ // fall back to `libgcc` to support older ndk versions.
+ let has_unwind = build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
- // Since ndk r23 beta 3 `libgcc` was replaced with `libunwind` thus
- // check if we have `libunwind` available and if so use it. Otherwise
- // fall back to `libgcc` to support older ndk versions.
- let has_unwind =
- build.is_flag_supported("-lunwind").expect("Unable to invoke compiler");
-
- if has_unwind {
- println!("cargo:rustc-link-lib=unwind");
- } else {
- println!("cargo:rustc-link-lib=gcc");
- }
+ if has_unwind {
+ println!("cargo:rustc-link-lib=unwind");
+ } else {
+ println!("cargo:rustc-link-lib=gcc");
}
} else if target.contains("freebsd") {
println!("cargo:rustc-link-lib=gcc_s");
@@ -63,111 +45,3 @@ fn main() {
// redox is handled in lib.rs
}
}
-
-mod llvm_libunwind {
- use std::env;
- use std::path::Path;
-
- /// Compile the libunwind C/C++ source code.
- pub fn compile() {
- let target = env::var("TARGET").expect("TARGET was not set");
- let target_env = env::var("CARGO_CFG_TARGET_ENV").unwrap();
- let mut cc_cfg = cc::Build::new();
- let mut cpp_cfg = cc::Build::new();
- let root = Path::new("../../src/llvm-project/libunwind");
-
- cpp_cfg.cpp(true);
- cpp_cfg.cpp_set_stdlib(None);
- cpp_cfg.flag("-nostdinc++");
- cpp_cfg.flag("-fno-exceptions");
- cpp_cfg.flag("-fno-rtti");
- cpp_cfg.flag_if_supported("-fvisibility-global-new-delete-hidden");
-
- // Don't set this for clang
- // By default, Clang builds C code in GNU C17 mode.
- // By default, Clang builds C++ code according to the C++98 standard,
- // with many C++11 features accepted as extensions.
- if cpp_cfg.get_compiler().is_like_gnu() {
- cpp_cfg.flag("-std=c++11");
- cc_cfg.flag("-std=c99");
- }
-
- if target.contains("x86_64-fortanix-unknown-sgx") || target_env == "musl" {
- // use the same GCC C compiler command to compile C++ code so we do not need to setup the
- // C++ compiler env variables on the builders.
- // Don't set this for clang++, as clang++ is able to compile this without libc++.
- if cpp_cfg.get_compiler().is_like_gnu() {
- cpp_cfg.cpp(false);
- }
- }
-
- for cfg in [&mut cc_cfg, &mut cpp_cfg].iter_mut() {
- cfg.warnings(false);
- cfg.flag("-fstrict-aliasing");
- cfg.flag("-funwind-tables");
- cfg.flag("-fvisibility=hidden");
- cfg.define("_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS", None);
- cfg.include(root.join("include"));
- cfg.cargo_metadata(false);
-
- if target.contains("x86_64-fortanix-unknown-sgx") {
- cfg.static_flag(true);
- cfg.opt_level(3);
- cfg.flag("-fno-stack-protector");
- cfg.flag("-ffreestanding");
- cfg.flag("-fexceptions");
-
- // easiest way to undefine since no API available in cc::Build to undefine
- cfg.flag("-U_FORTIFY_SOURCE");
- cfg.define("_FORTIFY_SOURCE", "0");
- cfg.define("RUST_SGX", "1");
- cfg.define("__NO_STRING_INLINES", None);
- cfg.define("__NO_MATH_INLINES", None);
- cfg.define("_LIBUNWIND_IS_BAREMETAL", None);
- cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
- cfg.define("NDEBUG", None);
- }
- }
-
- let mut c_sources = vec![
- "Unwind-sjlj.c",
- "UnwindLevel1-gcc-ext.c",
- "UnwindLevel1.c",
- "UnwindRegistersRestore.S",
- "UnwindRegistersSave.S",
- ];
-
- let cpp_sources = vec!["Unwind-EHABI.cpp", "Unwind-seh.cpp", "libunwind.cpp"];
- let cpp_len = cpp_sources.len();
-
- if target.contains("x86_64-fortanix-unknown-sgx") {
- c_sources.push("UnwindRustSgx.c");
- }
-
- for src in c_sources {
- cc_cfg.file(root.join("src").join(src).canonicalize().unwrap());
- }
-
- for src in cpp_sources {
- cpp_cfg.file(root.join("src").join(src).canonicalize().unwrap());
- }
-
- let out_dir = env::var("OUT_DIR").unwrap();
- println!("cargo:rustc-link-search=native={}", &out_dir);
-
- cpp_cfg.compile("unwind-cpp");
-
- let mut count = 0;
- for entry in std::fs::read_dir(&out_dir).unwrap() {
- let obj = entry.unwrap().path().canonicalize().unwrap();
- if let Some(ext) = obj.extension() {
- if ext == "o" {
- cc_cfg.object(&obj);
- count += 1;
- }
- }
- }
- assert_eq!(cpp_len, count, "Can't get object files from {:?}", &out_dir);
- cc_cfg.compile("unwind");
- }
-}
diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs
index 53b13b9..06384b1 100644
--- a/library/unwind/src/lib.rs
+++ b/library/unwind/src/lib.rs
@@ -1,6 +1,8 @@
#![no_std]
#![unstable(feature = "panic_unwind", issue = "32837")]
#![feature(link_cfg)]
+#![feature(native_link_modifiers)]
+#![feature(native_link_modifiers_bundle)]
#![feature(nll)]
#![feature(staged_api)]
#![feature(static_nobundle)]
@@ -42,14 +44,14 @@
if #[cfg(all(feature = "llvm-libunwind", feature = "system-llvm-libunwind"))] {
compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time");
} else if #[cfg(feature = "llvm-libunwind")] {
- #[link(name = "unwind", kind = "static")]
+ #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
} else if #[cfg(feature = "system-llvm-libunwind")] {
- #[link(name = "unwind", kind = "static-nobundle", cfg(target_feature = "crt-static"))]
+ #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "unwind", cfg(not(target_feature = "crt-static")))]
extern "C" {}
} else {
- #[link(name = "unwind", kind = "static", cfg(target_feature = "crt-static"))]
+ #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
}
@@ -77,10 +79,10 @@
extern "C" {}
#[cfg(target_os = "redox")]
-#[link(name = "gcc_eh", kind = "static-nobundle", cfg(target_feature = "crt-static"))]
+#[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))]
#[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))]
extern "C" {}
#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
-#[link(name = "unwind", kind = "static")]
+#[link(name = "unwind", kind = "static", modifiers = "-bundle")]
extern "C" {}
diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs
index 196be74..5e15fe7 100644
--- a/library/unwind/src/libunwind.rs
+++ b/library/unwind/src/libunwind.rs
@@ -77,9 +77,18 @@ pub enum _Unwind_Context {}
pub type _Unwind_Exception_Cleanup_Fn =
extern "C" fn(unwind_code: _Unwind_Reason_Code, exception: *mut _Unwind_Exception);
+
+// FIXME: The `#[link]` attributes on `extern "C"` block marks those symbols declared in
+// the block are reexported in dylib build of libstd. This is needed when build rustc with
+// feature `llvm-libunwind', as no other cdylib will provided those _Unwind_* symbols.
+// However the `link` attribute is duplicated multiple times and does not just export symbol,
+// a better way to manually export symbol would be another attribute like `#[export]`.
+// See the logic in function rustc_codegen_ssa::src::back::exported_symbols, module
+// rustc_codegen_ssa::src::back::symbol_export, rustc_middle::middle::exported_symbols
+// and RFC 2841
#[cfg_attr(
all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
- link(name = "unwind", kind = "static")
+ link(name = "unwind", kind = "static", modifiers = "-bundle")
)]
extern "C-unwind" {
pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !;
@@ -106,9 +115,10 @@ pub enum _Unwind_Action {
}
pub use _Unwind_Action::*;
- #[cfg_attr(all(feature = "llvm-libunwind",
- any(target_os = "fuchsia", target_os = "linux")),
- link(name = "unwind", kind = "static"))]
+ #[cfg_attr(
+ all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
+ link(name = "unwind", kind = "static", modifiers = "-bundle")
+ )]
extern "C" {
pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word;
pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word);
@@ -163,9 +173,10 @@ enum _Unwind_VRS_DataRepresentation {
pub const UNWIND_SP_REG: c_int = 13;
pub const UNWIND_IP_REG: c_int = 15;
- #[cfg_attr(all(feature = "llvm-libunwind",
- any(target_os = "fuchsia", target_os = "linux")),
- link(name = "unwind", kind = "static"))]
+ #[cfg_attr(
+ all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
+ link(name = "unwind", kind = "static", modifiers = "-bundle")
+ )]
extern "C" {
fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context,
regclass: _Unwind_VRS_RegClass,
@@ -228,9 +239,10 @@ pub unsafe fn _Unwind_FindEnclosingFunction(pc: *mut c_void) -> *mut c_void {
cfg_if::cfg_if! {
if #[cfg(not(all(target_os = "ios", target_arch = "arm")))] {
// Not 32-bit iOS
- #[cfg_attr(all(feature = "llvm-libunwind",
- any(target_os = "fuchsia", target_os = "linux")),
- link(name = "unwind", kind = "static"))]
+ #[cfg_attr(
+ all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux")),
+ link(name = "unwind", kind = "static", modifiers = "-bundle")
+ )]
extern "C-unwind" {
pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
}
@@ -241,9 +253,6 @@ pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn,
}
} else {
// 32-bit iOS uses SjLj and does not provide _Unwind_Backtrace()
- #[cfg_attr(all(feature = "llvm-libunwind",
- any(target_os = "fuchsia", target_os = "linux")),
- link(name = "unwind", kind = "static"))]
extern "C-unwind" {
pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code;
}
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index d259899..8f27ada 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -23,7 +23,7 @@
use crate::builder::Cargo;
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::cache::{Interned, INTERNER};
-use crate::config::TargetSelection;
+use crate::config::{LlvmLibunwind, TargetSelection};
use crate::dist;
use crate::native;
use crate::tool::SourceType;
@@ -234,6 +234,18 @@ fn copy_self_contained_objects(
}
}
+ if target.contains("musl")
+ || target.contains("x86_64-fortanix-unknown-sgx")
+ || builder.config.llvm_libunwind == LlvmLibunwind::InTree
+ && (target.contains("linux") || target.contains("fuchsia"))
+ {
+ let libunwind_path = builder.ensure(native::Libunwind { target });
+ let libunwind_source = libunwind_path.join("libunwind.a");
+ let libunwind_target = libdir_self_contained.join("libunwind.a");
+ builder.copy(&libunwind_source, &libunwind_target);
+ target_deps.push((libunwind_target, DependencyType::TargetSelfContained));
+ }
+
target_deps
}
@@ -1121,6 +1133,10 @@ fn run(self, builder: &Builder<'_>) -> Compiler {
&lld_install.join("bin").join(&src_exe),
&gcc_ld_dir.join(exe("ld", target_compiler.host)),
);
+ builder.copy(
+ &lld_install.join("bin").join(&src_exe),
+ &gcc_ld_dir.join(exe("ld64", target_compiler.host)),
+ );
}
// Similarly, copy `llvm-dwp` into libdir for Split DWARF. Only copy it when the LLVM
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index d7d511c..7c1bb1a 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -412,6 +412,8 @@ fn prepare_image(builder: &Builder<'_>, compiler: Compiler, image: &Path) {
let gcc_lld_dir = dst_dir.join("gcc-ld");
t!(fs::create_dir(&gcc_lld_dir));
builder.copy(&src_dir.join(&rust_lld), &gcc_lld_dir.join(exe("ld", compiler.host)));
+ builder
+ .copy(&src_dir.join(&rust_lld), &gcc_lld_dir.join(exe("ld64", compiler.host)));
}
// Copy over llvm-dwp if it's there
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 2172b01..0a23d4f 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -10,7 +10,7 @@
use std::env;
use std::env::consts::EXE_EXTENSION;
-use std::ffi::OsString;
+use std::ffi::{OsStr, OsString};
use std::fs::{self, File};
use std::io;
use std::path::{Path, PathBuf};
@@ -952,3 +952,154 @@ fn run(self, builder: &Builder<'_>) -> Self::Output {
out_dir
}
}
+
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+pub struct Libunwind {
+ pub target: TargetSelection,
+}
+
+impl Step for Libunwind {
+ type Output = PathBuf;
+
+ fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
+ run.path("src/llvm-project/libunwind")
+ }
+
+ fn make_run(run: RunConfig<'_>) {
+ run.builder.ensure(Libunwind { target: run.target });
+ }
+
+ /// Build linunwind.a
+ fn run(self, builder: &Builder<'_>) -> Self::Output {
+ if builder.config.dry_run {
+ return PathBuf::new();
+ }
+
+ let out_dir = builder.native_dir(self.target).join("libunwind");
+ let root = builder.src.join("src/llvm-project/libunwind");
+
+ if up_to_date(&root, &out_dir.join("libunwind.a")) {
+ return out_dir;
+ }
+
+ builder.info(&format!("Building libunwind.a for {}", self.target.triple));
+ t!(fs::create_dir_all(&out_dir));
+
+ let mut cc_cfg = cc::Build::new();
+ let mut cpp_cfg = cc::Build::new();
+
+ cpp_cfg.cpp(true);
+ cpp_cfg.cpp_set_stdlib(None);
+ cpp_cfg.flag("-nostdinc++");
+ cpp_cfg.flag("-fno-exceptions");
+ cpp_cfg.flag("-fno-rtti");
+ cpp_cfg.flag_if_supported("-fvisibility-global-new-delete-hidden");
+
+ for cfg in [&mut cc_cfg, &mut cpp_cfg].iter_mut() {
+ if let Some(ar) = builder.ar(self.target) {
+ cfg.archiver(ar);
+ }
+ cfg.target(&self.target.triple);
+ cfg.host(&builder.config.build.triple);
+ cfg.warnings(false);
+ cfg.debug(false);
+ // get_compiler() need set opt_level first.
+ cfg.opt_level(3);
+ cfg.flag("-fstrict-aliasing");
+ cfg.flag("-funwind-tables");
+ cfg.flag("-fvisibility=hidden");
+ cfg.define("_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS", None);
+ cfg.include(root.join("include"));
+ cfg.cargo_metadata(false);
+ cfg.out_dir(&out_dir);
+
+ if self.target.contains("x86_64-fortanix-unknown-sgx") {
+ cfg.static_flag(true);
+ cfg.flag("-fno-stack-protector");
+ cfg.flag("-ffreestanding");
+ cfg.flag("-fexceptions");
+
+ // easiest way to undefine since no API available in cc::Build to undefine
+ cfg.flag("-U_FORTIFY_SOURCE");
+ cfg.define("_FORTIFY_SOURCE", "0");
+ cfg.define("RUST_SGX", "1");
+ cfg.define("__NO_STRING_INLINES", None);
+ cfg.define("__NO_MATH_INLINES", None);
+ cfg.define("_LIBUNWIND_IS_BAREMETAL", None);
+ cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
+ cfg.define("NDEBUG", None);
+ }
+ }
+
+ cc_cfg.compiler(builder.cc(self.target));
+ if let Ok(cxx) = builder.cxx(self.target) {
+ cpp_cfg.compiler(cxx);
+ } else {
+ cc_cfg.compiler(builder.cc(self.target));
+ }
+
+ // Don't set this for clang
+ // By default, Clang builds C code in GNU C17 mode.
+ // By default, Clang builds C++ code according to the C++98 standard,
+ // with many C++11 features accepted as extensions.
+ if cc_cfg.get_compiler().is_like_gnu() {
+ cc_cfg.flag("-std=c99");
+ }
+ if cpp_cfg.get_compiler().is_like_gnu() {
+ cpp_cfg.flag("-std=c++11");
+ }
+
+ if self.target.contains("x86_64-fortanix-unknown-sgx") || self.target.contains("musl") {
+ // use the same GCC C compiler command to compile C++ code so we do not need to setup the
+ // C++ compiler env variables on the builders.
+ // Don't set this for clang++, as clang++ is able to compile this without libc++.
+ if cpp_cfg.get_compiler().is_like_gnu() {
+ cpp_cfg.cpp(false);
+ cpp_cfg.compiler(builder.cc(self.target));
+ }
+ }
+
+ let mut c_sources = vec![
+ "Unwind-sjlj.c",
+ "UnwindLevel1-gcc-ext.c",
+ "UnwindLevel1.c",
+ "UnwindRegistersRestore.S",
+ "UnwindRegistersSave.S",
+ ];
+
+ let cpp_sources = vec!["Unwind-EHABI.cpp", "Unwind-seh.cpp", "libunwind.cpp"];
+ let cpp_len = cpp_sources.len();
+
+ if self.target.contains("x86_64-fortanix-unknown-sgx") {
+ c_sources.push("UnwindRustSgx.c");
+ }
+
+ for src in c_sources {
+ cc_cfg.file(root.join("src").join(src).canonicalize().unwrap());
+ }
+
+ for src in &cpp_sources {
+ cpp_cfg.file(root.join("src").join(src).canonicalize().unwrap());
+ }
+
+ cpp_cfg.compile("unwind-cpp");
+
+ // FIXME: https://github.com/alexcrichton/cc-rs/issues/545#issuecomment-679242845
+ let mut count = 0;
+ for entry in fs::read_dir(&out_dir).unwrap() {
+ let file = entry.unwrap().path().canonicalize().unwrap();
+ if file.is_file() && file.extension() == Some(OsStr::new("o")) {
+ // file name starts with "Unwind-EHABI", "Unwind-seh" or "libunwind"
+ let file_name = file.file_name().unwrap().to_str().expect("UTF-8 file name");
+ if cpp_sources.iter().any(|f| file_name.starts_with(&f[..f.len() - 4])) {
+ cc_cfg.object(&file);
+ count += 1;
+ }
+ }
+ }
+ assert_eq!(cpp_len, count, "Can't get object files from {:?}", &out_dir);
+
+ cc_cfg.compile("unwind");
+ out_dir
+ }
+}
diff --git a/src/doc/rustc/src/command-line-arguments.md b/src/doc/rustc/src/command-line-arguments.md
index 7d3cad7..7f482f0 100644
--- a/src/doc/rustc/src/command-line-arguments.md
+++ b/src/doc/rustc/src/command-line-arguments.md
@@ -93,7 +93,7 @@
<a id="option-edition"></a>
## `--edition`: specify the edition to use
-This flag takes a value of `2015` or `2018`. The default is `2015`. More
+This flag takes a value of `2015`, `2018` or `2021`. The default is `2015`. More
information about editions may be found in the [edition guide].
[edition guide]: ../edition-guide/introduction.html
diff --git a/src/doc/unstable-book/src/library-features/asm.md b/src/doc/unstable-book/src/library-features/asm.md
index 220b74c..a10928a 100644
--- a/src/doc/unstable-book/src/library-features/asm.md
+++ b/src/doc/unstable-book/src/library-features/asm.md
@@ -31,6 +31,7 @@
- MIPS32r2 and MIPS64r2
- wasm32
- BPF
+- SPIR-V
## Basic usage
@@ -188,8 +189,7 @@
Some instructions require that the operands be in a specific register.
Therefore, Rust inline assembly provides some more specific constraint specifiers.
-While `reg` is generally available on any architecture, these are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi`
-among others can be addressed by their name.
+While `reg` is generally available on any architecture, explicit registers are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi` among others can be addressed by their name.
```rust,allow_fail,no_run
#![feature(asm)]
@@ -199,11 +199,9 @@
}
```
-In this example we call the `out` instruction to output the content of the `cmd` variable
-to port `0x64`. Since the `out` instruction only accepts `eax` (and its sub registers) as operand
-we had to use the `eax` constraint specifier.
+In this example we call the `out` instruction to output the content of the `cmd` variable to port `0x64`. Since the `out` instruction only accepts `eax` (and its sub registers) as operand we had to use the `eax` constraint specifier.
-Note that unlike other operand types, explicit register operands cannot be used in the template string: you can't use `{}` and should write the register name directly instead. Also, they must appear at the end of the operand list after all other operand types.
+> **Note**: unlike other operand types, explicit register operands cannot be used in the template string: you can't use `{}` and should write the register name directly instead. Also, they must appear at the end of the operand list after all other operand types.
Consider this example which uses the x86 `mul` instruction:
@@ -237,11 +235,9 @@
## Clobbered registers
In many cases inline assembly will modify state that is not needed as an output.
-Usually this is either because we have to use a scratch register in the assembly,
-or instructions modify state that we don't need to further examine.
+Usually this is either because we have to use a scratch register in the assembly or because instructions modify state that we don't need to further examine.
This state is generally referred to as being "clobbered".
-We need to tell the compiler about this since it may need to save and restore this state
-around the inline assembly block.
+We need to tell the compiler about this since it may need to save and restore this state around the inline assembly block.
```rust,allow_fail
#![feature(asm)]
@@ -321,8 +317,7 @@
}
```
-Note that the `fn` or `static` item does not need to be public or `#[no_mangle]`:
-the compiler will automatically insert the appropriate mangled symbol name into the assembly code.
+Note that the `fn` or `static` item does not need to be public or `#[no_mangle]`: the compiler will automatically insert the appropriate mangled symbol name into the assembly code.
By default, `asm!` assumes that any register not specified as an output will have its contents preserved by the assembly code. The [`clobber_abi`](#abi-clobbers) argument to `asm!` tells the compiler to automatically insert the necessary clobber operands according to the given calling convention ABI: any register which is not fully preserved in that ABI will be treated as clobbered.
@@ -355,9 +350,8 @@
## Memory address operands
Sometimes assembly instructions require operands passed via memory addresses/memory locations.
-You have to manually use the memory address syntax specified by the respectively architectures.
-For example, in x86/x86_64 and intel assembly syntax, you should wrap inputs/outputs in `[]`
-to indicate they are memory operands:
+You have to manually use the memory address syntax specified by the target architecture.
+For example, on x86/x86_64 using intel assembly syntax, you should wrap inputs/outputs in `[]` to indicate they are memory operands:
```rust,allow_fail
#![feature(asm, llvm_asm)]
@@ -373,9 +367,15 @@
## Labels
-The compiler is allowed to instantiate multiple copies an `asm!` block, for example when the function containing it is inlined in multiple places. As a consequence, you should only use GNU assembler [local labels] inside inline assembly code. Defining symbols in assembly code may lead to assembler and/or linker errors due to duplicate symbol definitions.
+Any reuse of a named label, local or otherwise, can result in a assembler or linker error or may cause other strange behavior. Reuse of a named label can happen in a variety of ways including:
-Moreover, due to [an llvm bug], you shouldn't use labels exclusively made of `0` and `1` digits, e.g. `0`, `11` or `101010`, as they may end up being interpreted as binary values.
+- explicitly: using a label more than once in one `asm!` block, or multiple times across blocks
+- implicitly via inlining: the compiler is allowed to instantiate multiple copies of an `asm!` block, for example when the function containing it is inlined in multiple places.
+- implicitly via LTO: LTO can cause code from *other crates* to be placed in the same codegen unit, and so could bring in arbitrary labels
+
+As a consequence, you should only use GNU assembler **numeric** [local labels] inside inline assembly code. Defining symbols in assembly code may lead to assembler and/or linker errors due to duplicate symbol definitions.
+
+Moreover, on x86 when using the default intel syntax, due to [an llvm bug], you shouldn't use labels exclusively made of `0` and `1` digits, e.g. `0`, `11` or `101010`, as they may end up being interpreted as binary values. Using `option(att_syntax)` will avoid any ambiguity, but that affects the syntax of the _entire_ `asm!` block.
```rust,allow_fail
#![feature(asm)]
@@ -410,7 +410,7 @@
## Options
-By default, an inline assembly block is treated the same way as an external FFI function call with a custom calling convention: it may read/write memory, have observable side effects, etc. However in many cases, it is desirable to give the compiler more information about what the assembly code is actually doing so that it can optimize better.
+By default, an inline assembly block is treated the same way as an external FFI function call with a custom calling convention: it may read/write memory, have observable side effects, etc. However, in many cases it is desirable to give the compiler more information about what the assembly code is actually doing so that it can optimize better.
Let's take our previous example of an `add` instruction:
@@ -470,6 +470,7 @@
- MIPS32r2 and MIPS64r2
- wasm32
- BPF
+- SPIR-V
Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.
@@ -584,6 +585,8 @@
| PowerPC | `reg` | `r[0-31]` | `r` |
| PowerPC | `reg_nonzero` | | `r[1-31]` | `b` |
| PowerPC | `freg` | `f[0-31]` | `f` |
+| PowerPC | `cr` | `cr[0-7]`, `cr` | Only clobbers |
+| PowerPC | `xer` | `xer` | Only clobbers |
| wasm32 | `local` | None\* | `r` |
| BPF | `reg` | `r[0-10]` | `r` |
| BPF | `wreg` | `w[0-10]` | `w` |
@@ -637,6 +640,8 @@
| PowerPC | `reg` | None | `i8`, `i16`, `i32` |
| PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32` |
| PowerPC | `freg` | None | `f32`, `f64` |
+| PowerPC | `cr` | N/A | Only clobbers |
+| PowerPC | `xer` | N/A | Only clobbers |
| wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` |
| BPF | `reg` | None | `i8` `i16` `i32` `i64` |
| BPF | `wreg` | `alu32` | `i8` `i16` `i32` |
@@ -836,7 +841,7 @@
- Note that a `lateout` may be allocated to the same register as an `in`, in which case this rule does not apply. Code should not rely on this however since it depends on the results of register allocation.
- Behavior is undefined if execution unwinds out of an asm block.
- This also applies if the assembly code calls a function which then unwinds.
-- The set of memory locations that assembly code is allowed the read and write are the same as those allowed for an FFI function.
+- The set of memory locations that assembly code is allowed to read and write are the same as those allowed for an FFI function.
- Refer to the unsafe code guidelines for the exact rules.
- If the `readonly` option is set, then only memory reads are allowed.
- If the `nomem` option is set then no reads or writes to memory are allowed.
diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs
index fa29b54..0c81a55 100644
--- a/src/librustdoc/clean/inline.rs
+++ b/src/librustdoc/clean/inline.rs
@@ -9,7 +9,7 @@
use rustc_hir::def::{DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::Mutability;
-use rustc_metadata::creader::LoadedMacro;
+use rustc_metadata::creader::{CStore, LoadedMacro};
use rustc_middle::ty::{self, TyCtxt};
use rustc_span::hygiene::MacroKind;
use rustc_span::symbol::{kw, sym, Symbol};
@@ -179,7 +179,7 @@
let fqn = if let ItemType::Macro = kind {
// Check to see if it is a macro 2.0 or built-in macro
if matches!(
- cx.enter_resolver(|r| r.cstore().load_macro_untracked(did, cx.sess())),
+ CStore::from_tcx(cx.tcx).load_macro_untracked(did, cx.sess()),
LoadedMacro::MacroDef(def, _)
if matches!(&def.kind, ast::ItemKind::MacroDef(ast_def)
if !ast_def.macro_rules)
@@ -558,7 +558,7 @@ fn build_macro(
import_def_id: Option<DefId>,
) -> clean::ItemKind {
let imported_from = cx.tcx.crate_name(def_id.krate);
- match cx.enter_resolver(|r| r.cstore().load_macro_untracked(def_id, cx.sess())) {
+ match CStore::from_tcx(cx.tcx).load_macro_untracked(def_id, cx.sess()) {
LoadedMacro::MacroDef(item_def, _) => {
if let ast::ItemKind::MacroDef(ref def) = item_def.kind {
clean::MacroItem(clean::Macro {
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs
index b6ff389..b566239 100644
--- a/src/librustdoc/clean/mod.rs
+++ b/src/librustdoc/clean/mod.rs
@@ -91,7 +91,6 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
items.extend(self.foreigns.iter().map(|x| x.clean(cx)));
items.extend(self.mods.iter().map(|x| x.clean(cx)));
items.extend(self.items.iter().map(|x| x.clean(cx)).flatten());
- items.extend(self.macros.iter().map(|x| x.clean(cx)));
// determine if we should display the inner contents or
// the outer `mod` item for the source code.
@@ -1703,12 +1702,28 @@ fn clean(&self, cx: &mut DocContext<'_>) -> VariantStruct {
}
}
+impl Clean<Vec<Item>> for hir::VariantData<'_> {
+ fn clean(&self, cx: &mut DocContext<'_>) -> Vec<Item> {
+ self.fields().iter().map(|x| x.clean(cx)).collect()
+ }
+}
+
impl Clean<Item> for ty::VariantDef {
fn clean(&self, cx: &mut DocContext<'_>) -> Item {
let kind = match self.ctor_kind {
CtorKind::Const => Variant::CLike,
CtorKind::Fn => Variant::Tuple(
- self.fields.iter().map(|f| cx.tcx.type_of(f.did).clean(cx)).collect(),
+ self.fields
+ .iter()
+ .map(|field| {
+ let name = Some(field.ident.name);
+ let kind = StructFieldItem(cx.tcx.type_of(field.did).clean(cx));
+ let what_rustc_thinks =
+ Item::from_def_id_and_parts(field.did, name, kind, cx);
+ // don't show `pub` for fields, which are always public
+ Item { visibility: Visibility::Inherited, ..what_rustc_thinks }
+ })
+ .collect(),
),
CtorKind::Fictive => Variant::Struct(VariantStruct {
struct_type: CtorKind::Fictive,
@@ -1738,13 +1753,7 @@ impl Clean<Variant> for hir::VariantData<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> Variant {
match self {
hir::VariantData::Struct(..) => Variant::Struct(self.clean(cx)),
- // Important note here: `Variant::Tuple` is used on tuple structs which are not in an
- // enum (so where converting from `ty::VariantDef`). In case we are in an enum, the kind
- // is provided by the `Variant` wrapper directly, and since we need the fields' name
- // (even for a tuple struct variant!), it's simpler to just store it as a
- // `Variant::Struct` instead of a `Variant::Tuple` (otherwise it would force us to make
- // a lot of changes when rendering them to generate the name as well).
- hir::VariantData::Tuple(..) => Variant::Struct(self.clean(cx)),
+ hir::VariantData::Tuple(..) => Variant::Tuple(self.clean(cx)),
hir::VariantData::Unit(..) => Variant::CLike,
}
}
@@ -1861,6 +1870,10 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Vec<Item> {
ItemKind::Fn(ref sig, ref generics, body_id) => {
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
}
+ ItemKind::Macro(ref macro_def) => MacroItem(Macro {
+ source: display_macro_source(cx, name, ¯o_def, def_id, &item.vis),
+ imported_from: None,
+ }),
ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
let items = item_ids
.iter()
@@ -2138,24 +2151,6 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Item {
}
}
-impl Clean<Item> for (&hir::MacroDef<'_>, Option<Symbol>) {
- fn clean(&self, cx: &mut DocContext<'_>) -> Item {
- let (item, renamed) = self;
- let name = renamed.unwrap_or(item.ident.name);
- let def_id = item.def_id.to_def_id();
-
- Item::from_hir_id_and_parts(
- item.hir_id(),
- Some(name),
- MacroItem(Macro {
- source: display_macro_source(cx, name, &item.ast, def_id, &item.vis),
- imported_from: None,
- }),
- cx,
- )
- }
-}
-
impl Clean<TypeBinding> for hir::TypeBinding<'_> {
fn clean(&self, cx: &mut DocContext<'_>) -> TypeBinding {
TypeBinding { name: self.ident.name, kind: self.kind.clean(cx) }
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 7025574..4194c99 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -715,6 +715,7 @@ impl ItemKind {
StructItem(s) => s.fields.iter(),
UnionItem(u) => u.fields.iter(),
VariantItem(Variant::Struct(v)) => v.fields.iter(),
+ VariantItem(Variant::Tuple(v)) => v.iter(),
EnumItem(e) => e.variants.iter(),
TraitItem(t) => t.items.iter(),
ImplItem(i) => i.items.iter(),
@@ -1937,7 +1938,7 @@ impl Visibility {
#[derive(Clone, Debug)]
crate enum Variant {
CLike,
- Tuple(Vec<Type>),
+ Tuple(Vec<Item>),
Struct(VariantStruct),
}
diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs
index 083d82c..bf14a17 100644
--- a/src/librustdoc/doctest.rs
+++ b/src/librustdoc/doctest.rs
@@ -1171,10 +1171,21 @@ fn nested_visit_map(&mut self) -> intravisit::NestedVisitorMap<Self::Map> {
}
fn visit_item(&mut self, item: &'hir hir::Item<'_>) {
- let name = if let hir::ItemKind::Impl(impl_) = &item.kind {
- rustc_hir_pretty::id_to_string(&self.map, impl_.self_ty.hir_id)
- } else {
- item.ident.to_string()
+ let name = match &item.kind {
+ hir::ItemKind::Macro(ref macro_def) => {
+ // FIXME(#88038): Non exported macros have historically not been tested,
+ // but we really ought to start testing them.
+ let def_id = item.def_id.to_def_id();
+ if macro_def.macro_rules && !self.tcx.has_attr(def_id, sym::macro_export) {
+ intravisit::walk_item(self, item);
+ return;
+ }
+ item.ident.to_string()
+ }
+ hir::ItemKind::Impl(impl_) => {
+ rustc_hir_pretty::id_to_string(&self.map, impl_.self_ty.hir_id)
+ }
+ _ => item.ident.to_string(),
};
self.visit_testable(name, item.hir_id(), item.span, |this| {
@@ -1216,15 +1227,6 @@ fn visit_field_def(&mut self, f: &'hir hir::FieldDef<'_>) {
intravisit::walk_field_def(this, f);
});
}
-
- fn visit_macro_def(&mut self, macro_def: &'hir hir::MacroDef<'_>) {
- self.visit_testable(
- macro_def.ident.to_string(),
- macro_def.hir_id(),
- macro_def.span,
- |_| (),
- );
- }
}
#[cfg(test)]
diff --git a/src/librustdoc/doctree.rs b/src/librustdoc/doctree.rs
index eadac89..8f1e8f2 100644
--- a/src/librustdoc/doctree.rs
+++ b/src/librustdoc/doctree.rs
@@ -5,6 +5,7 @@
use rustc_hir as hir;
+#[derive(Debug)]
crate struct Module<'hir> {
crate name: Symbol,
crate where_inner: Span,
@@ -13,20 +14,11 @@
// (item, renamed)
crate items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>)>,
crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
- crate macros: Vec<(&'hir hir::MacroDef<'hir>, Option<Symbol>)>,
}
impl Module<'hir> {
crate fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Module<'hir> {
- Module {
- name,
- id,
- where_inner,
- mods: Vec::new(),
- items: Vec::new(),
- foreigns: Vec::new(),
- macros: Vec::new(),
- }
+ Module { name, id, where_inner, mods: Vec::new(), items: Vec::new(), foreigns: Vec::new() }
}
crate fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs
index 45aae71..b4859e4 100644
--- a/src/librustdoc/fold.rs
+++ b/src/librustdoc/fold.rs
@@ -56,6 +56,10 @@ fn fold_inner_recur(&mut self, kind: ItemKind) -> ItemKind {
|| j.fields.iter().any(|f| f.is_stripped());
VariantItem(Variant::Struct(j))
}
+ Variant::Tuple(fields) => {
+ let fields = fields.into_iter().filter_map(|x| self.fold_item(x)).collect();
+ VariantItem(Variant::Tuple(fields))
+ }
_ => VariantItem(i2),
}
}
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs
index eb7c12d..54be830 100644
--- a/src/librustdoc/html/format.rs
+++ b/src/librustdoc/html/format.rs
@@ -387,7 +387,7 @@ impl clean::GenericBound {
let modifier_str = match modifier {
hir::TraitBoundModifier::None => "",
hir::TraitBoundModifier::Maybe => "?",
- hir::TraitBoundModifier::MaybeConst => "?const",
+ hir::TraitBoundModifier::MaybeConst => "~const",
};
if f.alternate() {
write!(f, "{}{:#}", modifier_str, ty.print(cx))
diff --git a/src/librustdoc/html/length_limit.rs b/src/librustdoc/html/length_limit.rs
new file mode 100644
index 0000000..bbdc91c
--- /dev/null
+++ b/src/librustdoc/html/length_limit.rs
@@ -0,0 +1,119 @@
+//! See [`HtmlWithLimit`].
+
+use std::fmt::Write;
+use std::ops::ControlFlow;
+
+use crate::html::escape::Escape;
+
+/// A buffer that allows generating HTML with a length limit.
+///
+/// This buffer ensures that:
+///
+/// * all tags are closed,
+/// * tags are closed in the reverse order of when they were opened (i.e., the correct HTML order),
+/// * no tags are left empty (e.g., `<em></em>`) due to the length limit being reached,
+/// * all text is escaped.
+#[derive(Debug)]
+pub(super) struct HtmlWithLimit {
+ buf: String,
+ len: usize,
+ limit: usize,
+ /// A list of tags that have been requested to be opened via [`Self::open_tag()`]
+ /// but have not actually been pushed to `buf` yet. This ensures that tags are not
+ /// left empty (e.g., `<em></em>`) due to the length limit being reached.
+ queued_tags: Vec<&'static str>,
+ /// A list of all tags that have been opened but not yet closed.
+ unclosed_tags: Vec<&'static str>,
+}
+
+impl HtmlWithLimit {
+ /// Create a new buffer, with a limit of `length_limit`.
+ pub(super) fn new(length_limit: usize) -> Self {
+ let buf = if length_limit > 1000 {
+ // If the length limit is really large, don't preallocate tons of memory.
+ String::new()
+ } else {
+ // The length limit is actually a good heuristic for initial allocation size.
+ // Measurements showed that using it as the initial capacity ended up using less memory
+ // than `String::new`.
+ // See https://github.com/rust-lang/rust/pull/88173#discussion_r692531631 for more.
+ String::with_capacity(length_limit)
+ };
+ Self {
+ buf,
+ len: 0,
+ limit: length_limit,
+ unclosed_tags: Vec::new(),
+ queued_tags: Vec::new(),
+ }
+ }
+
+ /// Finish using the buffer and get the written output.
+ /// This function will close all unclosed tags for you.
+ pub(super) fn finish(mut self) -> String {
+ self.close_all_tags();
+ self.buf
+ }
+
+ /// Write some plain text to the buffer, escaping as needed.
+ ///
+ /// This function skips writing the text if the length limit was reached
+ /// and returns [`ControlFlow::Break`].
+ pub(super) fn push(&mut self, text: &str) -> ControlFlow<(), ()> {
+ if self.len + text.len() > self.limit {
+ return ControlFlow::BREAK;
+ }
+
+ self.flush_queue();
+ write!(self.buf, "{}", Escape(text)).unwrap();
+ self.len += text.len();
+
+ ControlFlow::CONTINUE
+ }
+
+ /// Open an HTML tag.
+ ///
+ /// **Note:** HTML attributes have not yet been implemented.
+ /// This function will panic if called with a non-alphabetic `tag_name`.
+ pub(super) fn open_tag(&mut self, tag_name: &'static str) {
+ assert!(
+ tag_name.chars().all(|c| ('a'..='z').contains(&c)),
+ "tag_name contained non-alphabetic chars: {:?}",
+ tag_name
+ );
+ self.queued_tags.push(tag_name);
+ }
+
+ /// Close the most recently opened HTML tag.
+ pub(super) fn close_tag(&mut self) {
+ match self.unclosed_tags.pop() {
+ // Close the most recently opened tag.
+ Some(tag_name) => write!(self.buf, "</{}>", tag_name).unwrap(),
+ // There are valid cases where `close_tag()` is called without
+ // there being any tags to close. For example, this occurs when
+ // a tag is opened after the length limit is exceeded;
+ // `flush_queue()` will never be called, and thus, the tag will
+ // not end up being added to `unclosed_tags`.
+ None => {}
+ }
+ }
+
+ /// Write all queued tags and add them to the `unclosed_tags` list.
+ fn flush_queue(&mut self) {
+ for tag_name in self.queued_tags.drain(..) {
+ write!(self.buf, "<{}>", tag_name).unwrap();
+
+ self.unclosed_tags.push(tag_name);
+ }
+ }
+
+ /// Close all unclosed tags.
+ fn close_all_tags(&mut self) {
+ while !self.unclosed_tags.is_empty() {
+ self.close_tag();
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests;
diff --git a/src/librustdoc/html/length_limit/tests.rs b/src/librustdoc/html/length_limit/tests.rs
new file mode 100644
index 0000000..2d02b8a
--- /dev/null
+++ b/src/librustdoc/html/length_limit/tests.rs
@@ -0,0 +1,120 @@
+use super::*;
+
+#[test]
+fn empty() {
+ assert_eq!(HtmlWithLimit::new(0).finish(), "");
+ assert_eq!(HtmlWithLimit::new(60).finish(), "");
+}
+
+#[test]
+fn basic() {
+ let mut buf = HtmlWithLimit::new(60);
+ buf.push("Hello ");
+ buf.open_tag("em");
+ buf.push("world");
+ buf.close_tag();
+ buf.push("!");
+ assert_eq!(buf.finish(), "Hello <em>world</em>!");
+}
+
+#[test]
+fn no_tags() {
+ let mut buf = HtmlWithLimit::new(60);
+ buf.push("Hello");
+ buf.push(" world!");
+ assert_eq!(buf.finish(), "Hello world!");
+}
+
+#[test]
+fn limit_0() {
+ let mut buf = HtmlWithLimit::new(0);
+ buf.push("Hello ");
+ buf.open_tag("em");
+ buf.push("world");
+ buf.close_tag();
+ buf.push("!");
+ assert_eq!(buf.finish(), "");
+}
+
+#[test]
+fn exactly_limit() {
+ let mut buf = HtmlWithLimit::new(12);
+ buf.push("Hello ");
+ buf.open_tag("em");
+ buf.push("world");
+ buf.close_tag();
+ buf.push("!");
+ assert_eq!(buf.finish(), "Hello <em>world</em>!");
+}
+
+#[test]
+fn multiple_nested_tags() {
+ let mut buf = HtmlWithLimit::new(60);
+ buf.open_tag("p");
+ buf.push("This is a ");
+ buf.open_tag("em");
+ buf.push("paragraph");
+ buf.open_tag("strong");
+ buf.push("!");
+ buf.close_tag();
+ buf.close_tag();
+ buf.close_tag();
+ assert_eq!(buf.finish(), "<p>This is a <em>paragraph<strong>!</strong></em></p>");
+}
+
+#[test]
+fn forgot_to_close_tags() {
+ let mut buf = HtmlWithLimit::new(60);
+ buf.open_tag("p");
+ buf.push("This is a ");
+ buf.open_tag("em");
+ buf.push("paragraph");
+ buf.open_tag("strong");
+ buf.push("!");
+ assert_eq!(buf.finish(), "<p>This is a <em>paragraph<strong>!</strong></em></p>");
+}
+
+#[test]
+fn past_the_limit() {
+ let mut buf = HtmlWithLimit::new(20);
+ buf.open_tag("p");
+ (0..10).try_for_each(|n| {
+ buf.open_tag("strong");
+ buf.push("word#")?;
+ buf.push(&n.to_string())?;
+ buf.close_tag();
+ ControlFlow::CONTINUE
+ });
+ buf.close_tag();
+ assert_eq!(
+ buf.finish(),
+ "<p>\
+ <strong>word#0</strong>\
+ <strong>word#1</strong>\
+ <strong>word#2</strong>\
+ </p>"
+ );
+}
+
+#[test]
+fn quickly_past_the_limit() {
+ let mut buf = HtmlWithLimit::new(6);
+ buf.open_tag("p");
+ buf.push("Hello");
+ buf.push(" World");
+ // intentionally not closing <p> before finishing
+ assert_eq!(buf.finish(), "<p>Hello</p>");
+}
+
+#[test]
+fn close_too_many() {
+ let mut buf = HtmlWithLimit::new(60);
+ buf.open_tag("p");
+ buf.push("Hello");
+ buf.close_tag();
+ // This call does not panic because there are valid cases
+ // where `close_tag()` is called with no tags left to close.
+ // So `close_tag()` does nothing in this case.
+ buf.close_tag();
+ assert_eq!(buf.finish(), "<p>Hello</p>");
+}
diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 7c6d7df..aa3723e 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -23,12 +23,13 @@
use rustc_middle::ty::TyCtxt;
use rustc_span::edition::Edition;
use rustc_span::Span;
+
use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::VecDeque;
use std::default::Default;
use std::fmt::Write;
-use std::ops::Range;
+use std::ops::{ControlFlow, Range};
use std::str;
use crate::clean::RenderedLink;
@@ -36,6 +37,7 @@
use crate::html::escape::Escape;
use crate::html::format::Buffer;
use crate::html::highlight;
+use crate::html::length_limit::HtmlWithLimit;
use crate::html::toc::TocBuilder;
use pulldown_cmark::{
@@ -1081,15 +1083,6 @@ fn markdown_summary_with_limit(
return (String::new(), false);
}
- let mut s = String::with_capacity(md.len() * 3 / 2);
- let mut text_length = 0;
- let mut stopped_early = false;
-
- fn push(s: &mut String, text_length: &mut usize, text: &str) {
- write!(s, "{}", Escape(text)).unwrap();
- *text_length += text.len();
- }
-
let mut replacer = |broken_link: BrokenLink<'_>| {
if let Some(link) =
link_names.iter().find(|link| &*link.original_text == broken_link.reference)
@@ -1101,56 +1094,48 @@ fn push(s: &mut String, text_length: &mut usize, text: &str) {
};
let p = Parser::new_with_broken_link_callback(md, opts(), Some(&mut replacer));
- let p = LinkReplacer::new(p, link_names);
+ let mut p = LinkReplacer::new(p, link_names);
- 'outer: for event in p {
+ let mut buf = HtmlWithLimit::new(length_limit);
+ let mut stopped_early = false;
+ p.try_for_each(|event| {
match &event {
Event::Text(text) => {
- for word in text.split_inclusive(char::is_whitespace) {
- if text_length + word.len() >= length_limit {
- stopped_early = true;
- break 'outer;
- }
-
- push(&mut s, &mut text_length, word);
+ let r =
+ text.split_inclusive(char::is_whitespace).try_for_each(|word| buf.push(word));
+ if r.is_break() {
+ stopped_early = true;
}
+ return r;
}
Event::Code(code) => {
- if text_length + code.len() >= length_limit {
+ buf.open_tag("code");
+ let r = buf.push(code);
+ if r.is_break() {
stopped_early = true;
- break;
+ } else {
+ buf.close_tag();
}
-
- s.push_str("<code>");
- push(&mut s, &mut text_length, code);
- s.push_str("</code>");
+ return r;
}
Event::Start(tag) => match tag {
- Tag::Emphasis => s.push_str("<em>"),
- Tag::Strong => s.push_str("<strong>"),
- Tag::CodeBlock(..) => break,
+ Tag::Emphasis => buf.open_tag("em"),
+ Tag::Strong => buf.open_tag("strong"),
+ Tag::CodeBlock(..) => return ControlFlow::BREAK,
_ => {}
},
Event::End(tag) => match tag {
- Tag::Emphasis => s.push_str("</em>"),
- Tag::Strong => s.push_str("</strong>"),
- Tag::Paragraph => break,
- Tag::Heading(..) => break,
+ Tag::Emphasis | Tag::Strong => buf.close_tag(),
+ Tag::Paragraph | Tag::Heading(..) => return ControlFlow::BREAK,
_ => {}
},
- Event::HardBreak | Event::SoftBreak => {
- if text_length + 1 >= length_limit {
- stopped_early = true;
- break;
- }
-
- push(&mut s, &mut text_length, " ");
- }
+ Event::HardBreak | Event::SoftBreak => buf.push(" ")?,
_ => {}
- }
- }
+ };
+ ControlFlow::CONTINUE
+ });
- (s, stopped_early)
+ (buf.finish(), stopped_early)
}
/// Renders a shortened first paragraph of the given Markdown as a subset of Markdown,
diff --git a/src/librustdoc/html/markdown/tests.rs b/src/librustdoc/html/markdown/tests.rs
index 1e4bdc2..eca75ef 100644
--- a/src/librustdoc/html/markdown/tests.rs
+++ b/src/librustdoc/html/markdown/tests.rs
@@ -225,6 +225,7 @@ fn t(input: &str, expect: &str) {
assert_eq!(output, expect, "original: {}", input);
}
+ t("", "");
t("hello [Rust](https://www.rust-lang.org) :)", "hello Rust :)");
t("*italic*", "<em>italic</em>");
t("**bold**", "<strong>bold</strong>");
@@ -264,6 +265,7 @@ fn t(input: &str, expect: &str) {
assert_eq!(output, expect, "original: {}", input);
}
+ t("", "");
t("hello [Rust](https://www.rust-lang.org) :)", "hello Rust :)");
t("**bold**", "bold");
t("Multi-line\nsummary", "Multi-line summary");
diff --git a/src/librustdoc/html/mod.rs b/src/librustdoc/html/mod.rs
index 60ebdf5..109b0a3 100644
--- a/src/librustdoc/html/mod.rs
+++ b/src/librustdoc/html/mod.rs
@@ -2,6 +2,7 @@
crate mod format;
crate mod highlight;
crate mod layout;
+mod length_limit;
// used by the error-index generator, so it needs to be public
pub mod markdown;
crate mod render;
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 8f4857a..722cfc9 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -937,6 +937,19 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
document_type_layout(w, cx, def_id);
}
+fn print_tuple_struct_fields(w: &mut Buffer, cx: &Context<'_>, s: &[clean::Item]) {
+ for (i, ty) in s
+ .iter()
+ .map(|f| if let clean::StructFieldItem(ref ty) = *f.kind { ty } else { unreachable!() })
+ .enumerate()
+ {
+ if i > 0 {
+ w.write_str(", ");
+ }
+ write!(w, "{}", ty.print(cx));
+ }
+}
+
fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum) {
wrap_into_docblock(w, |w| {
wrap_item(w, "enum", |w| {
@@ -964,14 +977,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
match *v.kind {
clean::VariantItem(ref var) => match var {
clean::Variant::CLike => write!(w, "{}", name),
- clean::Variant::Tuple(ref tys) => {
+ clean::Variant::Tuple(ref s) => {
write!(w, "{}(", name);
- for (i, ty) in tys.iter().enumerate() {
- if i > 0 {
- w.write_str(", ")
- }
- write!(w, "{}", ty.print(cx));
- }
+ print_tuple_struct_fields(w, cx, s);
w.write_str(")");
}
clean::Variant::Struct(ref s) => {
@@ -1024,14 +1032,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
id = id,
name = variant.name.as_ref().unwrap()
);
- if let clean::VariantItem(clean::Variant::Tuple(ref tys)) = *variant.kind {
+ if let clean::VariantItem(clean::Variant::Tuple(ref s)) = *variant.kind {
w.write_str("(");
- for (i, ty) in tys.iter().enumerate() {
- if i > 0 {
- w.write_str(", ");
- }
- write!(w, "{}", ty.print(cx));
- }
+ print_tuple_struct_fields(w, cx, s);
w.write_str(")");
}
w.write_str("</code>");
@@ -1041,7 +1044,11 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
document_non_exhaustive(w, variant);
use crate::clean::Variant;
- if let clean::VariantItem(Variant::Struct(ref s)) = *variant.kind {
+ if let Some((extra, fields)) = match *variant.kind {
+ clean::VariantItem(Variant::Struct(ref s)) => Some(("", &s.fields)),
+ clean::VariantItem(Variant::Tuple(ref fields)) => Some(("Tuple ", fields)),
+ _ => None,
+ } {
let variant_id = cx.derive_id(format!(
"{}.{}.fields",
ItemType::Variant,
@@ -1051,10 +1058,10 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
write!(
w,
"<h3>{extra}Fields of <b>{name}</b></h3><div>",
- extra = if s.struct_type == CtorKind::Fn { "Tuple " } else { "" },
+ extra = extra,
name = variant.name.as_ref().unwrap(),
);
- for field in &s.fields {
+ for field in fields {
use crate::clean::StructFieldItem;
if let StructFieldItem(ref ty) = *field.kind {
let id = cx.derive_id(format!(
diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css
index dab6d65..f9ddef4 100644
--- a/src/librustdoc/html/static/css/themes/ayu.css
+++ b/src/librustdoc/html/static/css/themes/ayu.css
@@ -40,7 +40,7 @@
.code-header {
color: #e6e1cf;
}
-pre > code {
+.docblock pre > code, pre > code {
color: #e6e1cf;
}
span code {
diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs
index f3eeea6..9453e6d 100644
--- a/src/librustdoc/json/conversions.rs
+++ b/src/librustdoc/json/conversions.rs
@@ -569,7 +569,18 @@ fn from_tcx(variant: clean::Variant, tcx: TyCtxt<'_>) -> Self {
use clean::Variant::*;
match variant {
CLike => Variant::Plain,
- Tuple(t) => Variant::Tuple(t.into_iter().map(|x| x.into_tcx(tcx)).collect()),
+ Tuple(fields) => Variant::Tuple(
+ fields
+ .into_iter()
+ .map(|f| {
+ if let clean::StructFieldItem(ty) = *f.kind {
+ ty.into_tcx(tcx)
+ } else {
+ unreachable!()
+ }
+ })
+ .collect(),
+ ),
Struct(s) => Variant::Struct(ids(s.fields)),
}
}
diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs
index 70f8b67..de32e31 100644
--- a/src/librustdoc/lib.rs
+++ b/src/librustdoc/lib.rs
@@ -5,6 +5,7 @@
#![feature(rustc_private)]
#![feature(array_methods)]
#![feature(box_patterns)]
+#![feature(control_flow_enum)]
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(test)]
diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs
index 4305268..a938804 100644
--- a/src/librustdoc/passes/stripper.rs
+++ b/src/librustdoc/passes/stripper.rs
@@ -40,6 +40,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
| clean::UnionItem(..)
| clean::AssocConstItem(..)
| clean::TraitAliasItem(..)
+ | clean::MacroItem(..)
| clean::ForeignTypeItem => {
if i.def_id.is_local() {
if !self.access_levels.is_exported(i.def_id.expect_def_id()) {
@@ -70,8 +71,8 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
clean::ImplItem(..) => {}
- // tymethods/macros have no control over privacy
- clean::MacroItem(..) | clean::TyMethodItem(..) => {}
+ // tymethods have no control over privacy
+ clean::TyMethodItem(..) => {}
// Proc-macros are always public
clean::ProcMacroItem(..) => {}
@@ -93,8 +94,8 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
// implementations of traits are always public.
clean::ImplItem(ref imp) if imp.trait_.is_some() => true,
- // Struct variant fields have inherited visibility
- clean::VariantItem(clean::Variant::Struct(..)) => true,
+ // Variant fields have inherited visibility
+ clean::VariantItem(clean::Variant::Struct(..) | clean::Variant::Tuple(..)) => true,
_ => false,
};
diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs
index e289103..897b914 100644
--- a/src/librustdoc/visit_ast.rs
+++ b/src/librustdoc/visit_ast.rs
@@ -9,7 +9,7 @@
use rustc_middle::middle::privacy::AccessLevel;
use rustc_middle::ty::TyCtxt;
use rustc_span;
-use rustc_span::def_id::LOCAL_CRATE;
+use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
use rustc_span::source_map::Spanned;
use rustc_span::symbol::{kw, sym, Symbol};
@@ -79,49 +79,23 @@ fn store_path(&mut self, did: DefId) {
&krate.module(),
self.cx.tcx.crate_name(LOCAL_CRATE),
);
- // Attach the crate's exported macros to the top-level module.
- // In the case of macros 2.0 (`pub macro`), and for built-in `derive`s or attributes as
- // well (_e.g._, `Copy`), these are wrongly bundled in there too, so we need to fix that by
- // moving them back to their correct locations.
- 'exported_macros: for def in krate.exported_macros() {
- // The `def` of a macro in `exported_macros` should correspond to either:
- // - a `#[macro_export] macro_rules!` macro,
- // - a built-in `derive` (or attribute) macro such as the ones in `::core`,
- // - a `pub macro`.
- // Only the last two need to be fixed, thus:
- if def.ast.macro_rules {
- top_level_module.macros.push((def, None));
- continue 'exported_macros;
- }
- let tcx = self.cx.tcx;
- // Note: this is not the same as `.parent_module()`. Indeed, the latter looks
- // for the closest module _ancestor_, which is not necessarily a direct parent
- // (since a direct parent isn't necessarily a module, c.f. #77828).
- let macro_parent_def_id = {
- use rustc_middle::ty::DefIdTree;
- tcx.parent(def.def_id.to_def_id()).unwrap()
- };
- let macro_parent_path = tcx.def_path(macro_parent_def_id);
- // HACK: rustdoc has no way to lookup `doctree::Module`s by their HirId. Instead,
- // lookup the module by its name, by looking at each path segment one at a time.
- let mut cur_mod = &mut top_level_module;
- for path_segment in macro_parent_path.data {
- // Path segments may refer to a module (in which case they belong to the type
- // namespace), which is _necessary_ for the macro to be accessible outside it
- // (no "associated macros" as of yet). Else we bail with an outer `continue`.
- let path_segment_ty_ns = match path_segment.data {
- rustc_hir::definitions::DefPathData::TypeNs(symbol) => symbol,
- _ => continue 'exported_macros,
- };
- // Descend into the child module that matches this path segment (if any).
- match cur_mod.mods.iter_mut().find(|child| child.name == path_segment_ty_ns) {
- Some(child_mod) => cur_mod = &mut *child_mod,
- None => continue 'exported_macros,
+
+ // `#[macro_export] macro_rules!` items are reexported at the top level of the
+ // crate, regardless of where they're defined. We want to document the
+ // top level rexport of the macro, not its original definition, since
+ // the rexport defines the path that a user will actually see. Accordingly,
+ // we add the rexport as an item here, and then skip over the original
+ // definition in `visit_item()` below.
+ for export in self.cx.tcx.module_exports(CRATE_DEF_ID).unwrap_or(&[]) {
+ if let Res::Def(DefKind::Macro(_), def_id) = export.res {
+ if let Some(local_def_id) = def_id.as_local() {
+ if self.cx.tcx.has_attr(def_id, sym::macro_export) {
+ let hir_id = self.cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
+ let item = self.cx.tcx.hir().expect_item(hir_id);
+ top_level_module.items.push((item, None));
+ }
}
}
- let cur_mod_def_id = tcx.hir().local_def_id(cur_mod.id).to_def_id();
- assert_eq!(cur_mod_def_id, macro_parent_def_id);
- cur_mod.macros.push((def, None));
}
self.cx.cache.exact_paths = self.exact_paths;
top_level_module
@@ -238,10 +212,6 @@ fn maybe_inline_local(
self.inlining = prev;
true
}
- Node::MacroDef(def) if !glob => {
- om.macros.push((def, renamed));
- true
- }
_ => false,
};
self.view_item_stack.remove(&res_hir_id);
@@ -257,7 +227,10 @@ fn visit_item(
debug!("visiting item {:?}", item);
let name = renamed.unwrap_or(item.ident.name);
- if item.vis.node.is_pub() {
+ let def_id = item.def_id.to_def_id();
+ let is_pub = item.vis.node.is_pub() || self.cx.tcx.has_attr(def_id, sym::macro_export);
+
+ if is_pub {
self.store_path(item.def_id.to_def_id());
}
@@ -269,7 +242,7 @@ fn visit_item(
}
}
// If we're inlining, skip private items.
- _ if self.inlining && !item.vis.node.is_pub() => {}
+ _ if self.inlining && !is_pub => {}
hir::ItemKind::GlobalAsm(..) => {}
hir::ItemKind::Use(_, hir::UseKind::ListStem) => {}
hir::ItemKind::Use(ref path, kind) => {
@@ -285,7 +258,7 @@ fn visit_item(
// If there was a private module in the current path then don't bother inlining
// anything as it will probably be stripped anyway.
- if item.vis.node.is_pub() && self.inside_public_path {
+ if is_pub && self.inside_public_path {
let please_inline = attrs.iter().any(|item| match item.meta_item_list() {
Some(ref list) if item.has_name(sym::doc) => {
list.iter().any(|i| i.has_name(sym::inline))
@@ -307,6 +280,26 @@ fn visit_item(
om.items.push((item, renamed))
}
+ hir::ItemKind::Macro(ref macro_def) => {
+ // `#[macro_export] macro_rules!` items are handled seperately in `visit()`,
+ // above, since they need to be documented at the module top level. Accordingly,
+ // we only want to handle macros if one of three conditions holds:
+ //
+ // 1. This macro was defined by `macro`, and thus isn't covered by the case
+ // above.
+ // 2. This macro isn't marked with `#[macro_export]`, and thus isn't covered
+ // by the case above.
+ // 3. We're inlining, since a reexport where inlining has been requested
+ // should be inlined even if it is also documented at the top level.
+
+ let def_id = item.def_id.to_def_id();
+ let is_macro_2_0 = !macro_def.macro_rules;
+ let nonexported = !self.cx.tcx.has_attr(def_id, sym::macro_export);
+
+ if is_macro_2_0 || nonexported || self.inlining {
+ om.items.push((item, renamed));
+ }
+ }
hir::ItemKind::Mod(ref m) => {
om.mods.push(self.visit_mod_contents(&item.vis, item.hir_id(), m, name));
}
diff --git a/src/test/assembly/asm/powerpc-types.rs b/src/test/assembly/asm/powerpc-types.rs
index 1e26364..55ca8ee 100644
--- a/src/test/assembly/asm/powerpc-types.rs
+++ b/src/test/assembly/asm/powerpc-types.rs
@@ -194,3 +194,15 @@ pub unsafe fn $func(x: $ty) -> $ty {
// CHECK: fmr 0, 0
// CHECK: #NO_APP
check_reg!(reg_f64_f0, f64, "0", "f0", "fmr");
+
+// CHECK-LABEL: reg_f32_f18:
+// CHECK: #APP
+// CHECK: fmr 18, 18
+// CHECK: #NO_APP
+check_reg!(reg_f32_f18, f32, "18", "f18", "fmr");
+
+// CHECK-LABEL: reg_f64_f18:
+// CHECK: #APP
+// CHECK: fmr 18, 18
+// CHECK: #NO_APP
+check_reg!(reg_f64_f18, f64, "18", "f18", "fmr");
diff --git a/src/test/assembly/asm/s390x-types.rs b/src/test/assembly/asm/s390x-types.rs
new file mode 100644
index 0000000..69d9cab
--- /dev/null
+++ b/src/test/assembly/asm/s390x-types.rs
@@ -0,0 +1,168 @@
+// min-llvm-version: 10.0.1
+// revisions: s390x
+// assembly-output: emit-asm
+//[s390x] compile-flags: --target s390x-unknown-linux-gnu
+//[s390x] needs-llvm-components: systemz
+
+#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
+#![crate_type = "rlib"]
+#![no_core]
+#![allow(asm_sub_register, non_camel_case_types)]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+ () => {};
+}
+#[rustc_builtin_macro]
+macro_rules! concat {
+ () => {};
+}
+#[rustc_builtin_macro]
+macro_rules! stringify {
+ () => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+type ptr = *const i32;
+
+impl Copy for i8 {}
+impl Copy for u8 {}
+impl Copy for i16 {}
+impl Copy for i32 {}
+impl Copy for i64 {}
+impl Copy for f32 {}
+impl Copy for f64 {}
+impl Copy for ptr {}
+
+extern "C" {
+ fn extern_func();
+ static extern_static: u8;
+}
+
+// Hack to avoid function merging
+extern "Rust" {
+ fn dont_merge(s: &str);
+}
+
+macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
+ #[no_mangle]
+ pub unsafe fn $func(x: $ty) -> $ty {
+ dont_merge(stringify!($func));
+
+ let y;
+ asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
+ y
+ }
+};}
+
+macro_rules! check_reg { ($func:ident, $ty:ty, $reg:tt, $mov:literal) => {
+ #[no_mangle]
+ pub unsafe fn $func(x: $ty) -> $ty {
+ dont_merge(stringify!($func));
+
+ let y;
+ asm!(concat!($mov, " %", $reg, ", %", $reg), lateout($reg) y, in($reg) x);
+ y
+ }
+};}
+
+// CHECK-LABEL: sym_fn_32:
+// CHECK: #APP
+// CHECK: brasl %r14, extern_func
+// CHECK: #NO_APP
+#[cfg(s390x)]
+#[no_mangle]
+pub unsafe fn sym_fn_32() {
+ asm!("brasl %r14, {}", sym extern_func);
+}
+
+// CHECK-LABEL: sym_static:
+// CHECK: #APP
+// CHECK: brasl %r14, extern_static
+// CHECK: #NO_APP
+#[no_mangle]
+pub unsafe fn sym_static() {
+ asm!("brasl %r14, {}", sym extern_static);
+}
+
+// CHECK-LABEL: reg_i8:
+// CHECK: #APP
+// CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i8, i8, reg, "lgr");
+
+// CHECK-LABEL: reg_i16:
+// CHECK: #APP
+// CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i16, i16, reg, "lgr");
+
+// CHECK-LABEL: reg_i32:
+// CHECK: #APP
+// CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i32, i32, reg, "lgr");
+
+// CHECK-LABEL: reg_i64:
+// CHECK: #APP
+// CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i64, i64, reg, "lgr");
+
+// CHECK-LABEL: reg_f32:
+// CHECK: #APP
+// CHECK: ler %f{{[0-9]+}}, %f{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_f32, f32, freg, "ler");
+
+// CHECK-LABEL: reg_f64:
+// CHECK: #APP
+// CHECK: ldr %f{{[0-9]+}}, %f{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_f64, f64, freg, "ldr");
+
+// CHECK-LABEL: reg_ptr:
+// CHECK: #APP
+// CHECK: lgr %r{{[0-9]+}}, %r{{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_ptr, ptr, reg, "lgr");
+
+// CHECK-LABEL: r0_i8:
+// CHECK: #APP
+// CHECK: lr %r0, %r0
+// CHECK: #NO_APP
+check_reg!(r0_i8, i8, "r0", "lr");
+
+// CHECK-LABEL: r0_i16:
+// CHECK: #APP
+// CHECK: lr %r0, %r0
+// CHECK: #NO_APP
+check_reg!(r0_i16, i16, "r0", "lr");
+
+// CHECK-LABEL: r0_i32:
+// CHECK: #APP
+// CHECK: lr %r0, %r0
+// CHECK: #NO_APP
+check_reg!(r0_i32, i32, "r0", "lr");
+
+// CHECK-LABEL: r0_i64:
+// CHECK: #APP
+// CHECK: lr %r0, %r0
+// CHECK: #NO_APP
+check_reg!(r0_i64, i64, "r0", "lr");
+
+// CHECK-LABEL: f0_f32:
+// CHECK: #APP
+// CHECK: ler %f0, %f0
+// CHECK: #NO_APP
+check_reg!(f0_f32, f32, "f0", "ler");
+
+// CHECK-LABEL: f0_f64:
+// CHECK: #APP
+// CHECK: ldr %f0, %f0
+// CHECK: #NO_APP
+check_reg!(f0_f64, f64, "f0", "ldr");
diff --git a/src/test/codegen/asm-powerpc-clobbers.rs b/src/test/codegen/asm-powerpc-clobbers.rs
new file mode 100644
index 0000000..91a82c6
--- /dev/null
+++ b/src/test/codegen/asm-powerpc-clobbers.rs
@@ -0,0 +1,48 @@
+// min-llvm-version: 10.0.1
+// revisions: powerpc powerpc64 powerpc64le
+//[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
+//[powerpc] needs-llvm-components: powerpc
+//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
+//[powerpc64] needs-llvm-components: powerpc
+//[powerpc64le] compile-flags: --target powerpc64le-unknown-linux-gnu
+//[powerpc64le] needs-llvm-components: powerpc
+
+#![crate_type = "rlib"]
+#![feature(no_core, rustc_attrs, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+ () => {};
+}
+
+// CHECK-LABEL: @cr_clobber
+// CHECK: call void asm sideeffect "", "~{cr}"()
+#[no_mangle]
+pub unsafe fn cr_clobber() {
+ asm!("", out("cr") _, options(nostack, nomem));
+}
+
+// CHECK-LABEL: @cr0_clobber
+// CHECK: call void asm sideeffect "", "~{cr0}"()
+#[no_mangle]
+pub unsafe fn cr0_clobber() {
+ asm!("", out("cr0") _, options(nostack, nomem));
+}
+
+// CHECK-LABEL: @cr5_clobber
+// CHECK: call void asm sideeffect "", "~{cr5}"()
+#[no_mangle]
+pub unsafe fn cr5_clobber() {
+ asm!("", out("cr5") _, options(nostack, nomem));
+}
+
+// CHECK-LABEL: @xer_clobber
+// CHECK: call void asm sideeffect "", "~{xer}"()
+#[no_mangle]
+pub unsafe fn xer_clobber() {
+ asm!("", out("xer") _, options(nostack, nomem));
+}
diff --git a/src/test/debuginfo/function-names.rs b/src/test/debuginfo/function-names.rs
index b9e59f8..dec25bb 100644
--- a/src/test/debuginfo/function-names.rs
+++ b/src/test/debuginfo/function-names.rs
@@ -82,8 +82,8 @@
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
-#![feature(const_generics, generators, generator_trait)]
-#![allow(incomplete_features)] // for const_generics
+#![feature(adt_const_params, generators, generator_trait)]
+#![allow(incomplete_features)]
use Mod1::TestTrait2;
use std::ops::Generator;
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-1.rs b/src/test/incremental/const-generics/hash-tyvid-regression-1.rs
index f98ae59..b5a0108 100644
--- a/src/test/incremental/const-generics/hash-tyvid-regression-1.rs
+++ b/src/test/incremental/const-generics/hash-tyvid-regression-1.rs
@@ -1,5 +1,5 @@
// revisions: cfail
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs, adt_const_params)]
#![allow(incomplete_features)]
// regression test for #77650
fn c<T, const N: std::num::NonZeroUsize>()
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-1.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-1.stderr
deleted file mode 100644
index cb8ca3a..0000000
--- a/src/test/incremental/const-generics/hash-tyvid-regression-1.stderr
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0277]: the trait bound `[T; _]: From<()>` is not satisfied
- --> $DIR/hash-tyvid-regression-1.rs:9:5
- |
-LL | <[T; N.get()]>::try_from(())
- | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<()>` is not implemented for `[T; _]`
- |
- = note: required because of the requirements on the impl of `Into<[T; _]>` for `()`
- = note: required because of the requirements on the impl of `TryFrom<()>` for `[T; _]`
-note: required by `try_from`
- --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
- |
-LL | fn try_from(value: T) -> Result<Self, Self::Error>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0308]: mismatched types
- --> $DIR/hash-tyvid-regression-1.rs:9:5
- |
-LL | <[T; N.get()]>::try_from(())
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `Result`
- |
- = note: expected unit type `()`
- found enum `Result<[T; _], Infallible>`
-help: consider using a semicolon here
- |
-LL | <[T; N.get()]>::try_from(());
- | +
-help: try adding a return type
- |
-LL | -> Result<[T; _], Infallible> where
- | +++++++++++++++++++++++++++++
-
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0277, E0308.
-For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-2.rs b/src/test/incremental/const-generics/hash-tyvid-regression-2.rs
index 22536ff..bba22bf 100644
--- a/src/test/incremental/const-generics/hash-tyvid-regression-2.rs
+++ b/src/test/incremental/const-generics/hash-tyvid-regression-2.rs
@@ -1,5 +1,5 @@
// revisions: cfail
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs, adt_const_params, const_generics_defaults)]
#![allow(incomplete_features)]
// regression test for #77650
struct C<T, const N: core::num::NonZeroUsize>([T; N.get()])
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-2.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-2.stderr
deleted file mode 100644
index 0e6040e..0000000
--- a/src/test/incremental/const-generics/hash-tyvid-regression-2.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0277]: can't compare `[B; _]` with `&&[A]`
- --> $DIR/hash-tyvid-regression-2.rs:12:16
- |
-LL | self.0 == other
- | ^^ no implementation for `[B; _] == &&[A]`
- |
- = help: the trait `PartialEq<&&[A]>` is not implemented for `[B; _]`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-3.rs b/src/test/incremental/const-generics/hash-tyvid-regression-3.rs
index 76b1ae1..61f568f 100644
--- a/src/test/incremental/const-generics/hash-tyvid-regression-3.rs
+++ b/src/test/incremental/const-generics/hash-tyvid-regression-3.rs
@@ -1,5 +1,5 @@
// revisions: cfail
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// regression test for #79251
struct Node<const D: usize>
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-3.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-3.stderr
deleted file mode 100644
index 555d467..0000000
--- a/src/test/incremental/const-generics/hash-tyvid-regression-3.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0599]: no method named `some_function` found for struct `SmallVec` in the current scope
- --> $DIR/hash-tyvid-regression-3.rs:17:19
- |
-LL | node.keys.some_function();
- | ^^^^^^^^^^^^^ method not found in `SmallVec<{ D * 2 }>`
-...
-LL | struct SmallVec<const D: usize> {}
- | ------------------------------- method `some_function` not found for this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-4.rs b/src/test/incremental/const-generics/hash-tyvid-regression-4.rs
index 35a675a..12e8ac7 100644
--- a/src/test/incremental/const-generics/hash-tyvid-regression-4.rs
+++ b/src/test/incremental/const-generics/hash-tyvid-regression-4.rs
@@ -1,5 +1,5 @@
// revisions: cfail
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// regression test for #79251
#[derive(Debug)]
diff --git a/src/test/incremental/const-generics/hash-tyvid-regression-4.stderr b/src/test/incremental/const-generics/hash-tyvid-regression-4.stderr
deleted file mode 100644
index c9a6715..0000000
--- a/src/test/incremental/const-generics/hash-tyvid-regression-4.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0599]: no method named `push` found for struct `SmallVec` in the current scope
- --> $DIR/hash-tyvid-regression-4.rs:23:19
- |
-LL | node.keys.push(k);
- | ^^^^ method not found in `SmallVec<_, { D * 2 }>`
-...
-LL | struct SmallVec<T, const D: usize> {
- | ---------------------------------- method `push` not found for this
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/incremental/const-generics/issue-61338.rs b/src/test/incremental/const-generics/issue-61338.rs
index 00b3b29..e9d67fe 100644
--- a/src/test/incremental/const-generics/issue-61338.rs
+++ b/src/test/incremental/const-generics/issue-61338.rs
@@ -1,7 +1,5 @@
// revisions:rpass1
-#![feature(const_generics)]
-
struct Struct<T>(T);
impl<T, const N: usize> Struct<[T; N]> {
diff --git a/src/test/incremental/const-generics/issue-61516.rs b/src/test/incremental/const-generics/issue-61516.rs
index a193bf9..c781484 100644
--- a/src/test/incremental/const-generics/issue-61516.rs
+++ b/src/test/incremental/const-generics/issue-61516.rs
@@ -1,7 +1,5 @@
// revisions:rpass1
-#![feature(const_generics)]
-
struct FakeArray<T, const N: usize>(T);
impl<T, const N: usize> FakeArray<T, N> {
diff --git a/src/test/incremental/const-generics/issue-62536.rs b/src/test/incremental/const-generics/issue-62536.rs
index 0eaeb91..93c1dbf 100644
--- a/src/test/incremental/const-generics/issue-62536.rs
+++ b/src/test/incremental/const-generics/issue-62536.rs
@@ -1,7 +1,4 @@
// revisions:cfail1
-#![feature(const_generics)]
-//[cfail1]~^ WARN the feature `const_generics` is incomplete
-
struct S<T, const N: usize>([T; N]);
fn f<T, const N: usize>(x: T) -> S<T, {N}> { panic!() }
diff --git a/src/test/incremental/const-generics/issue-64087.rs b/src/test/incremental/const-generics/issue-64087.rs
index 6b10c54..81c8135 100644
--- a/src/test/incremental/const-generics/issue-64087.rs
+++ b/src/test/incremental/const-generics/issue-64087.rs
@@ -1,6 +1,4 @@
// revisions:cfail1
-#![feature(const_generics)]
-//[cfail1]~^ WARN the feature `const_generics` is incomplete
fn combinator<T, const S: usize>() -> [T; S] {}
//[cfail1]~^ ERROR mismatched types
diff --git a/src/test/incremental/const-generics/issue-65623.rs b/src/test/incremental/const-generics/issue-65623.rs
index 353e323..22bbcbc 100644
--- a/src/test/incremental/const-generics/issue-65623.rs
+++ b/src/test/incremental/const-generics/issue-65623.rs
@@ -1,6 +1,4 @@
// revisions:rpass1
-#![feature(const_generics)]
-
pub struct Foo<T, const N: usize>([T; 0]);
impl<T, const N: usize> Foo<T, {N}> {
diff --git a/src/test/incremental/const-generics/issue-68477.rs b/src/test/incremental/const-generics/issue-68477.rs
index 925931b..9e35cf9 100644
--- a/src/test/incremental/const-generics/issue-68477.rs
+++ b/src/test/incremental/const-generics/issue-68477.rs
@@ -1,6 +1,8 @@
// edition:2018
// revisions:rpass1
-#![feature(const_generics)]
+
+// Needed to supply generic arguments to the anon const in `[(); FOO]`.
+#![feature(generic_const_exprs)]
const FOO: usize = 1;
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs
index a6edbb2..8262a2a 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs
@@ -1,5 +1,5 @@
// revisions: cfail
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features, unused_braces)]
trait Delegates<T> {}
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs
index 52eeec7..92bbcba 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-2.rs
@@ -1,5 +1,5 @@
// revisions: rpass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Z;
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs
index 11cca94..fc114f2 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs
@@ -1,5 +1,5 @@
// revisions: rpass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs, adt_const_params)]
#![allow(incomplete_features)]
use std::{convert::TryFrom, num::NonZeroUsize};
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs
index 1b769d0..c05d835 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-82034.rs
@@ -1,5 +1,5 @@
// revisions: rpass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub trait IsTrue {}
pub trait IsFalse {}
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs
index 20d4993..8886a55 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-1.rs
@@ -1,5 +1,5 @@
// revisions: rpass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub struct Ref<'a, const NUM: usize>(&'a i32);
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs
index be7ad6d..db1e2fc 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-2.rs
@@ -1,6 +1,6 @@
// revisions: cfail
#![allow(incomplete_features)]
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
pub struct Ref<'a>(&'a i32);
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs
index af4f209..5b2f5ed 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-85031-3.rs
@@ -1,5 +1,5 @@
// revisions: rpass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn test<const SIZE: usize>() {}
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs
index ba86336..d659c56 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-86953.rs
@@ -1,5 +1,5 @@
// revisions: rpass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo;
diff --git a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs
index da71363..5f5435b 100644
--- a/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs
+++ b/src/test/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-88022.rs
@@ -1,5 +1,5 @@
// revisions: cfail
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features, unused_braces)]
struct Buffer<T, const S: usize>
diff --git a/src/test/run-make/incr-foreign-head-span/Makefile b/src/test/run-make/incr-foreign-head-span/Makefile
new file mode 100644
index 0000000..712965e
--- /dev/null
+++ b/src/test/run-make/incr-foreign-head-span/Makefile
@@ -0,0 +1,21 @@
+include ../../run-make-fulldeps/tools.mk
+
+# ignore-none no-std is not supported
+# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for 'std'
+
+# Ensure that modifying a crate on disk (without recompiling it)
+# does not cause ICEs in downstream crates.
+# Previously, we would call `SourceMap.guess_head_span` on a span
+# from an external crate, which would cause us to read an upstream
+# source file from disk during compilation of a downstream crate
+# See #86480 for more details
+
+INCR=$(TMPDIR)/incr
+
+all:
+ cp first_crate.rs second_crate.rs $(TMPDIR)
+ $(RUSTC) $(TMPDIR)/first_crate.rs -C incremental=$(INCR) --target $(TARGET) --crate-type lib
+ $(RUSTC) $(TMPDIR)/second_crate.rs -C incremental=$(INCR) --target $(TARGET) --extern first-crate=$(TMPDIR) --crate-type lib
+ rm $(TMPDIR)/first_crate.rs
+ $(RUSTC) $(TMPDIR)/second_crate.rs -C incremental=$(INCR) --target $(TARGET) --cfg second_run --crate-type lib
+
diff --git a/src/test/run-make/incr-foreign-head-span/first_crate.rs b/src/test/run-make/incr-foreign-head-span/first_crate.rs
new file mode 100644
index 0000000..69dd103
--- /dev/null
+++ b/src/test/run-make/incr-foreign-head-span/first_crate.rs
@@ -0,0 +1 @@
+pub trait OtherTrait {}
diff --git a/src/test/run-make/incr-foreign-head-span/second_crate.rs b/src/test/run-make/incr-foreign-head-span/second_crate.rs
new file mode 100644
index 0000000..102f6b2
--- /dev/null
+++ b/src/test/run-make/incr-foreign-head-span/second_crate.rs
@@ -0,0 +1,8 @@
+extern crate first_crate;
+use first_crate::OtherTrait;
+
+#[cfg(not(second_run))]
+trait Foo: OtherTrait {}
+
+#[cfg(second_run)]
+trait Bar: OtherTrait {}
diff --git a/src/test/rustdoc-gui/ayu-code-tag-colors.goml b/src/test/rustdoc-gui/ayu-code-tag-colors.goml
deleted file mode 100644
index 50af36f..0000000
--- a/src/test/rustdoc-gui/ayu-code-tag-colors.goml
+++ /dev/null
@@ -1,13 +0,0 @@
-// The ayu theme has a different color for the "<code>" tags in the doc blocks. We need to
-// check that the rule isn't applied on other "<code>" elements.
-goto: file://|DOC_PATH|/test_docs/enum.AnEnum.html
-// We need to show the text, otherwise the colors aren't "computed" by the web browser.
-show-text: true
-// We set the theme to ayu.
-local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
-// We reload to get the text appearing and the theme applied.
-reload:
-
-assert-css: (".docblock code", {"color": "rgb(255, 180, 84)"}, ALL)
-// It includes variants and the "titles" as well (for example: "impl RefUnwindSafe for AnEnum").
-assert-css: ("div:not(.docblock) > code", {"color": "rgb(197, 197, 197)"}, ALL)
diff --git a/src/test/rustdoc-gui/code-color.goml b/src/test/rustdoc-gui/code-color.goml
new file mode 100644
index 0000000..2f95bfb
--- /dev/null
+++ b/src/test/rustdoc-gui/code-color.goml
@@ -0,0 +1,30 @@
+// The ayu theme has a different color for the "<code>" tags in the doc blocks. We need to
+// check that the rule isn't applied on other "<code>" elements.
+//
+// While we're at it, we also check it for the other themes.
+goto: file://|DOC_PATH|/test_docs/fn.foo.html
+// If the text isn't displayed, the browser doesn't compute color style correctly...
+show-text: true
+// Set the theme to dark.
+local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
+// We reload the page so the local storage settings are being used.
+reload:
+
+assert-css: (".docblock pre > code", {"color": "rgb(221, 221, 221)"}, ALL)
+assert-css: (".docblock > p > code", {"color": "rgb(221, 221, 221)"}, ALL)
+
+// Set the theme to ayu.
+local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
+// We reload the page so the local storage settings are being used.
+reload:
+
+assert-css: (".docblock pre > code", {"color": "rgb(230, 225, 207)"}, ALL)
+assert-css: (".docblock > p > code", {"color": "rgb(255, 180, 84)"}, ALL)
+
+// Set the theme to light.
+local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
+// We reload the page so the local storage settings are being used.
+reload:
+
+assert-css: (".docblock pre > code", {"color": "rgb(0, 0, 0)"}, ALL)
+assert-css: (".docblock > p > code", {"color": "rgb(0, 0, 0)"}, ALL)
diff --git a/src/test/rustdoc-gui/src/test_docs/lib.rs b/src/test/rustdoc-gui/src/test_docs/lib.rs
index bed72cc..af4f280 100644
--- a/src/test/rustdoc-gui/src/test_docs/lib.rs
+++ b/src/test/rustdoc-gui/src/test_docs/lib.rs
@@ -25,6 +25,8 @@
/// ```ignore (it's a test)
/// Let's say I'm just some text will ya?
/// ```
+///
+/// An inlined `code`!
pub fn foo() {}
/// Just a normal struct.
diff --git a/src/test/rustdoc-json/enums/variant_struct.rs b/src/test/rustdoc-json/enums/variant_struct.rs
new file mode 100644
index 0000000..246e6a0
--- /dev/null
+++ b/src/test/rustdoc-json/enums/variant_struct.rs
@@ -0,0 +1,11 @@
+// @has variant_struct.json "$.index[*][?(@.name=='EnumStruct')].visibility" \"public\"
+// @has - "$.index[*][?(@.name=='EnumStruct')].kind" \"enum\"
+pub enum EnumStruct {
+ // @has - "$.index[*][?(@.name=='VariantS')].inner.variant_kind" \"struct\"
+ // @has - "$.index[*][?(@.name=='x')]"
+ // @has - "$.index[*][?(@.name=='y')]"
+ VariantS {
+ x: u32,
+ y: String,
+ },
+}
diff --git a/src/test/rustdoc-json/enums/variant_tuple_struct.rs b/src/test/rustdoc-json/enums/variant_tuple_struct.rs
new file mode 100644
index 0000000..d948dc5
--- /dev/null
+++ b/src/test/rustdoc-json/enums/variant_tuple_struct.rs
@@ -0,0 +1,6 @@
+// @has variant_tuple_struct.json "$.index[*][?(@.name=='EnumTupleStruct')].visibility" \"public\"
+// @has - "$.index[*][?(@.name=='EnumTupleStruct')].kind" \"enum\"
+pub enum EnumTupleStruct {
+ // @has - "$.index[*][?(@.name=='VariantA')].inner.variant_kind" \"tuple\"
+ VariantA(u32, String),
+}
diff --git a/src/test/rustdoc-ui/deny-missing-docs-macro.stderr b/src/test/rustdoc-ui/deny-missing-docs-macro.stderr
index a564006..0867b08 100644
--- a/src/test/rustdoc-ui/deny-missing-docs-macro.stderr
+++ b/src/test/rustdoc-ui/deny-missing-docs-macro.stderr
@@ -1,4 +1,4 @@
-error: missing documentation for macro
+error: missing documentation for a macro
--> $DIR/deny-missing-docs-macro.rs:6:1
|
LL | macro_rules! foo {
diff --git a/src/test/rustdoc/const-generics/add-impl.rs b/src/test/rustdoc/const-generics/add-impl.rs
index 123dbaa..7e38eb8 100644
--- a/src/test/rustdoc/const-generics/add-impl.rs
+++ b/src/test/rustdoc/const-generics/add-impl.rs
@@ -1,4 +1,3 @@
-#![feature(const_generics)]
#![crate_name = "foo"]
use std::ops::Add;
diff --git a/src/test/rustdoc/const-generics/const-generic-slice.rs b/src/test/rustdoc/const-generics/const-generic-slice.rs
index 626a9e2..b20663c 100644
--- a/src/test/rustdoc/const-generics/const-generic-slice.rs
+++ b/src/test/rustdoc/const-generics/const-generic-slice.rs
@@ -1,5 +1,4 @@
#![crate_name = "foo"]
-#![feature(const_generics)]
pub trait Array {
type Item;
diff --git a/src/test/rustdoc/const-generics/const-impl.rs b/src/test/rustdoc/const-generics/const-impl.rs
index 7ddcb3a..fed37f6 100644
--- a/src/test/rustdoc/const-generics/const-impl.rs
+++ b/src/test/rustdoc/const-generics/const-impl.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(adt_const_params)]
#![crate_name = "foo"]
diff --git a/src/test/rustdoc/const-generics/const-evaluatable-checked.rs b/src/test/rustdoc/const-generics/generic_const_exprs.rs
similarity index 84%
rename from src/test/rustdoc/const-generics/const-evaluatable-checked.rs
rename to src/test/rustdoc/const-generics/generic_const_exprs.rs
index 1c074fd..35036a8 100644
--- a/src/test/rustdoc/const-generics/const-evaluatable-checked.rs
+++ b/src/test/rustdoc/const-generics/generic_const_exprs.rs
@@ -1,5 +1,5 @@
#![crate_name = "foo"]
-#![feature(const_evaluatable_checked, const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// make sure that `ConstEvaluatable` predicates dont cause rustdoc to ICE #77647
// @has foo/struct.Ice.html '//pre[@class="rust struct"]' \
diff --git a/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs b/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs
index f4c5dcc..4eac8e3 100644
--- a/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs
+++ b/src/test/rustdoc/const-generics/lazy_normalization_consts/const-equate-pred.rs
@@ -1,5 +1,5 @@
#![crate_name = "foo"]
-#![feature(lazy_normalization_consts)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// Checking if `Send` is implemented for `Hasher` requires us to evaluate a `ConstEquate` predicate,
diff --git a/src/test/rustdoc/macro-document-private-duplicate.rs b/src/test/rustdoc/macro-document-private-duplicate.rs
new file mode 100644
index 0000000..460785e
--- /dev/null
+++ b/src/test/rustdoc/macro-document-private-duplicate.rs
@@ -0,0 +1,23 @@
+// FIXME: If two macros in the same module have the same name
+// (yes, that's a thing), rustdoc lists both of them on the index page,
+// but only documents the first one on the page for the macro.
+// Fortunately, this can only happen in document private items mode,
+// but it still isn't ideal beahvior.
+//
+// See https://github.com/rust-lang/rust/pull/88019#discussion_r693920453
+//
+// compile-flags: --document-private-items
+
+// @has macro_document_private_duplicate/index.html 'Doc 1.'
+// @has macro_document_private_duplicate/macro.a_macro.html 'Doc 1.'
+/// Doc 1.
+macro_rules! a_macro {
+ () => ()
+}
+
+// @has macro_document_private_duplicate/index.html 'Doc 2.'
+// @!has macro_document_private_duplicate/macro.a_macro.html 'Doc 2.'
+/// Doc 2.
+macro_rules! a_macro {
+ () => ()
+}
diff --git a/src/test/rustdoc/macro-document-private.rs b/src/test/rustdoc/macro-document-private.rs
new file mode 100644
index 0000000..d249691
--- /dev/null
+++ b/src/test/rustdoc/macro-document-private.rs
@@ -0,0 +1,19 @@
+// Checks that private macros are documented when `--document-private-items`
+// is present.
+//
+// This is a regression test for issue #73754.
+//
+// compile-flags: --document-private-items
+
+#![feature(decl_macro)]
+
+
+// @has macro_document_private/macro.some_macro.html
+macro some_macro {
+ (a: tt) => {}
+}
+
+// @has macro_document_private/macro.another_macro.html
+macro_rules! another_macro {
+ (a: tt) => {}
+}
diff --git a/src/test/rustdoc/macro-indirect-use.rs b/src/test/rustdoc/macro-indirect-use.rs
new file mode 100644
index 0000000..b2d9336
--- /dev/null
+++ b/src/test/rustdoc/macro-indirect-use.rs
@@ -0,0 +1,16 @@
+// Checks that it is possible to make a macro public through a `pub use` of its
+// parent module.
+//
+// This is a regression test for issue #87257.
+
+#![feature(decl_macro)]
+
+mod outer {
+ pub mod inner {
+ pub macro some_macro() {}
+ }
+}
+
+// @has macro_indirect_use/inner/index.html
+// @has macro_indirect_use/inner/macro.some_macro.html
+pub use outer::inner;
diff --git a/src/test/rustdoc/macro-private-not-documented.rs b/src/test/rustdoc/macro-private-not-documented.rs
new file mode 100644
index 0000000..ae8b0e7
--- /dev/null
+++ b/src/test/rustdoc/macro-private-not-documented.rs
@@ -0,0 +1,19 @@
+// Checks that private macros aren't documented by default. They
+// should be still be documented in `--document-private-items` mode,
+// but that's tested in `macro-document-private.rs`.
+//
+//
+// This is a regression text for issue #88453.
+#![feature(decl_macro)]
+
+// @!has macro_private_not_documented/index.html 'a_macro'
+// @!has macro_private_not_documented/macro.a_macro.html
+macro_rules! a_macro {
+ () => ()
+}
+
+// @!has macro_private_not_documented/index.html 'another_macro'
+// @!has macro_private_not_documented/macro.another_macro.html
+macro another_macro {
+ () => ()
+}
diff --git a/src/test/rustfix/closure-immutable-outer-variable.fixed b/src/test/rustfix/closure-immutable-outer-variable.fixed
deleted file mode 100644
index 05bbc13..0000000
--- a/src/test/rustfix/closure-immutable-outer-variable.fixed
+++ /dev/null
@@ -1,10 +0,0 @@
-// Point at the captured immutable outer variable
-
-fn foo(mut f: Box<FnMut()>) {
- f();
-}
-
-fn main() {
- let mut y = true;
- foo(Box::new(move || y = false) as Box<_>);
-}
diff --git a/src/test/rustfix/closure-immutable-outer-variable.rs b/src/test/rustfix/closure-immutable-outer-variable.rs
deleted file mode 100644
index 6ed1bc1..0000000
--- a/src/test/rustfix/closure-immutable-outer-variable.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// Point at the captured immutable outer variable
-
-fn foo(mut f: Box<FnMut()>) {
- f();
-}
-
-fn main() {
- let y = true;
- foo(Box::new(move || y = false) as Box<_>);
-}
diff --git a/src/test/rustfix/empty-no-fixes.fixed b/src/test/rustfix/empty-no-fixes.fixed
deleted file mode 100644
index 3724a00..0000000
--- a/src/test/rustfix/empty-no-fixes.fixed
+++ /dev/null
@@ -1 +0,0 @@
-// compile-flags:--crate-type lib
diff --git a/src/test/rustfix/empty-no-fixes.rs b/src/test/rustfix/empty-no-fixes.rs
deleted file mode 100644
index 3724a00..0000000
--- a/src/test/rustfix/empty-no-fixes.rs
+++ /dev/null
@@ -1 +0,0 @@
-// compile-flags:--crate-type lib
diff --git a/src/test/rustfix/empty-no-fixes.rs.fixed b/src/test/rustfix/empty-no-fixes.rs.fixed
deleted file mode 100644
index e30d3ae..0000000
--- a/src/test/rustfix/empty-no-fixes.rs.fixed
+++ /dev/null
@@ -1,2 +0,0 @@
-// compile-flags:--crate-type lib
-fn foo() {}
diff --git a/src/test/rustfix/issue-45562.fixed b/src/test/rustfix/issue-45562.fixed
deleted file mode 100644
index 955b2cb..0000000
--- a/src/test/rustfix/issue-45562.fixed
+++ /dev/null
@@ -1,3 +0,0 @@
-#[no_mangle] pub static RAH: usize = 5;
-
-fn main() {}
diff --git a/src/test/rustfix/issue-45562.rs b/src/test/rustfix/issue-45562.rs
deleted file mode 100644
index a1ac070..0000000
--- a/src/test/rustfix/issue-45562.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-#[no_mangle] pub const RAH: usize = 5;
-
-fn main() {}
diff --git a/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed b/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
deleted file mode 100644
index b4ae4dc..0000000
--- a/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.fixed
+++ /dev/null
@@ -1,2 +0,0 @@
-extern crate std as other_std;
-fn main() {}
diff --git a/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs b/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
deleted file mode 100644
index a202b6c..0000000
--- a/src/test/rustfix/issue-45799-bad-extern-crate-rename-suggestion-formatting.rs
+++ /dev/null
@@ -1,2 +0,0 @@
-extern crate std;
-fn main() {}
diff --git a/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed b/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed
deleted file mode 100644
index bedc8e1..0000000
--- a/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.fixed
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(unused)]
-
-fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
- and_yet + 1
-}
-
-fn main() {
- let behold: isize = 2;
- let with_tears: usize = 3;
- light_flows_our_war_of_mocking_words(&(behold as usize));
- light_flows_our_war_of_mocking_words(&(with_tears + 4));
-}
diff --git a/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs b/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs
deleted file mode 100644
index 9c7ae96..0000000
--- a/src/test/rustfix/issue-46756-consider-borrowing-cast-or-binexpr.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#![allow(unused)]
-
-fn light_flows_our_war_of_mocking_words(and_yet: &usize) -> usize {
- and_yet + 1
-}
-
-fn main() {
- let behold: isize = 2;
- let with_tears: usize = 3;
- light_flows_our_war_of_mocking_words(behold as usize);
- light_flows_our_war_of_mocking_words(with_tears + 4);
-}
diff --git a/src/test/rustfix/main-no-fixes.fixed b/src/test/rustfix/main-no-fixes.fixed
deleted file mode 100644
index f328e4d..0000000
--- a/src/test/rustfix/main-no-fixes.fixed
+++ /dev/null
@@ -1 +0,0 @@
-fn main() {}
diff --git a/src/test/rustfix/main-no-fixes.rs b/src/test/rustfix/main-no-fixes.rs
deleted file mode 100644
index f328e4d..0000000
--- a/src/test/rustfix/main-no-fixes.rs
+++ /dev/null
@@ -1 +0,0 @@
-fn main() {}
diff --git a/src/test/rustfix/main-no-fixes.rs.fixed b/src/test/rustfix/main-no-fixes.rs.fixed
deleted file mode 100644
index f328e4d..0000000
--- a/src/test/rustfix/main-no-fixes.rs.fixed
+++ /dev/null
@@ -1 +0,0 @@
-fn main() {}
diff --git a/src/test/rustfix/missing-comma-in-match.fixed b/src/test/rustfix/missing-comma-in-match.fixed
deleted file mode 100644
index d4696ab..0000000
--- a/src/test/rustfix/missing-comma-in-match.fixed
+++ /dev/null
@@ -1,7 +0,0 @@
-fn main() {
- match &Some(3) {
- &None => 1,
- &Some(2) => { 3 }
- _ => 2
- };
-}
diff --git a/src/test/rustfix/missing-comma-in-match.rs b/src/test/rustfix/missing-comma-in-match.rs
deleted file mode 100644
index fed796c..0000000
--- a/src/test/rustfix/missing-comma-in-match.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-fn main() {
- match &Some(3) {
- &None => 1
- &Some(2) => { 3 }
- _ => 2
- };
-}
diff --git a/src/test/rustfix/str-as-char.fixed b/src/test/rustfix/str-as-char.fixed
deleted file mode 100644
index 900fee9..0000000
--- a/src/test/rustfix/str-as-char.fixed
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!("●●");
-}
diff --git a/src/test/rustfix/str-as-char.rs b/src/test/rustfix/str-as-char.rs
deleted file mode 100644
index b446551..0000000
--- a/src/test/rustfix/str-as-char.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!('●●');
-}
diff --git a/src/test/rustfix/tuple-float-index.fixed b/src/test/rustfix/tuple-float-index.fixed
deleted file mode 100644
index 358a27d..0000000
--- a/src/test/rustfix/tuple-float-index.fixed
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main () {
- ((1, (2, 3)).1).1;
-}
diff --git a/src/test/rustfix/tuple-float-index.rs b/src/test/rustfix/tuple-float-index.rs
deleted file mode 100644
index 7261225..0000000
--- a/src/test/rustfix/tuple-float-index.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main () {
- (1, (2, 3)).1.1;
-}
diff --git a/src/test/ui/abi/unsupported.aarch64.stderr b/src/test/ui/abi/unsupported.aarch64.stderr
index fdeb79f..225d49e 100644
--- a/src/test/ui/abi/unsupported.aarch64.stderr
+++ b/src/test/ui/abi/unsupported.aarch64.stderr
@@ -1,41 +1,47 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:24:1
+ --> $DIR/unsupported.rs:26:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:26:1
+ --> $DIR/unsupported.rs:28:1
|
LL | extern "amdgpu-kernel" fn amdgpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:28:1
+ --> $DIR/unsupported.rs:30:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
+error[E0570]: `"aapcs"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:32:1
+ |
+LL | extern "aapcs" fn aapcs() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:35:1
+ --> $DIR/unsupported.rs:38:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:37:1
+ --> $DIR/unsupported.rs:40:1
|
LL | extern "x86-interrupt" fn x86() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target
- --> $DIR/unsupported.rs:39:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -45,7 +51,7 @@
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
warning: use of calling convention not supported on this target
- --> $DIR/unsupported.rs:44:1
+ --> $DIR/unsupported.rs:50:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -53,6 +59,6 @@
= warning: 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 #87678 <https://github.com/rust-lang/rust/issues/87678>
-error: aborting due to 6 previous errors; 2 warnings emitted
+error: aborting due to 7 previous errors; 2 warnings emitted
For more information about this error, try `rustc --explain E0570`.
diff --git a/src/test/ui/abi/unsupported.arm.stderr b/src/test/ui/abi/unsupported.arm.stderr
new file mode 100644
index 0000000..b050ee0
--- /dev/null
+++ b/src/test/ui/abi/unsupported.arm.stderr
@@ -0,0 +1,58 @@
+error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:26:1
+ |
+LL | extern "ptx-kernel" fn ptx() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:28:1
+ |
+LL | extern "amdgpu-kernel" fn amdgpu() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"wasm"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:30:1
+ |
+LL | extern "wasm" fn wasm() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:36:1
+ |
+LL | extern "msp430-interrupt" fn msp430() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:38:1
+ |
+LL | extern "avr-interrupt" fn avr() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target
+ --> $DIR/unsupported.rs:40:1
+ |
+LL | extern "x86-interrupt" fn x86() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:43:1
+ |
+LL | extern "stdcall" fn stdcall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(unsupported_calling_conventions)]` on by default
+ = warning: 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 #87678 <https://github.com/rust-lang/rust/issues/87678>
+
+warning: use of calling convention not supported on this target
+ --> $DIR/unsupported.rs:50:1
+ |
+LL | extern "thiscall" fn thiscall() {}
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = warning: 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 #87678 <https://github.com/rust-lang/rust/issues/87678>
+
+error: aborting due to 6 previous errors; 2 warnings emitted
+
+For more information about this error, try `rustc --explain E0570`.
diff --git a/src/test/ui/abi/unsupported.i686.stderr b/src/test/ui/abi/unsupported.i686.stderr
index 81b1265..7ca9351 100644
--- a/src/test/ui/abi/unsupported.i686.stderr
+++ b/src/test/ui/abi/unsupported.i686.stderr
@@ -1,35 +1,35 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:24:1
+ --> $DIR/unsupported.rs:26:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:26:1
+ --> $DIR/unsupported.rs:28:1
|
LL | extern "amdgpu-kernel" fn amdgpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:28:1
+ --> $DIR/unsupported.rs:30:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:30:1
+ --> $DIR/unsupported.rs:32:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:35:1
+ --> $DIR/unsupported.rs:38:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/abi/unsupported.rs b/src/test/ui/abi/unsupported.rs
index f0debdc..9319eac 100644
--- a/src/test/ui/abi/unsupported.rs
+++ b/src/test/ui/abi/unsupported.rs
@@ -1,11 +1,13 @@
-// revisions: x64 i686 aarch64
+// revisions: x64 i686 aarch64 arm
//
// [x64] needs-llvm-components: x86
-// [x64]compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib
+// [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib
// [i686] needs-llvm-components: x86
-// [i686]compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib
+// [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib
// [aarch64] needs-llvm-components: aarch64
-// [aarch64]compile-flags: --target=aarch64-unknown-linux-gnu --crate-type=rlib
+// [aarch64] compile-flags: --target=aarch64-unknown-linux-gnu --crate-type=rlib
+// [arm] needs-llvm-components: arm
+// [arm] compile-flags: --target=armv7-unknown-linux-gnueabihf --crate-type=rlib
#![no_core]
#![feature(
no_core,
@@ -30,19 +32,25 @@ extern "wasm" fn wasm() {}
extern "aapcs" fn aapcs() {}
//[x64]~^ ERROR is not a supported ABI
//[i686]~^^ ERROR is not a supported ABI
+//[aarch64]~^^^ ERROR is not a supported ABI
extern "msp430-interrupt" fn msp430() {}
//~^ ERROR is not a supported ABI
extern "avr-interrupt" fn avr() {}
//~^ ERROR is not a supported ABI
extern "x86-interrupt" fn x86() {}
//[aarch64]~^ ERROR is not a supported ABI
+//[arm]~^^ ERROR is not a supported ABI
extern "stdcall" fn stdcall() {}
//[x64]~^ WARN use of calling convention not supported
//[x64]~^^ WARN this was previously accepted
//[aarch64]~^^^ WARN use of calling convention not supported
//[aarch64]~^^^^ WARN this was previously accepted
+//[arm]~^^^^^ WARN use of calling convention not supported
+//[arm]~^^^^^^ WARN this was previously accepted
extern "thiscall" fn thiscall() {}
//[x64]~^ WARN use of calling convention not supported
//[x64]~^^ WARN this was previously accepted
//[aarch64]~^^^ WARN use of calling convention not supported
//[aarch64]~^^^^ WARN this was previously accepted
+//[arm]~^^^^^ WARN use of calling convention not supported
+//[arm]~^^^^^^ WARN this was previously accepted
diff --git a/src/test/ui/abi/unsupported.x64.stderr b/src/test/ui/abi/unsupported.x64.stderr
index 60d067a..f2f5268 100644
--- a/src/test/ui/abi/unsupported.x64.stderr
+++ b/src/test/ui/abi/unsupported.x64.stderr
@@ -1,41 +1,41 @@
error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:24:1
+ --> $DIR/unsupported.rs:26:1
|
LL | extern "ptx-kernel" fn ptx() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"amdgpu-kernel"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:26:1
+ --> $DIR/unsupported.rs:28:1
|
LL | extern "amdgpu-kernel" fn amdgpu() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"wasm"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:28:1
+ --> $DIR/unsupported.rs:30:1
|
LL | extern "wasm" fn wasm() {}
| ^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"aapcs"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:30:1
+ --> $DIR/unsupported.rs:32:1
|
LL | extern "aapcs" fn aapcs() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:33:1
+ --> $DIR/unsupported.rs:36:1
|
LL | extern "msp430-interrupt" fn msp430() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target
- --> $DIR/unsupported.rs:35:1
+ --> $DIR/unsupported.rs:38:1
|
LL | extern "avr-interrupt" fn avr() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: use of calling convention not supported on this target
- --> $DIR/unsupported.rs:39:1
+ --> $DIR/unsupported.rs:43:1
|
LL | extern "stdcall" fn stdcall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -45,7 +45,7 @@
= note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678>
warning: use of calling convention not supported on this target
- --> $DIR/unsupported.rs:44:1
+ --> $DIR/unsupported.rs:50:1
|
LL | extern "thiscall" fn thiscall() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/array-slice-vec/match_arr_unknown_len.rs b/src/test/ui/array-slice-vec/match_arr_unknown_len.rs
index 45b2889..d190d70 100644
--- a/src/test/ui/array-slice-vec/match_arr_unknown_len.rs
+++ b/src/test/ui/array-slice-vec/match_arr_unknown_len.rs
@@ -1,6 +1,3 @@
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
-
fn is_123<const N: usize>(x: [u32; N]) -> bool {
match x {
[1, 2] => true, //~ ERROR mismatched types
diff --git a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr
index 0ad05b3..1a14ab4 100644
--- a/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr
+++ b/src/test/ui/array-slice-vec/match_arr_unknown_len.stderr
@@ -1,14 +1,5 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/match_arr_unknown_len.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
error[E0308]: mismatched types
- --> $DIR/match_arr_unknown_len.rs:6:9
+ --> $DIR/match_arr_unknown_len.rs:3:9
|
LL | [1, 2] => true,
| ^^^^^^ expected `2_usize`, found `N`
@@ -16,6 +7,6 @@
= note: expected array `[u32; 2]`
found array `[u32; N]`
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr
index d3a1cd3..46a54a1 100644
--- a/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr
+++ b/src/test/ui/associated-consts/associated-const-type-parameter-arrays.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `A`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr b/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr
index 0d84dca..f2e4ca5 100644
--- a/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr
+++ b/src/test/ui/associated-item/associated-item-duplicate-bounds.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^ cannot perform const operation using `A`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
index e72ef0e..4162cda 100644
--- a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
+++ b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr
@@ -4,7 +4,7 @@
LL | trait Baz: Foo + Bar<Self::Item> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: ...which again requires computing the super traits of `Baz` with associated type name `Item`, completing the cycle
+ = note: ...which immediately requires computing the super traits of `Baz` with associated type name `Item` again
note: cycle used when computing the super traits of `Baz`
--> $DIR/ambiguous-associated-type2.rs:7:1
|
diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr
index a694f88..57aacf6 100644
--- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr
+++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr
@@ -8,8 +8,10 @@
note: required by a bound in `Send`
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
-LL | pub unsafe auto trait Send {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Send`
+LL | / pub unsafe auto trait Send {
+LL | | // empty.
+LL | | }
+ | |_^ required by this bound in `Send`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Send {
@@ -25,8 +27,14 @@
note: required by a bound in `Iterator`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
-LL | pub trait Iterator {
- | ^^^^^^^^^^^^^^^^^^ required by this bound in `Iterator`
+LL | / pub trait Iterator {
+LL | | /// The type of the elements being iterated over.
+LL | | #[stable(feature = "rust1", since = "1.0.0")]
+LL | | type Item;
+... |
+LL | | }
+LL | | }
+ | |_^ required by this bound in `Iterator`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Iterator {
@@ -42,8 +50,14 @@
note: required by a bound in `Sync`
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
-LL | pub unsafe auto trait Sync {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Sync`
+LL | / pub unsafe auto trait Sync {
+LL | | // FIXME(estebank): once support to add notes in `rustc_on_unimplemented`
+LL | | // lands in beta, and it has been extended to check whether a closure is
+LL | | // anywhere in the requirement chain, extend it as such (#48534):
+... |
+LL | | // Empty
+LL | | }
+ | |_^ required by this bound in `Sync`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::C as Iterator>::Item: Sync {
diff --git a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr
index 775fe28..4da5a2c 100644
--- a/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr
+++ b/src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.stderr
@@ -8,8 +8,14 @@
note: required by a bound in `Debug`
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
-LL | pub trait Debug {
- | ^^^^^^^^^^^^^^^ required by this bound in `Debug`
+LL | / pub trait Debug {
+LL | | /// Formats the value using the given formatter.
+LL | | ///
+LL | | /// # Examples
+... |
+LL | | fn fmt(&self, f: &mut Formatter<'_>) -> Result;
+LL | | }
+ | |_^ required by this bound in `Debug`
help: consider further restricting the associated type
|
LL | trait Case1 where <<Self as Case1>::A as Iterator>::Item: Debug {
@@ -24,8 +30,14 @@
note: required by a bound in `Default`
--> $SRC_DIR/core/src/default.rs:LL:COL
|
-LL | pub trait Default: Sized {
- | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Default`
+LL | / pub trait Default: Sized {
+LL | | /// Returns the "default value" for a type.
+LL | | ///
+LL | | /// Default values are often some kind of initial value, identity value, or anything else that
+... |
+LL | | fn default() -> Self;
+LL | | }
+ | |_^ required by this bound in `Default`
help: consider further restricting the associated type
|
LL | pub trait Foo where <<Self as Foo>::Out as Baz>::Assoc: Default { type Out: Baz<Assoc: Default>; }
diff --git a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
index 43364a8..8fb570d 100644
--- a/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
+++ b/src/test/ui/async-await/edition-deny-async-fns-2015.stderr
@@ -4,7 +4,7 @@
LL | async fn foo() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -13,7 +13,7 @@
LL | fn baz() { async fn foo() {} }
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -22,7 +22,7 @@
LL | async fn async_baz() {
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -31,7 +31,7 @@
LL | async fn bar() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -40,7 +40,7 @@
LL | async fn foo() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -49,7 +49,7 @@
LL | async fn foo() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -58,7 +58,7 @@
LL | async fn bar() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -67,7 +67,7 @@
LL | async fn foo() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0670]: `async fn` is not permitted in Rust 2015
@@ -76,7 +76,7 @@
LL | async fn bar() {}
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0706]: functions in traits cannot be declared `async`
diff --git a/src/test/ui/async-await/issues/issue-78654.rs b/src/test/ui/async-await/issues/issue-78654.rs
index 37ebb4e..cc6dc38 100644
--- a/src/test/ui/async-await/issues/issue-78654.rs
+++ b/src/test/ui/async-await/issues/issue-78654.rs
@@ -1,7 +1,7 @@
// edition:2018
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Foo;
diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await.rs b/src/test/ui/async-await/suggest-switching-edition-on-await.rs
index 1402f1c..f2e0fb1 100644
--- a/src/test/ui/async-await/suggest-switching-edition-on-await.rs
+++ b/src/test/ui/async-await/suggest-switching-edition-on-await.rs
@@ -10,7 +10,7 @@ fn await_on_struct_missing() {
//~^ ERROR no field `await` on type
//~| NOTE unknown field
//~| NOTE to `.await` a `Future`, switch to Rust 2018
- //~| HELP set `edition = "2018"` in `Cargo.toml`
+ //~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
}
@@ -23,7 +23,7 @@ struct S {
//~^ ERROR no field `await` on type
//~| HELP a field with a similar name exists
//~| NOTE to `.await` a `Future`, switch to Rust 2018
- //~| HELP set `edition = "2018"` in `Cargo.toml`
+ //~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
}
@@ -32,7 +32,7 @@ fn await_on_63533(x: Pin<&mut dyn Future<Output = ()>>) {
//~^ ERROR no field `await` on type
//~| NOTE unknown field
//~| NOTE to `.await` a `Future`, switch to Rust 2018
- //~| HELP set `edition = "2018"` in `Cargo.toml`
+ //~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
}
@@ -40,6 +40,6 @@ fn await_on_apit(x: impl Future<Output = ()>) {
x.await;
//~^ ERROR no field `await` on type
//~| NOTE to `.await` a `Future`, switch to Rust 2018
- //~| HELP set `edition = "2018"` in `Cargo.toml`
+ //~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
}
diff --git a/src/test/ui/async-await/suggest-switching-edition-on-await.stderr b/src/test/ui/async-await/suggest-switching-edition-on-await.stderr
index 9ac2bc5..b38c897 100644
--- a/src/test/ui/async-await/suggest-switching-edition-on-await.stderr
+++ b/src/test/ui/async-await/suggest-switching-edition-on-await.stderr
@@ -5,7 +5,7 @@
| ^^^^^ unknown field
|
= note: to `.await` a `Future`, switch to Rust 2018 or later
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0609]: no field `await` on type `await_on_struct_similar::S`
@@ -15,7 +15,7 @@
| ^^^^^ help: a field with a similar name exists: `awai`
|
= note: to `.await` a `Future`, switch to Rust 2018 or later
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>`
@@ -25,7 +25,7 @@
| ^^^^^ unknown field
|
= note: to `.await` a `Future`, switch to Rust 2018 or later
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0609]: no field `await` on type `impl Future<Output = ()>`
@@ -35,7 +35,7 @@
| ^^^^^
|
= note: to `.await` a `Future`, switch to Rust 2018 or later
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error: aborting due to 4 previous errors
diff --git a/src/test/ui/binding/const-param.min.stderr b/src/test/ui/binding/const-param.min.stderr
deleted file mode 100644
index 0200c6d..0000000
--- a/src/test/ui/binding/const-param.min.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0158]: const parameters cannot be referenced in patterns
- --> $DIR/const-param.rs:8:9
- |
-LL | N => {}
- | ^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0158`.
diff --git a/src/test/ui/binding/const-param.rs b/src/test/ui/binding/const-param.rs
index 4aec801..2d05180 100644
--- a/src/test/ui/binding/const-param.rs
+++ b/src/test/ui/binding/const-param.rs
@@ -1,7 +1,4 @@
// Identifier pattern referring to a const generic parameter is an error (issue #68853).
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
fn check<const N: usize>() {
match 1 {
diff --git a/src/test/ui/binding/const-param.full.stderr b/src/test/ui/binding/const-param.stderr
similarity index 87%
rename from src/test/ui/binding/const-param.full.stderr
rename to src/test/ui/binding/const-param.stderr
index 0200c6d..adda808 100644
--- a/src/test/ui/binding/const-param.full.stderr
+++ b/src/test/ui/binding/const-param.stderr
@@ -1,5 +1,5 @@
error[E0158]: const parameters cannot be referenced in patterns
- --> $DIR/const-param.rs:8:9
+ --> $DIR/const-param.rs:5:9
|
LL | N => {}
| ^
diff --git a/src/test/ui/borrowck/mut-borrow-of-mut-ref.rs b/src/test/ui/borrowck/mut-borrow-of-mut-ref.rs
index 3f09284..7cdb16b 100644
--- a/src/test/ui/borrowck/mut-borrow-of-mut-ref.rs
+++ b/src/test/ui/borrowck/mut-borrow-of-mut-ref.rs
@@ -2,12 +2,36 @@
#![crate_type = "rlib"]
pub fn f(b: &mut i32) {
- g(&mut b);
+ //~^ NOTE the binding is already a mutable borrow
+ //~| NOTE the binding is already a mutable borrow
+ h(&mut b);
//~^ ERROR cannot borrow
+ //~| NOTE cannot borrow as mutable
//~| HELP try removing `&mut` here
g(&mut &mut b);
//~^ ERROR cannot borrow
+ //~| NOTE cannot borrow as mutable
//~| HELP try removing `&mut` here
}
-pub fn g(_: &mut i32) {}
+pub fn g(b: &mut i32) { //~ NOTE the binding is already a mutable borrow
+ h(&mut &mut b);
+ //~^ ERROR cannot borrow
+ //~| NOTE cannot borrow as mutable
+ //~| HELP try removing `&mut` here
+}
+
+pub fn h(_: &mut i32) {}
+
+trait Foo {
+ fn bar(&mut self);
+}
+
+impl Foo for &mut String {
+ fn bar(&mut self) {}
+}
+
+pub fn baz(f: &mut String) { //~ HELP consider making the binding mutable
+ f.bar(); //~ ERROR cannot borrow `f` as mutable, as it is not declared as mutable
+ //~^ NOTE cannot borrow as mutable
+}
diff --git a/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr b/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr
index cb7355b..e4c51bb 100644
--- a/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr
+++ b/src/test/ui/borrowck/mut-borrow-of-mut-ref.stderr
@@ -1,21 +1,65 @@
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable
- --> $DIR/mut-borrow-of-mut-ref.rs:5:7
+ --> $DIR/mut-borrow-of-mut-ref.rs:7:7
|
-LL | g(&mut b);
- | ^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
+LL | h(&mut b);
+ | ^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/mut-borrow-of-mut-ref.rs:4:13
+ |
+LL | pub fn f(b: &mut i32) {
+ | ^^^^^^^^
+help: try removing `&mut` here
+ |
+LL - h(&mut b);
+LL + h(b);
+ |
error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable
- --> $DIR/mut-borrow-of-mut-ref.rs:8:12
+ --> $DIR/mut-borrow-of-mut-ref.rs:11:12
|
LL | g(&mut &mut b);
- | ^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
+ | ^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/mut-borrow-of-mut-ref.rs:4:13
+ |
+LL | pub fn f(b: &mut i32) {
+ | ^^^^^^^^
+help: try removing `&mut` here
+ |
+LL - g(&mut &mut b);
+LL + g(&mut b);
+ |
-error: aborting due to 2 previous errors
+error[E0596]: cannot borrow `b` as mutable, as it is not declared as mutable
+ --> $DIR/mut-borrow-of-mut-ref.rs:18:12
+ |
+LL | h(&mut &mut b);
+ | ^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/mut-borrow-of-mut-ref.rs:17:13
+ |
+LL | pub fn g(b: &mut i32) {
+ | ^^^^^^^^
+help: try removing `&mut` here
+ |
+LL - h(&mut &mut b);
+LL + h(&mut b);
+ |
+
+error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable
+ --> $DIR/mut-borrow-of-mut-ref.rs:35:5
+ |
+LL | f.bar();
+ | ^ cannot borrow as mutable
+ |
+help: consider making the binding mutable
+ |
+LL | pub fn baz(mut f: &mut String) {
+ | +++
+
+error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0596`.
diff --git a/src/test/ui/closures/2229_closure_analysis/match/auxiliary/match_non_exhaustive_lib.rs b/src/test/ui/closures/2229_closure_analysis/match/auxiliary/match_non_exhaustive_lib.rs
new file mode 100644
index 0000000..4060c40
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/auxiliary/match_non_exhaustive_lib.rs
@@ -0,0 +1,10 @@
+#[non_exhaustive]
+pub enum E1 {}
+
+#[non_exhaustive]
+pub enum E2 { A, B }
+
+#[non_exhaustive]
+pub enum E3 { C }
+
+pub enum E4 { D }
diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87097.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.rs
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/issue-87097.rs
rename to src/test/ui/closures/2229_closure_analysis/match/issue-87097.rs
diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87097.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/issue-87097.stderr
rename to src/test/ui/closures/2229_closure_analysis/match/issue-87097.stderr
diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87426.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-87426.rs
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/issue-87426.rs
rename to src/test/ui/closures/2229_closure_analysis/match/issue-87426.rs
diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87988.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-87988.rs
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/issue-87988.rs
rename to src/test/ui/closures/2229_closure_analysis/match/issue-87988.rs
diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-88331.rs b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.rs
new file mode 100644
index 0000000..0a6d71c
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.rs
@@ -0,0 +1,33 @@
+// edition:2021
+
+#[derive(Copy, Clone, PartialEq, Eq)]
+pub struct Opcode(pub u8);
+
+impl Opcode {
+ pub const OP1: Opcode = Opcode(0x1);
+}
+
+pub fn example1(msg_type: Opcode) -> impl FnMut(&[u8]) {
+ move |i| match msg_type {
+ //~^ ERROR: non-exhaustive patterns: `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered
+ Opcode::OP1 => unimplemented!(),
+ }
+}
+
+#[derive(Copy, Clone, PartialEq, Eq)]
+pub struct Opcode2(Opcode);
+
+impl Opcode2 {
+ pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
+}
+
+
+pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
+
+ move |i| match msg_type {
+ //~^ ERROR: non-exhaustive patterns: `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered
+ Opcode2::OP2=> unimplemented!(),
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr
new file mode 100644
index 0000000..f02d234
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/issue-88331.stderr
@@ -0,0 +1,27 @@
+error[E0004]: non-exhaustive patterns: `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered
+ --> $DIR/issue-88331.rs:11:20
+ |
+LL | pub struct Opcode(pub u8);
+ | -------------------------- `Opcode` defined here
+...
+LL | move |i| match msg_type {
+ | ^^^^^^^^ patterns `Opcode(0_u8)` and `Opcode(2_u8..=u8::MAX)` not covered
+ |
+ = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+ = note: the matched value is of type `Opcode`
+
+error[E0004]: non-exhaustive patterns: `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered
+ --> $DIR/issue-88331.rs:27:20
+ |
+LL | pub struct Opcode2(Opcode);
+ | --------------------------- `Opcode2` defined here
+...
+LL | move |i| match msg_type {
+ | ^^^^^^^^ patterns `Opcode2(Opcode(0_u8))` and `Opcode2(Opcode(2_u8..=u8::MAX))` not covered
+ |
+ = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+ = note: the matched value is of type `Opcode2`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0004`.
diff --git a/src/test/ui/closures/2229_closure_analysis/match-edge-cases.rs b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_1.rs
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/match-edge-cases.rs
rename to src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_1.rs
diff --git a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs
new file mode 100644
index 0000000..ae724f9
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.rs
@@ -0,0 +1,37 @@
+// edition:2021
+
+enum SingleVariant {
+ A
+}
+
+struct TestStruct {
+ x: i32,
+ y: i32,
+ z: i32,
+}
+
+fn edge_case_if() {
+ let sv = SingleVariant::A;
+ let condition = true;
+ // sv should not be captured as it is a SingleVariant
+ let _a = || {
+ match sv {
+ SingleVariant::A if condition => (),
+ _ => ()
+ }
+ };
+ let mut mut_sv = sv;
+ _a();
+
+ // ts should be captured
+ let ts = TestStruct { x: 1, y: 1, z: 1 };
+ let _b = || { match ts {
+ TestStruct{ x: 1, .. } => (),
+ _ => ()
+ }};
+ let mut mut_ts = ts;
+ //~^ ERROR: cannot move out of `ts` because it is borrowed
+ _b();
+}
+
+fn main() {}
diff --git a/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr
new file mode 100644
index 0000000..1e42d73
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/match-edge-cases_2.stderr
@@ -0,0 +1,17 @@
+error[E0505]: cannot move out of `ts` because it is borrowed
+ --> $DIR/match-edge-cases_2.rs:32:22
+ |
+LL | let _b = || { match ts {
+ | -- -- borrow occurs due to use in closure
+ | |
+ | borrow of `ts` occurs here
+...
+LL | let mut mut_ts = ts;
+ | ^^ move out of `ts` occurs here
+LL |
+LL | _b();
+ | -- borrow later used here
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0505`.
diff --git a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs
new file mode 100644
index 0000000..318673e
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.rs
@@ -0,0 +1,54 @@
+// edition:2021
+
+// aux-build:match_non_exhaustive_lib.rs
+
+/* The error message for non-exhaustive matches on non-local enums
+ * marked as non-exhaustive should mention the fact that the enum
+ * is marked as non-exhaustive (issue #85227).
+ */
+
+// Ignore non_exhaustive in the same crate
+#[non_exhaustive]
+enum L1 { A, B }
+enum L2 { C }
+
+extern crate match_non_exhaustive_lib;
+use match_non_exhaustive_lib::{E1, E2, E3, E4};
+
+fn foo() -> (L1, L2) {todo!()}
+fn bar() -> (E1, E2, E3, E4) {todo!()}
+
+fn main() {
+ let (l1, l2) = foo();
+ // No error for enums defined in this crate
+ let _a = || { match l1 { L1::A => (), L1::B => () } };
+ // (except if the match is already non-exhaustive)
+ let _b = || { match l1 { L1::A => () } };
+ //~^ ERROR: non-exhaustive patterns: `B` not covered [E0004]
+
+ // l2 should not be captured as it is a non-exhaustive SingleVariant
+ // defined in this crate
+ let _c = || { match l2 { L2::C => (), _ => () } };
+ let mut mut_l2 = l2;
+ _c();
+
+ // E1 is not visibly uninhabited from here
+ let (e1, e2, e3, e4) = bar();
+ let _d = || { match e1 {} };
+ //~^ ERROR: non-exhaustive patterns: type `E1` is non-empty [E0004]
+ let _e = || { match e2 { E2::A => (), E2::B => () } };
+ //~^ ERROR: non-exhaustive patterns: `_` not covered [E0004]
+ let _f = || { match e2 { E2::A => (), E2::B => (), _ => () } };
+
+ // e3 should be captured as it is a non-exhaustive SingleVariant
+ // defined in another crate
+ let _g = || { match e3 { E3::C => (), _ => () } };
+ let mut mut_e3 = e3;
+ //~^ ERROR: cannot move out of `e3` because it is borrowed
+ _g();
+
+ // e4 should not be captured as it is a SingleVariant
+ let _h = || { match e4 { E4::D => (), _ => () } };
+ let mut mut_e4 = e4;
+ _h();
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr
new file mode 100644
index 0000000..91ffe1a
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/match/non-exhaustive-match.stderr
@@ -0,0 +1,50 @@
+error[E0004]: non-exhaustive patterns: `B` not covered
+ --> $DIR/non-exhaustive-match.rs:26:25
+ |
+LL | enum L1 { A, B }
+ | ----------------
+ | | |
+ | | not covered
+ | `L1` defined here
+...
+LL | let _b = || { match l1 { L1::A => () } };
+ | ^^ pattern `B` not covered
+ |
+ = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+ = note: the matched value is of type `L1`
+
+error[E0004]: non-exhaustive patterns: type `E1` is non-empty
+ --> $DIR/non-exhaustive-match.rs:37:25
+ |
+LL | let _d = || { match e1 {} };
+ | ^^
+ |
+ = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+ = note: the matched value is of type `E1`, which is marked as non-exhaustive
+
+error[E0004]: non-exhaustive patterns: `_` not covered
+ --> $DIR/non-exhaustive-match.rs:39:25
+ |
+LL | let _e = || { match e2 { E2::A => (), E2::B => () } };
+ | ^^ pattern `_` not covered
+ |
+ = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+ = note: the matched value is of type `E2`, which is marked as non-exhaustive
+
+error[E0505]: cannot move out of `e3` because it is borrowed
+ --> $DIR/non-exhaustive-match.rs:46:22
+ |
+LL | let _g = || { match e3 { E3::C => (), _ => () } };
+ | -- -- borrow occurs due to use in closure
+ | |
+ | borrow of `e3` occurs here
+LL | let mut mut_e3 = e3;
+ | ^^ move out of `e3` occurs here
+LL |
+LL | _g();
+ | -- borrow later used here
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0004, E0505.
+For more information about an error, try `rustc --explain E0004`.
diff --git a/src/test/ui/closures/2229_closure_analysis/pattern-matching-should-fail.rs b/src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.rs
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/pattern-matching-should-fail.rs
rename to src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.rs
diff --git a/src/test/ui/closures/2229_closure_analysis/pattern-matching-should-fail.stderr b/src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/pattern-matching-should-fail.stderr
rename to src/test/ui/closures/2229_closure_analysis/match/pattern-matching-should-fail.stderr
diff --git a/src/test/ui/closures/2229_closure_analysis/patterns-capture-analysis.rs b/src/test/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/patterns-capture-analysis.rs
rename to src/test/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.rs
diff --git a/src/test/ui/closures/2229_closure_analysis/patterns-capture-analysis.stderr b/src/test/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr
similarity index 100%
rename from src/test/ui/closures/2229_closure_analysis/patterns-capture-analysis.stderr
rename to src/test/ui/closures/2229_closure_analysis/match/patterns-capture-analysis.stderr
diff --git a/src/test/ui/closures/2229_closure_analysis/move_closure.rs b/src/test/ui/closures/2229_closure_analysis/move_closure.rs
index 6b49293..b542fa2 100644
--- a/src/test/ui/closures/2229_closure_analysis/move_closure.rs
+++ b/src/test/ui/closures/2229_closure_analysis/move_closure.rs
@@ -35,7 +35,7 @@ fn simple_ref() {
//~| ERROR: Min Capture analysis includes:
*ref_s += 10;
//~^ NOTE: Capturing ref_s[Deref] -> MutBorrow
- //~| NOTE: Min Capture ref_s[Deref] -> MutBorrow
+ //~| NOTE: Min Capture ref_s[] -> ByValue
};
c();
}
@@ -56,7 +56,7 @@ fn struct_contains_ref_to_another_struct_1() {
//~| ERROR: Min Capture analysis includes:
t.0.0 = "new s".into();
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> MutBorrow
- //~| NOTE: Min Capture t[(0, 0),Deref,(0, 0)] -> MutBorrow
+ //~| NOTE: Min Capture t[(0, 0)] -> ByValue
};
c();
@@ -79,7 +79,7 @@ fn struct_contains_ref_to_another_struct_2() {
//~| ERROR: Min Capture analysis includes:
let _t = t.0.0;
//~^ NOTE: Capturing t[(0, 0),Deref,(0, 0)] -> ImmBorrow
- //~| NOTE: Min Capture t[(0, 0),Deref] -> ImmBorrow
+ //~| NOTE: Min Capture t[(0, 0)] -> ByValue
};
c();
@@ -175,7 +175,7 @@ fn box_mut_1() {
//~| First Pass analysis includes:
//~| NOTE: Capturing box_p_foo[Deref,Deref,(0, 0)] -> MutBorrow
//~| Min Capture analysis includes:
- //~| NOTE: Min Capture box_p_foo[Deref,Deref,(0, 0)] -> MutBorrow
+ //~| NOTE: Min Capture box_p_foo[] -> ByValue
}
// Ensure that even in move closures, if the data is not owned by the root variable
@@ -192,7 +192,7 @@ fn box_mut_2() {
//~| First Pass analysis includes:
//~| NOTE: Capturing p_foo[Deref,Deref,(0, 0)] -> MutBorrow
//~| Min Capture analysis includes:
- //~| NOTE: Min Capture p_foo[Deref,Deref,(0, 0)] -> MutBorrow
+ //~| NOTE: Min Capture p_foo[] -> ByValue
}
// Test that move closures can take ownership of Copy type
diff --git a/src/test/ui/closures/2229_closure_analysis/move_closure.stderr b/src/test/ui/closures/2229_closure_analysis/move_closure.stderr
index b99b451..fd80e05 100644
--- a/src/test/ui/closures/2229_closure_analysis/move_closure.stderr
+++ b/src/test/ui/closures/2229_closure_analysis/move_closure.stderr
@@ -187,7 +187,7 @@
LL | | };
| |_____^
|
-note: Min Capture ref_s[Deref] -> MutBorrow
+note: Min Capture ref_s[] -> ByValue
--> $DIR/move_closure.rs:36:9
|
LL | *ref_s += 10;
@@ -223,7 +223,7 @@
LL | | };
| |_____^
|
-note: Min Capture t[(0, 0),Deref,(0, 0)] -> MutBorrow
+note: Min Capture t[(0, 0)] -> ByValue
--> $DIR/move_closure.rs:57:9
|
LL | t.0.0 = "new s".into();
@@ -259,7 +259,7 @@
LL | | };
| |_____^
|
-note: Min Capture t[(0, 0),Deref] -> ImmBorrow
+note: Min Capture t[(0, 0)] -> ByValue
--> $DIR/move_closure.rs:80:18
|
LL | let _t = t.0.0;
@@ -427,7 +427,7 @@
LL | let c = #[rustc_capture_analysis] move || box_p_foo.x += 10;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: Min Capture box_p_foo[Deref,Deref,(0, 0)] -> MutBorrow
+note: Min Capture box_p_foo[] -> ByValue
--> $DIR/move_closure.rs:172:47
|
LL | let c = #[rustc_capture_analysis] move || box_p_foo.x += 10;
@@ -451,7 +451,7 @@
LL | let c = #[rustc_capture_analysis] move || p_foo.x += 10;
| ^^^^^^^^^^^^^^^^^^^^^
|
-note: Min Capture p_foo[Deref,Deref,(0, 0)] -> MutBorrow
+note: Min Capture p_foo[] -> ByValue
--> $DIR/move_closure.rs:189:47
|
LL | let c = #[rustc_capture_analysis] move || p_foo.x += 10;
diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/issue-88372.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/issue-88372.rs
new file mode 100644
index 0000000..25fbb6c
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/run_pass/issue-88372.rs
@@ -0,0 +1,19 @@
+// edition:2021
+// run-pass
+
+
+fn solve<F>(validate: F) -> Option<u64>
+where
+ F: Fn(&mut [i8; 1]),
+{
+ let mut position: [i8; 1] = [1];
+ Some(0).map(|_| {
+ validate(&mut position);
+ let [_x] = position;
+ 0
+ })
+}
+
+fn main() {
+ solve(|_| ());
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/issue-88431.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/issue-88431.rs
new file mode 100644
index 0000000..9996205
--- /dev/null
+++ b/src/test/ui/closures/2229_closure_analysis/run_pass/issue-88431.rs
@@ -0,0 +1,59 @@
+// edition:2021
+// check-pass
+
+use std::collections::HashMap;
+use std::future::Future;
+use std::pin::Pin;
+
+pub struct GameMode {}
+
+struct GameStateManager<'a> {
+ gamestate_stack: Vec<Box<dyn GameState<'a> + 'a>>,
+}
+
+pub trait GameState<'a> {}
+
+async fn construct_gamestate_replay<'a>(
+ _gamemode: &GameMode,
+ _factory: &mut GameStateManager<'a>,
+) -> Box<dyn GameState<'a> + 'a> {
+ unimplemented!()
+}
+
+type FutureGameState<'a, 'b> = Pin<Box<dyn Future<Output = Box<dyn GameState<'a> + 'a>> + 'b>>;
+
+struct MenuOption<'a> {
+ command: Box<dyn for<'b> Fn(&'b mut GameStateManager<'a>) -> FutureGameState<'a, 'b> + 'a>,
+}
+
+impl<'a> MenuOption<'a> {
+ fn new(
+ _command: impl for<'b> Fn(&'b mut GameStateManager<'a>) -> FutureGameState<'a, 'b> + 'a,
+ ) -> Self {
+ unimplemented!()
+ }
+}
+
+struct MenuState<'a> {
+ options: Vec<MenuOption<'a>>,
+}
+
+impl<'a> GameState<'a> for MenuState<'a> {}
+
+pub async fn get_replay_menu<'a>(
+ gamemodes: &'a HashMap<&str, GameMode>,
+) -> Box<dyn GameState<'a> + 'a> {
+ let recordings: Vec<String> = vec![];
+ let _ = recordings
+ .into_iter()
+ .map(|entry| {
+ MenuOption::new(move |f| {
+ Box::pin(construct_gamestate_replay(&gamemodes[entry.as_str()], f))
+ })
+ })
+ .collect::<Vec<_>>();
+
+ todo!()
+}
+
+fn main() {}
diff --git a/src/test/ui/closures/2229_closure_analysis/run_pass/move_closure.rs b/src/test/ui/closures/2229_closure_analysis/run_pass/move_closure.rs
index e1b61e8..f76965b 100644
--- a/src/test/ui/closures/2229_closure_analysis/run_pass/move_closure.rs
+++ b/src/test/ui/closures/2229_closure_analysis/run_pass/move_closure.rs
@@ -56,28 +56,6 @@ fn no_ref_nested() {
c();
}
-struct A<'a>(&'a mut String, &'a mut String);
-// Test that reborrowing works as expected for move closures
-// by attempting a disjoint capture through a reference.
-fn disjoint_via_ref() {
- let mut x = String::new();
- let mut y = String::new();
-
- let mut a = A(&mut x, &mut y);
- let a = &mut a;
-
- let mut c1 = move || {
- a.0.truncate(0);
- };
-
- let mut c2 = move || {
- a.1.truncate(0);
- };
-
- c1();
- c2();
-}
-
// Test that even if a path is moved into the closure, the closure is not FnOnce
// if the path is not moved by the closure call.
fn data_moved_but_not_fn_once() {
@@ -109,7 +87,6 @@ fn main() {
no_ref();
no_ref_nested();
- disjoint_via_ref();
data_moved_but_not_fn_once();
returned_closure_owns_copy_type_data();
diff --git a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
index f3edf1c..97f3c75 100644
--- a/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
+++ b/src/test/ui/coherence/coherence-inherited-assoc-ty-cycle-err.stderr
@@ -14,7 +14,7 @@
LL | trait Trait<T> { type Assoc; }
| ^^^^^^^^^^^^^^
|
- = note: ...which again requires building specialization graph of trait `Trait`, completing the cycle
+ = note: ...which immediately requires building specialization graph of trait `Trait` again
note: cycle used when coherence checking all impls of trait `Trait`
--> $DIR/coherence-inherited-assoc-ty-cycle-err.rs:9:1
|
diff --git a/src/test/ui/const-generics/apit-with-const-param.rs b/src/test/ui/const-generics/apit-with-const-param.rs
index 3bc6214..2a04dc3 100644
--- a/src/test/ui/const-generics/apit-with-const-param.rs
+++ b/src/test/ui/const-generics/apit-with-const-param.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait Trait {}
diff --git a/src/test/ui/const-generics/argument_order.full.stderr b/src/test/ui/const-generics/argument_order.full.stderr
index e533d4f..9762748 100644
--- a/src/test/ui/const-generics/argument_order.full.stderr
+++ b/src/test/ui/const-generics/argument_order.full.stderr
@@ -1,11 +1,11 @@
error: lifetime parameters must be declared prior to const parameters
- --> $DIR/argument_order.rs:11:32
+ --> $DIR/argument_order.rs:10:32
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
error[E0747]: lifetime provided when a type was expected
- --> $DIR/argument_order.rs:19:23
+ --> $DIR/argument_order.rs:18:23
|
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^
diff --git a/src/test/ui/const-generics/argument_order.min.stderr b/src/test/ui/const-generics/argument_order.min.stderr
index f23bc6d..afd9ed1 100644
--- a/src/test/ui/const-generics/argument_order.min.stderr
+++ b/src/test/ui/const-generics/argument_order.min.stderr
@@ -1,23 +1,23 @@
error: type parameters must be declared prior to const parameters
- --> $DIR/argument_order.rs:5:28
+ --> $DIR/argument_order.rs:4:28
|
LL | struct Bad<const N: usize, T> {
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
error: lifetime parameters must be declared prior to const parameters
- --> $DIR/argument_order.rs:11:32
+ --> $DIR/argument_order.rs:10:32
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
error: type parameters must be declared prior to const parameters
- --> $DIR/argument_order.rs:11:36
+ --> $DIR/argument_order.rs:10:36
|
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
error[E0747]: lifetime provided when a type was expected
- --> $DIR/argument_order.rs:19:23
+ --> $DIR/argument_order.rs:18:23
|
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^
diff --git a/src/test/ui/const-generics/argument_order.rs b/src/test/ui/const-generics/argument_order.rs
index 95eaeea..97dd0f1 100644
--- a/src/test/ui/const-generics/argument_order.rs
+++ b/src/test/ui/const-generics/argument_order.rs
@@ -1,6 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics_defaults))]
struct Bad<const N: usize, T> {
//[min]~^ ERROR type parameters must be declared prior to const parameters
diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr b/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr
deleted file mode 100644
index 0fb23e4..0000000
--- a/src/test/ui/const-generics/array-size-in-generic-struct-param.full.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:8:38
- |
-LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
- | ^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/array-size-in-generic-struct-param.rs:19:10
- |
-LL | arr: [u8; CFG.arr_size],
- | ^^^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs
index 732a187..a712f69 100644
--- a/src/test/ui/const-generics/array-wrapper-struct-ctor.rs
+++ b/src/test/ui/const-generics/array-wrapper-struct-ctor.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
#![allow(dead_code)]
diff --git a/src/test/ui/const-generics/associated-type-bound-fail.min.stderr b/src/test/ui/const-generics/associated-type-bound-fail.min.stderr
deleted file mode 100644
index 7ab430b..0000000
--- a/src/test/ui/const-generics/associated-type-bound-fail.min.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error[E0277]: the trait bound `u16: Bar<N>` is not satisfied
- --> $DIR/associated-type-bound-fail.rs:13:5
- |
-LL | type Assoc = u16;
- | ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16`
- |
- = help: the following implementations were found:
- <u16 as Bar<3_usize>>
-note: required by a bound in `Foo::Assoc`
- --> $DIR/associated-type-bound-fail.rs:8:17
- |
-LL | type Assoc: Bar<N>;
- | ^^^^^^ required by this bound in `Foo::Assoc`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/associated-type-bound-fail.rs b/src/test/ui/const-generics/associated-type-bound-fail.rs
index 83b2670..937b8bc 100644
--- a/src/test/ui/const-generics/associated-type-bound-fail.rs
+++ b/src/test/ui/const-generics/associated-type-bound-fail.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
trait Bar<const N: usize> {}
trait Foo<const N: usize> {
diff --git a/src/test/ui/const-generics/associated-type-bound-fail.full.stderr b/src/test/ui/const-generics/associated-type-bound-fail.stderr
similarity index 84%
rename from src/test/ui/const-generics/associated-type-bound-fail.full.stderr
rename to src/test/ui/const-generics/associated-type-bound-fail.stderr
index 7ab430b..60e624f 100644
--- a/src/test/ui/const-generics/associated-type-bound-fail.full.stderr
+++ b/src/test/ui/const-generics/associated-type-bound-fail.stderr
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `u16: Bar<N>` is not satisfied
- --> $DIR/associated-type-bound-fail.rs:13:5
+ --> $DIR/associated-type-bound-fail.rs:9:5
|
LL | type Assoc = u16;
| ^^^^^^^^^^^^^^^^^ the trait `Bar<N>` is not implemented for `u16`
@@ -7,7 +7,7 @@
= help: the following implementations were found:
<u16 as Bar<3_usize>>
note: required by a bound in `Foo::Assoc`
- --> $DIR/associated-type-bound-fail.rs:8:17
+ --> $DIR/associated-type-bound-fail.rs:4:17
|
LL | type Assoc: Bar<N>;
| ^^^^^^ required by this bound in `Foo::Assoc`
diff --git a/src/test/ui/const-generics/associated-type-bound.rs b/src/test/ui/const-generics/associated-type-bound.rs
index 02f7739..3044736 100644
--- a/src/test/ui/const-generics/associated-type-bound.rs
+++ b/src/test/ui/const-generics/associated-type-bound.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
trait Bar<const N: usize> {}
trait Foo<const N: usize> {
diff --git a/src/test/ui/const-generics/auxiliary/const_generic_lib.rs b/src/test/ui/const-generics/auxiliary/const_generic_lib.rs
index 8d4cd9c..922f92d 100644
--- a/src/test/ui/const-generics/auxiliary/const_generic_lib.rs
+++ b/src/test/ui/const-generics/auxiliary/const_generic_lib.rs
@@ -1,6 +1,3 @@
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
pub struct Struct<const N: usize>(pub [u8; N]);
pub type Alias = Struct<2>;
diff --git a/src/test/ui/const-generics/auxiliary/crayte.rs b/src/test/ui/const-generics/auxiliary/crayte.rs
index d9baab9..19a8bb0 100644
--- a/src/test/ui/const-generics/auxiliary/crayte.rs
+++ b/src/test/ui/const-generics/auxiliary/crayte.rs
@@ -1,6 +1,4 @@
// edition:2018
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
pub trait Foo<const N: usize> {}
struct Local;
diff --git a/src/test/ui/const-generics/auxiliary/generics_of_parent.rs b/src/test/ui/const-generics/auxiliary/generics_of_parent.rs
index 576276d..5c2b1f4 100644
--- a/src/test/ui/const-generics/auxiliary/generics_of_parent.rs
+++ b/src/test/ui/const-generics/auxiliary/generics_of_parent.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// library portion of regression test for #87674
diff --git a/src/test/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs b/src/test/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs
index 0d03f56..cd5b816 100644
--- a/src/test/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs
+++ b/src/test/ui/const-generics/auxiliary/generics_of_parent_impl_trait.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// library portion of testing that `impl Trait<{ expr }>` doesnt
diff --git a/src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs b/src/test/ui/const-generics/backcompat/trait-resolution-breakage.rs
similarity index 100%
rename from src/test/ui/lazy_normalization_consts/trait-resolution-breakage.rs
rename to src/test/ui/const-generics/backcompat/trait-resolution-breakage.rs
diff --git a/src/test/ui/lazy_normalization_consts/unevaluated-consts.rs b/src/test/ui/const-generics/backcompat/unevaluated-consts.rs
similarity index 100%
rename from src/test/ui/lazy_normalization_consts/unevaluated-consts.rs
rename to src/test/ui/const-generics/backcompat/unevaluated-consts.rs
diff --git a/src/test/ui/const-generics/broken-mir-1.rs b/src/test/ui/const-generics/broken-mir-1.rs
index 34255fa..6b6140e 100644
--- a/src/test/ui/const-generics/broken-mir-1.rs
+++ b/src/test/ui/const-generics/broken-mir-1.rs
@@ -1,9 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
pub trait Foo {
fn foo(&self);
}
diff --git a/src/test/ui/const-generics/broken-mir-2.rs b/src/test/ui/const-generics/broken-mir-2.rs
index ac358b0..f9e0315 100644
--- a/src/test/ui/const-generics/broken-mir-2.rs
+++ b/src/test/ui/const-generics/broken-mir-2.rs
@@ -1,9 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
use std::fmt::Debug;
#[derive(Debug)]
diff --git a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs
index 44aef85..a6e7674 100644
--- a/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs
+++ b/src/test/ui/const-generics/cannot-infer-type-for-const-param.rs
@@ -1,7 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
// This test confirms that the types can be inferred correctly for this example with const
// generics. Previously this would ICE, and more recently error.
diff --git a/src/test/ui/const-generics/closing-args-token.min.stderr b/src/test/ui/const-generics/closing-args-token.min.stderr
deleted file mode 100644
index f4bb1e4..0000000
--- a/src/test/ui/const-generics/closing-args-token.min.stderr
+++ /dev/null
@@ -1,52 +0,0 @@
-error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/closing-args-token.rs:10:9
- |
-LL | S::<5 + 2 >> 7>;
- | ^^^^^
- |
-help: enclose the `const` expression in braces
- |
-LL | S::<{ 5 + 2 } >> 7>;
- | + +
-
-error: comparison operators cannot be chained
- --> $DIR/closing-args-token.rs:10:16
- |
-LL | S::<5 + 2 >> 7>;
- | ^ ^
- |
-help: split the comparison into two
- |
-LL | S::<5 + 2 >> 7 && 7>;
- | ++++
-
-error: comparison operators cannot be chained
- --> $DIR/closing-args-token.rs:16:20
- |
-LL | S::<{ 5 + 2 } >> 7>;
- | ^ ^
- |
-help: split the comparison into two
- |
-LL | S::<{ 5 + 2 } >> 7 && 7>;
- | ++++
-
-error: expected expression, found `;`
- --> $DIR/closing-args-token.rs:21:16
- |
-LL | T::<0 >= 3>;
- | ^ expected expression
-
-error: comparison operators cannot be chained
- --> $DIR/closing-args-token.rs:27:12
- |
-LL | T::<x >>= 2 > 0>;
- | ^^ ^
- |
-help: split the comparison into two
- |
-LL | T::<x >>= 2 && 2 > 0>;
- | ++++
-
-error: aborting due to 5 previous errors
-
diff --git a/src/test/ui/const-generics/coerce_unsized_array.rs b/src/test/ui/const-generics/coerce_unsized_array.rs
index 8e20df2..ffd5eb9 100644
--- a/src/test/ui/const-generics/coerce_unsized_array.rs
+++ b/src/test/ui/const-generics/coerce_unsized_array.rs
@@ -1,9 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn foo<const N: usize>(v: &[u8; N]) -> &[u8] {
v
}
diff --git a/src/test/ui/const-generics/concrete-const-as-fn-arg.rs b/src/test/ui/const-generics/concrete-const-as-fn-arg.rs
index 8c31c86..372f043 100644
--- a/src/test/ui/const-generics/concrete-const-as-fn-arg.rs
+++ b/src/test/ui/const-generics/concrete-const-as-fn-arg.rs
@@ -1,9 +1,5 @@
// Test that a concrete const type i.e. A<2>, can be used as an argument type in a function
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct A<const N: usize>; // ok
diff --git a/src/test/ui/const-generics/concrete-const-impl-method.rs b/src/test/ui/const-generics/concrete-const-impl-method.rs
index 3d3bd26..53c9c0e 100644
--- a/src/test/ui/const-generics/concrete-const-impl-method.rs
+++ b/src/test/ui/const-generics/concrete-const-impl-method.rs
@@ -1,10 +1,6 @@
// Test that a method/associated non-method within an impl block of a concrete const type i.e. A<2>,
// is callable.
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
pub struct A<const N: u32>;
diff --git a/src/test/ui/const-generics/condition-in-trait-const-arg.rs b/src/test/ui/const-generics/condition-in-trait-const-arg.rs
index ad40b48..6f85237 100644
--- a/src/test/ui/const-generics/condition-in-trait-const-arg.rs
+++ b/src/test/ui/const-generics/condition-in-trait-const-arg.rs
@@ -2,7 +2,7 @@
// run-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
trait IsZeroTrait<const IS_ZERO: bool>{}
diff --git a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs
index d1bffae..aa0f913 100644
--- a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs
+++ b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This tests that the `conservative_is_privately_uninhabited` fn doesn't cause
diff --git a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs
index 96dbac1..d086441 100644
--- a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs
+++ b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This tests that the `conservative_is_privately_uninhabited` fn doesn't cause
diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr
index bfa4ba3..ac69342 100644
--- a/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr
+++ b/src/test/ui/const-generics/const-arg-in-const-arg.min.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:14:23
@@ -14,7 +14,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:24:23
@@ -23,7 +23,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:29:24
@@ -32,7 +32,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:30:24
@@ -41,7 +41,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:35:27
@@ -50,7 +50,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/const-arg-in-const-arg.rs:36:27
@@ -59,7 +59,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:15:23
@@ -67,8 +67,8 @@
LL | let _: [u8; faz::<'a>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:16:23
@@ -76,8 +76,8 @@
LL | let _: [u8; baz::<'a>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:17:23
@@ -85,8 +85,8 @@
LL | let _: [u8; faz::<'b>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:18:23
@@ -94,8 +94,8 @@
LL | let _: [u8; baz::<'b>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:25:23
@@ -103,8 +103,8 @@
LL | let _ = [0; faz::<'a>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:26:23
@@ -112,8 +112,8 @@
LL | let _ = [0; baz::<'a>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:27:23
@@ -121,8 +121,8 @@
LL | let _ = [0; faz::<'b>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:28:23
@@ -130,8 +130,8 @@
LL | let _ = [0; baz::<'b>(&())];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:31:24
@@ -139,8 +139,8 @@
LL | let _: Foo<{ faz::<'a>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:32:24
@@ -148,8 +148,8 @@
LL | let _: Foo<{ baz::<'a>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:33:24
@@ -157,8 +157,8 @@
LL | let _: Foo<{ faz::<'b>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:34:24
@@ -166,8 +166,8 @@
LL | let _: Foo<{ baz::<'b>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:37:27
@@ -175,8 +175,8 @@
LL | let _ = Foo::<{ faz::<'a>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:38:27
@@ -184,8 +184,8 @@
LL | let _ = Foo::<{ baz::<'a>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:39:27
@@ -193,8 +193,8 @@
LL | let _ = Foo::<{ faz::<'b>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/const-arg-in-const-arg.rs:40:27
@@ -202,8 +202,8 @@
LL | let _ = Foo::<{ baz::<'b>(&()) }>;
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error: aborting due to 23 previous errors
diff --git a/src/test/ui/const-generics/const-arg-in-const-arg.rs b/src/test/ui/const-generics/const-arg-in-const-arg.rs
index 8279f4a..39f0b23 100644
--- a/src/test/ui/const-generics/const-arg-in-const-arg.rs
+++ b/src/test/ui/const-generics/const-arg-in-const-arg.rs
@@ -1,5 +1,5 @@
// revisions: min
-// FIXME(const_generics): This test currently causes an ICE because
+// FIXME(generic_const_exprs): This test currently causes an ICE because
// we don't yet correctly deal with lifetimes, reenable this test once
// this is fixed.
diff --git a/src/test/ui/const-generics/const-arg-in-fn.rs b/src/test/ui/const-generics/const-arg-in-fn.rs
index 43ed12e..9b225b1 100644
--- a/src/test/ui/const-generics/const-arg-in-fn.rs
+++ b/src/test/ui/const-generics/const-arg-in-fn.rs
@@ -1,9 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn const_u32_identity<const X: u32>() -> u32 {
X
}
diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr
deleted file mode 100644
index d0ea51e..0000000
--- a/src/test/ui/const-generics/const-arg-type-arg-misordered.full.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0747]: constant provided when a type was expected
- --> $DIR/const-arg-type-arg-misordered.rs:7:35
- |
-LL | fn foo<const N: usize>() -> Array<N, ()> {
- | ^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0747`.
diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs
index 5415791..8ee17e6 100644
--- a/src/test/ui/const-generics/const-arg-type-arg-misordered.rs
+++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
type Array<T, const N: usize> = [T; N];
fn foo<const N: usize>() -> Array<N, ()> {
diff --git a/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr b/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr
similarity index 88%
rename from src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr
rename to src/test/ui/const-generics/const-arg-type-arg-misordered.stderr
index d7b7df0..104ee9b 100644
--- a/src/test/ui/const-generics/const-arg-type-arg-misordered.min.stderr
+++ b/src/test/ui/const-generics/const-arg-type-arg-misordered.stderr
@@ -1,5 +1,5 @@
error[E0747]: constant provided when a type was expected
- --> $DIR/const-arg-type-arg-misordered.rs:7:35
+ --> $DIR/const-arg-type-arg-misordered.rs:3:35
|
LL | fn foo<const N: usize>() -> Array<N, ()> {
| ^
diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr
deleted file mode 100644
index 6ef698b..0000000
--- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.min.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/const-argument-cross-crate-mismatch.rs:9:67
- |
-LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
- | ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
-
-error[E0308]: mismatched types
- --> $DIR/const-argument-cross-crate-mismatch.rs:11:65
- |
-LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
- | ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs
index a8f533e..d863d09 100644
--- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs
+++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.rs
@@ -1,7 +1,4 @@
// aux-build:const_generic_lib.rs
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
extern crate const_generic_lib;
diff --git a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.stderr
similarity index 85%
rename from src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr
rename to src/test/ui/const-generics/const-argument-cross-crate-mismatch.stderr
index 6ef698b..aefd514 100644
--- a/src/test/ui/const-generics/const-argument-cross-crate-mismatch.full.stderr
+++ b/src/test/ui/const-generics/const-argument-cross-crate-mismatch.stderr
@@ -1,11 +1,11 @@
error[E0308]: mismatched types
- --> $DIR/const-argument-cross-crate-mismatch.rs:9:67
+ --> $DIR/const-argument-cross-crate-mismatch.rs:6:67
|
LL | let _ = const_generic_lib::function(const_generic_lib::Struct([0u8, 1u8]));
| ^^^^^^^^^^ expected an array with a fixed size of 3 elements, found one with 2 elements
error[E0308]: mismatched types
- --> $DIR/const-argument-cross-crate-mismatch.rs:11:65
+ --> $DIR/const-argument-cross-crate-mismatch.rs:8:65
|
LL | let _: const_generic_lib::Alias = const_generic_lib::Struct([0u8, 1u8, 2u8]);
| ^^^^^^^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
diff --git a/src/test/ui/const-generics/const-argument-if-length.full.stderr b/src/test/ui/const-generics/const-argument-if-length.full.stderr
index 8e62147..8c5c3b1 100644
--- a/src/test/ui/const-generics/const-argument-if-length.full.stderr
+++ b/src/test/ui/const-generics/const-argument-if-length.full.stderr
@@ -1,24 +1,5 @@
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/const-argument-if-length.rs:7:28
- |
-LL | pub const fn is_zst<T: ?Sized>() -> usize {
- | - this type parameter needs to be `std::marker::Sized`
-LL | if std::mem::size_of::<T>() == 0 {
- | ^ doesn't have a size known at compile-time
- |
-note: required by a bound in `std::mem::size_of`
- --> $SRC_DIR/core/src/mem/mod.rs:LL:COL
- |
-LL | pub const fn size_of<T>() -> usize {
- | ^ required by this bound in `std::mem::size_of`
-help: consider removing the `?Sized` bound to make the type parameter `Sized`
- |
-LL - pub const fn is_zst<T: ?Sized>() -> usize {
-LL + pub const fn is_zst<T>() -> usize {
- |
-
-error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/const-argument-if-length.rs:16:12
+ --> $DIR/const-argument-if-length.rs:15:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
@@ -41,6 +22,14 @@
LL | value: Box<T>,
| ++++ +
+error: unconstrained generic constant
+ --> $DIR/const-argument-if-length.rs:17:10
+ |
+LL | pad: [u8; is_zst::<T>()],
+ | ^^^^^^^^^^^^^^^^^^^
+ |
+ = help: try adding a `where` bound using this expression: `where [(); is_zst::<T>()]:`
+
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/const-argument-if-length.min.stderr b/src/test/ui/const-generics/const-argument-if-length.min.stderr
index cdbbbf2..b123036 100644
--- a/src/test/ui/const-generics/const-argument-if-length.min.stderr
+++ b/src/test/ui/const-generics/const-argument-if-length.min.stderr
@@ -1,14 +1,14 @@
error: generic parameters may not be used in const operations
- --> $DIR/const-argument-if-length.rs:18:24
+ --> $DIR/const-argument-if-length.rs:17:24
|
LL | pad: [u8; is_zst::<T>()],
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0277]: the size for values of type `T` cannot be known at compilation time
- --> $DIR/const-argument-if-length.rs:16:12
+ --> $DIR/const-argument-if-length.rs:15:12
|
LL | pub struct AtLeastByte<T: ?Sized> {
| - this type parameter needs to be `std::marker::Sized`
diff --git a/src/test/ui/const-generics/const-argument-if-length.rs b/src/test/ui/const-generics/const-argument-if-length.rs
index 67ed85f..db1eafc 100644
--- a/src/test/ui/const-generics/const-argument-if-length.rs
+++ b/src/test/ui/const-generics/const-argument-if-length.rs
@@ -1,11 +1,10 @@
// revisions: full min
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
pub const fn is_zst<T: ?Sized>() -> usize {
if std::mem::size_of::<T>() == 0 {
- //[full]~^ ERROR the size for values of type `T` cannot be known at compilation time
1
} else {
0
@@ -17,6 +16,7 @@ pub struct AtLeastByte<T: ?Sized> {
//~^ ERROR the size for values of type `T` cannot be known at compilation time
pad: [u8; is_zst::<T>()],
//[min]~^ ERROR generic parameters may not be used in const operations
+ //[full]~^^ ERROR unconstrained generic constant
}
fn main() {}
diff --git a/src/test/ui/const-generics/const-argument-non-static-lifetime.rs b/src/test/ui/const-generics/const-argument-non-static-lifetime.rs
index dc34621..2aca7bd 100644
--- a/src/test/ui/const-generics/const-argument-non-static-lifetime.rs
+++ b/src/test/ui/const-generics/const-argument-non-static-lifetime.rs
@@ -2,7 +2,7 @@
// revisions: full
// FIXME(#75323) Omitted min revision for now due to ICE.
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
#![allow(dead_code)]
diff --git a/src/test/ui/const-generics/const-expression-parameter.min.stderr b/src/test/ui/const-generics/const-expression-parameter.min.stderr
deleted file mode 100644
index 4ce0ecd..0000000
--- a/src/test/ui/const-generics/const-expression-parameter.min.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/const-expression-parameter.rs:15:20
- |
-LL | i32_identity::<1 + 2>();
- | ^^^^^
- |
-help: enclose the `const` expression in braces
- |
-LL | i32_identity::<{ 1 + 2 }>();
- | + +
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/const-fn-with-const-param.rs b/src/test/ui/const-generics/const-fn-with-const-param.rs
index 5c1ee4e..161bfaa 100644
--- a/src/test/ui/const-generics/const-fn-with-const-param.rs
+++ b/src/test/ui/const-generics/const-fn-with-const-param.rs
@@ -1,9 +1,5 @@
// Checks that `const fn` with const params can be used.
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
const fn const_u32_identity<const X: u32>() -> u32 {
X
diff --git a/src/test/ui/const-generics/const-generic-array-wrapper.rs b/src/test/ui/const-generics/const-generic-array-wrapper.rs
deleted file mode 100644
index 224fc79..0000000
--- a/src/test/ui/const-generics/const-generic-array-wrapper.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-struct Foo<T, const N: usize>([T; N]);
-
-impl<T, const N: usize> Foo<T, N> {
- fn foo(&self) -> usize {
- N
- }
-}
-
-fn main() {
- let foo = Foo([0u32; 21]);
- assert_eq!(foo.0, [0u32; 21]);
- assert_eq!(foo.foo(), 21);
-}
diff --git a/src/test/ui/const-generics/const-generic-type_name.rs b/src/test/ui/const-generics/const-generic-type_name.rs
index 95632f7..bb16be9 100644
--- a/src/test/ui/const-generics/const-generic-type_name.rs
+++ b/src/test/ui/const-generics/const-generic-type_name.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
#[derive(Debug)]
struct S<const N: usize>;
diff --git a/src/test/ui/const-generics/const-param-after-const-literal-arg.rs b/src/test/ui/const-generics/const-param-after-const-literal-arg.rs
index 6c2b14f..d8a0e07 100644
--- a/src/test/ui/const-generics/const-param-after-const-literal-arg.rs
+++ b/src/test/ui/const-generics/const-param-after-const-literal-arg.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct Foo<const A: usize, const B: usize>;
diff --git a/src/test/ui/const-generics/const-param-before-other-params.full.stderr b/src/test/ui/const-generics/const-param-before-other-params.full.stderr
index 09a4f66..982417e 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.full.stderr
+++ b/src/test/ui/const-generics/const-param-before-other-params.full.stderr
@@ -1,8 +1,8 @@
error: lifetime parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:5:21
|
-LL | fn bar<const X: (), 'a>(_: &'a ()) {
- | --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>`
+LL | fn bar<const X: u8, 'a>(_: &'a ()) {
+ | --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: u8>`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/const-param-before-other-params.min.stderr b/src/test/ui/const-generics/const-param-before-other-params.min.stderr
index a9349ce..f439cd9 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.min.stderr
+++ b/src/test/ui/const-generics/const-param-before-other-params.min.stderr
@@ -1,32 +1,14 @@
error: lifetime parameters must be declared prior to const parameters
--> $DIR/const-param-before-other-params.rs:5:21
|
-LL | fn bar<const X: (), 'a>(_: &'a ()) {
- | --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
+LL | fn bar<const X: u8, 'a>(_: &'a ()) {
+ | --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: u8>`
error: type parameters must be declared prior to const parameters
- --> $DIR/const-param-before-other-params.rs:10:21
+ --> $DIR/const-param-before-other-params.rs:9:21
|
-LL | fn foo<const X: (), T>(_: &T) {}
- | --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
+LL | fn foo<const X: u8, T>(_: &T) {}
+ | --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: u8>`
-error: `()` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-before-other-params.rs:5:17
- |
-LL | fn bar<const X: (), 'a>(_: &'a ()) {
- | ^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: `()` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-before-other-params.rs:10:17
- |
-LL | fn foo<const X: (), T>(_: &T) {}
- | ^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs
index 508bb3e..0a7b57f 100644
--- a/src/test/ui/const-generics/const-param-before-other-params.rs
+++ b/src/test/ui/const-generics/const-param-before-other-params.rs
@@ -1,14 +1,12 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(const_generics_defaults))]
#![cfg_attr(full, allow(incomplete_features))]
-fn bar<const X: (), 'a>(_: &'a ()) {
+fn bar<const X: u8, 'a>(_: &'a ()) {
//~^ ERROR lifetime parameters must be declared prior to const parameters
- //[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
}
-fn foo<const X: (), T>(_: &T) {}
+fn foo<const X: u8, T>(_: &T) {}
//[min]~^ ERROR type parameters must be declared prior to const parameters
-//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
fn main() {}
diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr
index 119f932..d6753a7 100644
--- a/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr
+++ b/src/test/ui/const-generics/const-param-elided-lifetime.full.stderr
@@ -1,29 +1,29 @@
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:10:19
+ --> $DIR/const-param-elided-lifetime.rs:9:19
|
LL | struct A<const N: &u8>;
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:15:15
+ --> $DIR/const-param-elided-lifetime.rs:14:15
|
LL | impl<const N: &u8> A<N> {
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:18:21
+ --> $DIR/const-param-elided-lifetime.rs:17:21
|
LL | fn foo<const M: &u8>(&self) {}
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:23:15
+ --> $DIR/const-param-elided-lifetime.rs:22:15
|
LL | impl<const N: &u8> B for A<N> {}
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:27:17
+ --> $DIR/const-param-elided-lifetime.rs:26:17
|
LL | fn bar<const N: &u8>() {}
| ^ explicit lifetime name needed here
diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr b/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr
index 613918f..48d85e7 100644
--- a/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr
+++ b/src/test/ui/const-generics/const-param-elided-lifetime.min.stderr
@@ -1,77 +1,77 @@
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:10:19
+ --> $DIR/const-param-elided-lifetime.rs:9:19
|
LL | struct A<const N: &u8>;
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:15:15
+ --> $DIR/const-param-elided-lifetime.rs:14:15
|
LL | impl<const N: &u8> A<N> {
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:18:21
+ --> $DIR/const-param-elided-lifetime.rs:17:21
|
LL | fn foo<const M: &u8>(&self) {}
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:23:15
+ --> $DIR/const-param-elided-lifetime.rs:22:15
|
LL | impl<const N: &u8> B for A<N> {}
| ^ explicit lifetime name needed here
error[E0637]: `&` without an explicit lifetime name cannot be used here
- --> $DIR/const-param-elided-lifetime.rs:27:17
+ --> $DIR/const-param-elided-lifetime.rs:26:17
|
LL | fn bar<const N: &u8>() {}
| ^ explicit lifetime name needed here
error: `&'static u8` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-elided-lifetime.rs:10:19
+ --> $DIR/const-param-elided-lifetime.rs:9:19
|
LL | struct A<const N: &u8>;
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-elided-lifetime.rs:15:15
+ --> $DIR/const-param-elided-lifetime.rs:14:15
|
LL | impl<const N: &u8> A<N> {
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-elided-lifetime.rs:18:21
+ --> $DIR/const-param-elided-lifetime.rs:17:21
|
LL | fn foo<const M: &u8>(&self) {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-elided-lifetime.rs:23:15
+ --> $DIR/const-param-elided-lifetime.rs:22:15
|
LL | impl<const N: &u8> B for A<N> {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
- --> $DIR/const-param-elided-lifetime.rs:27:17
+ --> $DIR/const-param-elided-lifetime.rs:26:17
|
LL | fn bar<const N: &u8>() {}
| ^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 10 previous errors
diff --git a/src/test/ui/const-generics/const-param-elided-lifetime.rs b/src/test/ui/const-generics/const-param-elided-lifetime.rs
index 89715a7..487b82d 100644
--- a/src/test/ui/const-generics/const-param-elided-lifetime.rs
+++ b/src/test/ui/const-generics/const-param-elided-lifetime.rs
@@ -3,8 +3,7 @@
// elided lifetimes within the type of a const generic parameters to be 'static, like elided
// lifetimes within const/static items.
// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct A<const N: &u8>;
diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr b/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr
deleted file mode 100644
index c2ec735..0000000
--- a/src/test/ui/const-generics/const-param-from-outer-fn.min.stderr
+++ /dev/null
@@ -1,13 +0,0 @@
-error[E0401]: can't use generic parameters from outer function
- --> $DIR/const-param-from-outer-fn.rs:8:9
- |
-LL | fn foo<const X: u32>() {
- | - const parameter from outer function
-LL | fn bar() -> u32 {
- | --- try adding a local generic parameter in this method instead
-LL | X
- | ^ use of generic parameter from outer function
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0401`.
diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.rs b/src/test/ui/const-generics/const-param-from-outer-fn.rs
deleted file mode 100644
index 27b9ca9..0000000
--- a/src/test/ui/const-generics/const-param-from-outer-fn.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-fn foo<const X: u32>() {
- fn bar() -> u32 {
- X //~ ERROR can't use generic parameters from outer function
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/const-param-in-async.rs b/src/test/ui/const-generics/const-param-in-async.rs
index 9dc9c80..f823431 100644
--- a/src/test/ui/const-generics/const-param-in-async.rs
+++ b/src/test/ui/const-generics/const-param-in-async.rs
@@ -1,8 +1,5 @@
// edition:2018
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
async fn foo<const N: usize>(arg: [u8; N]) -> usize { arg.len() }
diff --git a/src/test/ui/const-generics/const-param-in-trait.rs b/src/test/ui/const-generics/const-param-in-trait.rs
deleted file mode 100644
index 79b3ae2..0000000
--- a/src/test/ui/const-generics/const-param-in-trait.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// Check that const parameters are permitted in traits.
-// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-
-trait Trait<const T: u8> {}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr
index 9804363..a7b78b8 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr
+++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.min.stderr
@@ -17,7 +17,7 @@
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/const-param-type-depends-on-const-param.rs:15:35
@@ -26,7 +26,7 @@
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 4 previous errors
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs b/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs
index 62b146e..9d50f9a 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs
+++ b/src/test/ui/const-generics/const-param-type-depends-on-const-param.rs
@@ -1,6 +1,6 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
// Currently, const parameters cannot depend on other generic parameters,
diff --git a/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs b/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs
index 910a964..71d91fd 100644
--- a/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs
+++ b/src/test/ui/const-generics/const-param-type-depends-on-type-param.rs
@@ -1,6 +1,6 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
// Currently, const parameters cannot depend on other generic parameters,
diff --git a/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr b/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr
deleted file mode 100644
index 923964a..0000000
--- a/src/test/ui/const-generics/const-parameter-uppercase-lint.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error: const parameter `x` should have an upper case name
- --> $DIR/const-parameter-uppercase-lint.rs:8:15
- |
-LL | fn noop<const x: u32>() {
- | ^ help: convert the identifier to upper case (notice the capitalization): `X`
- |
-note: the lint level is defined here
- --> $DIR/const-parameter-uppercase-lint.rs:6:9
- |
-LL | #![deny(non_upper_case_globals)]
- | ^^^^^^^^^^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/const-parameter-uppercase-lint.rs b/src/test/ui/const-generics/const-parameter-uppercase-lint.rs
index 5d97907..b08d62c 100644
--- a/src/test/ui/const-generics/const-parameter-uppercase-lint.rs
+++ b/src/test/ui/const-generics/const-parameter-uppercase-lint.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
#![deny(non_upper_case_globals)]
fn noop<const x: u32>() {
diff --git a/src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr b/src/test/ui/const-generics/const-parameter-uppercase-lint.stderr
similarity index 77%
rename from src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr
rename to src/test/ui/const-generics/const-parameter-uppercase-lint.stderr
index 923964a..efaa182 100644
--- a/src/test/ui/const-generics/const-parameter-uppercase-lint.full.stderr
+++ b/src/test/ui/const-generics/const-parameter-uppercase-lint.stderr
@@ -1,11 +1,11 @@
error: const parameter `x` should have an upper case name
- --> $DIR/const-parameter-uppercase-lint.rs:8:15
+ --> $DIR/const-parameter-uppercase-lint.rs:3:15
|
LL | fn noop<const x: u32>() {
| ^ help: convert the identifier to upper case (notice the capitalization): `X`
|
note: the lint level is defined here
- --> $DIR/const-parameter-uppercase-lint.rs:6:9
+ --> $DIR/const-parameter-uppercase-lint.rs:1:9
|
LL | #![deny(non_upper_case_globals)]
| ^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/const-generics/const-types.rs b/src/test/ui/const-generics/const-types.rs
deleted file mode 100644
index fb150f8..0000000
--- a/src/test/ui/const-generics/const-types.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Check that arrays can be used with generic const and type.
-// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-#![allow(dead_code, unused_variables)]
-
-struct ConstArray<T, const LEN: usize> {
- array: [T; LEN],
-}
-
-fn main() {
- let arr = ConstArray::<i32, 8> {
- array: [0; 8],
- };
-}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr
deleted file mode 100644
index d6a54ea..0000000
--- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/feature-gate-const_evaluatable_checked.rs:8:30
- |
-LL | fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
- | ^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs b/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs
deleted file mode 100644
index f49ca02..0000000
--- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-type Arr<const N: usize> = [u8; N - 1];
-//[min]~^ ERROR generic parameters may not be used in const operations
-
-fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
- //[full]~^ ERROR constant expression depends
- Default::default()
-}
-
-fn main() {
- let x = test::<33>();
- assert_eq!(x, [0; 32]);
-}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr
deleted file mode 100644
index 9f3d94b..0000000
--- a/src/test/ui/const-generics/const_evaluatable_checked/simple.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/simple.rs:7:53
- |
-LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/simple.rs:7:35
- |
-LL | fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple.rs
deleted file mode 100644
index 94ad71b..0000000
--- a/src/test/ui/const-generics/const_evaluatable_checked/simple.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// [full] run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![feature(const_evaluatable_checked)]
-#![allow(incomplete_features)]
-
-fn test<const N: usize>() -> [u8; N - 1] where [u8; N - 1]: Default {
- //[min]~^ ERROR generic parameters
- //[min]~| ERROR generic parameters
- Default::default()
-}
-
-fn main() {
- let x = test::<33>();
- assert_eq!(x, [0; 32]);
-}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr
deleted file mode 100644
index 1aa66f9..0000000
--- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/simple_fail.rs:6:33
- |
-LL | type Arr<const N: usize> = [u8; N - 1];
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/simple_fail.rs:10:48
- |
-LL | fn test<const N: usize>() -> Arr<N> where [u8; N - 1]: Sized {
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs b/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs
deleted file mode 100644
index f08d249..0000000
--- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, feature(const_evaluatable_checked))]
-#![allow(incomplete_features)]
-
-type Arr<const N: usize> = [u8; N - 1];
-//[min]~^ ERROR generic parameters may not be used in const operations
-//[full]~^^ ERROR evaluation of `Arr::<0_usize>::{constant#0}` failed
-
-fn test<const N: usize>() -> Arr<N> where [u8; N - 1]: Sized {
-//[min]~^ ERROR generic parameters may not be used in const operations
-//[full]~^^ ERROR evaluation of `test::<0_usize>::{constant#0}` failed
- todo!()
-}
-
-fn main() {
- test::<0>();
-}
diff --git a/src/test/ui/const-generics/core-types.rs b/src/test/ui/const-generics/core-types.rs
index b6fa478..91410c4 100644
--- a/src/test/ui/const-generics/core-types.rs
+++ b/src/test/ui/const-generics/core-types.rs
@@ -2,7 +2,7 @@
// run-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct A<const N: u8>;
diff --git a/src/test/ui/const-generics/cross_crate_complex.rs b/src/test/ui/const-generics/cross_crate_complex.rs
index 1d495c9..ebde155 100644
--- a/src/test/ui/const-generics/cross_crate_complex.rs
+++ b/src/test/ui/const-generics/cross_crate_complex.rs
@@ -1,10 +1,6 @@
// aux-build:crayte.rs
// edition:2018
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
extern crate crayte;
use crayte::*;
diff --git a/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs b/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs
index 6514409..5c54874 100644
--- a/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs
+++ b/src/test/ui/const-generics/defaults/auxiliary/const_defaulty.rs
@@ -1,6 +1,4 @@
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
pub struct Defaulted<const N: usize=3>;
impl Defaulted {
diff --git a/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr b/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr
index 44df2ac..aa289ec 100644
--- a/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr
+++ b/src/test/ui/const-generics/defaults/complex-generic-default-expr.min.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-generic-default-expr.rs:10:62
@@ -14,7 +14,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs b/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs
index d355800..814c996 100644
--- a/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs
+++ b/src/test/ui/const-generics/defaults/complex-generic-default-expr.rs
@@ -1,6 +1,6 @@
// revisions: full min
//[full] check-pass
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![feature(const_generics_defaults)]
#![allow(incomplete_features)]
diff --git a/src/test/ui/const-generics/defaults/complex-unord-param.rs b/src/test/ui/const-generics/defaults/complex-unord-param.rs
index d24e403..c27ed29 100644
--- a/src/test/ui/const-generics/defaults/complex-unord-param.rs
+++ b/src/test/ui/const-generics/defaults/complex-unord-param.rs
@@ -1,7 +1,7 @@
// [full] run-pass
// revisions: full min
// Checks a complicated usage of unordered params
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(const_generics_defaults))]
#![cfg_attr(full, allow(incomplete_features))]
#![allow(dead_code)]
diff --git a/src/test/ui/const-generics/defaults/const-default.rs b/src/test/ui/const-generics/defaults/const-default.rs
index 4fa21b8..e7cbf01 100644
--- a/src/test/ui/const-generics/defaults/const-default.rs
+++ b/src/test/ui/const-generics/defaults/const-default.rs
@@ -1,9 +1,5 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
-
pub struct ConstDefault<const N: usize = 3>;
diff --git a/src/test/ui/const-generics/defaults/default-annotation.rs b/src/test/ui/const-generics/defaults/default-annotation.rs
index 8eb8f36..2b41dbb 100644
--- a/src/test/ui/const-generics/defaults/default-annotation.rs
+++ b/src/test/ui/const-generics/defaults/default-annotation.rs
@@ -1,13 +1,12 @@
// run-pass
#![feature(staged_api)]
-
-#![feature(const_generics)]
#![feature(const_generics_defaults)]
#![allow(incomplete_features)]
-
+// FIXME(const_generics): It seems like we aren't testing the right thing here,
+// I would assume that we want the attributes to apply to the const parameter defaults
+// themselves.
#![stable(feature = "const_default_test", since="none")]
-
#[unstable(feature = "const_default_stable", issue="none")]
pub struct ConstDefaultUnstable<const N: usize = 3>;
diff --git a/src/test/ui/const-generics/defaults/default-on-impl.min.stderr b/src/test/ui/const-generics/defaults/default-on-impl.min.stderr
deleted file mode 100644
index c417a26..0000000
--- a/src/test/ui/const-generics/defaults/default-on-impl.min.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
- --> $DIR/default-on-impl.rs:8:12
- |
-LL | impl<const N: usize = 1> Foo<N> {}
- | ^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/defaults/default-on-impl.rs b/src/test/ui/const-generics/defaults/default-on-impl.rs
index 735549d..280d92f 100644
--- a/src/test/ui/const-generics/defaults/default-on-impl.rs
+++ b/src/test/ui/const-generics/defaults/default-on-impl.rs
@@ -1,7 +1,4 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
struct Foo<const N: usize>;
diff --git a/src/test/ui/const-generics/defaults/default-on-impl.full.stderr b/src/test/ui/const-generics/defaults/default-on-impl.stderr
similarity index 85%
rename from src/test/ui/const-generics/defaults/default-on-impl.full.stderr
rename to src/test/ui/const-generics/defaults/default-on-impl.stderr
index c417a26..0f85cec 100644
--- a/src/test/ui/const-generics/defaults/default-on-impl.full.stderr
+++ b/src/test/ui/const-generics/defaults/default-on-impl.stderr
@@ -1,5 +1,5 @@
error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
- --> $DIR/default-on-impl.rs:8:12
+ --> $DIR/default-on-impl.rs:5:12
|
LL | impl<const N: usize = 1> Foo<N> {}
| ^
diff --git a/src/test/ui/const-generics/defaults/external.rs b/src/test/ui/const-generics/defaults/external.rs
index 32acf56..276e743 100644
--- a/src/test/ui/const-generics/defaults/external.rs
+++ b/src/test/ui/const-generics/defaults/external.rs
@@ -1,9 +1,6 @@
// aux-build:const_defaulty.rs
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
extern crate const_defaulty;
use const_defaulty::Defaulted;
diff --git a/src/test/ui/const-generics/defaults/cec-concrete-default.rs b/src/test/ui/const-generics/defaults/generic-expr-default-concrete.rs
similarity index 75%
rename from src/test/ui/const-generics/defaults/cec-concrete-default.rs
rename to src/test/ui/const-generics/defaults/generic-expr-default-concrete.rs
index c2a41cf..52cea51 100644
--- a/src/test/ui/const-generics/defaults/cec-concrete-default.rs
+++ b/src/test/ui/const-generics/defaults/generic-expr-default-concrete.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
+#![feature(generic_const_exprs, const_generics_defaults)]
#![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>;
diff --git a/src/test/ui/const-generics/defaults/cec-concrete-default.stderr b/src/test/ui/const-generics/defaults/generic-expr-default-concrete.stderr
similarity index 85%
rename from src/test/ui/const-generics/defaults/cec-concrete-default.stderr
rename to src/test/ui/const-generics/defaults/generic-expr-default-concrete.stderr
index 090e507..905a285 100644
--- a/src/test/ui/const-generics/defaults/cec-concrete-default.stderr
+++ b/src/test/ui/const-generics/defaults/generic-expr-default-concrete.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/cec-concrete-default.rs:10:5
+ --> $DIR/generic-expr-default-concrete.rs:10:5
|
LL | Foo::<10, 12>
| ^^^^^^^^^^^^^ expected `11_usize`, found `12_usize`
diff --git a/src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.rs b/src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.rs
similarity index 81%
rename from src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.rs
rename to src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.rs
index 15822df..3a11631 100644
--- a/src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.rs
+++ b/src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
+#![feature(generic_const_exprs, const_generics_defaults)]
#![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>;
diff --git a/src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.stderr b/src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.stderr
similarity index 84%
rename from src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.stderr
rename to src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.stderr
index f97fc26..d5a3071 100644
--- a/src/test/ui/const-generics/defaults/cec-generic-default-mismatched-types.stderr
+++ b/src/test/ui/const-generics/defaults/generic-expr-default-mismatched-types.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/cec-generic-default-mismatched-types.rs:12:5
+ --> $DIR/generic-expr-default-mismatched-types.rs:12:5
|
LL | Foo::<N, { N + 2 }>
| ^^^^^^^^^^^^^^^^^^^ expected `{ N + 1 }`, found `{ N + 2 }`
diff --git a/src/test/ui/const-generics/defaults/cec-generic-default.rs b/src/test/ui/const-generics/defaults/generic-expr-default.rs
similarity index 88%
rename from src/test/ui/const-generics/defaults/cec-generic-default.rs
rename to src/test/ui/const-generics/defaults/generic-expr-default.rs
index 76ff7c7..0adbd5c 100644
--- a/src/test/ui/const-generics/defaults/cec-generic-default.rs
+++ b/src/test/ui/const-generics/defaults/generic-expr-default.rs
@@ -1,4 +1,4 @@
-#![feature(const_evaluatable_checked, const_generics, const_generics_defaults)]
+#![feature(generic_const_exprs, const_generics_defaults)]
#![allow(incomplete_features)]
pub struct Foo<const N: usize, const M: usize = { N + 1 }>;
diff --git a/src/test/ui/const-generics/defaults/cec-generic-default.stderr b/src/test/ui/const-generics/defaults/generic-expr-default.stderr
similarity index 87%
rename from src/test/ui/const-generics/defaults/cec-generic-default.stderr
rename to src/test/ui/const-generics/defaults/generic-expr-default.stderr
index 0234ea8..ada1498 100644
--- a/src/test/ui/const-generics/defaults/cec-generic-default.stderr
+++ b/src/test/ui/const-generics/defaults/generic-expr-default.stderr
@@ -1,5 +1,5 @@
error: unconstrained generic constant
- --> $DIR/cec-generic-default.rs:5:54
+ --> $DIR/generic-expr-default.rs:5:54
|
LL | pub fn needs_evaluatable_bound<const N1: usize>() -> Foo<N1> {
| ^^^^^^^
@@ -7,7 +7,7 @@
= help: try adding a `where` bound using this expression: `where [(); { N + 1 }]:`
error: unconstrained generic constant
- --> $DIR/cec-generic-default.rs:14:58
+ --> $DIR/generic-expr-default.rs:14:58
|
LL | fn needs_evaluatable_bound_alias<T, const N: usize>() -> FooAlias<N>
| ^^^^^^^^^^^
diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr
index 29d835e..725cc36 100644
--- a/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr
+++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.full.stderr
@@ -1,11 +1,11 @@
error: lifetime parameters must be declared prior to const parameters
- --> $DIR/intermixed-lifetime.rs:7:28
+ --> $DIR/intermixed-lifetime.rs:5:28
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
error: lifetime parameters must be declared prior to type parameters
- --> $DIR/intermixed-lifetime.rs:10:37
+ --> $DIR/intermixed-lifetime.rs:8:37
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr b/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr
index 29d835e..725cc36 100644
--- a/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr
+++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.min.stderr
@@ -1,11 +1,11 @@
error: lifetime parameters must be declared prior to const parameters
- --> $DIR/intermixed-lifetime.rs:7:28
+ --> $DIR/intermixed-lifetime.rs:5:28
|
LL | struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
| -----------------^^---------- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
error: lifetime parameters must be declared prior to type parameters
- --> $DIR/intermixed-lifetime.rs:10:37
+ --> $DIR/intermixed-lifetime.rs:8:37
|
LL | struct Bar<const N: usize, T = u32, 'a>(&'a (), T);
| --------------------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const N: usize, T = u32>`
diff --git a/src/test/ui/const-generics/defaults/intermixed-lifetime.rs b/src/test/ui/const-generics/defaults/intermixed-lifetime.rs
index 307e3aa..cc215ab 100644
--- a/src/test/ui/const-generics/defaults/intermixed-lifetime.rs
+++ b/src/test/ui/const-generics/defaults/intermixed-lifetime.rs
@@ -1,8 +1,6 @@
// Checks that lifetimes cannot be interspersed between consts and types.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
struct Foo<const N: usize, 'a, T = u32>(&'a (), T);
//~^ Error lifetime parameters must be declared prior to const parameters
diff --git a/src/test/ui/const-generics/defaults/mismatch.min.stderr b/src/test/ui/const-generics/defaults/mismatch.min.stderr
deleted file mode 100644
index 4aa8401..0000000
--- a/src/test/ui/const-generics/defaults/mismatch.min.stderr
+++ /dev/null
@@ -1,58 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/mismatch.rs:12:28
- |
-LL | let e: Example::<13> = ();
- | ------------- ^^ expected struct `Example`, found `()`
- | |
- | expected due to this
- |
- = note: expected struct `Example`
- found unit type `()`
-
-error[E0308]: mismatched types
- --> $DIR/mismatch.rs:15:34
- |
-LL | let e: Example2::<u32, 13> = ();
- | ------------------- ^^ expected struct `Example2`, found `()`
- | |
- | expected due to this
- |
- = note: expected struct `Example2`
- found unit type `()`
-
-error[E0308]: mismatched types
- --> $DIR/mismatch.rs:18:34
- |
-LL | let e: Example3::<13, u32> = ();
- | ------------------- ^^ expected struct `Example3`, found `()`
- | |
- | expected due to this
- |
- = note: expected struct `Example3`
- found unit type `()`
-
-error[E0308]: mismatched types
- --> $DIR/mismatch.rs:21:28
- |
-LL | let e: Example3::<7> = ();
- | ------------- ^^ expected struct `Example3`, found `()`
- | |
- | expected due to this
- |
- = note: expected struct `Example3<7_usize>`
- found unit type `()`
-
-error[E0308]: mismatched types
- --> $DIR/mismatch.rs:24:28
- |
-LL | let e: Example4::<7> = ();
- | ------------- ^^ expected struct `Example4`, found `()`
- | |
- | expected due to this
- |
- = note: expected struct `Example4<7_usize>`
- found unit type `()`
-
-error: aborting due to 5 previous errors
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/defaults/mismatch.rs b/src/test/ui/const-generics/defaults/mismatch.rs
index 9d9a879..4ae93a9 100644
--- a/src/test/ui/const-generics/defaults/mismatch.rs
+++ b/src/test/ui/const-generics/defaults/mismatch.rs
@@ -1,7 +1,4 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
pub struct Example<const N: usize=13>;
pub struct Example2<T=u32, const N: usize=13>(T);
diff --git a/src/test/ui/const-generics/defaults/mismatch.full.stderr b/src/test/ui/const-generics/defaults/mismatch.stderr
similarity index 94%
rename from src/test/ui/const-generics/defaults/mismatch.full.stderr
rename to src/test/ui/const-generics/defaults/mismatch.stderr
index 4aa8401..3c7f4fe 100644
--- a/src/test/ui/const-generics/defaults/mismatch.full.stderr
+++ b/src/test/ui/const-generics/defaults/mismatch.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/mismatch.rs:12:28
+ --> $DIR/mismatch.rs:9:28
|
LL | let e: Example::<13> = ();
| ------------- ^^ expected struct `Example`, found `()`
@@ -10,7 +10,7 @@
found unit type `()`
error[E0308]: mismatched types
- --> $DIR/mismatch.rs:15:34
+ --> $DIR/mismatch.rs:12:34
|
LL | let e: Example2::<u32, 13> = ();
| ------------------- ^^ expected struct `Example2`, found `()`
@@ -21,7 +21,7 @@
found unit type `()`
error[E0308]: mismatched types
- --> $DIR/mismatch.rs:18:34
+ --> $DIR/mismatch.rs:15:34
|
LL | let e: Example3::<13, u32> = ();
| ------------------- ^^ expected struct `Example3`, found `()`
@@ -32,7 +32,7 @@
found unit type `()`
error[E0308]: mismatched types
- --> $DIR/mismatch.rs:21:28
+ --> $DIR/mismatch.rs:18:28
|
LL | let e: Example3::<7> = ();
| ------------- ^^ expected struct `Example3`, found `()`
@@ -43,7 +43,7 @@
found unit type `()`
error[E0308]: mismatched types
- --> $DIR/mismatch.rs:24:28
+ --> $DIR/mismatch.rs:21:28
|
LL | let e: Example4::<7> = ();
| ------------- ^^ expected struct `Example4`, found `()`
diff --git a/src/test/ui/const-generics/defaults/needs-feature.min.stderr b/src/test/ui/const-generics/defaults/needs-feature.min.stderr
index a400620..158fa2e 100644
--- a/src/test/ui/const-generics/defaults/needs-feature.min.stderr
+++ b/src/test/ui/const-generics/defaults/needs-feature.min.stderr
@@ -1,5 +1,5 @@
error: type parameters must be declared prior to const parameters
- --> $DIR/needs-feature.rs:9:26
+ --> $DIR/needs-feature.rs:7:26
|
LL | struct A<const N: usize, T=u32>(T);
| -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>`
diff --git a/src/test/ui/const-generics/defaults/needs-feature.none.stderr b/src/test/ui/const-generics/defaults/needs-feature.none.stderr
deleted file mode 100644
index a400620..0000000
--- a/src/test/ui/const-generics/defaults/needs-feature.none.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: type parameters must be declared prior to const parameters
- --> $DIR/needs-feature.rs:9:26
- |
-LL | struct A<const N: usize, T=u32>(T);
- | -----------------^----- help: reorder the parameters: lifetimes, then types, then consts: `<T = u32, const N: usize>`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/defaults/needs-feature.rs b/src/test/ui/const-generics/defaults/needs-feature.rs
index b58dee0..9ba8184 100644
--- a/src/test/ui/const-generics/defaults/needs-feature.rs
+++ b/src/test/ui/const-generics/defaults/needs-feature.rs
@@ -1,10 +1,8 @@
//[full] run-pass
// Verifies that having generic parameters after constants is not permitted without the
-// `const_generics` feature.
+// `const_generics_defaults` feature.
// revisions: min full
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![cfg_attr(full, feature(const_generics_defaults))]
struct A<const N: usize, T=u32>(T);
//[min]~^ ERROR type parameters must be declared prior
diff --git a/src/test/ui/const-generics/defaults/simple-defaults.rs b/src/test/ui/const-generics/defaults/simple-defaults.rs
index c003cb2..bc01fe2 100644
--- a/src/test/ui/const-generics/defaults/simple-defaults.rs
+++ b/src/test/ui/const-generics/defaults/simple-defaults.rs
@@ -1,9 +1,6 @@
// run-pass
// Checks that type param defaults are allowed after const params.
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
#![allow(dead_code)]
struct FixedOutput<'a, const N: usize, T=u32> {
diff --git a/src/test/ui/const-generics/defaults/type-default-const-param-name.rs b/src/test/ui/const-generics/defaults/type-default-const-param-name.rs
index e68075e..8b35c58 100644
--- a/src/test/ui/const-generics/defaults/type-default-const-param-name.rs
+++ b/src/test/ui/const-generics/defaults/type-default-const-param-name.rs
@@ -1,8 +1,5 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
struct N;
diff --git a/src/test/ui/const-generics/defaults/wrong-order.min.stderr b/src/test/ui/const-generics/defaults/wrong-order.min.stderr
deleted file mode 100644
index eb0bcb2..0000000
--- a/src/test/ui/const-generics/defaults/wrong-order.min.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: generic parameters with a default must be trailing
- --> $DIR/wrong-order.rs:6:10
- |
-LL | struct A<T = u32, const N: usize> {
- | ^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/defaults/wrong-order.rs b/src/test/ui/const-generics/defaults/wrong-order.rs
index 88e9e96..33564a4 100644
--- a/src/test/ui/const-generics/defaults/wrong-order.rs
+++ b/src/test/ui/const-generics/defaults/wrong-order.rs
@@ -1,7 +1,4 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features)]
struct A<T = u32, const N: usize> {
//~^ ERROR generic parameters with a default must be trailing
diff --git a/src/test/ui/const-generics/defaults/wrong-order.full.stderr b/src/test/ui/const-generics/defaults/wrong-order.stderr
similarity index 83%
rename from src/test/ui/const-generics/defaults/wrong-order.full.stderr
rename to src/test/ui/const-generics/defaults/wrong-order.stderr
index eb0bcb2..47a2c6f 100644
--- a/src/test/ui/const-generics/defaults/wrong-order.full.stderr
+++ b/src/test/ui/const-generics/defaults/wrong-order.stderr
@@ -1,5 +1,5 @@
error: generic parameters with a default must be trailing
- --> $DIR/wrong-order.rs:6:10
+ --> $DIR/wrong-order.rs:3:10
|
LL | struct A<T = u32, const N: usize> {
| ^
diff --git a/src/test/ui/const-generics/derive-debug-array-wrapper.rs b/src/test/ui/const-generics/derive-debug-array-wrapper.rs
deleted file mode 100644
index ce1481d..0000000
--- a/src/test/ui/const-generics/derive-debug-array-wrapper.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-// Check that deriving debug on struct with const is permitted.
-// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-#[derive(Debug)]
-struct X<const N: usize> {
- a: [u32; N],
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/different_byref.min.stderr b/src/test/ui/const-generics/different_byref.min.stderr
deleted file mode 100644
index 93874fb..0000000
--- a/src/test/ui/const-generics/different_byref.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: `[usize; 1]` is forbidden as the type of a const generic parameter
- --> $DIR/different_byref.rs:7:23
- |
-LL | struct Const<const V: [usize; 1]> {}
- | ^^^^^^^^^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/different_byref.rs b/src/test/ui/const-generics/different_byref.rs
deleted file mode 100644
index 7977560..0000000
--- a/src/test/ui/const-generics/different_byref.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Check that different const types are different.
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-struct Const<const V: [usize; 1]> {}
-//[min]~^ ERROR `[usize; 1]` is forbidden
-
-fn main() {
- let mut x = Const::<{ [3] }> {};
- x = Const::<{ [4] }> {};
- //[full]~^ ERROR mismatched types
-}
diff --git a/src/test/ui/const-generics/different_byref_simple.min.stderr b/src/test/ui/const-generics/different_byref_simple.min.stderr
deleted file mode 100644
index 027e282..0000000
--- a/src/test/ui/const-generics/different_byref_simple.min.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/different_byref_simple.rs:11:9
- |
-LL | u = ConstUsize::<4> {};
- | ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
- |
- = note: expected struct `ConstUsize<3_usize>`
- found struct `ConstUsize<4_usize>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/different_byref_simple.full.stderr b/src/test/ui/const-generics/different_generic_args.full.stderr
similarity index 89%
rename from src/test/ui/const-generics/different_byref_simple.full.stderr
rename to src/test/ui/const-generics/different_generic_args.full.stderr
index 027e282..a2dcc03 100644
--- a/src/test/ui/const-generics/different_byref_simple.full.stderr
+++ b/src/test/ui/const-generics/different_generic_args.full.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/different_byref_simple.rs:11:9
+ --> $DIR/different_generic_args.rs:11:9
|
LL | u = ConstUsize::<4> {};
| ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
diff --git a/src/test/ui/const-generics/different_byref_simple.full.stderr b/src/test/ui/const-generics/different_generic_args.min.stderr
similarity index 88%
copy from src/test/ui/const-generics/different_byref_simple.full.stderr
copy to src/test/ui/const-generics/different_generic_args.min.stderr
index 027e282..a2dcc03 100644
--- a/src/test/ui/const-generics/different_byref_simple.full.stderr
+++ b/src/test/ui/const-generics/different_generic_args.min.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/different_byref_simple.rs:11:9
+ --> $DIR/different_generic_args.rs:11:9
|
LL | u = ConstUsize::<4> {};
| ^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
diff --git a/src/test/ui/const-generics/different_byref_simple.rs b/src/test/ui/const-generics/different_generic_args.rs
similarity index 65%
rename from src/test/ui/const-generics/different_byref_simple.rs
rename to src/test/ui/const-generics/different_generic_args.rs
index b48189f..9ee0e07 100644
--- a/src/test/ui/const-generics/different_byref_simple.rs
+++ b/src/test/ui/const-generics/different_generic_args.rs
@@ -1,7 +1,7 @@
-// Check that different const types are different.
+// Check that types with different const arguments are different.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
struct ConstUsize<const V: usize> {}
diff --git a/src/test/ui/const-generics/different_generic_args_array.rs b/src/test/ui/const-generics/different_generic_args_array.rs
new file mode 100644
index 0000000..4d225df
--- /dev/null
+++ b/src/test/ui/const-generics/different_generic_args_array.rs
@@ -0,0 +1,11 @@
+// Check that different const types are different.
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
+
+struct Const<const V: [usize; 1]> {}
+
+fn main() {
+ let mut x = Const::<{ [3] }> {};
+ x = Const::<{ [4] }> {};
+ //~^ ERROR mismatched types
+}
diff --git a/src/test/ui/const-generics/different_byref.full.stderr b/src/test/ui/const-generics/different_generic_args_array.stderr
similarity index 64%
rename from src/test/ui/const-generics/different_byref.full.stderr
rename to src/test/ui/const-generics/different_generic_args_array.stderr
index d6b3232..c0709a9 100644
--- a/src/test/ui/const-generics/different_byref.full.stderr
+++ b/src/test/ui/const-generics/different_generic_args_array.stderr
@@ -1,11 +1,11 @@
error[E0308]: mismatched types
- --> $DIR/different_byref.rs:12:9
+ --> $DIR/different_generic_args_array.rs:9:9
|
LL | x = Const::<{ [4] }> {};
| ^^^^^^^^^^^^^^^^^^^ expected `3_usize`, found `4_usize`
|
- = note: expected type `[3_usize]`
- found type `[4_usize]`
+ = note: expected struct `Const<[3_usize]>`
+ found struct `Const<[4_usize]>`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs b/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs
index afef748..6c4ee1a 100644
--- a/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs
+++ b/src/test/ui/const-generics/dont-evaluate-array-len-on-err-1.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This tests that during error handling for the "trait not implemented" error
diff --git a/src/test/ui/const-generics/dyn-supertraits.rs b/src/test/ui/const-generics/dyn-supertraits.rs
index 73ed235..3dee326 100644
--- a/src/test/ui/const-generics/dyn-supertraits.rs
+++ b/src/test/ui/const-generics/dyn-supertraits.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait Foo<const N: usize> {
fn myfun(&self) -> usize;
diff --git a/src/test/ui/const-generics/closing-args-token.rs b/src/test/ui/const-generics/early/closing-args-token.rs
similarity index 82%
rename from src/test/ui/const-generics/closing-args-token.rs
rename to src/test/ui/const-generics/early/closing-args-token.rs
index a9b552e..cb4d629 100644
--- a/src/test/ui/const-generics/closing-args-token.rs
+++ b/src/test/ui/const-generics/early/closing-args-token.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct S<const X: u32>;
struct T<const X: bool>;
diff --git a/src/test/ui/const-generics/closing-args-token.full.stderr b/src/test/ui/const-generics/early/closing-args-token.stderr
similarity index 83%
rename from src/test/ui/const-generics/closing-args-token.full.stderr
rename to src/test/ui/const-generics/early/closing-args-token.stderr
index f4bb1e4..58fff3a 100644
--- a/src/test/ui/const-generics/closing-args-token.full.stderr
+++ b/src/test/ui/const-generics/early/closing-args-token.stderr
@@ -1,5 +1,5 @@
error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/closing-args-token.rs:10:9
+ --> $DIR/closing-args-token.rs:5:9
|
LL | S::<5 + 2 >> 7>;
| ^^^^^
@@ -10,7 +10,7 @@
| + +
error: comparison operators cannot be chained
- --> $DIR/closing-args-token.rs:10:16
+ --> $DIR/closing-args-token.rs:5:16
|
LL | S::<5 + 2 >> 7>;
| ^ ^
@@ -21,7 +21,7 @@
| ++++
error: comparison operators cannot be chained
- --> $DIR/closing-args-token.rs:16:20
+ --> $DIR/closing-args-token.rs:11:20
|
LL | S::<{ 5 + 2 } >> 7>;
| ^ ^
@@ -32,13 +32,13 @@
| ++++
error: expected expression, found `;`
- --> $DIR/closing-args-token.rs:21:16
+ --> $DIR/closing-args-token.rs:16:16
|
LL | T::<0 >= 3>;
| ^ expected expression
error: comparison operators cannot be chained
- --> $DIR/closing-args-token.rs:27:12
+ --> $DIR/closing-args-token.rs:22:12
|
LL | T::<x >>= 2 > 0>;
| ^^ ^
diff --git a/src/test/ui/const-generics/const-expression-parameter.rs b/src/test/ui/const-generics/early/const-expression-parameter.rs
similarity index 71%
rename from src/test/ui/const-generics/const-expression-parameter.rs
rename to src/test/ui/const-generics/early/const-expression-parameter.rs
index cb609a5..4cf7ba8 100644
--- a/src/test/ui/const-generics/const-expression-parameter.rs
+++ b/src/test/ui/const-generics/early/const-expression-parameter.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn i32_identity<const X: i32>() -> i32 {
5
}
diff --git a/src/test/ui/const-generics/const-expression-parameter.full.stderr b/src/test/ui/const-generics/early/const-expression-parameter.stderr
similarity index 86%
rename from src/test/ui/const-generics/const-expression-parameter.full.stderr
rename to src/test/ui/const-generics/early/const-expression-parameter.stderr
index 4ce0ecd..4ce1be2 100644
--- a/src/test/ui/const-generics/const-expression-parameter.full.stderr
+++ b/src/test/ui/const-generics/early/const-expression-parameter.stderr
@@ -1,5 +1,5 @@
error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/const-expression-parameter.rs:15:20
+ --> $DIR/const-expression-parameter.rs:10:20
|
LL | i32_identity::<1 + 2>();
| ^^^^^
diff --git a/src/test/ui/const-generics/early/const-param-from-outer-fn.rs b/src/test/ui/const-generics/early/const-param-from-outer-fn.rs
new file mode 100644
index 0000000..c3b418e
--- /dev/null
+++ b/src/test/ui/const-generics/early/const-param-from-outer-fn.rs
@@ -0,0 +1,7 @@
+fn foo<const X: u32>() {
+ fn bar() -> u32 {
+ X //~ ERROR can't use generic parameters from outer function
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.full.stderr b/src/test/ui/const-generics/early/const-param-from-outer-fn.stderr
similarity index 90%
rename from src/test/ui/const-generics/const-param-from-outer-fn.full.stderr
rename to src/test/ui/const-generics/early/const-param-from-outer-fn.stderr
index c2ec735..a9f9787 100644
--- a/src/test/ui/const-generics/const-param-from-outer-fn.full.stderr
+++ b/src/test/ui/const-generics/early/const-param-from-outer-fn.stderr
@@ -1,5 +1,5 @@
error[E0401]: can't use generic parameters from outer function
- --> $DIR/const-param-from-outer-fn.rs:8:9
+ --> $DIR/const-param-from-outer-fn.rs:3:9
|
LL | fn foo<const X: u32>() {
| - const parameter from outer function
diff --git a/src/test/ui/const-generics/const-param-hygiene.rs b/src/test/ui/const-generics/early/const-param-hygiene.rs
similarity index 71%
rename from src/test/ui/const-generics/const-param-hygiene.rs
rename to src/test/ui/const-generics/early/const-param-hygiene.rs
index 9cafb05..fd4e5b4 100644
--- a/src/test/ui/const-generics/const-param-hygiene.rs
+++ b/src/test/ui/const-generics/early/const-param-hygiene.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
macro_rules! bar {
($($t:tt)*) => { impl<const N: usize> $($t)* };
diff --git a/src/test/ui/const-generics/const-param-shadowing.rs b/src/test/ui/const-generics/early/const-param-shadowing.rs
similarity index 100%
rename from src/test/ui/const-generics/const-param-shadowing.rs
rename to src/test/ui/const-generics/early/const-param-shadowing.rs
diff --git a/src/test/ui/const-generics/const-param-shadowing.stderr b/src/test/ui/const-generics/early/const-param-shadowing.stderr
similarity index 100%
rename from src/test/ui/const-generics/const-param-shadowing.stderr
rename to src/test/ui/const-generics/early/const-param-shadowing.stderr
diff --git a/src/test/ui/const-generics/diagnostics.rs b/src/test/ui/const-generics/early/invalid-const-arguments.rs
similarity index 85%
rename from src/test/ui/const-generics/diagnostics.rs
rename to src/test/ui/const-generics/early/invalid-const-arguments.rs
index 1581af5..6619c97 100644
--- a/src/test/ui/const-generics/diagnostics.rs
+++ b/src/test/ui/const-generics/early/invalid-const-arguments.rs
@@ -1,6 +1,4 @@
#![crate_type="lib"]
-#![feature(min_const_generics)]
-#![allow(incomplete_features)]
struct A<const N: u8>;
trait Foo {}
diff --git a/src/test/ui/const-generics/diagnostics.stderr b/src/test/ui/const-generics/early/invalid-const-arguments.stderr
similarity index 89%
rename from src/test/ui/const-generics/diagnostics.stderr
rename to src/test/ui/const-generics/early/invalid-const-arguments.stderr
index dd37d4e..b46e7e2 100644
--- a/src/test/ui/const-generics/diagnostics.stderr
+++ b/src/test/ui/const-generics/early/invalid-const-arguments.stderr
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `N` in this scope
- --> $DIR/diagnostics.rs:7:16
+ --> $DIR/invalid-const-arguments.rs:5:16
|
LL | struct A<const N: u8>;
| ---------------------- similarly named struct `A` defined here
@@ -17,7 +17,7 @@
| +++
error[E0412]: cannot find type `T` in this scope
- --> $DIR/diagnostics.rs:16:32
+ --> $DIR/invalid-const-arguments.rs:14:32
|
LL | struct A<const N: u8>;
| ---------------------- similarly named struct `A` defined here
@@ -35,7 +35,7 @@
| +++
error[E0747]: unresolved item provided when a constant was expected
- --> $DIR/diagnostics.rs:7:16
+ --> $DIR/invalid-const-arguments.rs:5:16
|
LL | impl Foo for A<N> {}
| ^
@@ -46,7 +46,7 @@
| + +
error[E0747]: type provided when a constant was expected
- --> $DIR/diagnostics.rs:12:19
+ --> $DIR/invalid-const-arguments.rs:10:19
|
LL | impl<N> Foo for B<N> {}
| ^
@@ -57,7 +57,7 @@
| ~~~~~~~~~~~
error[E0747]: unresolved item provided when a constant was expected
- --> $DIR/diagnostics.rs:16:32
+ --> $DIR/invalid-const-arguments.rs:14:32
|
LL | impl<const N: u8> Foo for C<N, T> {}
| ^
diff --git a/src/test/ui/const-generics/macro_rules-braces.rs b/src/test/ui/const-generics/early/macro_rules-braces.rs
similarity index 67%
rename from src/test/ui/const-generics/macro_rules-braces.rs
rename to src/test/ui/const-generics/early/macro_rules-braces.rs
index 605a108..0ae9146 100644
--- a/src/test/ui/const-generics/macro_rules-braces.rs
+++ b/src/test/ui/const-generics/early/macro_rules-braces.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
mod m {
pub const P: usize = 0;
}
@@ -12,42 +8,42 @@ fn test<const N: usize>() {
struct Foo<const M: usize>;
macro_rules! foo {
($x:expr) => {
- [u8; $x] //[full]~ ERROR constant expression depends
+ [u8; $x]
}
}
macro_rules! bar {
($x:expr) => {
- [u8; { $x }] //[full]~ ERROR constant expression depends
+ [u8; { $x }]
}
}
macro_rules! baz {
( $x:expr) => {
- Foo<$x> //[full]~ ERROR constant expression depends
+ Foo<$x>
}
}
macro_rules! biz {
($x:expr) => {
- Foo<{ $x }> //[full]~ ERROR constant expression depends
+ Foo<{ $x }>
};
}
let _: foo!(N);
let _: foo!({ N });
- let _: foo!({{ N }}); //[min]~ ERROR generic parameters may not
+ let _: foo!({{ N }}); //~ ERROR generic parameters may not
let _: foo!(Q);
let _: foo!(m::P);
let _: bar!(N);
- let _: bar!({ N }); //[min]~ ERROR generic parameters may not
+ let _: bar!({ N }); //~ ERROR generic parameters may not
let _: bar!(Q);
let _: bar!(m::P);
let _: baz!(N);
let _: baz!({ N });
- let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
+ let _: baz!({{ N }}); //~ ERROR generic parameters may not
let _: baz!(Q);
let _: baz!({ m::P });
let _: baz!(m::P); //~ ERROR expressions must be enclosed in braces
let _: biz!(N);
- let _: biz!({ N }); //[min]~ ERROR generic parameters may not
+ let _: biz!({ N }); //~ ERROR generic parameters may not
let _: biz!(Q);
let _: biz!(m::P);
let _: foo!(3);
diff --git a/src/test/ui/const-generics/macro_rules-braces.min.stderr b/src/test/ui/const-generics/early/macro_rules-braces.stderr
similarity index 67%
rename from src/test/ui/const-generics/macro_rules-braces.min.stderr
rename to src/test/ui/const-generics/early/macro_rules-braces.stderr
index c2e8c2c..49382db 100644
--- a/src/test/ui/const-generics/macro_rules-braces.min.stderr
+++ b/src/test/ui/const-generics/early/macro_rules-braces.stderr
@@ -1,5 +1,5 @@
error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/macro_rules-braces.rs:48:17
+ --> $DIR/macro_rules-braces.rs:44:17
|
LL | let _: baz!(m::P);
| ^^^^
@@ -10,7 +10,7 @@
| + +
error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/macro_rules-braces.rs:68:17
+ --> $DIR/macro_rules-braces.rs:64:17
|
LL | let _: baz!(10 + 7);
| ^^^^^^
@@ -21,40 +21,40 @@
| + +
error: generic parameters may not be used in const operations
- --> $DIR/macro_rules-braces.rs:36:20
+ --> $DIR/macro_rules-braces.rs:32:20
|
LL | let _: foo!({{ N }});
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/macro_rules-braces.rs:40:19
+ --> $DIR/macro_rules-braces.rs:36:19
|
LL | let _: bar!({ N });
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/macro_rules-braces.rs:45:20
+ --> $DIR/macro_rules-braces.rs:41:20
|
LL | let _: baz!({{ N }});
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/macro_rules-braces.rs:50:19
+ --> $DIR/macro_rules-braces.rs:46:19
|
LL | let _: biz!({ N });
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 6 previous errors
diff --git a/src/test/ui/const-generics/exhaustive-value.min.stderr b/src/test/ui/const-generics/exhaustive-value.min.stderr
deleted file mode 100644
index 4e89e4a..0000000
--- a/src/test/ui/const-generics/exhaustive-value.min.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0277]: the trait bound `(): Foo<N>` is not satisfied
- --> $DIR/exhaustive-value.rs:266:5
- |
-LL | <() as Foo<N>>::test()
- | ^^^^^^^^^^^^^^^^^^^^ the trait `Foo<N>` is not implemented for `()`
- |
- = help: the following implementations were found:
- <() as Foo<0_u8>>
- <() as Foo<100_u8>>
- <() as Foo<101_u8>>
- <() as Foo<102_u8>>
- and 252 others
-note: required by `Foo::test`
- --> $DIR/exhaustive-value.rs:6:5
- |
-LL | fn test() {}
- | ^^^^^^^^^
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/exhaustive-value.rs b/src/test/ui/const-generics/exhaustive-value.rs
index 921f9a4..778d498 100644
--- a/src/test/ui/const-generics/exhaustive-value.rs
+++ b/src/test/ui/const-generics/exhaustive-value.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
trait Foo<const N: u8> {
fn test() {}
}
diff --git a/src/test/ui/const-generics/exhaustive-value.full.stderr b/src/test/ui/const-generics/exhaustive-value.stderr
similarity index 88%
rename from src/test/ui/const-generics/exhaustive-value.full.stderr
rename to src/test/ui/const-generics/exhaustive-value.stderr
index 4e89e4a..0c6aced 100644
--- a/src/test/ui/const-generics/exhaustive-value.full.stderr
+++ b/src/test/ui/const-generics/exhaustive-value.stderr
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `(): Foo<N>` is not satisfied
- --> $DIR/exhaustive-value.rs:266:5
+ --> $DIR/exhaustive-value.rs:262:5
|
LL | <() as Foo<N>>::test()
| ^^^^^^^^^^^^^^^^^^^^ the trait `Foo<N>` is not implemented for `()`
@@ -11,7 +11,7 @@
<() as Foo<102_u8>>
and 252 others
note: required by `Foo::test`
- --> $DIR/exhaustive-value.rs:6:5
+ --> $DIR/exhaustive-value.rs:2:5
|
LL | fn test() {}
| ^^^^^^^^^
diff --git a/src/test/ui/const-generics/fn-const-param-call.rs b/src/test/ui/const-generics/fn-const-param-call.rs
index 70a104e..dc516fb 100644
--- a/src/test/ui/const-generics/fn-const-param-call.rs
+++ b/src/test/ui/const-generics/fn-const-param-call.rs
@@ -1,7 +1,7 @@
// Check that functions cannot be used as const parameters.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
fn function() -> u32 {
diff --git a/src/test/ui/const-generics/fn-const-param-infer.rs b/src/test/ui/const-generics/fn-const-param-infer.rs
index d090479..22f5f52 100644
--- a/src/test/ui/const-generics/fn-const-param-infer.rs
+++ b/src/test/ui/const-generics/fn-const-param-infer.rs
@@ -1,6 +1,6 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Checked<const F: fn(usize) -> bool>;
diff --git a/src/test/ui/const-generics/fn-taking-const-generic-array.rs b/src/test/ui/const-generics/fn-taking-const-generic-array.rs
deleted file mode 100644
index 58c1b95..0000000
--- a/src/test/ui/const-generics/fn-taking-const-generic-array.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-use std::fmt::Display;
-
-fn print_slice<T: Display, const N: usize>(slice: &[T; N]) {
- for x in slice.iter() {
- println!("{}", x);
- }
-}
-
-fn main() {
- print_slice(&[1, 2, 3]);
-}
diff --git a/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr b/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr
deleted file mode 100644
index 80eac99..0000000
--- a/src/test/ui/const-generics/forbid-non-structural_match-types.min.stderr
+++ /dev/null
@@ -1,27 +0,0 @@
-error: `A` is forbidden as the type of a const generic parameter
- --> $DIR/forbid-non-structural_match-types.rs:9:19
- |
-LL | struct B<const X: A>; // ok
- | ^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: `C` is forbidden as the type of a const generic parameter
- --> $DIR/forbid-non-structural_match-types.rs:14:19
- |
-LL | struct D<const X: C>;
- | ^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
- --> $DIR/forbid-non-structural_match-types.rs:14:19
- |
-LL | struct D<const X: C>;
- | ^ `C` doesn't derive both `PartialEq` and `Eq`
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0741`.
diff --git a/src/test/ui/const-generics/forbid-non-structural_match-types.rs b/src/test/ui/const-generics/forbid-non-structural_match-types.rs
index 0fdb3ed..6ae9d5c 100644
--- a/src/test/ui/const-generics/forbid-non-structural_match-types.rs
+++ b/src/test/ui/const-generics/forbid-non-structural_match-types.rs
@@ -1,17 +1,13 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
#[derive(PartialEq, Eq)]
struct A;
struct B<const X: A>; // ok
-//[min]~^ ERROR `A` is forbidden
struct C;
struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]`
-//[min]~^ ERROR `C` is forbidden
fn main() {}
diff --git a/src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr b/src/test/ui/const-generics/forbid-non-structural_match-types.stderr
similarity index 85%
rename from src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr
rename to src/test/ui/const-generics/forbid-non-structural_match-types.stderr
index 5c0f175..81b9bdf 100644
--- a/src/test/ui/const-generics/forbid-non-structural_match-types.full.stderr
+++ b/src/test/ui/const-generics/forbid-non-structural_match-types.stderr
@@ -1,5 +1,5 @@
error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
- --> $DIR/forbid-non-structural_match-types.rs:14:19
+ --> $DIR/forbid-non-structural_match-types.rs:11:19
|
LL | struct D<const X: C>;
| ^ `C` doesn't derive both `PartialEq` and `Eq`
diff --git a/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr b/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr
deleted file mode 100644
index b827e48..0000000
--- a/src/test/ui/const-generics/foreign-item-const-parameter.min.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0044]: foreign items may not have const parameters
- --> $DIR/foreign-item-const-parameter.rs:7:5
- |
-LL | fn foo<const X: usize>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
- |
- = help: replace the const parameters with concrete consts
-
-error[E0044]: foreign items may not have type or const parameters
- --> $DIR/foreign-item-const-parameter.rs:9:5
- |
-LL | fn bar<T, const X: usize>(_: T);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
- |
- = help: replace the type or const parameters with concrete types or consts
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0044`.
diff --git a/src/test/ui/const-generics/foreign-item-const-parameter.rs b/src/test/ui/const-generics/foreign-item-const-parameter.rs
index 83caa89..4fe377b5 100644
--- a/src/test/ui/const-generics/foreign-item-const-parameter.rs
+++ b/src/test/ui/const-generics/foreign-item-const-parameter.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
extern "C" {
fn foo<const X: usize>(); //~ ERROR foreign items may not have const parameters
diff --git a/src/test/ui/const-generics/foreign-item-const-parameter.full.stderr b/src/test/ui/const-generics/foreign-item-const-parameter.stderr
similarity index 86%
rename from src/test/ui/const-generics/foreign-item-const-parameter.full.stderr
rename to src/test/ui/const-generics/foreign-item-const-parameter.stderr
index b827e48..b02db87 100644
--- a/src/test/ui/const-generics/foreign-item-const-parameter.full.stderr
+++ b/src/test/ui/const-generics/foreign-item-const-parameter.stderr
@@ -1,5 +1,5 @@
error[E0044]: foreign items may not have const parameters
- --> $DIR/foreign-item-const-parameter.rs:7:5
+ --> $DIR/foreign-item-const-parameter.rs:2:5
|
LL | fn foo<const X: usize>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^ can't have const parameters
@@ -7,7 +7,7 @@
= help: replace the const parameters with concrete consts
error[E0044]: foreign items may not have type or const parameters
- --> $DIR/foreign-item-const-parameter.rs:9:5
+ --> $DIR/foreign-item-const-parameter.rs:4:5
|
LL | fn bar<T, const X: usize>(_: T);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't have type or const parameters
diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr b/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr
deleted file mode 100644
index 2d19a58..0000000
--- a/src/test/ui/const-generics/generic-function-call-in-array-length.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/generic-function-call-in-array-length.rs:8:29
- |
-LL | fn bar<const N: usize>() -> [u32; foo(N)] {
- | ^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr b/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr
deleted file mode 100644
index d7a3f04..0000000
--- a/src/test/ui/const-generics/generic-function-call-in-array-length.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/generic-function-call-in-array-length.rs:8:39
- |
-LL | fn bar<const N: usize>() -> [u32; foo(N)] {
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/generic-function-call-in-array-length.rs:11:13
- |
-LL | [0; foo(N)]
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/generic-function-call-in-array-length.rs b/src/test/ui/const-generics/generic-function-call-in-array-length.rs
deleted file mode 100644
index a6d2bbd..0000000
--- a/src/test/ui/const-generics/generic-function-call-in-array-length.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-// revisions: full min
-
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
-const fn foo(n: usize) -> usize { n * 2 }
-
-fn bar<const N: usize>() -> [u32; foo(N)] {
- //[min]~^ ERROR generic parameters may not be used in const operations
- //[full]~^^ ERROR constant expression depends on a generic parameter
- [0; foo(N)]
- //[min]~^ ERROR generic parameters may not be used in const operations
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/generic-param-mismatch.min.stderr b/src/test/ui/const-generics/generic-param-mismatch.min.stderr
deleted file mode 100644
index aff8780..0000000
--- a/src/test/ui/const-generics/generic-param-mismatch.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0308]: mismatched types
- --> $DIR/generic-param-mismatch.rs:6:5
- |
-LL | fn test<const N: usize, const M: usize>() -> [u8; M] {
- | ------- expected `[u8; M]` because of return type
-LL | [0; N]
- | ^^^^^^ expected `M`, found `N`
- |
- = note: expected array `[u8; M]`
- found array `[u8; N]`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/generic-param-mismatch.rs b/src/test/ui/const-generics/generic-param-mismatch.rs
index 22fffe4..2e201e5 100644
--- a/src/test/ui/const-generics/generic-param-mismatch.rs
+++ b/src/test/ui/const-generics/generic-param-mismatch.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
fn test<const N: usize, const M: usize>() -> [u8; M] {
[0; N] //~ ERROR mismatched types
}
diff --git a/src/test/ui/const-generics/generic-param-mismatch.full.stderr b/src/test/ui/const-generics/generic-param-mismatch.stderr
similarity index 91%
rename from src/test/ui/const-generics/generic-param-mismatch.full.stderr
rename to src/test/ui/const-generics/generic-param-mismatch.stderr
index aff8780..d0776d4 100644
--- a/src/test/ui/const-generics/generic-param-mismatch.full.stderr
+++ b/src/test/ui/const-generics/generic-param-mismatch.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/generic-param-mismatch.rs:6:5
+ --> $DIR/generic-param-mismatch.rs:2:5
|
LL | fn test<const N: usize, const M: usize>() -> [u8; M] {
| ------- expected `[u8; M]` because of return type
diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr
deleted file mode 100644
index c13882e..0000000
--- a/src/test/ui/const-generics/generic-sum-in-array-length.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/generic-sum-in-array-length.rs:6:45
- |
-LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
- | ^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr b/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr
deleted file mode 100644
index cff5a62..0000000
--- a/src/test/ui/const-generics/generic-sum-in-array-length.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/generic-sum-in-array-length.rs:6:53
- |
-LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
- | ^ cannot perform const operation using `A`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `A`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/generic-sum-in-array-length.rs:6:57
- |
-LL | fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
- | ^ cannot perform const operation using `B`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `B`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/generic-sum-in-array-length.rs b/src/test/ui/const-generics/generic-sum-in-array-length.rs
deleted file mode 100644
index 7ee0394..0000000
--- a/src/test/ui/const-generics/generic-sum-in-array-length.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// revisions: full min
-
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
-fn foo<const A: usize, const B: usize>(bar: [usize; A + B]) {}
-//[min]~^ ERROR generic parameters may not be used in const operations
-//[min]~| ERROR generic parameters may not be used in const operations
-//[full]~^^^ ERROR constant expression depends on a generic parameter
-
-fn main() {}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-1.rs b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-1.rs
similarity index 87%
rename from src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-1.rs
rename to src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-1.rs
index 744a1c4..06f00de 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-1.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-1.rs
@@ -1,5 +1,5 @@
// check-pass
-#![feature(const_evaluatable_checked, const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo<const N: u8>([u8; N as usize])
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-2.rs b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
similarity index 92%
rename from src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-2.rs
rename to src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
index 5437746..3b5b87b 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-2.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.rs
@@ -1,4 +1,4 @@
-#![feature(const_evaluatable_checked, const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Evaluatable<const N: u128> {}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-2.stderr b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-2.stderr
rename to src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-2.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-3.rs b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.rs
similarity index 96%
rename from src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-3.rs
rename to src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.rs
index 2ca06bd..7561ae2 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-3.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Trait {}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-3.stderr b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-3.stderr
rename to src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-3.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-4.rs b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-4.rs
similarity index 94%
rename from src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-4.rs
rename to src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-4.rs
index 0bb4fcf..184263f 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/abstract-const-as-cast-4.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/abstract-const-as-cast-4.rs
@@ -1,5 +1,5 @@
// check-pass
-#![feature(const_evaluatable_checked, const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Trait {}
diff --git a/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr b/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr
new file mode 100644
index 0000000..deb6f3b
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr
@@ -0,0 +1,18 @@
+error: unconstrained generic constant
+ --> $DIR/array-size-in-generic-struct-param.rs:8:38
+ |
+LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]);
+ | ^^^^^^^^^^^^
+ |
+ = help: try adding a `where` bound using this expression: `where [(); 0 + N]:`
+
+error: overly complex generic constant
+ --> $DIR/array-size-in-generic-struct-param.rs:19:15
+ |
+LL | arr: [u8; CFG.arr_size],
+ | ^^^^^^^^^^^^ unsupported projection
+ |
+ = help: consider moving this anonymous constant into a `const` function
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr b/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr
similarity index 74%
rename from src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr
rename to src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr
index 8f6e568..18e9135 100644
--- a/src/test/ui/const-generics/array-size-in-generic-struct-param.min.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/array-size-in-generic-struct-param.rs:19:15
@@ -14,7 +14,7 @@
| ^^^ cannot perform const operation using `CFG`
|
= help: const parameters may only be used as standalone arguments, i.e. `CFG`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: `Config` is forbidden as the type of a const generic parameter
--> $DIR/array-size-in-generic-struct-param.rs:17:21
@@ -23,7 +23,7 @@
| ^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 3 previous errors
diff --git a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs b/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs
similarity index 78%
rename from src/test/ui/const-generics/array-size-in-generic-struct-param.rs
rename to src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs
index cd0a974..7d3fe41 100644
--- a/src/test/ui/const-generics/array-size-in-generic-struct-param.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs
@@ -1,12 +1,12 @@
// Tests that array sizes that depend on const-params are checked using `ConstEvaluatable`.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs, adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
#[allow(dead_code)]
struct ArithArrayLen<const N: usize>([u32; 0 + N]);
-//[full]~^ ERROR constant expression depends on a generic parameter
+//[full]~^ ERROR unconstrained generic constant
//[min]~^^ ERROR generic parameters may not be used in const operations
#[derive(PartialEq, Eq)]
@@ -17,7 +17,7 @@ struct Config {
struct B<const CFG: Config> {
//[min]~^ ERROR `Config` is forbidden
arr: [u8; CFG.arr_size],
- //[full]~^ ERROR constant expression depends on a generic parameter
+ //[full]~^ ERROR overly complex generic constant
//[min]~^^ ERROR generic parameters may not be used in const operations
}
diff --git a/src/test/ui/const_evaluatable/associated-const.rs b/src/test/ui/const-generics/generic_const_exprs/associated-const.rs
similarity index 100%
rename from src/test/ui/const_evaluatable/associated-const.rs
rename to src/test/ui/const-generics/generic_const_exprs/associated-const.rs
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/associated-consts.rs b/src/test/ui/const-generics/generic_const_exprs/associated-consts.rs
similarity index 89%
rename from src/test/ui/const-generics/const_evaluatable_checked/associated-consts.rs
rename to src/test/ui/const-generics/generic_const_exprs/associated-consts.rs
index 533fe55..4d89f18 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/associated-consts.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/associated-consts.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub trait BlockCipher {
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/auxiliary/const_evaluatable_lib.rs b/src/test/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs
similarity index 76%
rename from src/test/ui/const-generics/const_evaluatable_checked/auxiliary/const_evaluatable_lib.rs
rename to src/test/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs
index 9745dfe..15d618c 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/auxiliary/const_evaluatable_lib.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/auxiliary/const_evaluatable_lib.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub fn test1<T>() -> [u8; std::mem::size_of::<T>() - 1]
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/closures.rs b/src/test/ui/const-generics/generic_const_exprs/closures.rs
similarity index 71%
rename from src/test/ui/const-generics/const_evaluatable_checked/closures.rs
rename to src/test/ui/const-generics/generic_const_exprs/closures.rs
index 32f4359..847843f 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/closures.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/closures.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn test<const N: usize>() -> [u8; N + (|| 42)()] {}
//~^ ERROR overly complex generic constant
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/closures.stderr b/src/test/ui/const-generics/generic_const_exprs/closures.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/closures.stderr
rename to src/test/ui/const-generics/generic_const_exprs/closures.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate.rs b/src/test/ui/const-generics/generic_const_exprs/cross_crate.rs
similarity index 87%
rename from src/test/ui/const-generics/const_evaluatable_checked/cross_crate.rs
rename to src/test/ui/const-generics/generic_const_exprs/cross_crate.rs
index 53b2378..dfc69e0 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/cross_crate.rs
@@ -1,6 +1,6 @@
// aux-build:const_evaluatable_lib.rs
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
extern crate const_evaluatable_lib;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.rs b/src/test/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs
similarity index 86%
rename from src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.rs
rename to src/test/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs
index e3a4d9a..b08fffd 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/cross_crate_predicate.rs
@@ -1,5 +1,5 @@
// aux-build:const_evaluatable_lib.rs
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
extern crate const_evaluatable_lib;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr b/src/test/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr
rename to src/test/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.rs b/src/test/ui/const-generics/generic_const_exprs/different-fn.rs
similarity index 84%
rename from src/test/ui/const-generics/const_evaluatable_checked/different-fn.rs
rename to src/test/ui/const-generics/generic_const_exprs/different-fn.rs
index 26c4295..e8bc703 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/different-fn.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
use std::mem::size_of;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr b/src/test/ui/const-generics/generic_const_exprs/different-fn.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr
rename to src/test/ui/const-generics/generic_const_exprs/different-fn.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/division.rs b/src/test/ui/const-generics/generic_const_exprs/division.rs
similarity index 76%
rename from src/test/ui/const-generics/const_evaluatable_checked/division.rs
rename to src/test/ui/const-generics/generic_const_exprs/division.rs
index 71a5f2d..098fa9e 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/division.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/division.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn with_bound<const N: usize>() where [u8; N / 2]: Sized {
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/dont-eagerly-error-in-is-const-evaluatable.rs b/src/test/ui/const-generics/generic_const_exprs/dont-eagerly-error-in-is-const-evaluatable.rs
similarity index 84%
rename from src/test/ui/const-generics/const_evaluatable_checked/dont-eagerly-error-in-is-const-evaluatable.rs
rename to src/test/ui/const-generics/generic_const_exprs/dont-eagerly-error-in-is-const-evaluatable.rs
index 92a410a..3543960 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/dont-eagerly-error-in-is-const-evaluatable.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/dont-eagerly-error-in-is-const-evaluatable.rs
@@ -1,6 +1,5 @@
// run-pass
-#![feature(const_generics)]
-#![feature(const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This test is a repro for #82279. It checks that we don't error
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/drop_impl.rs b/src/test/ui/const-generics/generic_const_exprs/drop_impl.rs
similarity index 78%
rename from src/test/ui/const-generics/const_evaluatable_checked/drop_impl.rs
rename to src/test/ui/const-generics/generic_const_exprs/drop_impl.rs
index 41fb5d7..077f77a 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/drop_impl.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/drop_impl.rs
@@ -1,5 +1,5 @@
//check-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo<const N: usize>
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/elaborate-trait-pred.rs b/src/test/ui/const-generics/generic_const_exprs/elaborate-trait-pred.rs
similarity index 88%
rename from src/test/ui/const-generics/const_evaluatable_checked/elaborate-trait-pred.rs
rename to src/test/ui/const-generics/generic_const_exprs/elaborate-trait-pred.rs
index 4a4fd1e..e411115 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/elaborate-trait-pred.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/elaborate-trait-pred.rs
@@ -1,7 +1,7 @@
// run-pass
// Test that we use the elaborated predicates from traits
// to satisfy const evaluatable predicates.
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
use std::mem::size_of;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/eval-privacy.rs b/src/test/ui/const-generics/generic_const_exprs/eval-privacy.rs
similarity index 90%
rename from src/test/ui/const-generics/const_evaluatable_checked/eval-privacy.rs
rename to src/test/ui/const-generics/generic_const_exprs/eval-privacy.rs
index 9f457fb..80d0662 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/eval-privacy.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/eval-privacy.rs
@@ -1,5 +1,5 @@
#![crate_type = "lib"]
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
pub struct Const<const U: u8>;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/eval-privacy.stderr b/src/test/ui/const-generics/generic_const_exprs/eval-privacy.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/eval-privacy.stderr
rename to src/test/ui/const-generics/generic_const_exprs/eval-privacy.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/evaluated-to-ambig.rs b/src/test/ui/const-generics/generic_const_exprs/evaluated-to-ambig.rs
similarity index 90%
rename from src/test/ui/const-generics/const_evaluatable_checked/evaluated-to-ambig.rs
rename to src/test/ui/const-generics/generic_const_exprs/evaluated-to-ambig.rs
index 0f36ce3..340e35e 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/evaluated-to-ambig.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/evaluated-to-ambig.rs
@@ -4,7 +4,7 @@
// only contain generic parameters. This is incorrect as trying to unify `N > 1` with `M > 1`
// should fail.
#![allow(incomplete_features)]
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
enum Assert<const COND: bool> {}
trait IsTrue {}
diff --git a/src/test/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.rs b/src/test/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.rs
new file mode 100644
index 0000000..10ab2fd
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.rs
@@ -0,0 +1,11 @@
+type Arr<const N: usize> = [u8; N - 1];
+//~^ ERROR generic parameters may not be used in const operations
+
+fn test<const N: usize>() -> Arr<N> where Arr<N>: Default {
+ Default::default()
+}
+
+fn main() {
+ let x = test::<33>();
+ assert_eq!(x, [0; 32]);
+}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr b/src/test/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr
similarity index 62%
rename from src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr
rename to src/test/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr
index 7de4bfc..2d60eba 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/feature-gate-const_evaluatable_checked.min.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/feature-gate-generic_const_exprs.stderr
@@ -1,11 +1,11 @@
error: generic parameters may not be used in const operations
- --> $DIR/feature-gate-const_evaluatable_checked.rs:5:33
+ --> $DIR/feature-gate-generic_const_exprs.rs:1:33
|
LL | type Arr<const N: usize> = [u8; N - 1];
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs b/src/test/ui/const-generics/generic_const_exprs/fn_call.rs
similarity index 91%
rename from src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs
rename to src/test/ui/const-generics/generic_const_exprs/fn_call.rs
index c182f5e..cbe4277 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/fn_call.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/fn_call.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
const fn test_me<T>(a: usize, b: usize) -> usize {
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/from-sig-fail.rs b/src/test/ui/const-generics/generic_const_exprs/from-sig-fail.rs
similarity index 77%
rename from src/test/ui/const-generics/const_evaluatable_checked/from-sig-fail.rs
rename to src/test/ui/const-generics/generic_const_exprs/from-sig-fail.rs
index 8167d78..9095314 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/from-sig-fail.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/from-sig-fail.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn test<const N: usize>() -> [u8; N - 1] {
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/from-sig-fail.stderr b/src/test/ui/const-generics/generic_const_exprs/from-sig-fail.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/from-sig-fail.stderr
rename to src/test/ui/const-generics/generic_const_exprs/from-sig-fail.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/from-sig.rs b/src/test/ui/const-generics/generic_const_exprs/from-sig.rs
similarity index 79%
rename from src/test/ui/const-generics/const_evaluatable_checked/from-sig.rs
rename to src/test/ui/const-generics/generic_const_exprs/from-sig.rs
index 5c05a5a..28de4f8 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/from-sig.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/from-sig.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo<const B: bool>;
diff --git a/src/test/ui/const_evaluatable/function-call.rs b/src/test/ui/const-generics/generic_const_exprs/function-call.rs
similarity index 100%
rename from src/test/ui/const_evaluatable/function-call.rs
rename to src/test/ui/const-generics/generic_const_exprs/function-call.rs
diff --git a/src/test/ui/const_evaluatable/function-call.stderr b/src/test/ui/const-generics/generic_const_exprs/function-call.stderr
similarity index 100%
rename from src/test/ui/const_evaluatable/function-call.stderr
rename to src/test/ui/const-generics/generic_const_exprs/function-call.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs b/src/test/ui/const-generics/generic_const_exprs/impl-bounds.rs
similarity index 87%
rename from src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs
rename to src/test/ui/const-generics/generic_const_exprs/impl-bounds.rs
index 193a365..7120d6e 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/impl-bounds.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/impl-bounds.rs
@@ -1,5 +1,5 @@
// check-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
use std::mem::size_of;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/infer-too-generic.rs b/src/test/ui/const-generics/generic_const_exprs/infer-too-generic.rs
similarity index 89%
rename from src/test/ui/const-generics/const_evaluatable_checked/infer-too-generic.rs
rename to src/test/ui/const-generics/generic_const_exprs/infer-too-generic.rs
index cad06ea..b8058c2 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/infer-too-generic.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/infer-too-generic.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
use std::{mem, ptr};
diff --git a/src/test/ui/const-generics/issues/issue-62504.full.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-62504.full.stderr
similarity index 79%
rename from src/test/ui/const-generics/issues/issue-62504.full.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-62504.full.stderr
index efbcdc3..f2ae361 100644
--- a/src/test/ui/const-generics/issues/issue-62504.full.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-62504.full.stderr
@@ -7,13 +7,13 @@
= note: expected type `X`
found type `Self::SIZE`
-error: constant expression depends on a generic parameter
+error: unconstrained generic constant
--> $DIR/issue-62504.rs:18:25
|
LL | ArrayHolder([0; Self::SIZE])
| ^^^^^^^^^^
|
- = note: this may fail depending on what value the parameter takes
+ = help: try adding a `where` bound using this expression: `where [(); Self::SIZE]:`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/issues/issue-62504.min.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-62504.min.stderr
similarity index 100%
rename from src/test/ui/const-generics/issues/issue-62504.min.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-62504.min.stderr
diff --git a/src/test/ui/const-generics/issues/issue-62504.rs b/src/test/ui/const-generics/generic_const_exprs/issue-62504.rs
similarity index 66%
rename from src/test/ui/const-generics/issues/issue-62504.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-62504.rs
index 1b70cd1..a97f4b8 100644
--- a/src/test/ui/const-generics/issues/issue-62504.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-62504.rs
@@ -1,6 +1,6 @@
// revisions: full min
#![allow(incomplete_features)]
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
trait HasSize {
@@ -16,8 +16,9 @@ impl<const X: usize> HasSize for ArrayHolder<X> {
impl<const X: usize> ArrayHolder<X> {
pub const fn new() -> Self {
ArrayHolder([0; Self::SIZE])
- //~^ ERROR constant expression depends on a generic parameter
- //~| ERROR mismatched types
+ //~^ ERROR mismatched types
+ //[full]~^^ ERROR unconstrained generic constant
+ //[min]~^^^ ERROR constant expression depends on a generic parameter
}
}
diff --git a/src/test/ui/const-generics/issues/issue-69654.rs b/src/test/ui/const-generics/generic_const_exprs/issue-69654.rs
similarity index 90%
rename from src/test/ui/const-generics/issues/issue-69654.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-69654.rs
index b1214b1..9b36699 100644
--- a/src/test/ui/const-generics/issues/issue-69654.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-69654.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Bar<T> {}
diff --git a/src/test/ui/const-generics/issues/issue-69654.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr
similarity index 100%
rename from src/test/ui/const-generics/issues/issue-69654.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-69654.stderr
diff --git a/src/test/ui/const-generics/issues/issue-72787.min.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
similarity index 76%
rename from src/test/ui/const-generics/issues/issue-72787.min.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
index 86d1da0..3c7a740 100644
--- a/src/test/ui/const-generics/issues/issue-72787.min.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72787.min.stderr
@@ -1,20 +1,20 @@
error: generic parameters may not be used in const operations
- --> $DIR/issue-72787.rs:10:17
+ --> $DIR/issue-72787.rs:11:17
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `LHS`
|
= help: const parameters may only be used as standalone arguments, i.e. `LHS`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/issue-72787.rs:10:24
+ --> $DIR/issue-72787.rs:11:24
|
LL | Condition<{ LHS <= RHS }>: True
| ^^^ cannot perform const operation using `RHS`
|
= help: const parameters may only be used as standalone arguments, i.e. `RHS`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:25:25
@@ -23,7 +23,7 @@
| ^ cannot perform const operation using `I`
|
= help: const parameters may only be used as standalone arguments, i.e. `I`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/issue-72787.rs:25:36
@@ -32,7 +32,7 @@
| ^ cannot perform const operation using `J`
|
= help: const parameters may only be used as standalone arguments, i.e. `J`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0283]: type annotations needed
--> $DIR/issue-72787.rs:21:26
@@ -42,7 +42,7 @@
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
note: required by a bound in `True`
- --> $DIR/issue-72787.rs:7:1
+ --> $DIR/issue-72787.rs:8:1
|
LL | pub trait True {}
| ^^^^^^^^^^^^^^ required by this bound in `True`
@@ -55,7 +55,7 @@
|
= note: cannot satisfy `IsLessOrEqual<I, 8_u32>: True`
note: required by a bound in `True`
- --> $DIR/issue-72787.rs:7:1
+ --> $DIR/issue-72787.rs:8:1
|
LL | pub trait True {}
| ^^^^^^^^^^^^^^ required by this bound in `True`
diff --git a/src/test/ui/const-generics/issues/issue-72787.rs b/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
similarity index 63%
rename from src/test/ui/const-generics/issues/issue-72787.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
index 16bc947..77ad57f 100644
--- a/src/test/ui/const-generics/issues/issue-72787.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72787.rs
@@ -1,5 +1,6 @@
+// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
pub struct IsLessOrEqual<const LHS: u32, const RHS: u32>;
@@ -8,8 +9,7 @@ pub trait True {}
impl<const LHS: u32, const RHS: u32> True for IsLessOrEqual<LHS, RHS> where
Condition<{ LHS <= RHS }>: True
-//[full]~^ Error constant expression depends on a generic parameter
-//[min]~^^ Error generic parameters may not be used in const operations
+//[min]~^ Error generic parameters may not be used in const operations
//[min]~| Error generic parameters may not be used in const operations
{
}
@@ -23,11 +23,7 @@ impl<const I: u32, const J: u32> S<I, J>
//[min]~| Error type annotations needed [E0283]
IsLessOrEqual<J, 8>: True,
IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
-//[full]~^ constant expression depends on a generic parameter
-//[full]~| constant expression depends on a generic parameter
-//[full]~| constant expression depends on a generic parameter
-//[full]~| constant expression depends on a generic parameter
-//[min]~^^^^^ Error generic parameters may not be used in const operations
+//[min]~^ Error generic parameters may not be used in const operations
//[min]~| Error generic parameters may not be used in const operations
// Condition<{ 8 - I <= 8 - J }>: True,
{
diff --git a/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr
new file mode 100644
index 0000000..d536f6f
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.full.stderr
@@ -0,0 +1,21 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-72819-generic-in-const-eval.rs:20:12
+ |
+LL | let x: Arr<{usize::MAX}> = Arr {};
+ | ^^^^^^^^^^^^^^^^^ expected `false`, found `true`
+ |
+ = note: expected type `false`
+ found type `true`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-72819-generic-in-const-eval.rs:20:32
+ |
+LL | let x: Arr<{usize::MAX}> = Arr {};
+ | ^^^ expected `false`, found `true`
+ |
+ = note: expected type `false`
+ found type `true`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr
similarity index 74%
rename from src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr
index 6646be4..4267141 100644
--- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.min.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.min.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs b/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.rs
similarity index 66%
rename from src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.rs
index f612d8b..7a5aa9e 100644
--- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-72819-generic-in-const-eval.rs
@@ -1,13 +1,12 @@
// Regression test for #72819: ICE due to failure in resolving the const generic in `Arr`'s type
// bounds.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
struct Arr<const N: usize>
where Assert::<{N < usize::MAX / 2}>: IsTrue,
-//[full]~^ ERROR constant expression depends on a generic parameter
-//[min]~^^ ERROR generic parameters may not be used in const operations
+//[min]~^ ERROR generic parameters may not be used in const operations
{
}
@@ -19,4 +18,6 @@ impl IsTrue for Assert<true> {}
fn main() {
let x: Arr<{usize::MAX}> = Arr {};
+ //[full]~^ ERROR mismatched types
+ //[full]~| ERROR mismatched types
}
diff --git a/src/test/ui/const-generics/issues/issue-73899.rs b/src/test/ui/const-generics/generic_const_exprs/issue-73899.rs
similarity index 83%
rename from src/test/ui/const-generics/issues/issue-73899.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-73899.rs
index 2a3a5ab..d1ab1be 100644
--- a/src/test/ui/const-generics/issues/issue-73899.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-73899.rs
@@ -1,6 +1,5 @@
// run-pass
-#![feature(const_evaluatable_checked)]
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Foo {}
diff --git a/src/test/ui/const-generics/issues/issue-74634.rs b/src/test/ui/const-generics/generic_const_exprs/issue-74634.rs
similarity index 83%
rename from src/test/ui/const-generics/issues/issue-74634.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-74634.rs
index 0f23fa9..cd1f7a9 100644
--- a/src/test/ui/const-generics/issues/issue-74634.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-74634.rs
@@ -1,4 +1,5 @@
-#![feature(const_generics)]
+// check-pass
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait If<const COND: bool> {}
@@ -12,7 +13,7 @@ trait IsZero<const N: u8> {
struct False;
impl<const N: u8> IsZero<N> for ()
-where (): If<{N == 0}> { //~ERROR constant expression
+where (): If<{N == 0}> {
type Answer = True;
}
diff --git a/src/test/ui/const-generics/issues/issue-76595.rs b/src/test/ui/const-generics/generic_const_exprs/issue-76595.rs
similarity index 83%
rename from src/test/ui/const-generics/issues/issue-76595.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-76595.rs
index 2d7051c..faa8b3d 100644
--- a/src/test/ui/const-generics/issues/issue-76595.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-76595.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Bool<const B: bool>;
diff --git a/src/test/ui/const-generics/issues/issue-76595.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr
similarity index 100%
rename from src/test/ui/const-generics/issues/issue-76595.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-76595.stderr
diff --git a/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.rs b/src/test/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.rs
similarity index 89%
rename from src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.rs
index 8f02bfb..2fa9a71 100644
--- a/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This test is a minimized reproduction for #79518 where
diff --git a/src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr
similarity index 100%
rename from src/test/ui/const-generics/issues/issue-79518-default_trait_method_normalization.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-79518-default_trait_method_normalization.stderr
diff --git a/src/test/ui/const-generics/issues/issue-80561-incorrect-param-env.rs b/src/test/ui/const-generics/generic_const_exprs/issue-80561-incorrect-param-env.rs
similarity index 87%
rename from src/test/ui/const-generics/issues/issue-80561-incorrect-param-env.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-80561-incorrect-param-env.rs
index a34d74b..77d3c98 100644
--- a/src/test/ui/const-generics/issues/issue-80561-incorrect-param-env.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-80561-incorrect-param-env.rs
@@ -1,5 +1,5 @@
// check-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This tests that the correct `param_env` is used so that
diff --git a/src/test/ui/mir/issue-80742.rs b/src/test/ui/const-generics/generic_const_exprs/issue-80742.rs
similarity index 88%
rename from src/test/ui/mir/issue-80742.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-80742.rs
index c06d182..275f699 100644
--- a/src/test/ui/mir/issue-80742.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-80742.rs
@@ -3,8 +3,7 @@
// This test used to cause an ICE in rustc_mir::interpret::step::eval_rvalue_into_place
#![allow(incomplete_features)]
-#![feature(const_evaluatable_checked)]
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
use std::fmt::Debug;
use std::marker::PhantomData;
diff --git a/src/test/ui/mir/issue-80742.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr
similarity index 90%
rename from src/test/ui/mir/issue-80742.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr
index b2b40be..56cb11b 100644
--- a/src/test/ui/mir/issue-80742.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-80742.stderr
@@ -7,13 +7,13 @@
| size_of called on unsized type `dyn Debug`
| inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
- ::: $DIR/issue-80742.rs:23:10
+ ::: $DIR/issue-80742.rs:22:10
|
LL | [u8; size_of::<T>() + 1]: ,
- | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:23:10
+ | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:22:10
error[E0599]: the function or associated item `new` exists for struct `Inline<dyn Debug>`, but its trait bounds were not satisfied
- --> $DIR/issue-80742.rs:31:36
+ --> $DIR/issue-80742.rs:30:36
|
LL | / struct Inline<T>
LL | | where
@@ -44,20 +44,20 @@
| size_of called on unsized type `dyn Debug`
| inside `std::mem::size_of::<dyn Debug>` at $SRC_DIR/core/src/mem/mod.rs:LL:COL
|
- ::: $DIR/issue-80742.rs:15:10
+ ::: $DIR/issue-80742.rs:14:10
|
LL | [u8; size_of::<T>() + 1]: ,
- | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:15:10
+ | -------------- inside `Inline::<dyn Debug>::{constant#0}` at $DIR/issue-80742.rs:14:10
error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time
- --> $DIR/issue-80742.rs:31:15
+ --> $DIR/issue-80742.rs:30:15
|
LL | let dst = Inline::<dyn Debug>::new(0);
| ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `dyn Debug`
note: required by a bound in `Inline`
- --> $DIR/issue-80742.rs:13:15
+ --> $DIR/issue-80742.rs:12:15
|
LL | struct Inline<T>
| ^ required by this bound in `Inline`
diff --git a/src/test/ui/const-generics/issues/issue-83765.rs b/src/test/ui/const-generics/generic_const_exprs/issue-83765.rs
similarity index 94%
rename from src/test/ui/const-generics/issues/issue-83765.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-83765.rs
index f34badc..fac811d 100644
--- a/src/test/ui/const-generics/issues/issue-83765.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-83765.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait TensorDimension {
diff --git a/src/test/ui/const-generics/issues/issue-83765.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-83765.stderr
similarity index 100%
rename from src/test/ui/const-generics/issues/issue-83765.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-83765.stderr
diff --git a/src/test/ui/const-generics/issues/issue-84408.rs b/src/test/ui/const-generics/generic_const_exprs/issue-84408.rs
similarity index 92%
rename from src/test/ui/const-generics/issues/issue-84408.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-84408.rs
index e1ba850..fb2e559 100644
--- a/src/test/ui/const-generics/issues/issue-84408.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-84408.rs
@@ -1,7 +1,7 @@
// Regression test for #84408.
// check-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Melon<const X: usize> {
diff --git a/src/test/ui/const-generics/issues/issue-85848.rs b/src/test/ui/const-generics/generic_const_exprs/issue-85848.rs
similarity index 89%
rename from src/test/ui/const-generics/issues/issue-85848.rs
rename to src/test/ui/const-generics/generic_const_exprs/issue-85848.rs
index 4787198..771e68b 100644
--- a/src/test/ui/const-generics/issues/issue-85848.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/issue-85848.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_fn_trait_bound, const_evaluatable_checked)]
+#![feature(const_fn_trait_bound, generic_const_exprs)]
#![allow(incomplete_features)]
trait _Contains<T> {
diff --git a/src/test/ui/const-generics/issues/issue-85848.stderr b/src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr
similarity index 100%
rename from src/test/ui/const-generics/issues/issue-85848.stderr
rename to src/test/ui/const-generics/generic_const_exprs/issue-85848.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/less_than.rs b/src/test/ui/const-generics/generic_const_exprs/less_than.rs
similarity index 81%
rename from src/test/ui/const-generics/const_evaluatable_checked/less_than.rs
rename to src/test/ui/const-generics/generic_const_exprs/less_than.rs
index 907ea25..2e9af1b 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/less_than.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/less_than.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo<const B: bool>;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs b/src/test/ui/const-generics/generic_const_exprs/let-bindings.rs
similarity index 88%
rename from src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs
rename to src/test/ui/const-generics/generic_const_exprs/let-bindings.rs
index a6bb392..cd5d76d 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/let-bindings.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// We do not yet want to support let-bindings in abstract consts,
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/let-bindings.stderr b/src/test/ui/const-generics/generic_const_exprs/let-bindings.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/let-bindings.stderr
rename to src/test/ui/const-generics/generic_const_exprs/let-bindings.stderr
diff --git a/src/test/ui/const_evaluatable/needs_where_clause.rs b/src/test/ui/const-generics/generic_const_exprs/needs_where_clause.rs
similarity index 81%
rename from src/test/ui/const_evaluatable/needs_where_clause.rs
rename to src/test/ui/const-generics/generic_const_exprs/needs_where_clause.rs
index 498a2ae..2bd3c80 100644
--- a/src/test/ui/const_evaluatable/needs_where_clause.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/needs_where_clause.rs
@@ -1,5 +1,5 @@
#![crate_type = "lib"]
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
const fn complex_maths<T>(n : usize) -> usize {
diff --git a/src/test/ui/const_evaluatable/needs_where_clause.stderr b/src/test/ui/const-generics/generic_const_exprs/needs_where_clause.stderr
similarity index 100%
rename from src/test/ui/const_evaluatable/needs_where_clause.stderr
rename to src/test/ui/const-generics/generic_const_exprs/needs_where_clause.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-1.rs b/src/test/ui/const-generics/generic_const_exprs/nested-abstract-consts-1.rs
similarity index 87%
rename from src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-1.rs
rename to src/test/ui/const-generics/generic_const_exprs/nested-abstract-consts-1.rs
index 0fe84c1..7e50228 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-1.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/nested-abstract-consts-1.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn callee<const M2: usize>() -> usize
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-2.rs b/src/test/ui/const-generics/generic_const_exprs/nested-abstract-consts-2.rs
similarity index 91%
rename from src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-2.rs
rename to src/test/ui/const-generics/generic_const_exprs/nested-abstract-consts-2.rs
index 4f58823..769e3ae 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/nested-abstract-consts-2.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/nested-abstract-consts-2.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_evaluatable_checked, const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Generic<const K: u64>;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs b/src/test/ui/const-generics/generic_const_exprs/nested_uneval_unification-1.rs
similarity index 91%
rename from src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs
rename to src/test/ui/const-generics/generic_const_exprs/nested_uneval_unification-1.rs
index 4d0b87e..316887e 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/nested_uneval_unification-1.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn zero_init<const N: usize>() -> Substs1<N>
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-2.rs b/src/test/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
similarity index 91%
rename from src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-2.rs
rename to src/test/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
index be8219a..d45a646 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-2.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/nested_uneval_unification-2.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features, unused_parens, unused_braces)]
fn zero_init<const N: usize>() -> Substs1<{ (N) }>
diff --git a/src/test/ui/const_evaluatable/no_where_clause.rs b/src/test/ui/const-generics/generic_const_exprs/no_where_clause.rs
similarity index 89%
rename from src/test/ui/const_evaluatable/no_where_clause.rs
rename to src/test/ui/const-generics/generic_const_exprs/no_where_clause.rs
index 12f4a22..9c5de03 100644
--- a/src/test/ui/const_evaluatable/no_where_clause.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/no_where_clause.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features, unused)]
const fn complex_maths(n : usize) -> usize {
diff --git a/src/test/ui/const_evaluatable/no_where_clause.stderr b/src/test/ui/const-generics/generic_const_exprs/no_where_clause.stderr
similarity index 100%
rename from src/test/ui/const_evaluatable/no_where_clause.stderr
rename to src/test/ui/const-generics/generic_const_exprs/no_where_clause.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.rs b/src/test/ui/const-generics/generic_const_exprs/object-safety-err-ret.rs
similarity index 85%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.rs
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-err-ret.rs
index 5be4b41..24d333a 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/object-safety-err-ret.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.stderr b/src/test/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-ret.stderr
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.rs b/src/test/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.rs
similarity index 88%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.rs
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.rs
index 5fbd4a5..42c1cc5 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
#![deny(where_clauses_object_safety)]
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.stderr b/src/test/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-err-where-bounds.stderr
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-err-where-bounds.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.rs b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.rs
similarity index 74%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.rs
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.rs
index 9a95908..c6c196d 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Foo<const N: usize> {
@@ -16,7 +16,7 @@ impl<const N: usize> Foo<N> for () {
}
fn main() {
- // FIXME(const_evaluatable_checked): Improve the error message here.
+ // FIXME(generic_const_exprs): Improve the error message here.
use_dyn(&());
//~^ ERROR type annotations needed
}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.stderr b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok-infer-err.stderr
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-ok-infer-err.stderr
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok.rs b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok.rs
similarity index 86%
rename from src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok.rs
rename to src/test/ui/const-generics/generic_const_exprs/object-safety-ok.rs
index ae78b79..f4c89f6 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/object-safety-ok.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/object-safety-ok.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Foo<const N: usize> {
diff --git a/src/test/ui/const-generics/generic_const_exprs/simple_fail.rs b/src/test/ui/const-generics/generic_const_exprs/simple_fail.rs
new file mode 100644
index 0000000..c47a350
--- /dev/null
+++ b/src/test/ui/const-generics/generic_const_exprs/simple_fail.rs
@@ -0,0 +1,14 @@
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
+
+type Arr<const N: usize> = [u8; N - 1];
+//~^ ERROR evaluation of `Arr::<0_usize>::{constant#0}` failed
+
+fn test<const N: usize>() -> Arr<N> where [u8; N - 1]: Sized {
+//~^ ERROR evaluation of `test::<0_usize>::{constant#0}` failed
+ todo!()
+}
+
+fn main() {
+ test::<0>();
+}
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr b/src/test/ui/const-generics/generic_const_exprs/simple_fail.stderr
similarity index 89%
rename from src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr
rename to src/test/ui/const-generics/generic_const_exprs/simple_fail.stderr
index 1f2313a..99fc92f 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/simple_fail.full.stderr
+++ b/src/test/ui/const-generics/generic_const_exprs/simple_fail.stderr
@@ -1,11 +1,11 @@
error[E0080]: evaluation of `test::<0_usize>::{constant#0}` failed
- --> $DIR/simple_fail.rs:10:48
+ --> $DIR/simple_fail.rs:7:48
|
LL | fn test<const N: usize>() -> Arr<N> where [u8; N - 1]: Sized {
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
error[E0080]: evaluation of `Arr::<0_usize>::{constant#0}` failed
- --> $DIR/simple_fail.rs:6:33
+ --> $DIR/simple_fail.rs:4:33
|
LL | type Arr<const N: usize> = [u8; N - 1];
| ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs b/src/test/ui/const-generics/generic_const_exprs/subexprs_are_const_evalutable.rs
similarity index 86%
rename from src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs
rename to src/test/ui/const-generics/generic_const_exprs/subexprs_are_const_evalutable.rs
index 11c0760..d6574a3 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/subexprs_are_const_evalutable.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn make_array<const M: usize>() -> [(); M + 1] {
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/ty-alias-substitution.rs b/src/test/ui/const-generics/generic_const_exprs/ty-alias-substitution.rs
similarity index 83%
rename from src/test/ui/const-generics/const_evaluatable_checked/ty-alias-substitution.rs
rename to src/test/ui/const-generics/generic_const_exprs/ty-alias-substitution.rs
index 5c768a6..d058b36 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/ty-alias-substitution.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/ty-alias-substitution.rs
@@ -1,6 +1,6 @@
// check-pass
// Test that we correctly substitute generic arguments for type aliases.
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
type Alias<T, const N: usize> = [T; N + 1];
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unop.rs b/src/test/ui/const-generics/generic_const_exprs/unop.rs
similarity index 81%
rename from src/test/ui/const-generics/const_evaluatable_checked/unop.rs
rename to src/test/ui/const-generics/generic_const_exprs/unop.rs
index 8e0768b..c12fef0 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/unop.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/unop.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Foo<const B: bool>;
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unused-complex-default-expr.rs b/src/test/ui/const-generics/generic_const_exprs/unused-complex-default-expr.rs
similarity index 65%
rename from src/test/ui/const-generics/const_evaluatable_checked/unused-complex-default-expr.rs
rename to src/test/ui/const-generics/generic_const_exprs/unused-complex-default-expr.rs
index 21f14f5..67fefd0 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/unused-complex-default-expr.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/unused-complex-default-expr.rs
@@ -1,5 +1,5 @@
// check-pass
-#![feature(const_generics, const_evaluatable_checked, const_generics_defaults)]
+#![feature(generic_const_exprs, const_generics_defaults)]
#![allow(incomplete_features)]
struct Foo<const N: usize, const M: usize = { N + 1 }>;
struct Bar<const N: usize>(Foo<N, 3>);
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.rs b/src/test/ui/const-generics/generic_const_exprs/unused_expr.rs
similarity index 89%
rename from src/test/ui/const-generics/const_evaluatable_checked/unused_expr.rs
rename to src/test/ui/const-generics/generic_const_exprs/unused_expr.rs
index 9c603c5..c1bf19e 100644
--- a/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.rs
+++ b/src/test/ui/const-generics/generic_const_exprs/unused_expr.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn add<const N: usize>() -> [u8; { N + 1; 5 }] {
diff --git a/src/test/ui/const-generics/const_evaluatable_checked/unused_expr.stderr b/src/test/ui/const-generics/generic_const_exprs/unused_expr.stderr
similarity index 100%
rename from src/test/ui/const-generics/const_evaluatable_checked/unused_expr.stderr
rename to src/test/ui/const-generics/generic_const_exprs/unused_expr.stderr
diff --git a/src/test/ui/const-generics/impl-const-generic-struct.rs b/src/test/ui/const-generics/impl-const-generic-struct.rs
index 1aa2269..7eb2c6a 100644
--- a/src/test/ui/const-generics/impl-const-generic-struct.rs
+++ b/src/test/ui/const-generics/impl-const-generic-struct.rs
@@ -1,9 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct S<const X: u32>;
impl<const X: u32> S<X> {
diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr b/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr
deleted file mode 100644
index ebc8f45..0000000
--- a/src/test/ui/const-generics/impl-trait-with-const-arguments.min.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
- --> $DIR/impl-trait-with-const-arguments.rs:23:20
- |
-LL | assert_eq!(f::<4usize>(Usizable), 20usize);
- | ^^^^^^ explicit generic argument not allowed
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0632`.
diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.rs b/src/test/ui/const-generics/impl-trait-with-const-arguments.rs
index 2e6e49b..24ba393 100644
--- a/src/test/ui/const-generics/impl-trait-with-const-arguments.rs
+++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
trait Usizer {
fn m(self) -> usize;
}
diff --git a/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr b/src/test/ui/const-generics/impl-trait-with-const-arguments.stderr
similarity index 86%
rename from src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr
rename to src/test/ui/const-generics/impl-trait-with-const-arguments.stderr
index ebc8f45..6268a56 100644
--- a/src/test/ui/const-generics/impl-trait-with-const-arguments.full.stderr
+++ b/src/test/ui/const-generics/impl-trait-with-const-arguments.stderr
@@ -1,5 +1,5 @@
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
- --> $DIR/impl-trait-with-const-arguments.rs:23:20
+ --> $DIR/impl-trait-with-const-arguments.rs:18:20
|
LL | assert_eq!(f::<4usize>(Usizable), 20usize);
| ^^^^^^ explicit generic argument not allowed
diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr b/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr
deleted file mode 100644
index 7a12f3b..0000000
--- a/src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
- --> $DIR/incorrect-number-of-const-args.rs:11:5
- |
-LL | foo::<0>();
- | ^^^ - supplied 1 generic argument
- | |
- | expected 2 generic arguments
- |
-note: function defined here, with 2 generic parameters: `X`, `Y`
- --> $DIR/incorrect-number-of-const-args.rs:6:4
- |
-LL | fn foo<const X: usize, const Y: usize>() -> usize {
- | ^^^ - -
-help: add missing generic argument
- |
-LL | foo::<0, Y>();
- | +++
-
-error[E0107]: this function takes 2 generic arguments but 3 generic arguments were supplied
- --> $DIR/incorrect-number-of-const-args.rs:14:5
- |
-LL | foo::<0, 0, 0>();
- | ^^^ - help: remove this generic argument
- | |
- | expected 2 generic arguments
- |
-note: function defined here, with 2 generic parameters: `X`, `Y`
- --> $DIR/incorrect-number-of-const-args.rs:6:4
- |
-LL | fn foo<const X: usize, const Y: usize>() -> usize {
- | ^^^ - -
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0107`.
diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.rs b/src/test/ui/const-generics/incorrect-number-of-const-args.rs
index 305559d..de2d126 100644
--- a/src/test/ui/const-generics/incorrect-number-of-const-args.rs
+++ b/src/test/ui/const-generics/incorrect-number-of-const-args.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn foo<const X: usize, const Y: usize>() -> usize {
0
}
diff --git a/src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr b/src/test/ui/const-generics/incorrect-number-of-const-args.stderr
similarity index 82%
rename from src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr
rename to src/test/ui/const-generics/incorrect-number-of-const-args.stderr
index 7a12f3b..bf873da 100644
--- a/src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr
+++ b/src/test/ui/const-generics/incorrect-number-of-const-args.stderr
@@ -1,5 +1,5 @@
error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
- --> $DIR/incorrect-number-of-const-args.rs:11:5
+ --> $DIR/incorrect-number-of-const-args.rs:6:5
|
LL | foo::<0>();
| ^^^ - supplied 1 generic argument
@@ -7,7 +7,7 @@
| expected 2 generic arguments
|
note: function defined here, with 2 generic parameters: `X`, `Y`
- --> $DIR/incorrect-number-of-const-args.rs:6:4
+ --> $DIR/incorrect-number-of-const-args.rs:1:4
|
LL | fn foo<const X: usize, const Y: usize>() -> usize {
| ^^^ - -
@@ -17,7 +17,7 @@
| +++
error[E0107]: this function takes 2 generic arguments but 3 generic arguments were supplied
- --> $DIR/incorrect-number-of-const-args.rs:14:5
+ --> $DIR/incorrect-number-of-const-args.rs:9:5
|
LL | foo::<0, 0, 0>();
| ^^^ - help: remove this generic argument
@@ -25,7 +25,7 @@
| expected 2 generic arguments
|
note: function defined here, with 2 generic parameters: `X`, `Y`
- --> $DIR/incorrect-number-of-const-args.rs:6:4
+ --> $DIR/incorrect-number-of-const-args.rs:1:4
|
LL | fn foo<const X: usize, const Y: usize>() -> usize {
| ^^^ - -
diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr
deleted file mode 100644
index 01fb137..0000000
--- a/src/test/ui/const-generics/infer/cannot-infer-const-args.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0282]: type annotations needed
- --> $DIR/cannot-infer-const-args.rs:11:5
- |
-LL | foo();
- | ^^^ cannot infer the value of const parameter `X` declared on the function `foo`
- |
-help: consider specifying the const argument
- |
-LL | foo::<X>();
- | ~~~~~~~~
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.rs b/src/test/ui/const-generics/infer/cannot-infer-const-args.rs
index cc52892..f85a729 100644
--- a/src/test/ui/const-generics/infer/cannot-infer-const-args.rs
+++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn foo<const X: usize>() -> usize {
0
}
diff --git a/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr b/src/test/ui/const-generics/infer/cannot-infer-const-args.stderr
similarity index 88%
rename from src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr
rename to src/test/ui/const-generics/infer/cannot-infer-const-args.stderr
index 01fb137..828f497 100644
--- a/src/test/ui/const-generics/infer/cannot-infer-const-args.full.stderr
+++ b/src/test/ui/const-generics/infer/cannot-infer-const-args.stderr
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
- --> $DIR/cannot-infer-const-args.rs:11:5
+ --> $DIR/cannot-infer-const-args.rs:6:5
|
LL | foo();
| ^^^ cannot infer the value of const parameter `X` declared on the function `foo`
diff --git a/src/test/ui/const-generics/infer/method-chain.min.stderr b/src/test/ui/const-generics/infer/method-chain.min.stderr
deleted file mode 100644
index 979d50b..0000000
--- a/src/test/ui/const-generics/infer/method-chain.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0282]: type annotations needed
- --> $DIR/method-chain.rs:20:33
- |
-LL | Foo.bar().bar().bar().bar().baz();
- | ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz`
- |
-help: consider specifying the const argument
- |
-LL | Foo.bar().bar().bar().bar().baz::<N>();
- | ~~~~~~~~
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/const-generics/infer/method-chain.rs b/src/test/ui/const-generics/infer/method-chain.rs
index 8ac6a7d..0c5eed4 100644
--- a/src/test/ui/const-generics/infer/method-chain.rs
+++ b/src/test/ui/const-generics/infer/method-chain.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct Foo;
impl Foo {
diff --git a/src/test/ui/const-generics/infer/method-chain.full.stderr b/src/test/ui/const-generics/infer/method-chain.stderr
similarity index 93%
rename from src/test/ui/const-generics/infer/method-chain.full.stderr
rename to src/test/ui/const-generics/infer/method-chain.stderr
index 979d50b..53d92e5 100644
--- a/src/test/ui/const-generics/infer/method-chain.full.stderr
+++ b/src/test/ui/const-generics/infer/method-chain.stderr
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
- --> $DIR/method-chain.rs:20:33
+ --> $DIR/method-chain.rs:15:33
|
LL | Foo.bar().bar().bar().bar().baz();
| ^^^ cannot infer the value of const parameter `N` declared on the associated function `baz`
diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.min.stderr b/src/test/ui/const-generics/infer/one-param-uninferred.min.stderr
deleted file mode 100644
index 31b7fc7..0000000
--- a/src/test/ui/const-generics/infer/one-param-uninferred.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0282]: type annotations needed
- --> $DIR/one-param-uninferred.rs:15:23
- |
-LL | let _: [u8; 17] = foo();
- | ^^^ cannot infer the value of const parameter `M` declared on the function `foo`
- |
-help: consider specifying the const argument
- |
-LL | let _: [u8; 17] = foo::<M>();
- | ~~~~~~~~
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.rs b/src/test/ui/const-generics/infer/one-param-uninferred.rs
index 0e94713..d601865 100644
--- a/src/test/ui/const-generics/infer/one-param-uninferred.rs
+++ b/src/test/ui/const-generics/infer/one-param-uninferred.rs
@@ -1,10 +1,4 @@
// Test that we emit an error if we cannot properly infer a constant.
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(min, feature(min_const_generics))]
-
fn foo<const N: usize, const M: usize>() -> [u8; N] {
todo!()
}
diff --git a/src/test/ui/const-generics/infer/one-param-uninferred.full.stderr b/src/test/ui/const-generics/infer/one-param-uninferred.stderr
similarity index 90%
rename from src/test/ui/const-generics/infer/one-param-uninferred.full.stderr
rename to src/test/ui/const-generics/infer/one-param-uninferred.stderr
index 31b7fc7..acf5917 100644
--- a/src/test/ui/const-generics/infer/one-param-uninferred.full.stderr
+++ b/src/test/ui/const-generics/infer/one-param-uninferred.stderr
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
- --> $DIR/one-param-uninferred.rs:15:23
+ --> $DIR/one-param-uninferred.rs:9:23
|
LL | let _: [u8; 17] = foo();
| ^^^ cannot infer the value of const parameter `M` declared on the function `foo`
diff --git a/src/test/ui/const-generics/infer/uninferred-consts.min.stderr b/src/test/ui/const-generics/infer/uninferred-consts.min.stderr
deleted file mode 100644
index bee4b69..0000000
--- a/src/test/ui/const-generics/infer/uninferred-consts.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0282]: type annotations needed
- --> $DIR/uninferred-consts.rs:13:9
- |
-LL | Foo.foo();
- | ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo`
- |
-help: consider specifying the const argument
- |
-LL | Foo.foo::<A>();
- | ~~~~~~~~
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/const-generics/infer/uninferred-consts.rs b/src/test/ui/const-generics/infer/uninferred-consts.rs
index bcd9aad..657f4b5 100644
--- a/src/test/ui/const-generics/infer/uninferred-consts.rs
+++ b/src/test/ui/const-generics/infer/uninferred-consts.rs
@@ -1,8 +1,4 @@
// Test that we emit an error if we cannot properly infer a constant.
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
// taken from https://github.com/rust-lang/rust/issues/70507#issuecomment-615268893
struct Foo;
diff --git a/src/test/ui/const-generics/infer/uninferred-consts.full.stderr b/src/test/ui/const-generics/infer/uninferred-consts.stderr
similarity index 90%
rename from src/test/ui/const-generics/infer/uninferred-consts.full.stderr
rename to src/test/ui/const-generics/infer/uninferred-consts.stderr
index bee4b69..a6c79fc 100644
--- a/src/test/ui/const-generics/infer/uninferred-consts.full.stderr
+++ b/src/test/ui/const-generics/infer/uninferred-consts.stderr
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
- --> $DIR/uninferred-consts.rs:13:9
+ --> $DIR/uninferred-consts.rs:9:9
|
LL | Foo.foo();
| ^^^ cannot infer the value of const parameter `A` declared on the associated function `foo`
diff --git a/src/test/ui/const-generics/infer_arg_from_pat.rs b/src/test/ui/const-generics/infer_arg_from_pat.rs
index 5e2a3ea..10317a1 100644
--- a/src/test/ui/const-generics/infer_arg_from_pat.rs
+++ b/src/test/ui/const-generics/infer_arg_from_pat.rs
@@ -1,10 +1,6 @@
// run-pass
//
// see issue #70529
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct A<const N: usize> {
arr: [u8; N],
diff --git a/src/test/ui/const-generics/infer_arr_len_from_pat.rs b/src/test/ui/const-generics/infer_arr_len_from_pat.rs
index 0273383..40f6f5b 100644
--- a/src/test/ui/const-generics/infer_arr_len_from_pat.rs
+++ b/src/test/ui/const-generics/infer_arr_len_from_pat.rs
@@ -1,10 +1,6 @@
// check-pass
//
// see issue #70529
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
fn as_chunks<const N: usize>() -> [u8; N] {
loop {}
diff --git a/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs b/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs
index 96e5976..2b8731b 100644
--- a/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs
+++ b/src/test/ui/const-generics/integer-literal-generic-arg-in-where-clause.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
fn takes_closure_of_array_3<F>(f: F) where F: Fn([i32; 3]) {
f([1, 2, 3]);
diff --git a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr
deleted file mode 100644
index 3e90dbe..0000000
--- a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/intrinsics-type_name-as-const-argument.rs:14:8
- |
-LL | T: Trait<{std::intrinsics::type_name::<T>()}>
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr
index 8701d54..b8a1027 100644
--- a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr
+++ b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr
@@ -1,20 +1,20 @@
error: generic parameters may not be used in const operations
- --> $DIR/intrinsics-type_name-as-const-argument.rs:14:44
+ --> $DIR/intrinsics-type_name-as-const-argument.rs:15:44
|
LL | T: Trait<{std::intrinsics::type_name::<T>()}>
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: `&'static str` is forbidden as the type of a const generic parameter
- --> $DIR/intrinsics-type_name-as-const-argument.rs:9:22
+ --> $DIR/intrinsics-type_name-as-const-argument.rs:10:22
|
LL | trait Trait<const S: &'static str> {}
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs
index f24dd42..147a00c 100644
--- a/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs
+++ b/src/test/ui/const-generics/intrinsics-type_name-as-const-argument.rs
@@ -1,7 +1,8 @@
+// [full] check-pass
// revisions: full min
#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params, generic_const_exprs))]
#![feature(core_intrinsics)]
#![feature(const_type_name)]
@@ -13,7 +14,6 @@ struct Bug<T>
where
T: Trait<{std::intrinsics::type_name::<T>()}>
//[min]~^ ERROR generic parameters may not be used in const operations
- //[full]~^^ ERROR constant expression depends on a generic parameter
{
t: T
}
diff --git a/src/test/ui/const-generics/invalid-enum.rs b/src/test/ui/const-generics/invalid-enum.rs
index 32939dc..bc3c092 100644
--- a/src/test/ui/const-generics/invalid-enum.rs
+++ b/src/test/ui/const-generics/invalid-enum.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(adt_const_params, const_generics_defaults)]
#![allow(incomplete_features)]
#[derive(PartialEq, Eq)]
diff --git a/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs b/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs
index f59eb60..6a10ee2 100644
--- a/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs
+++ b/src/test/ui/const-generics/issues/auxiliary/const_generic_issues_lib.rs
@@ -1,5 +1,5 @@
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
// All of these three items must be in `lib2` to reproduce the error
@@ -10,6 +10,6 @@ pub trait TypeFn {
pub struct GenericType<const B: i8>;
// Removing the braces around `42` resolves the crash
-impl TypeFn for GenericType<{ 42 }> {
+impl TypeFn for GenericType<{ 40 + 2 }> {
type Output = ();
}
diff --git a/src/test/ui/const-generics/issues/auxiliary/impl-const.rs b/src/test/ui/const-generics/issues/auxiliary/impl-const.rs
index 4a6b578..de3a408 100644
--- a/src/test/ui/const-generics/issues/auxiliary/impl-const.rs
+++ b/src/test/ui/const-generics/issues/auxiliary/impl-const.rs
@@ -1,5 +1,4 @@
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![feature(generic_const_exprs)]
pub struct Num<const N: usize>;
diff --git a/src/test/ui/const-generics/issues/issue-56445-1.full.stderr b/src/test/ui/const-generics/issues/issue-56445-1.full.stderr
index 8416d64..179643a 100644
--- a/src/test/ui/const-generics/issues/issue-56445-1.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-56445-1.full.stderr
@@ -1,20 +1,11 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-56445-1.rs:3:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
error[E0771]: use of non-static lifetime `'a` in const generic
- --> $DIR/issue-56445-1.rs:8:26
+ --> $DIR/issue-56445-1.rs:9:26
|
LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
| ^^
|
= note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052>
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0771`.
diff --git a/src/test/ui/const-generics/issues/issue-56445-1.min.stderr b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr
index f7056f2..179643a 100644
--- a/src/test/ui/const-generics/issues/issue-56445-1.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-56445-1.min.stderr
@@ -1,5 +1,5 @@
error[E0771]: use of non-static lifetime `'a` in const generic
- --> $DIR/issue-56445-1.rs:8:26
+ --> $DIR/issue-56445-1.rs:9:26
|
LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
| ^^
diff --git a/src/test/ui/const-generics/issues/issue-56445-1.rs b/src/test/ui/const-generics/issues/issue-56445-1.rs
index bc9e1de..aeef778 100644
--- a/src/test/ui/const-generics/issues/issue-56445-1.rs
+++ b/src/test/ui/const-generics/issues/issue-56445-1.rs
@@ -1,6 +1,7 @@
// Regression test for https://github.com/rust-lang/rust/issues/56445#issuecomment-518402995.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
+#![cfg_attr(full, feature(adt_const_params))]
+#![cfg_attr(full, allow(incomplete_features))]
#![crate_type = "lib"]
use std::marker::PhantomData;
diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr
deleted file mode 100644
index c03b725..0000000
--- a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.full.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-60818-struct-constructors.rs:3:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs
index 6e64c78..0066490 100644
--- a/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs
+++ b/src/test/ui/const-generics/issues/issue-60818-struct-constructors.rs
@@ -1,6 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
struct Generic<const V: usize>;
diff --git a/src/test/ui/const-generics/issues/issue-61336-1.full.stderr b/src/test/ui/const-generics/issues/issue-61336-1.full.stderr
deleted file mode 100644
index f18728e..0000000
--- a/src/test/ui/const-generics/issues/issue-61336-1.full.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61336-1.rs:3:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/const-generics/issues/issue-61336-1.rs b/src/test/ui/const-generics/issues/issue-61336-1.rs
index c93b296..beb37e6 100644
--- a/src/test/ui/const-generics/issues/issue-61336-1.rs
+++ b/src/test/ui/const-generics/issues/issue-61336-1.rs
@@ -1,7 +1,4 @@
// build-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
-
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
[x; N]
}
diff --git a/src/test/ui/const-generics/issues/issue-61336-2.full.stderr b/src/test/ui/const-generics/issues/issue-61336-2.full.stderr
deleted file mode 100644
index 8f07d20..0000000
--- a/src/test/ui/const-generics/issues/issue-61336-2.full.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61336-2.rs:2:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0277]: the trait bound `T: Copy` is not satisfied
- --> $DIR/issue-61336-2.rs:9:5
- |
-LL | [x; { N }]
- | ^^^^^^^^^^ the trait `Copy` is not implemented for `T`
- |
- = note: the `Copy` trait is required because the repeated element will be copied
-help: consider restricting type parameter `T`
- |
-LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
- | +++++++++++++++++++
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/issues/issue-61336-2.rs b/src/test/ui/const-generics/issues/issue-61336-2.rs
index a1cf641..b7cd29f 100644
--- a/src/test/ui/const-generics/issues/issue-61336-2.rs
+++ b/src/test/ui/const-generics/issues/issue-61336-2.rs
@@ -1,6 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
-
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
[x; { N }]
}
diff --git a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr b/src/test/ui/const-generics/issues/issue-61336-2.stderr
similarity index 93%
rename from src/test/ui/const-generics/issues/issue-61336-2.min.stderr
rename to src/test/ui/const-generics/issues/issue-61336-2.stderr
index 9b62ffc..48aaaf5 100644
--- a/src/test/ui/const-generics/issues/issue-61336-2.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-61336-2.stderr
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `T: Copy` is not satisfied
- --> $DIR/issue-61336-2.rs:9:5
+ --> $DIR/issue-61336-2.rs:6:5
|
LL | [x; { N }]
| ^^^^^^^^^^ the trait `Copy` is not implemented for `T`
diff --git a/src/test/ui/const-generics/issues/issue-61336.full.stderr b/src/test/ui/const-generics/issues/issue-61336.full.stderr
deleted file mode 100644
index 4883463..0000000
--- a/src/test/ui/const-generics/issues/issue-61336.full.stderr
+++ /dev/null
@@ -1,24 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61336.rs:2:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error[E0277]: the trait bound `T: Copy` is not satisfied
- --> $DIR/issue-61336.rs:9:5
- |
-LL | [x; N]
- | ^^^^^^ the trait `Copy` is not implemented for `T`
- |
- = note: the `Copy` trait is required because the repeated element will be copied
-help: consider restricting type parameter `T`
- |
-LL | fn g<T: std::marker::Copy, const N: usize>(x: T) -> [T; N] {
- | +++++++++++++++++++
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/issues/issue-61336.rs b/src/test/ui/const-generics/issues/issue-61336.rs
index c0106ee..80be1d8 100644
--- a/src/test/ui/const-generics/issues/issue-61336.rs
+++ b/src/test/ui/const-generics/issues/issue-61336.rs
@@ -1,6 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
-
fn f<T: Copy, const N: usize>(x: T) -> [T; N] {
[x; N]
}
diff --git a/src/test/ui/const-generics/issues/issue-61336.min.stderr b/src/test/ui/const-generics/issues/issue-61336.stderr
similarity index 93%
rename from src/test/ui/const-generics/issues/issue-61336.min.stderr
rename to src/test/ui/const-generics/issues/issue-61336.stderr
index dc89184..665a1a6 100644
--- a/src/test/ui/const-generics/issues/issue-61336.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-61336.stderr
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `T: Copy` is not satisfied
- --> $DIR/issue-61336.rs:9:5
+ --> $DIR/issue-61336.rs:6:5
|
LL | [x; N]
| ^^^^^^ the trait `Copy` is not implemented for `T`
diff --git a/src/test/ui/const-generics/issues/issue-61422.full.stderr b/src/test/ui/const-generics/issues/issue-61422.full.stderr
deleted file mode 100644
index ac6c378..0000000
--- a/src/test/ui/const-generics/issues/issue-61422.full.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61422.rs:3:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/const-generics/issues/issue-61422.rs b/src/test/ui/const-generics/issues/issue-61422.rs
index 421f696..0b9cf40 100644
--- a/src/test/ui/const-generics/issues/issue-61422.rs
+++ b/src/test/ui/const-generics/issues/issue-61422.rs
@@ -1,7 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
-
use std::mem;
// Neither of the uninits below are currently accepted as not UB, however,
diff --git a/src/test/ui/const-generics/issues/issue-61432.full.stderr b/src/test/ui/const-generics/issues/issue-61432.full.stderr
deleted file mode 100644
index 82b36de..0000000
--- a/src/test/ui/const-generics/issues/issue-61432.full.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61432.rs:3:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/const-generics/issues/issue-61432.rs b/src/test/ui/const-generics/issues/issue-61432.rs
index 97ab07d..6192af8 100644
--- a/src/test/ui/const-generics/issues/issue-61432.rs
+++ b/src/test/ui/const-generics/issues/issue-61432.rs
@@ -1,13 +1,6 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
fn promote<const N: i32>() {
- // works:
- //
- // let n = N;
- // let _ = &n;
-
let _ = &N;
}
diff --git a/src/test/ui/const-generics/issues/issue-61522-array-len-succ.full.stderr b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.full.stderr
deleted file mode 100644
index 56deec1..0000000
--- a/src/test/ui/const-generics/issues/issue-61522-array-len-succ.full.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-61522-array-len-succ.rs:6:40
- |
-LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
- | ^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-61522-array-len-succ.rs:11:24
- |
-LL | fn inner(&self) -> &[u8; COUNT + 1] {
- | ^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/issues/issue-61522-array-len-succ.min.stderr b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.min.stderr
deleted file mode 100644
index 36a0a37a..0000000
--- a/src/test/ui/const-generics/issues/issue-61522-array-len-succ.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-61522-array-len-succ.rs:6:45
- |
-LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
- | ^^^^^ cannot perform const operation using `COUNT`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `COUNT`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/issue-61522-array-len-succ.rs:11:30
- |
-LL | fn inner(&self) -> &[u8; COUNT + 1] {
- | ^^^^^ cannot perform const operation using `COUNT`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `COUNT`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/issues/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issues/issue-61522-array-len-succ.rs
deleted file mode 100644
index d4a948b..0000000
--- a/src/test/ui/const-generics/issues/issue-61522-array-len-succ.rs
+++ /dev/null
@@ -1,18 +0,0 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
-//[full]~^ ERROR constant expression depends on a generic parameter
-//[min]~^^ ERROR generic parameters may not be used
-
-impl<const COUNT: usize> MyArray<COUNT> {
- fn inner(&self) -> &[u8; COUNT + 1] {
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used
- &self.0
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-61747.full.stderr b/src/test/ui/const-generics/issues/issue-61747.full.stderr
deleted file mode 100644
index b7f6634..0000000
--- a/src/test/ui/const-generics/issues/issue-61747.full.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61747.rs:2:27
- |
-LL | #![cfg_attr(full, feature(const_generics))]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-61747.rs:7:23
- |
-LL | fn successor() -> Const<{C + 1}> {
- | ^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error; 1 warning emitted
-
diff --git a/src/test/ui/const-generics/issues/issue-61747.min.stderr b/src/test/ui/const-generics/issues/issue-61747.min.stderr
deleted file mode 100644
index b85533c..0000000
--- a/src/test/ui/const-generics/issues/issue-61747.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-61747.rs:7:30
- |
-LL | fn successor() -> Const<{C + 1}> {
- | ^ cannot perform const operation using `C`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `C`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-61747.rs b/src/test/ui/const-generics/issues/issue-61747.rs
deleted file mode 100644
index 3aa2e6a..0000000
--- a/src/test/ui/const-generics/issues/issue-61747.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))] //[full]~WARN the feature `const_generics` is incomplete
-
-struct Const<const N: usize>;
-
-impl<const C: usize> Const<{C}> {
- fn successor() -> Const<{C + 1}> {
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used
- Const
- }
-}
-
-fn main() {
- let _x: Const::<2> = Const::<1>::successor();
-}
diff --git a/src/test/ui/const-generics/issues/issue-61935.full.stderr b/src/test/ui/const-generics/issues/issue-61935.full.stderr
deleted file mode 100644
index b970f4e..0000000
--- a/src/test/ui/const-generics/issues/issue-61935.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-61935.rs:9:14
- |
-LL | Self:FooImpl<{N==0}>
- | ^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-61935.min.stderr b/src/test/ui/const-generics/issues/issue-61935.min.stderr
deleted file mode 100644
index 9382dca3..0000000
--- a/src/test/ui/const-generics/issues/issue-61935.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-61935.rs:9:23
- |
-LL | Self:FooImpl<{N==0}>
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-61935.rs b/src/test/ui/const-generics/issues/issue-61935.rs
deleted file mode 100644
index ed861c6..0000000
--- a/src/test/ui/const-generics/issues/issue-61935.rs
+++ /dev/null
@@ -1,25 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-trait Foo {}
-
-impl<const N: usize> Foo for [(); N]
- where
- Self:FooImpl<{N==0}>
-//[full]~^ERROR constant expression depends on a generic parameter
-//[min]~^^ERROR generic parameters may not be used in const operations
-{}
-
-trait FooImpl<const IS_ZERO: bool>{}
-
-impl FooImpl<true> for [(); 0] {}
-
-impl<const N:usize> FooImpl<false> for [();N] {}
-
-fn foo(_: impl Foo) {}
-
-fn main() {
- foo([]);
- foo([()]);
-}
diff --git a/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs b/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs
index 1a0e46e..fa76aea 100644
--- a/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs
+++ b/src/test/ui/const-generics/issues/issue-62187-encountered-polymorphic-const.rs
@@ -1,9 +1,4 @@
// run-pass
-
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
pub trait BitLen: Sized {
const BIT_LEN: usize;
}
diff --git a/src/test/ui/const-generics/issues/issue-62220.full.stderr b/src/test/ui/const-generics/issues/issue-62220.full.stderr
deleted file mode 100644
index 373360c..0000000
--- a/src/test/ui/const-generics/issues/issue-62220.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-62220.rs:12:27
- |
-LL | pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-62220.min.stderr b/src/test/ui/const-generics/issues/issue-62220.min.stderr
deleted file mode 100644
index 72311d0..0000000
--- a/src/test/ui/const-generics/issues/issue-62220.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-62220.rs:7:59
- |
-LL | pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-62220.rs b/src/test/ui/const-generics/issues/issue-62220.rs
deleted file mode 100644
index c26784c..0000000
--- a/src/test/ui/const-generics/issues/issue-62220.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-pub struct Vector<T, const N: usize>([T; N]);
-
-pub type TruncatedVector<T, const N: usize> = Vector<T, { N - 1 }>;
-//[min]~^ ERROR generic parameters may not be used in const operations
-
-impl<T, const N: usize> Vector<T, { N }> {
- /// Drop the last component and return the vector with one fewer dimension.
- pub fn trunc(self) -> (TruncatedVector<T, { N }>, T) {
- //[full]~^ ERROR constant expression depends on a generic parameter
- unimplemented!()
- }
-}
-
-fn vec4<T>(a: T, b: T, c: T, d: T) -> Vector<T, 4> {
- Vector([a, b, c, d])
-}
-
-fn main() {
- let (_xyz, _w): (TruncatedVector<u32, 4>, u32) = vec4(0u32, 1, 2, 3).trunc();
-}
diff --git a/src/test/ui/const-generics/issues/issue-62456.full.stderr b/src/test/ui/const-generics/issues/issue-62456.full.stderr
deleted file mode 100644
index 833e70c..0000000
--- a/src/test/ui/const-generics/issues/issue-62456.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-62456.rs:6:20
- |
-LL | let _ = [0u64; N + 1];
- | ^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-62456.min.stderr b/src/test/ui/const-generics/issues/issue-62456.min.stderr
deleted file mode 100644
index 920318f..0000000
--- a/src/test/ui/const-generics/issues/issue-62456.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-62456.rs:6:20
- |
-LL | let _ = [0u64; N + 1];
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-62456.rs b/src/test/ui/const-generics/issues/issue-62456.rs
deleted file mode 100644
index e24cf36..0000000
--- a/src/test/ui/const-generics/issues/issue-62456.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-fn foo<const N: usize>() {
- let _ = [0u64; N + 1];
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used in const operations
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr b/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr
deleted file mode 100644
index 5c9387d..0000000
--- a/src/test/ui/const-generics/issues/issue-62579-no-match.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: `NoMatch` is forbidden as the type of a const generic parameter
- --> $DIR/issue-62579-no-match.rs:9:17
- |
-LL | fn foo<const T: NoMatch>() -> bool {
- | ^^^^^^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-62579-no-match.rs b/src/test/ui/const-generics/issues/issue-62579-no-match.rs
deleted file mode 100644
index 46813f5..0000000
--- a/src/test/ui/const-generics/issues/issue-62579-no-match.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// [full] run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-#[derive(PartialEq, Eq)]
-struct NoMatch;
-
-fn foo<const T: NoMatch>() -> bool {
- //[min]~^ ERROR `NoMatch` is forbidden as the type of a const generic parameter
- true
-}
-
-fn main() {
- foo::<{NoMatch}>();
-}
diff --git a/src/test/ui/const-generics/issues/issue-62878.full.stderr b/src/test/ui/const-generics/issues/issue-62878.full.stderr
index 08f6454..f074a65 100644
--- a/src/test/ui/const-generics/issues/issue-62878.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-62878.full.stderr
@@ -4,21 +4,13 @@
LL | fn foo<const N: usize, const A: [u8; N]>() {}
| ^ the type must not depend on the parameter `N`
-error: constant expression depends on a generic parameter
- --> $DIR/issue-62878.rs:10:14
- |
-LL | foo::<_, {[1]}>();
- | ^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
error[E0308]: mismatched types
--> $DIR/issue-62878.rs:10:15
|
LL | foo::<_, {[1]}>();
| ^^^ expected `usize`, found array `[{integer}; 1]`
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
Some errors have detailed explanations: E0308, E0770.
For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/issues/issue-62878.min.stderr b/src/test/ui/const-generics/issues/issue-62878.min.stderr
index e4a71fe..af029a6 100644
--- a/src/test/ui/const-generics/issues/issue-62878.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-62878.min.stderr
@@ -11,7 +11,7 @@
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/issues/issue-62878.rs b/src/test/ui/const-generics/issues/issue-62878.rs
index fb62576..38f5ff7 100644
--- a/src/test/ui/const-generics/issues/issue-62878.rs
+++ b/src/test/ui/const-generics/issues/issue-62878.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics, generic_arg_infer))]
+#![cfg_attr(full, feature(adt_const_params, generic_arg_infer))]
#![cfg_attr(full, allow(incomplete_features))]
fn foo<const N: usize, const A: [u8; N]>() {}
@@ -9,5 +9,4 @@
fn main() {
foo::<_, {[1]}>();
//[full]~^ ERROR mismatched types
- //[full]~| ERROR constant expression
}
diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr
index 2fb38ad..b1141cf 100644
--- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
--> $DIR/issue-63322-forbid-dyn.rs:9:18
diff --git a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs
index 334e2aa..01a6caa 100644
--- a/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs
+++ b/src/test/ui/const-generics/issues/issue-63322-forbid-dyn.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
trait A {}
diff --git a/src/test/ui/const-generics/issues/issue-64494.full.stderr b/src/test/ui/const-generics/issues/issue-64494.full.stderr
deleted file mode 100644
index abb26d6..0000000
--- a/src/test/ui/const-generics/issues/issue-64494.full.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-64494.rs:15:53
- |
-LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-64494.rs:18:53
- |
-LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/issues/issue-64494.min.stderr b/src/test/ui/const-generics/issues/issue-64494.min.stderr
deleted file mode 100644
index 846db0c..0000000
--- a/src/test/ui/const-generics/issues/issue-64494.min.stderr
+++ /dev/null
@@ -1,30 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-64494.rs:15:38
- |
-LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
- | ^^^^^^ cannot perform const operation using `T`
- |
- = note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/issue-64494.rs:18:38
- |
-LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
- | ^^^^^^ cannot perform const operation using `T`
- |
- = note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error[E0119]: conflicting implementations of trait `MyTrait`
- --> $DIR/issue-64494.rs:18:1
- |
-LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
- | ------------------------------------ first implementation here
-...
-LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0119`.
diff --git a/src/test/ui/const-generics/issues/issue-64494.rs b/src/test/ui/const-generics/issues/issue-64494.rs
deleted file mode 100644
index 96d1920..0000000
--- a/src/test/ui/const-generics/issues/issue-64494.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-trait Foo {
- const VAL: usize;
-}
-
-trait MyTrait {}
-
-trait True {}
-struct Is<const T: bool>;
-impl True for Is<{true}> {}
-
-impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
-//[full]~^ ERROR constant expression depends on a generic parameter
-//[min]~^^ ERROR generic parameters may not be used in const operations
-impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
-//[full]~^ ERROR constant expression depends on a generic parameter
-//[min]~^^ ERROR generic parameters may not be used in const operations
-//[min]~| ERROR conflicting implementations of trait `MyTrait`
-
-fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-64519.rs b/src/test/ui/const-generics/issues/issue-64519.rs
index 8c603b7..969289b 100644
--- a/src/test/ui/const-generics/issues/issue-64519.rs
+++ b/src/test/ui/const-generics/issues/issue-64519.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct Foo<const D: usize> {
state: Option<[u8; D]>,
}
diff --git a/src/test/ui/const-generics/issues/issue-64519.stderr b/src/test/ui/const-generics/issues/issue-64519.stderr
deleted file mode 100644
index 6552aea..0000000
--- a/src/test/ui/const-generics/issues/issue-64519.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-64519.rs:3:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/const-generics/issues/issue-66205.full.stderr b/src/test/ui/const-generics/issues/issue-66205.full.stderr
deleted file mode 100644
index 7e150f5..0000000
--- a/src/test/ui/const-generics/issues/issue-66205.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-66205.rs:7:12
- |
-LL | fact::<{ N - 1 }>();
- | ^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-66205.min.stderr b/src/test/ui/const-generics/issues/issue-66205.min.stderr
deleted file mode 100644
index b41793b..0000000
--- a/src/test/ui/const-generics/issues/issue-66205.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-66205.rs:7:14
- |
-LL | fact::<{ N - 1 }>();
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-66205.rs b/src/test/ui/const-generics/issues/issue-66205.rs
deleted file mode 100644
index 14249b6..0000000
--- a/src/test/ui/const-generics/issues/issue-66205.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-#![allow(dead_code, unconditional_recursion)]
-
-fn fact<const N: usize>() {
- fact::<{ N - 1 }>();
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used in const operations
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.min.stderr b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.min.stderr
deleted file mode 100644
index e96b9e7..0000000
--- a/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.min.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: `&'static str` is forbidden as the type of a const generic parameter
- --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:8:25
- |
-LL | trait Trait<const NAME: &'static str> {
- | ^^^^^^^^^^^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs
index 2a741ba..091419f 100644
--- a/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs
+++ b/src/test/ui/const-generics/issues/issue-66596-impl-trait-for-str-const-arg.rs
@@ -1,12 +1,9 @@
-//[full] check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+// check-pass
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
trait Trait<const NAME: &'static str> {
-//[min]~^ ERROR `&'static str` is forbidden
type Assoc;
}
diff --git a/src/test/ui/const-generics/issues/issue-66906.rs b/src/test/ui/const-generics/issues/issue-66906.rs
index a871b11..a0b3f91 100644
--- a/src/test/ui/const-generics/issues/issue-66906.rs
+++ b/src/test/ui/const-generics/issues/issue-66906.rs
@@ -1,7 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
pub struct Tuple;
diff --git a/src/test/ui/const-generics/issues/issue-67185-1.rs b/src/test/ui/const-generics/issues/issue-67185-1.rs
index ed35a5f..69425b2 100644
--- a/src/test/ui/const-generics/issues/issue-67185-1.rs
+++ b/src/test/ui/const-generics/issues/issue-67185-1.rs
@@ -1,7 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait Baz {
type Quaks;
diff --git a/src/test/ui/const-generics/issues/issue-67185-2.min.stderr b/src/test/ui/const-generics/issues/issue-67185-2.min.stderr
deleted file mode 100644
index 19f419c..0000000
--- a/src/test/ui/const-generics/issues/issue-67185-2.min.stderr
+++ /dev/null
@@ -1,111 +0,0 @@
-error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:16:1
- |
-LL | / trait Foo
-LL | |
-LL | | where
-LL | | [<u8 as Baz>::Quaks; 2]: Bar,
-LL | | <u8 as Baz>::Quaks: Bar,
-LL | | {
-LL | | }
- | |_^ the trait `Bar` is not implemented for `[u16; 3]`
- |
- = help: the following implementations were found:
- <[[u16; 3]; 3] as Bar>
- <[u16; 4] as Bar>
- = help: see issue #48214
- = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
-
-error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:16:1
- |
-LL | / trait Foo
-LL | |
-LL | | where
-LL | | [<u8 as Baz>::Quaks; 2]: Bar,
-LL | | <u8 as Baz>::Quaks: Bar,
-LL | | {
-LL | | }
- | |_^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
- |
- = help: the following implementations were found:
- <[[u16; 3]; 3] as Bar>
- <[u16; 4] as Bar>
- = help: see issue #48214
- = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
-
-error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:26:6
- |
-LL | impl Foo for FooImpl {}
- | ^^^ the trait `Bar` is not implemented for `[u16; 3]`
- |
- = help: the following implementations were found:
- <[[u16; 3]; 3] as Bar>
- <[u16; 4] as Bar>
-note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:20:29
- |
-LL | trait Foo
- | --- required by a bound in this
-...
-LL | <u8 as Baz>::Quaks: Bar,
- | ^^^ required by this bound in `Foo`
-
-error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:26:6
- |
-LL | impl Foo for FooImpl {}
- | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
- |
- = help: the following implementations were found:
- <[[u16; 3]; 3] as Bar>
- <[u16; 4] as Bar>
-note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:19:34
- |
-LL | trait Foo
- | --- required by a bound in this
-...
-LL | [<u8 as Baz>::Quaks; 2]: Bar,
- | ^^^ required by this bound in `Foo`
-
-error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:30:14
- |
-LL | fn f(_: impl Foo) {}
- | ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
- |
- = help: the following implementations were found:
- <[[u16; 3]; 3] as Bar>
- <[u16; 4] as Bar>
-note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:19:34
- |
-LL | trait Foo
- | --- required by a bound in this
-...
-LL | [<u8 as Baz>::Quaks; 2]: Bar,
- | ^^^ required by this bound in `Foo`
-
-error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:30:14
- |
-LL | fn f(_: impl Foo) {}
- | ^^^ the trait `Bar` is not implemented for `[u16; 3]`
- |
- = help: the following implementations were found:
- <[[u16; 3]; 3] as Bar>
- <[u16; 4] as Bar>
-note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:20:29
- |
-LL | trait Foo
- | --- required by a bound in this
-...
-LL | <u8 as Baz>::Quaks: Bar,
- | ^^^ required by this bound in `Foo`
-
-error: aborting due to 6 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/const-generics/issues/issue-67185-2.rs b/src/test/ui/const-generics/issues/issue-67185-2.rs
index 94a713d..c1a04e2 100644
--- a/src/test/ui/const-generics/issues/issue-67185-2.rs
+++ b/src/test/ui/const-generics/issues/issue-67185-2.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
trait Baz {
type Quaks;
}
diff --git a/src/test/ui/const-generics/issues/issue-67185-2.full.stderr b/src/test/ui/const-generics/issues/issue-67185-2.stderr
similarity index 90%
rename from src/test/ui/const-generics/issues/issue-67185-2.full.stderr
rename to src/test/ui/const-generics/issues/issue-67185-2.stderr
index 19f419c..7167bea 100644
--- a/src/test/ui/const-generics/issues/issue-67185-2.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-67185-2.stderr
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:16:1
+ --> $DIR/issue-67185-2.rs:12:1
|
LL | / trait Foo
LL | |
@@ -17,7 +17,7 @@
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:16:1
+ --> $DIR/issue-67185-2.rs:12:1
|
LL | / trait Foo
LL | |
@@ -35,7 +35,7 @@
= help: add `#![feature(trivial_bounds)]` to the crate attributes to enable
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:26:6
+ --> $DIR/issue-67185-2.rs:22:6
|
LL | impl Foo for FooImpl {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
@@ -44,7 +44,7 @@
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:20:29
+ --> $DIR/issue-67185-2.rs:16:29
|
LL | trait Foo
| --- required by a bound in this
@@ -53,7 +53,7 @@
| ^^^ required by this bound in `Foo`
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:26:6
+ --> $DIR/issue-67185-2.rs:22:6
|
LL | impl Foo for FooImpl {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
@@ -62,7 +62,7 @@
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:19:34
+ --> $DIR/issue-67185-2.rs:15:34
|
LL | trait Foo
| --- required by a bound in this
@@ -71,7 +71,7 @@
| ^^^ required by this bound in `Foo`
error[E0277]: the trait bound `[[u16; 3]; 2]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:30:14
+ --> $DIR/issue-67185-2.rs:26:14
|
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[[u16; 3]; 2]`
@@ -80,7 +80,7 @@
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:19:34
+ --> $DIR/issue-67185-2.rs:15:34
|
LL | trait Foo
| --- required by a bound in this
@@ -89,7 +89,7 @@
| ^^^ required by this bound in `Foo`
error[E0277]: the trait bound `[u16; 3]: Bar` is not satisfied
- --> $DIR/issue-67185-2.rs:30:14
+ --> $DIR/issue-67185-2.rs:26:14
|
LL | fn f(_: impl Foo) {}
| ^^^ the trait `Bar` is not implemented for `[u16; 3]`
@@ -98,7 +98,7 @@
<[[u16; 3]; 3] as Bar>
<[u16; 4] as Bar>
note: required by a bound in `Foo`
- --> $DIR/issue-67185-2.rs:20:29
+ --> $DIR/issue-67185-2.rs:16:29
|
LL | trait Foo
| --- required by a bound in this
diff --git a/src/test/ui/const-generics/issues/issue-67375.full.stderr b/src/test/ui/const-generics/issues/issue-67375.full.stderr
index 0fe6527..5386ef5 100644
--- a/src/test/ui/const-generics/issues/issue-67375.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-67375.full.stderr
@@ -1,15 +1,15 @@
-warning: cannot use constants which depend on generic parameters in types
- --> $DIR/issue-67375.rs:8:12
+error: overly complex generic constant
+ --> $DIR/issue-67375.rs:7:17
|
LL | inner: [(); { [|_: &T| {}; 0].len() }],
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ | ^^^----------^^^^^^^^^^^^
+ | |
+ | unsupported rvalue
|
- = note: `#[warn(const_evaluatable_unchecked)]` on by default
- = warning: 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 #76200 <https://github.com/rust-lang/rust/issues/76200>
+ = help: consider moving this anonymous constant into a `const` function
error[E0392]: parameter `T` is never used
- --> $DIR/issue-67375.rs:6:12
+ --> $DIR/issue-67375.rs:5:12
|
LL | struct Bug<T> {
| ^ unused parameter
@@ -17,6 +17,6 @@
= help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData`
= help: if you intended `T` to be a const parameter, use `const T: usize` instead
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0392`.
diff --git a/src/test/ui/const-generics/issues/issue-67375.min.stderr b/src/test/ui/const-generics/issues/issue-67375.min.stderr
index be81fa9..5256d96 100644
--- a/src/test/ui/const-generics/issues/issue-67375.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-67375.min.stderr
@@ -1,14 +1,14 @@
error: generic parameters may not be used in const operations
- --> $DIR/issue-67375.rs:8:25
+ --> $DIR/issue-67375.rs:7:25
|
LL | inner: [(); { [|_: &T| {}; 0].len() }],
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0392]: parameter `T` is never used
- --> $DIR/issue-67375.rs:6:12
+ --> $DIR/issue-67375.rs:5:12
|
LL | struct Bug<T> {
| ^ unused parameter
diff --git a/src/test/ui/const-generics/issues/issue-67375.rs b/src/test/ui/const-generics/issues/issue-67375.rs
index a8875b8..b5b842a 100644
--- a/src/test/ui/const-generics/issues/issue-67375.rs
+++ b/src/test/ui/const-generics/issues/issue-67375.rs
@@ -1,14 +1,12 @@
// revisions: full min
-
#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
struct Bug<T> {
//~^ ERROR parameter `T` is never used
inner: [(); { [|_: &T| {}; 0].len() }],
//[min]~^ ERROR generic parameters may not be used in const operations
- //[full]~^^ WARN cannot use constants which depend on generic parameters in types
- //[full]~^^^ WARN this was previously accepted by the compiler
+ //[full]~^^ ERROR overly complex generic constant
}
fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-67739.full.stderr b/src/test/ui/const-generics/issues/issue-67739.full.stderr
index dcbe5b9..f1a426c 100644
--- a/src/test/ui/const-generics/issues/issue-67739.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-67739.full.stderr
@@ -1,10 +1,10 @@
-error: constant expression depends on a generic parameter
+error: unconstrained generic constant
--> $DIR/issue-67739.rs:11:15
|
LL | [0u8; mem::size_of::<Self::Associated>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: this may fail depending on what value the parameter takes
+ = help: try adding a `where` bound using this expression: `where [(); mem::size_of::<Self::Associated>()]:`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-67739.rs b/src/test/ui/const-generics/issues/issue-67739.rs
index e4960e5..de0eb7f 100644
--- a/src/test/ui/const-generics/issues/issue-67739.rs
+++ b/src/test/ui/const-generics/issues/issue-67739.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
use std::mem;
@@ -9,7 +9,8 @@ pub trait Trait {
fn associated_size(&self) -> usize {
[0u8; mem::size_of::<Self::Associated>()];
- //~^ ERROR constant expression depends on a generic parameter
+ //[min]~^ ERROR constant expression depends on a generic parameter
+ //[full]~^^ ERROR unconstrained generic constant
0
}
}
diff --git a/src/test/ui/const-generics/issues/issue-67945-1.full.stderr b/src/test/ui/const-generics/issues/issue-67945-1.full.stderr
index 63c50b5..1edc782 100644
--- a/src/test/ui/const-generics/issues/issue-67945-1.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-67945-1.full.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/issue-67945-1.rs:13:20
+ --> $DIR/issue-67945-1.rs:10:20
|
LL | struct Bug<S> {
| - this type parameter
@@ -13,7 +13,7 @@
found union `MaybeUninit<_>`
error[E0392]: parameter `S` is never used
- --> $DIR/issue-67945-1.rs:10:12
+ --> $DIR/issue-67945-1.rs:7:12
|
LL | struct Bug<S> {
| ^ unused parameter
diff --git a/src/test/ui/const-generics/issues/issue-67945-1.min.stderr b/src/test/ui/const-generics/issues/issue-67945-1.min.stderr
index 074d36c..eee04eb 100644
--- a/src/test/ui/const-generics/issues/issue-67945-1.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-67945-1.min.stderr
@@ -1,23 +1,23 @@
error: generic parameters may not be used in const operations
- --> $DIR/issue-67945-1.rs:13:16
+ --> $DIR/issue-67945-1.rs:10:16
|
LL | let x: S = MaybeUninit::uninit();
| ^ cannot perform const operation using `S`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/issue-67945-1.rs:16:45
+ --> $DIR/issue-67945-1.rs:13:45
|
LL | let b = &*(&x as *const _ as *const S);
| ^ cannot perform const operation using `S`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0392]: parameter `S` is never used
- --> $DIR/issue-67945-1.rs:10:12
+ --> $DIR/issue-67945-1.rs:7:12
|
LL | struct Bug<S> {
| ^ unused parameter
diff --git a/src/test/ui/const-generics/issues/issue-67945-1.rs b/src/test/ui/const-generics/issues/issue-67945-1.rs
index 84737e4..7b7e842 100644
--- a/src/test/ui/const-generics/issues/issue-67945-1.rs
+++ b/src/test/ui/const-generics/issues/issue-67945-1.rs
@@ -1,11 +1,8 @@
// revisions: full min
-
#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
-use std::marker::PhantomData;
-
-use std::mem::{self, MaybeUninit};
+use std::mem::MaybeUninit;
struct Bug<S> {
//~^ ERROR parameter `S` is never used
diff --git a/src/test/ui/const-generics/issues/issue-67945-2.full.stderr b/src/test/ui/const-generics/issues/issue-67945-2.full.stderr
index b900406..118cf44 100644
--- a/src/test/ui/const-generics/issues/issue-67945-2.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-67945-2.full.stderr
@@ -1,27 +1,17 @@
-error[E0308]: mismatched types
- --> $DIR/issue-67945-2.rs:11:20
+error: overly complex generic constant
+ --> $DIR/issue-67945-2.rs:7:13
|
-LL | struct Bug<S> {
- | - this type parameter
-...
-LL | let x: S = MaybeUninit::uninit();
- | - ^^^^^^^^^^^^^^^^^^^^^ expected type parameter `S`, found union `MaybeUninit`
- | |
- | expected due to this
+LL | A: [(); {
+ | _____________^
+LL | |
+LL | | let x: Option<Box<Self>> = None;
+ | | ---- unsupported rvalue
+LL | |
+LL | | 0
+LL | | }],
+ | |_____^
|
- = note: expected type parameter `S`
- found union `MaybeUninit<_>`
+ = help: consider moving this anonymous constant into a `const` function
-error[E0392]: parameter `S` is never used
- --> $DIR/issue-67945-2.rs:8:12
- |
-LL | struct Bug<S> {
- | ^ unused parameter
- |
- = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
- = help: if you intended `S` to be a const parameter, use `const S: usize` instead
+error: aborting due to previous error
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0308, E0392.
-For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/issues/issue-67945-2.min.stderr b/src/test/ui/const-generics/issues/issue-67945-2.min.stderr
index c06df79..6e07af1 100644
--- a/src/test/ui/const-generics/issues/issue-67945-2.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-67945-2.min.stderr
@@ -1,30 +1,8 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-67945-2.rs:11:16
+error: generic `Self` types are currently not permitted in anonymous constants
+ --> $DIR/issue-67945-2.rs:9:27
|
-LL | let x: S = MaybeUninit::uninit();
- | ^ cannot perform const operation using `S`
- |
- = note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+LL | let x: Option<Box<Self>> = None;
+ | ^^^^
-error: generic parameters may not be used in const operations
- --> $DIR/issue-67945-2.rs:14:45
- |
-LL | let b = &*(&x as *const _ as *const S);
- | ^ cannot perform const operation using `S`
- |
- = note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+error: aborting due to previous error
-error[E0392]: parameter `S` is never used
- --> $DIR/issue-67945-2.rs:8:12
- |
-LL | struct Bug<S> {
- | ^ unused parameter
- |
- = help: consider removing `S`, referring to it in a field, or using a marker such as `PhantomData`
- = help: if you intended `S` to be a const parameter, use `const S: usize` instead
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0392`.
diff --git a/src/test/ui/const-generics/issues/issue-67945-2.rs b/src/test/ui/const-generics/issues/issue-67945-2.rs
index 4a46786..cbb4e14 100644
--- a/src/test/ui/const-generics/issues/issue-67945-2.rs
+++ b/src/test/ui/const-generics/issues/issue-67945-2.rs
@@ -1,20 +1,16 @@
// revisions: full min
#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
-use std::mem::MaybeUninit;
-
-struct Bug<S> {
- //~^ ERROR parameter `S` is never used
+struct Bug<S: ?Sized> {
A: [(); {
- let x: S = MaybeUninit::uninit();
- //[min]~^ ERROR generic parameters may not be used in const operations
- //[full]~^^ ERROR mismatched types
- let b = &*(&x as *const _ as *const S);
- //[min]~^ ERROR generic parameters may not be used in const operations
+ //[full]~^ ERROR overly complex generic constant
+ let x: Option<Box<Self>> = None;
+ //[min]~^ ERROR generic `Self` types are currently not permitted in anonymous constants
0
}],
+ B: S
}
fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-67945-3.full.stderr b/src/test/ui/const-generics/issues/issue-67945-3.full.stderr
deleted file mode 100644
index fa66252..0000000
--- a/src/test/ui/const-generics/issues/issue-67945-3.full.stderr
+++ /dev/null
@@ -1,16 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-67945-3.rs:7:8
- |
-LL | A: [(); {
- | ________^
-LL | |
-LL | | let x: Option<Box<Self>> = None;
-LL | |
-LL | | 0
-LL | | }],
- | |______^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-67945-3.min.stderr b/src/test/ui/const-generics/issues/issue-67945-3.min.stderr
deleted file mode 100644
index 5c30429..0000000
--- a/src/test/ui/const-generics/issues/issue-67945-3.min.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: generic `Self` types are currently not permitted in anonymous constants
- --> $DIR/issue-67945-3.rs:9:27
- |
-LL | let x: Option<Box<Self>> = None;
- | ^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-67945-3.rs b/src/test/ui/const-generics/issues/issue-67945-3.rs
deleted file mode 100644
index 5bad61c..0000000
--- a/src/test/ui/const-generics/issues/issue-67945-3.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// revisions: full min
-
-#![cfg_attr(full, allow(incomplete_features))]
-#![cfg_attr(full, feature(const_generics))]
-
-struct Bug<S: ?Sized> {
- A: [(); {
- //[full]~^ ERROR constant expression depends on a generic parameter
- let x: Option<Box<Self>> = None;
- //[min]~^ ERROR generic `Self` types are currently not permitted in anonymous constants
- 0
- }],
- B: S
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs b/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs
index 43c3999..ad5710b 100644
--- a/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs
+++ b/src/test/ui/const-generics/issues/issue-68104-print-stack-overflow.rs
@@ -1,9 +1,7 @@
// aux-build:impl-const.rs
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
extern crate impl_const;
diff --git a/src/test/ui/const-generics/issues/issue-68366.min.stderr b/src/test/ui/const-generics/issues/issue-68366.min.stderr
index da4cbd3..9f370b0 100644
--- a/src/test/ui/const-generics/issues/issue-68366.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-68366.min.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
--> $DIR/issue-68366.rs:11:13
diff --git a/src/test/ui/const-generics/issues/issue-68366.rs b/src/test/ui/const-generics/issues/issue-68366.rs
index 37afed6..4c2741a 100644
--- a/src/test/ui/const-generics/issues/issue-68366.rs
+++ b/src/test/ui/const-generics/issues/issue-68366.rs
@@ -3,7 +3,7 @@
// type.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
struct Collatz<const N: Option<usize>>;
diff --git a/src/test/ui/const-generics/issues/issue-68596.rs b/src/test/ui/const-generics/issues/issue-68596.rs
index 0bb23be..c3c9141 100644
--- a/src/test/ui/const-generics/issues/issue-68596.rs
+++ b/src/test/ui/const-generics/issues/issue-68596.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
pub struct S(u8);
impl S {
diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr
index 4782b1d..df04c48 100644
--- a/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-68615-adt.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-68615-adt.rs b/src/test/ui/const-generics/issues/issue-68615-adt.rs
index ddea3e8..3ef1ad4 100644
--- a/src/test/ui/const-generics/issues/issue-68615-adt.rs
+++ b/src/test/ui/const-generics/issues/issue-68615-adt.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Const<const V: [usize; 0]> {}
diff --git a/src/test/ui/const-generics/issues/issue-68615-array.min.stderr b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr
index d0c190b..1b45170 100644
--- a/src/test/ui/const-generics/issues/issue-68615-array.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-68615-array.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-68615-array.rs b/src/test/ui/const-generics/issues/issue-68615-array.rs
index 56afd9b..93477be 100644
--- a/src/test/ui/const-generics/issues/issue-68615-array.rs
+++ b/src/test/ui/const-generics/issues/issue-68615-array.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Foo<const V: [usize; 0] > {}
diff --git a/src/test/ui/const-generics/issues/issue-68977.full.stderr b/src/test/ui/const-generics/issues/issue-68977.full.stderr
deleted file mode 100644
index 25dcd88..0000000
--- a/src/test/ui/const-generics/issues/issue-68977.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-68977.rs:34:44
- |
-LL | FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
- | ^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-68977.min.stderr b/src/test/ui/const-generics/issues/issue-68977.min.stderr
deleted file mode 100644
index 0b3d5b9..0000000
--- a/src/test/ui/const-generics/issues/issue-68977.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/issue-68977.rs:28:17
- |
-LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
- | ^^^^^^^^ cannot perform const operation using `INT_BITS`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `INT_BITS`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/issue-68977.rs:28:28
- |
-LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
- | ^^^^^^^^^ cannot perform const operation using `FRAC_BITS`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `FRAC_BITS`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/issues/issue-68977.rs b/src/test/ui/const-generics/issues/issue-68977.rs
deleted file mode 100644
index a0ffcc8..0000000
--- a/src/test/ui/const-generics/issues/issue-68977.rs
+++ /dev/null
@@ -1,43 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-struct PhantomU8<const X: u8>;
-
-trait FxpStorage {
- type SInt; // Add arithmetic traits as needed.
-}
-
-macro_rules! fxp_storage_impls {
- ($($($n:literal)|+ => $sint:ty),* $(,)?) => {
- $($(impl FxpStorage for PhantomU8<$n> {
- type SInt = $sint;
- })*)*
- }
-}
-
-fxp_storage_impls! {
- 1 => i8,
- 2 => i16,
- 3 | 4 => i32,
- 5 | 6 | 7 | 8 => i64,
- 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 => i128,
-}
-
-type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
- PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
- //[min]~^ ERROR generic parameters may not be used in const operations
- //[min]~| ERROR generic parameters may not be used in const operations
-
-struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
-where
- FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
- //[full]~^ ERROR constant expression depends on a generic parameter
-{
- storage: <FxpStorageHelper<INT_BITS, FRAC_BITS> as FxpStorage>::SInt,
-}
-
-fn main() {
- Fxp::<1, 15> { storage: 0i16 };
- Fxp::<2, 15> { storage: 0i32 };
-}
diff --git a/src/test/ui/const-generics/issues/issue-69654-run-pass.rs b/src/test/ui/const-generics/issues/issue-69654-run-pass.rs
index 45318ca..63d7fde 100644
--- a/src/test/ui/const-generics/issues/issue-69654-run-pass.rs
+++ b/src/test/ui/const-generics/issues/issue-69654-run-pass.rs
@@ -1,8 +1,6 @@
-#![feature(const_generics)]
-#![allow(incomplete_features, unused_braces)]
-
+// run-pass
trait Bar<T> {}
-impl<T> Bar<T> for [u8; {7}] {}
+impl<T> Bar<T> for [u8; 7] {}
struct Foo<const N: usize> {}
impl<const N: usize> Foo<N>
@@ -14,5 +12,4 @@ fn foo() {}
fn main() {
Foo::foo();
- //~^ ERROR the function or associated item
}
diff --git a/src/test/ui/const-generics/issues/issue-69654-run-pass.stderr b/src/test/ui/const-generics/issues/issue-69654-run-pass.stderr
deleted file mode 100644
index a82a606..0000000
--- a/src/test/ui/const-generics/issues/issue-69654-run-pass.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-error[E0599]: the function or associated item `foo` exists for struct `Foo<{_: usize}>`, but its trait bounds were not satisfied
- --> $DIR/issue-69654-run-pass.rs:16:10
- |
-LL | struct Foo<const N: usize> {}
- | -------------------------- function or associated item `foo` not found for this
-...
-LL | Foo::foo();
- | ^^^ function or associated item cannot be called on `Foo<{_: usize}>` due to unsatisfied trait bounds
- |
- = note: the following trait bounds were not satisfied:
- `[u8; _]: Bar<[(); _]>`
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/const-generics/issues/issue-70125-1.rs b/src/test/ui/const-generics/issues/issue-70125-1.rs
index 5c118d2..0027cd4 100644
--- a/src/test/ui/const-generics/issues/issue-70125-1.rs
+++ b/src/test/ui/const-generics/issues/issue-70125-1.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
const L: usize = 4;
diff --git a/src/test/ui/const-generics/issues/issue-70125-2.rs b/src/test/ui/const-generics/issues/issue-70125-2.rs
index f821312..cfd5e78 100644
--- a/src/test/ui/const-generics/issues/issue-70125-2.rs
+++ b/src/test/ui/const-generics/issues/issue-70125-2.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn main() {
<()>::foo();
}
diff --git a/src/test/ui/const-generics/issues/issue-70167.rs b/src/test/ui/const-generics/issues/issue-70167.rs
index 9e912b6..3961941 100644
--- a/src/test/ui/const-generics/issues/issue-70167.rs
+++ b/src/test/ui/const-generics/issues/issue-70167.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
pub trait Trait<const N: usize>: From<<Self as Trait<N>>::Item> {
type Item;
}
diff --git a/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs b/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs
index f055482..2ec37cc 100644
--- a/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs
+++ b/src/test/ui/const-generics/issues/issue-70180-1-stalled_on.rs
@@ -1,8 +1,4 @@
// build-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
pub fn works() {
let array/*: [_; _]*/ = default_array();
diff --git a/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs b/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs
index 21cefc0..95e5484 100644
--- a/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs
+++ b/src/test/ui/const-generics/issues/issue-70180-2-stalled_on.rs
@@ -1,8 +1,4 @@
// build-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
fn works() {
let array/*: [u8; _]*/ = default_byte_array();
diff --git a/src/test/ui/const-generics/issues/issue-70225.rs b/src/test/ui/const-generics/issues/issue-70225.rs
index 8f8d753..d458d7b 100644
--- a/src/test/ui/const-generics/issues/issue-70225.rs
+++ b/src/test/ui/const-generics/issues/issue-70225.rs
@@ -1,6 +1,4 @@
// check-pass
-#![feature(const_generics)]
-#![allow(incomplete_features)]
#![deny(dead_code)]
// We previously incorrectly linted `L` as unused here.
diff --git a/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs b/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs
index 189a325..a764882 100644
--- a/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs
+++ b/src/test/ui/const-generics/issues/issue-70273-assoc-fn.rs
@@ -1,7 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait T<const A: usize> {
fn f();
diff --git a/src/test/ui/const-generics/issues/issue-71169.full.stderr b/src/test/ui/const-generics/issues/issue-71169.full.stderr
index 7b1a2f9..1f5880f 100644
--- a/src/test/ui/const-generics/issues/issue-71169.full.stderr
+++ b/src/test/ui/const-generics/issues/issue-71169.full.stderr
@@ -4,14 +4,6 @@
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
| ^^^ the type must not depend on the parameter `LEN`
-error: constant expression depends on a generic parameter
- --> $DIR/issue-71169.rs:10:14
- |
-LL | foo::<4, DATA>();
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0770`.
diff --git a/src/test/ui/const-generics/issues/issue-71169.min.stderr b/src/test/ui/const-generics/issues/issue-71169.min.stderr
index 1c6e08a..87ed2d4 100644
--- a/src/test/ui/const-generics/issues/issue-71169.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-71169.min.stderr
@@ -11,7 +11,7 @@
| ^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/issues/issue-71169.rs b/src/test/ui/const-generics/issues/issue-71169.rs
index a574da4..617149a 100644
--- a/src/test/ui/const-generics/issues/issue-71169.rs
+++ b/src/test/ui/const-generics/issues/issue-71169.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
@@ -8,5 +8,4 @@
fn main() {
const DATA: [u8; 4] = *b"ABCD";
foo::<4, DATA>();
- //[full]~^ ERROR constant expression depends on
}
diff --git a/src/test/ui/const-generics/issues/issue-71202.rs b/src/test/ui/const-generics/issues/issue-71202.rs
index 78dee17..57fd72b 100644
--- a/src/test/ui/const-generics/issues/issue-71202.rs
+++ b/src/test/ui/const-generics/issues/issue-71202.rs
@@ -1,6 +1,4 @@
-// check-pass
-
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features, const_evaluatable_unchecked)]
use std::marker::PhantomData;
@@ -10,7 +8,7 @@ struct DataHolder<T> {
}
impl<T: Copy> DataHolder<T> {
- const ITEM_IS_COPY: [(); 1 - {
+ const ITEM_IS_COPY: [(); 1 - { //~ ERROR unconstrained generic constant
trait NotCopy {
const VALUE: bool = false;
}
diff --git a/src/test/ui/const-generics/issues/issue-71202.stderr b/src/test/ui/const-generics/issues/issue-71202.stderr
new file mode 100644
index 0000000..2775406
--- /dev/null
+++ b/src/test/ui/const-generics/issues/issue-71202.stderr
@@ -0,0 +1,33 @@
+error: unconstrained generic constant
+ --> $DIR/issue-71202.rs:11:5
+ |
+LL | / const ITEM_IS_COPY: [(); 1 - {
+LL | | trait NotCopy {
+LL | | const VALUE: bool = false;
+LL | | }
+... |
+LL | | <IsCopy<T>>::VALUE
+LL | | } as usize] = [];
+ | |_____________________^
+ |
+ = help: try adding a `where` bound using this expression: `where [(); 1 - {
+ trait NotCopy {
+ const VALUE: bool = false;
+ }
+
+ impl<__Type: ?Sized> NotCopy for __Type {}
+
+ struct IsCopy<__Type: ?Sized>(PhantomData<__Type>);
+
+ impl<__Type> IsCopy<__Type>
+ where
+ __Type: Sized + Copy,
+ {
+ const VALUE: bool = true;
+ }
+
+ <IsCopy<T>>::VALUE
+ } as usize]:`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/const-generics/issues/issue-71381.rs b/src/test/ui/const-generics/issues/issue-71381.rs
index f015d69..66f819d 100644
--- a/src/test/ui/const-generics/issues/issue-71381.rs
+++ b/src/test/ui/const-generics/issues/issue-71381.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Test(*const usize);
diff --git a/src/test/ui/const-generics/issues/issue-71382.rs b/src/test/ui/const-generics/issues/issue-71382.rs
index 3a56db9..4392d72 100644
--- a/src/test/ui/const-generics/issues/issue-71382.rs
+++ b/src/test/ui/const-generics/issues/issue-71382.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Test();
diff --git a/src/test/ui/const-generics/issues/issue-71611.rs b/src/test/ui/const-generics/issues/issue-71611.rs
index 6468d0b..fbb91ca 100644
--- a/src/test/ui/const-generics/issues/issue-71611.rs
+++ b/src/test/ui/const-generics/issues/issue-71611.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
fn func<A, const F: fn(inner: A)>(outer: A) {
diff --git a/src/test/ui/const-generics/issues/issue-71986.rs b/src/test/ui/const-generics/issues/issue-71986.rs
index 6bfdba5..6f0a98e 100644
--- a/src/test/ui/const-generics/issues/issue-71986.rs
+++ b/src/test/ui/const-generics/issues/issue-71986.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
pub trait Foo<const B: bool> {}
pub fn bar<T: Foo<{ true }>>() {}
diff --git a/src/test/ui/const-generics/issues/issue-72352.rs b/src/test/ui/const-generics/issues/issue-72352.rs
index 9cd95c1..2fa1d7a 100644
--- a/src/test/ui/const-generics/issues/issue-72352.rs
+++ b/src/test/ui/const-generics/issues/issue-72352.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
use std::ffi::{CStr, CString};
diff --git a/src/test/ui/const-generics/issues/issue-72787.full.stderr b/src/test/ui/const-generics/issues/issue-72787.full.stderr
deleted file mode 100644
index fbb7ae5..0000000
--- a/src/test/ui/const-generics/issues/issue-72787.full.stderr
+++ /dev/null
@@ -1,42 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-72787.rs:10:32
- |
-LL | Condition<{ LHS <= RHS }>: True
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-72787.rs:25:42
- |
-LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-72787.rs:25:42
- |
-LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-72787.rs:25:42
- |
-LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-72787.rs:25:42
- |
-LL | IsLessOrEqual<{ 8 - I }, { 8 - J }>: True,
- | ^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 5 previous errors
-
diff --git a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr b/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr
deleted file mode 100644
index 82f9b9d..0000000
--- a/src/test/ui/const-generics/issues/issue-72819-generic-in-const-eval.full.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-72819-generic-in-const-eval.rs:8:39
- |
-LL | where Assert::<{N < usize::MAX / 2}>: IsTrue,
- | ^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-73120.rs b/src/test/ui/const-generics/issues/issue-73120.rs
index c153a93..050dc9b 100644
--- a/src/test/ui/const-generics/issues/issue-73120.rs
+++ b/src/test/ui/const-generics/issues/issue-73120.rs
@@ -1,6 +1,7 @@
-// revisions: full min
// check-pass
// aux-build:const_generic_issues_lib.rs
+#![feature(generic_const_exprs)]
+#![allow(incomplete_features)]
extern crate const_generic_issues_lib as lib2;
fn unused_function(
_: <lib2::GenericType<42> as lib2::TypeFn>::Output
diff --git a/src/test/ui/const-generics/issues/issue-73260.rs b/src/test/ui/const-generics/issues/issue-73260.rs
index 04e4e9c..d762f9c 100644
--- a/src/test/ui/const-generics/issues/issue-73260.rs
+++ b/src/test/ui/const-generics/issues/issue-73260.rs
@@ -1,11 +1,10 @@
// compile-flags: -Zsave-analysis
-
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
struct Arr<const N: usize>
-where Assert::<{N < usize::MAX / 2}>: IsTrue, //~ ERROR constant expression
-{
-}
+where
+ Assert::<{N < usize::MAX / 2}>: IsTrue,
+{}
enum Assert<const CHECK: bool> {}
diff --git a/src/test/ui/const-generics/issues/issue-73260.stderr b/src/test/ui/const-generics/issues/issue-73260.stderr
index 6a912ff..f1fc50e 100644
--- a/src/test/ui/const-generics/issues/issue-73260.stderr
+++ b/src/test/ui/const-generics/issues/issue-73260.stderr
@@ -1,13 +1,5 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-73260.rs:6:39
- |
-LL | where Assert::<{N < usize::MAX / 2}>: IsTrue,
- | ^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
error[E0308]: mismatched types
- --> $DIR/issue-73260.rs:17:12
+ --> $DIR/issue-73260.rs:16:12
|
LL | let x: Arr<{usize::MAX}> = Arr {};
| ^^^^^^^^^^^^^^^^^ expected `false`, found `true`
@@ -16,7 +8,7 @@
found type `true`
error[E0308]: mismatched types
- --> $DIR/issue-73260.rs:17:32
+ --> $DIR/issue-73260.rs:16:32
|
LL | let x: Arr<{usize::MAX}> = Arr {};
| ^^^ expected `false`, found `true`
@@ -24,6 +16,6 @@
= note: expected type `false`
found type `true`
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/issues/issue-73491.min.stderr b/src/test/ui/const-generics/issues/issue-73491.min.stderr
index c8f2e0d..f2b58e5 100644
--- a/src/test/ui/const-generics/issues/issue-73491.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-73491.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-73491.rs b/src/test/ui/const-generics/issues/issue-73491.rs
index c7cb92b..f15c1f2 100644
--- a/src/test/ui/const-generics/issues/issue-73491.rs
+++ b/src/test/ui/const-generics/issues/issue-73491.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
const LEN: usize = 1024;
diff --git a/src/test/ui/const-generics/issues/issue-73508.full.stderr b/src/test/ui/const-generics/issues/issue-73508.full.stderr
deleted file mode 100644
index 81691a1..0000000
--- a/src/test/ui/const-generics/issues/issue-73508.full.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: using raw pointers as const generic parameters is forbidden
- --> $DIR/issue-73508.rs:5:33
- |
-LL | pub const fn func_name<const X: *const u32>() {}
- | ^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-73508.min.stderr b/src/test/ui/const-generics/issues/issue-73508.min.stderr
deleted file mode 100644
index 81691a1..0000000
--- a/src/test/ui/const-generics/issues/issue-73508.min.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: using raw pointers as const generic parameters is forbidden
- --> $DIR/issue-73508.rs:5:33
- |
-LL | pub const fn func_name<const X: *const u32>() {}
- | ^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-73508.rs b/src/test/ui/const-generics/issues/issue-73508.rs
deleted file mode 100644
index f02c416..0000000
--- a/src/test/ui/const-generics/issues/issue-73508.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-pub const fn func_name<const X: *const u32>() {}
-//~^ ERROR using raw pointers
-
-fn main() {}
diff --git a/src/test/ui/const-generics/issues/issue-74101.min.stderr b/src/test/ui/const-generics/issues/issue-74101.min.stderr
index a7f0ecf0..82ffb23 100644
--- a/src/test/ui/const-generics/issues/issue-74101.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-74101.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `[u8; _]` is forbidden as the type of a const generic parameter
--> $DIR/issue-74101.rs:9:21
@@ -14,7 +14,7 @@
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/issues/issue-74101.rs b/src/test/ui/const-generics/issues/issue-74101.rs
index d4fd72e..6b606b9 100644
--- a/src/test/ui/const-generics/issues/issue-74101.rs
+++ b/src/test/ui/const-generics/issues/issue-74101.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
fn test<const N: [u8; 1 + 2]>() {}
diff --git a/src/test/ui/const-generics/issues/issue-74255.min.stderr b/src/test/ui/const-generics/issues/issue-74255.min.stderr
index 62ad439..b462d84 100644
--- a/src/test/ui/const-generics/issues/issue-74255.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-74255.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-74255.rs b/src/test/ui/const-generics/issues/issue-74255.rs
index 75a876c..0e52392 100644
--- a/src/test/ui/const-generics/issues/issue-74255.rs
+++ b/src/test/ui/const-generics/issues/issue-74255.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
#[derive(PartialEq, Eq)]
diff --git a/src/test/ui/const-generics/issues/issue-74634.stderr b/src/test/ui/const-generics/issues/issue-74634.stderr
deleted file mode 100644
index 091a1ac..0000000
--- a/src/test/ui/const-generics/issues/issue-74634.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-74634.rs:15:11
- |
-LL | where (): If<{N == 0}> {
- | ^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/issues/issue-74906.rs b/src/test/ui/const-generics/issues/issue-74906.rs
index dc3c337..cc1f285 100644
--- a/src/test/ui/const-generics/issues/issue-74906.rs
+++ b/src/test/ui/const-generics/issues/issue-74906.rs
@@ -1,8 +1,6 @@
// edition:2018
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+
const SIZE: usize = 16;
diff --git a/src/test/ui/const-generics/issues/issue-74950.min.stderr b/src/test/ui/const-generics/issues/issue-74950.min.stderr
index 4e640ff..729ecc2 100644
--- a/src/test/ui/const-generics/issues/issue-74950.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-74950.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
@@ -14,7 +14,7 @@
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
@@ -23,7 +23,7 @@
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
@@ -32,7 +32,7 @@
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `Inner` is forbidden as the type of a const generic parameter
--> $DIR/issue-74950.rs:17:23
@@ -41,7 +41,7 @@
| ^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 5 previous errors
diff --git a/src/test/ui/const-generics/issues/issue-74950.rs b/src/test/ui/const-generics/issues/issue-74950.rs
index 91e5cc7..3e1ca47 100644
--- a/src/test/ui/const-generics/issues/issue-74950.rs
+++ b/src/test/ui/const-generics/issues/issue-74950.rs
@@ -1,6 +1,6 @@
// [full] build-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
diff --git a/src/test/ui/const-generics/issues/issue-75047.min.stderr b/src/test/ui/const-generics/issues/issue-75047.min.stderr
index 3c1c3ea..7798ae7 100644
--- a/src/test/ui/const-generics/issues/issue-75047.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-75047.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-75047.rs b/src/test/ui/const-generics/issues/issue-75047.rs
index 9743774..ee3dcf9 100644
--- a/src/test/ui/const-generics/issues/issue-75047.rs
+++ b/src/test/ui/const-generics/issues/issue-75047.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Bar<T>(T);
diff --git a/src/test/ui/const-generics/issues/issue-75299.rs b/src/test/ui/const-generics/issues/issue-75299.rs
index 9d3f25b..83ef09a 100644
--- a/src/test/ui/const-generics/issues/issue-75299.rs
+++ b/src/test/ui/const-generics/issues/issue-75299.rs
@@ -1,8 +1,5 @@
// compile-flags: -Zmir-opt-level=4
// run-pass
-
-#![feature(const_generics)]
-#![allow(incomplete_features)]
fn main() {
fn foo<const N: usize>() -> [u8; N] {
[0; N]
diff --git a/src/test/ui/const-generics/issues/issue-75763.rs b/src/test/ui/const-generics/issues/issue-75763.rs
index c311de0..214a04b 100644
--- a/src/test/ui/const-generics/issues/issue-75763.rs
+++ b/src/test/ui/const-generics/issues/issue-75763.rs
@@ -1,15 +1,15 @@
// ignore-test
// FIXME(const_generics): This test causes an ICE after reverting #76030.
-
+#![feature(adt_const_params)]
#![allow(incomplete_features)]
-#![feature(const_generics)]
+
struct Bug<const S: &'static str>;
fn main() {
let b: Bug::<{
unsafe {
- // FIXME(const_generics): Decide on how to deal with invalid values as const params.
+ // FIXME(adt_const_params): Decide on how to deal with invalid values as const params.
std::mem::transmute::<&[u8], &str>(&[0xC0, 0xC1, 0xF5])
}
}>;
diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr
deleted file mode 100644
index 88b8ff8..0000000
--- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/issue-76701-ty-param-in-const.rs:5:21
- |
-LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-76701-ty-param-in-const.rs:11:37
- |
-LL | fn const_param<const N: usize>() -> [u8; N + 1] {
- | ^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs
index 9948982..2e6b022 100644
--- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs
+++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs
@@ -1,16 +1,10 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used in const operations
+ //~^ ERROR generic parameters may not be used in const operations
todo!()
}
fn const_param<const N: usize>() -> [u8; N + 1] {
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used in const operations
+ //~^ ERROR generic parameters may not be used in const operations
todo!()
}
diff --git a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr
similarity index 64%
rename from src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr
rename to src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr
index 32f70fa..3b53e18 100644
--- a/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.stderr
+++ b/src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.stderr
@@ -1,20 +1,20 @@
error: generic parameters may not be used in const operations
- --> $DIR/issue-76701-ty-param-in-const.rs:5:46
+ --> $DIR/issue-76701-ty-param-in-const.rs:1:46
|
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] {
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
- --> $DIR/issue-76701-ty-param-in-const.rs:11:42
+ --> $DIR/issue-76701-ty-param-in-const.rs:6:42
|
LL | fn const_param<const N: usize>() -> [u8; N + 1] {
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/issues/issue-80062.stderr b/src/test/ui/const-generics/issues/issue-80062.stderr
index aad8907..754f18d 100644
--- a/src/test/ui/const-generics/issues/issue-80062.stderr
+++ b/src/test/ui/const-generics/issues/issue-80062.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-80375.stderr b/src/test/ui/const-generics/issues/issue-80375.stderr
index 9765a63..5409002 100644
--- a/src/test/ui/const-generics/issues/issue-80375.stderr
+++ b/src/test/ui/const-generics/issues/issue-80375.stderr
@@ -5,7 +5,7 @@
| ^^^^^ cannot perform const operation using `COUNT`
|
= help: const parameters may only be used as standalone arguments, i.e. `COUNT`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/issues/issue-87076.rs b/src/test/ui/const-generics/issues/issue-87076.rs
index 5dfda94..8a56767 100644
--- a/src/test/ui/const-generics/issues/issue-87076.rs
+++ b/src/test/ui/const-generics/issues/issue-87076.rs
@@ -1,6 +1,6 @@
// build-pass
-#![feature(const_generics)]
+#![feature(adt_const_params)]
#![allow(incomplete_features)]
#[derive(PartialEq, Eq)]
diff --git a/src/test/ui/const-generics/late-bound-vars/in_closure.rs b/src/test/ui/const-generics/late-bound-vars/in_closure.rs
index 0aaeaff..5294cc3 100644
--- a/src/test/ui/const-generics/late-bound-vars/in_closure.rs
+++ b/src/test/ui/const-generics/late-bound-vars/in_closure.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
const fn inner<'a>() -> usize where &'a (): Sized {
diff --git a/src/test/ui/const-generics/late-bound-vars/simple.rs b/src/test/ui/const-generics/late-bound-vars/simple.rs
index 2c411a3..6da5395 100644
--- a/src/test/ui/const-generics/late-bound-vars/simple.rs
+++ b/src/test/ui/const-generics/late-bound-vars/simple.rs
@@ -1,5 +1,5 @@
// run-pass
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
const fn inner<'a>() -> usize where &'a (): Sized {
diff --git a/src/test/ui/const-generics/macro_rules-braces.full.stderr b/src/test/ui/const-generics/macro_rules-braces.full.stderr
deleted file mode 100644
index b29e853..0000000
--- a/src/test/ui/const-generics/macro_rules-braces.full.stderr
+++ /dev/null
@@ -1,72 +0,0 @@
-error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/macro_rules-braces.rs:48:17
- |
-LL | let _: baz!(m::P);
- | ^^^^
- |
-help: enclose the `const` expression in braces
- |
-LL | let _: baz!({ m::P });
- | + +
-
-error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/macro_rules-braces.rs:68:17
- |
-LL | let _: baz!(10 + 7);
- | ^^^^^^
- |
-help: enclose the `const` expression in braces
- |
-LL | let _: baz!({ 10 + 7 });
- | + +
-
-error: constant expression depends on a generic parameter
- --> $DIR/macro_rules-braces.rs:15:13
- |
-LL | [u8; $x]
- | ^^^^^^^^
-...
-LL | let _: foo!({{ N }});
- | ------------- in this macro invocation
- |
- = note: this may fail depending on what value the parameter takes
- = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: constant expression depends on a generic parameter
- --> $DIR/macro_rules-braces.rs:20:13
- |
-LL | [u8; { $x }]
- | ^^^^^^^^^^^^
-...
-LL | let _: bar!({ N });
- | ----------- in this macro invocation
- |
- = note: this may fail depending on what value the parameter takes
- = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: constant expression depends on a generic parameter
- --> $DIR/macro_rules-braces.rs:25:13
- |
-LL | Foo<$x>
- | ^^^^^^^
-...
-LL | let _: baz!({{ N }});
- | ------------- in this macro invocation
- |
- = note: this may fail depending on what value the parameter takes
- = note: this error originates in the macro `baz` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: constant expression depends on a generic parameter
- --> $DIR/macro_rules-braces.rs:30:13
- |
-LL | Foo<{ $x }>
- | ^^^^^^^^^^^
-...
-LL | let _: biz!({ N });
- | ----------- in this macro invocation
- |
- = note: this may fail depending on what value the parameter takes
- = note: this error originates in the macro `biz` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to 6 previous errors
-
diff --git a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr
index 1766924..bf0d0f3 100644
--- a/src/test/ui/const-generics/min_const_generics/complex-expression.stderr
+++ b/src/test/ui/const-generics/min_const_generics/complex-expression.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-expression.rs:12:40
@@ -14,7 +14,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-expression.rs:16:17
@@ -23,7 +23,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-expression.rs:21:17
@@ -32,7 +32,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-expression.rs:25:45
@@ -41,7 +41,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-expression.rs:28:47
@@ -50,7 +50,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic parameters may not be used in const operations
--> $DIR/complex-expression.rs:32:32
@@ -59,7 +59,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
warning: cannot use constants which depend on generic parameters in types
--> $DIR/complex-expression.rs:37:17
diff --git a/src/test/ui/const-generics/min_const_generics/complex-types.stderr b/src/test/ui/const-generics/min_const_generics/complex-types.stderr
index a658a7b..4ddbadb 100644
--- a/src/test/ui/const-generics/min_const_generics/complex-types.stderr
+++ b/src/test/ui/const-generics/min_const_generics/complex-types.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:6:21
@@ -14,7 +14,7 @@
| ^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `No` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:11:21
@@ -23,7 +23,7 @@
| ^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static u8` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:14:21
@@ -32,7 +32,7 @@
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `!` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:17:21
@@ -41,7 +41,7 @@
| ^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:20:19
@@ -50,7 +50,7 @@
| ^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `()` is forbidden as the type of a const generic parameter
--> $DIR/complex-types.rs:23:20
@@ -59,7 +59,7 @@
| ^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 7 previous errors
diff --git a/src/test/ui/const-generics/min_const_generics/const_default_first.rs b/src/test/ui/const-generics/min_const_generics/const_default_first.rs
index ae82c85..bba4e68 100644
--- a/src/test/ui/const-generics/min_const_generics/const_default_first.rs
+++ b/src/test/ui/const-generics/min_const_generics/const_default_first.rs
@@ -1,5 +1,4 @@
#![crate_type = "lib"]
-#![feature(const_generics)]
#![feature(const_generics_defaults)]
#![allow(incomplete_features, dead_code)]
diff --git a/src/test/ui/const-generics/min_const_generics/const_default_first.stderr b/src/test/ui/const-generics/min_const_generics/const_default_first.stderr
index f7a2e48..1a33364 100644
--- a/src/test/ui/const-generics/min_const_generics/const_default_first.stderr
+++ b/src/test/ui/const-generics/min_const_generics/const_default_first.stderr
@@ -1,5 +1,5 @@
error: generic parameters with a default must be trailing
- --> $DIR/const_default_first.rs:6:19
+ --> $DIR/const_default_first.rs:5:19
|
LL | struct Both<const N: usize=3, T> {
| ^
diff --git a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs
index 881f8b9..6215b7d 100644
--- a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs
+++ b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.rs
@@ -1,5 +1,5 @@
// This test checks that non-static lifetimes are prohibited under `min_const_generics`. It
-// currently emits an error with `min_const_generics`. This will ICE under `const_generics`.
+// currently emits an error with `min_const_generics`.
fn test<const N: usize>() {}
diff --git a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr
index 5def54c..5f641b0 100644
--- a/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr
+++ b/src/test/ui/const-generics/min_const_generics/forbid-non-static-lifetimes.stderr
@@ -4,8 +4,8 @@
LL | test::<{ let _: &'a (); 3 },>();
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error[E0658]: a non-static lifetime is not allowed in a `const`
--> $DIR/forbid-non-static-lifetimes.rs:21:16
@@ -13,8 +13,8 @@
LL | [(); (|_: &'a u8| (), 0).1];
| ^^
|
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
- = help: add `#![feature(const_generics)]` to the crate attributes to enable
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
+ = help: add `#![feature(generic_const_exprs)]` to the crate attributes to enable
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr
index 4fdfb5f..16a7687 100644
--- a/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr
+++ b/src/test/ui/const-generics/min_const_generics/self-ty-in-const-1.stderr
@@ -5,7 +5,7 @@
| ^^^^ cannot perform const operation using `Self`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: generic `Self` types are currently not permitted in anonymous constants
--> $DIR/self-ty-in-const-1.rs:12:41
diff --git a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr
index 647ef54..f306932 100644
--- a/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr
+++ b/src/test/ui/const-generics/min_const_generics/static-reference-array-const-param.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs b/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs
index 435a63a..2adfa9a 100644
--- a/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs
+++ b/src/test/ui/const-generics/min_const_generics/type_and_const_defaults.rs
@@ -1,7 +1,6 @@
// run-pass
-#![feature(const_generics)]
#![feature(const_generics_defaults)]
-#![allow(incomplete_features, dead_code)]
+#![allow(dead_code)]
struct Both<T=u32, const N: usize=3> {
arr: [T; N]
diff --git a/src/test/ui/const-generics/mut-ref-const-param-array.rs b/src/test/ui/const-generics/mut-ref-const-param-array.rs
deleted file mode 100644
index 6a5739d..0000000
--- a/src/test/ui/const-generics/mut-ref-const-param-array.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-
-use std::ops::AddAssign;
-
-fn inc<T: AddAssign + Clone, const N: usize>(v: &mut [T; N]) -> &mut [T; N] {
- for x in v.iter_mut() {
- *x += x.clone();
- }
- v
-}
-
-fn main() {
- let mut v = [1, 2, 3];
- inc(&mut v);
- assert_eq!(v, [2, 4, 6]);
-}
diff --git a/src/test/ui/const-generics/nested-type.min.stderr b/src/test/ui/const-generics/nested-type.min.stderr
index 6defd39..4f32284 100644
--- a/src/test/ui/const-generics/nested-type.min.stderr
+++ b/src/test/ui/const-generics/nested-type.min.stderr
@@ -12,7 +12,7 @@
| |__^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> $DIR/nested-type.rs:15:5
diff --git a/src/test/ui/const-generics/nested-type.rs b/src/test/ui/const-generics/nested-type.rs
index be8ebb7..039f996 100644
--- a/src/test/ui/const-generics/nested-type.rs
+++ b/src/test/ui/const-generics/nested-type.rs
@@ -1,6 +1,6 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Foo<const N: [u8; { //[min]~ ERROR `[u8; _]` is forbidden
diff --git a/src/test/ui/const-generics/occurs-check/bind-param.rs b/src/test/ui/const-generics/occurs-check/bind-param.rs
index 68d1865..ee42440 100644
--- a/src/test/ui/const-generics/occurs-check/bind-param.rs
+++ b/src/test/ui/const-generics/occurs-check/bind-param.rs
@@ -1,5 +1,5 @@
// build-pass
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// This test does not use any "unevaluated" consts, so it should compile just fine.
diff --git a/src/test/ui/const-generics/occurs-check/unify-fixpoint.rs b/src/test/ui/const-generics/occurs-check/unify-fixpoint.rs
index 3cb9b7b..e6f8e4a 100644
--- a/src/test/ui/const-generics/occurs-check/unify-fixpoint.rs
+++ b/src/test/ui/const-generics/occurs-check/unify-fixpoint.rs
@@ -1,14 +1,8 @@
-#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
-
-// It depends on how we normalize constants and how const equate works if this
-// compiles.
-//
-// Please ping @lcnr if the output if this test changes.
+// check-pass
+#![feature(generic_const_exprs)] //~ WARN the feature `generic_const_exprs` is incomplete
fn bind<const N: usize>(value: [u8; N + 2]) -> [u8; N * 2] {
- //~^ ERROR constant expression depends on a generic parameter
- //~| ERROR constant expression depends on a generic parameter
todo!()
}
diff --git a/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr b/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr
index 671f110..f9b56bd 100644
--- a/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr
+++ b/src/test/ui/const-generics/occurs-check/unify-fixpoint.stderr
@@ -1,27 +1,11 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/unify-fixpoint.rs:1:12
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
+ --> $DIR/unify-fixpoint.rs:2:12
|
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
+LL | #![feature(generic_const_exprs)]
+ | ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
-error: constant expression depends on a generic parameter
- --> $DIR/unify-fixpoint.rs:9:32
- |
-LL | fn bind<const N: usize>(value: [u8; N + 2]) -> [u8; N * 2] {
- | ^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/unify-fixpoint.rs:9:48
- |
-LL | fn bind<const N: usize>(value: [u8; N + 2]) -> [u8; N * 2] {
- | ^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors; 1 warning emitted
+warning: 1 warning emitted
diff --git a/src/test/ui/const-generics/occurs-check/unify-n-nplusone.rs b/src/test/ui/const-generics/occurs-check/unify-n-nplusone.rs
index 552b1b2..c6324bc 100644
--- a/src/test/ui/const-generics/occurs-check/unify-n-nplusone.rs
+++ b/src/test/ui/const-generics/occurs-check/unify-n-nplusone.rs
@@ -1,10 +1,9 @@
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
-// This test would try to unify `N` with `N + 1` which must fail the occurs check.
+// This test would tries to unify `N` with `N + 1` which must fail the occurs check.
fn bind<const N: usize>(value: [u8; N]) -> [u8; N + 1] {
- //~^ ERROR constant expression depends on a generic parameter
todo!()
}
@@ -12,6 +11,6 @@
fn main() {
let mut arr = Default::default();
- arr = bind(arr);
+ arr = bind(arr); //~ ERROR mismatched types
sink(arr);
}
diff --git a/src/test/ui/const-generics/occurs-check/unify-n-nplusone.stderr b/src/test/ui/const-generics/occurs-check/unify-n-nplusone.stderr
index c1ac7ee..6b8e688 100644
--- a/src/test/ui/const-generics/occurs-check/unify-n-nplusone.stderr
+++ b/src/test/ui/const-generics/occurs-check/unify-n-nplusone.stderr
@@ -1,10 +1,9 @@
-error: constant expression depends on a generic parameter
- --> $DIR/unify-n-nplusone.rs:6:44
+error[E0308]: mismatched types
+ --> $DIR/unify-n-nplusone.rs:14:11
|
-LL | fn bind<const N: usize>(value: [u8; N]) -> [u8; N + 1] {
- | ^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
+LL | arr = bind(arr);
+ | ^^^^^^^^^ encountered a self-referencing constant
error: aborting due to previous error
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-1.rs b/src/test/ui/const-generics/occurs-check/unused-substs-1.rs
index 6ded9f1..9d12250 100644
--- a/src/test/ui/const-generics/occurs-check/unused-substs-1.rs
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-1.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
trait Bar<const M: usize> {}
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-2.rs b/src/test/ui/const-generics/occurs-check/unused-substs-2.rs
index 2d00141..9a73f1a 100644
--- a/src/test/ui/const-generics/occurs-check/unused-substs-2.rs
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-2.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-3.rs b/src/test/ui/const-generics/occurs-check/unused-substs-3.rs
index 2e306f8..0d38bd39 100644
--- a/src/test/ui/const-generics/occurs-check/unused-substs-3.rs
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-3.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// The goal is is to get an unevaluated const `ct` with a `Ty::Infer(TyVar(_#1t)` subst.
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-4.rs b/src/test/ui/const-generics/occurs-check/unused-substs-4.rs
index 9c7f5ab..03c2f54 100644
--- a/src/test/ui/const-generics/occurs-check/unused-substs-4.rs
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-4.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
fn bind<const N: usize>(value: [u8; N]) -> [u8; 3 + 4] {
diff --git a/src/test/ui/const-generics/occurs-check/unused-substs-5.rs b/src/test/ui/const-generics/occurs-check/unused-substs-5.rs
index e5d487d..383ab4c 100644
--- a/src/test/ui/const-generics/occurs-check/unused-substs-5.rs
+++ b/src/test/ui/const-generics/occurs-check/unused-substs-5.rs
@@ -1,4 +1,4 @@
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
// `N + 1` also depends on `T` here even if it doesn't use it.
diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr
index e8fd9e7..9f0b2ef 100644
--- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr
+++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.full.stderr
@@ -3,8 +3,6 @@
|
LL | struct Bar<T = [u8; N], const N: usize>(T);
| ^
- |
- = note: using type defaults and const parameters in the same parameter list is currently not permitted
error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:8:21
diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr
index 5fa6423..17defbe 100644
--- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr
+++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.min.stderr
@@ -13,7 +13,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0128]: generic parameters with a default cannot use forward declared identifiers
--> $DIR/params-in-ct-in-ty-param-lazy-norm.rs:8:21
diff --git a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs
index 76c1b84..b24a7af 100644
--- a/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs
+++ b/src/test/ui/const-generics/params-in-ct-in-ty-param-lazy-norm.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
struct Foo<T, U = [u8; std::mem::size_of::<T>()]>(T, U);
diff --git a/src/test/ui/const-generics/parent_generics_of_encoding.rs b/src/test/ui/const-generics/parent_generics_of_encoding.rs
index 31be8e7..b87e396 100644
--- a/src/test/ui/const-generics/parent_generics_of_encoding.rs
+++ b/src/test/ui/const-generics/parent_generics_of_encoding.rs
@@ -1,6 +1,6 @@
// aux-build:generics_of_parent.rs
// check-pass
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
extern crate generics_of_parent;
diff --git a/src/test/ui/const-generics/parent_generics_of_encoding_impl_trait.rs b/src/test/ui/const-generics/parent_generics_of_encoding_impl_trait.rs
index 988777b..ed81c01 100644
--- a/src/test/ui/const-generics/parent_generics_of_encoding_impl_trait.rs
+++ b/src/test/ui/const-generics/parent_generics_of_encoding_impl_trait.rs
@@ -1,5 +1,5 @@
// aux-build:generics_of_parent_impl_trait.rs
-#![feature(const_generics, const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![allow(incomplete_features)]
extern crate generics_of_parent_impl_trait;
diff --git a/src/test/ui/const-generics/raw-ptr-const-param-deref.rs b/src/test/ui/const-generics/raw-ptr-const-param-deref.rs
index ca7d33c..65595f0 100644
--- a/src/test/ui/const-generics/raw-ptr-const-param-deref.rs
+++ b/src/test/ui/const-generics/raw-ptr-const-param-deref.rs
@@ -1,7 +1,7 @@
// Checks that pointers must not be used as the type of const params.
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
const A: u32 = 3;
diff --git a/src/test/ui/const-generics/raw-ptr-const-param.rs b/src/test/ui/const-generics/raw-ptr-const-param.rs
index a04c6d5..27ef9e7 100644
--- a/src/test/ui/const-generics/raw-ptr-const-param.rs
+++ b/src/test/ui/const-generics/raw-ptr-const-param.rs
@@ -1,6 +1,6 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Const<const P: *const u32>; //~ ERROR: using raw pointers as const generic parameters
diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr b/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr
index 166a35e..fed802f 100644
--- a/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr
+++ b/src/test/ui/const-generics/slice-const-param-mismatch.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static [u8]` is forbidden as the type of a const generic parameter
--> $DIR/slice-const-param-mismatch.rs:9:28
@@ -14,7 +14,7 @@
| ^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/slice-const-param-mismatch.rs b/src/test/ui/const-generics/slice-const-param-mismatch.rs
index f020e2b..7127323 100644
--- a/src/test/ui/const-generics/slice-const-param-mismatch.rs
+++ b/src/test/ui/const-generics/slice-const-param-mismatch.rs
@@ -1,6 +1,6 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
diff --git a/src/test/ui/const-generics/slice-const-param.min.stderr b/src/test/ui/const-generics/slice-const-param.min.stderr
deleted file mode 100644
index ed39a0c..0000000
--- a/src/test/ui/const-generics/slice-const-param.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: `&'static str` is forbidden as the type of a const generic parameter
- --> $DIR/slice-const-param.rs:7:40
- |
-LL | pub fn function_with_str<const STRING: &'static str>() -> &'static str {
- | ^^^^^^^^^^^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: `&'static [u8]` is forbidden as the type of a const generic parameter
- --> $DIR/slice-const-param.rs:12:41
- |
-LL | pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
- | ^^^^^^^^^^^^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/slice-const-param.rs b/src/test/ui/const-generics/slice-const-param.rs
index bf1bf8a..05d21e0 100644
--- a/src/test/ui/const-generics/slice-const-param.rs
+++ b/src/test/ui/const-generics/slice-const-param.rs
@@ -1,16 +1,13 @@
-//[full] run-pass
-// revisions: min full
+// run-pass
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
+#![feature(adt_const_params)]
+#![allow(incomplete_features)]
pub fn function_with_str<const STRING: &'static str>() -> &'static str {
- //[min]~^ ERROR `&'static str` is forbidden
STRING
}
pub fn function_with_bytes<const BYTES: &'static [u8]>() -> &'static [u8] {
- //[min]~^ ERROR `&'static [u8]` is forbidden
BYTES
}
diff --git a/src/test/ui/const-generics/std/const-generics-range.min.stderr b/src/test/ui/const-generics/std/const-generics-range.min.stderr
index 86e6159..d4b2ad6 100644
--- a/src/test/ui/const-generics/std/const-generics-range.min.stderr
+++ b/src/test/ui/const-generics/std/const-generics-range.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter
--> $DIR/const-generics-range.rs:12:28
@@ -14,7 +14,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `RangeFull` is forbidden as the type of a const generic parameter
--> $DIR/const-generics-range.rs:17:28
@@ -23,7 +23,7 @@
| ^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter
--> $DIR/const-generics-range.rs:23:33
@@ -32,7 +32,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `RangeTo<usize>` is forbidden as the type of a const generic parameter
--> $DIR/const-generics-range.rs:28:26
@@ -41,7 +41,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
--> $DIR/const-generics-range.rs:33:35
@@ -50,7 +50,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 6 previous errors
diff --git a/src/test/ui/const-generics/std/const-generics-range.rs b/src/test/ui/const-generics/std/const-generics-range.rs
index deaab83..46c06f3 100644
--- a/src/test/ui/const-generics/std/const-generics-range.rs
+++ b/src/test/ui/const-generics/std/const-generics-range.rs
@@ -1,6 +1,6 @@
// [full] check-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
// `Range` should be usable within const generics:
diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr
deleted file mode 100644
index db99803..0000000
--- a/src/test/ui/const-generics/struct-with-invalid-const-param.full.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0573]: expected type, found const parameter `C`
- --> $DIR/struct-with-invalid-const-param.rs:7:23
- |
-LL | struct S<const C: u8>(C);
- | ^ not a type
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0573`.
diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr
deleted file mode 100644
index db99803..0000000
--- a/src/test/ui/const-generics/struct-with-invalid-const-param.min.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0573]: expected type, found const parameter `C`
- --> $DIR/struct-with-invalid-const-param.rs:7:23
- |
-LL | struct S<const C: u8>(C);
- | ^ not a type
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0573`.
diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.rs b/src/test/ui/const-generics/struct-with-invalid-const-param.rs
index 32970cc..be1c4b0 100644
--- a/src/test/ui/const-generics/struct-with-invalid-const-param.rs
+++ b/src/test/ui/const-generics/struct-with-invalid-const-param.rs
@@ -1,8 +1,4 @@
// Checks that a const param cannot be stored in a struct.
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct S<const C: u8>(C); //~ ERROR expected type, found const parameter
diff --git a/src/test/ui/const-generics/struct-with-invalid-const-param.stderr b/src/test/ui/const-generics/struct-with-invalid-const-param.stderr
index 47617c7..67f497a 100644
--- a/src/test/ui/const-generics/struct-with-invalid-const-param.stderr
+++ b/src/test/ui/const-generics/struct-with-invalid-const-param.stderr
@@ -1,18 +1,9 @@
error[E0573]: expected type, found const parameter `C`
- --> $DIR/struct-with-invalid-const-param.rs:4:23
+ --> $DIR/struct-with-invalid-const-param.rs:3:23
|
LL | struct S<const C: u8>(C);
| ^ not a type
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/struct-with-invalid-const-param.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0573`.
diff --git a/src/test/ui/const-generics/trait-const-args.rs b/src/test/ui/const-generics/trait-const-args.rs
index 30d05c7..2cdef3f 100644
--- a/src/test/ui/const-generics/trait-const-args.rs
+++ b/src/test/ui/const-generics/trait-const-args.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct Const<const N: usize>;
trait Foo<const N: usize> {}
diff --git a/src/test/ui/const-generics/transmute-const-param-static-reference.min.stderr b/src/test/ui/const-generics/transmute-const-param-static-reference.min.stderr
index f735be9..039c427 100644
--- a/src/test/ui/const-generics/transmute-const-param-static-reference.min.stderr
+++ b/src/test/ui/const-generics/transmute-const-param-static-reference.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to previous error
diff --git a/src/test/ui/const-generics/transmute-const-param-static-reference.rs b/src/test/ui/const-generics/transmute-const-param-static-reference.rs
index 3147d61..6b443c8 100644
--- a/src/test/ui/const-generics/transmute-const-param-static-reference.rs
+++ b/src/test/ui/const-generics/transmute-const-param-static-reference.rs
@@ -1,7 +1,7 @@
// revisions: full min
//[full] check-pass
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Const<const P: &'static ()>;
diff --git a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs
index bf855d4..926e807 100644
--- a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs
+++ b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs
@@ -1,7 +1,7 @@
// run-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
use std::mem::MaybeUninit;
diff --git a/src/test/ui/const-generics/type-after-const-ok.rs b/src/test/ui/const-generics/type-after-const-ok.rs
index 920c067..68d1940 100644
--- a/src/test/ui/const-generics/type-after-const-ok.rs
+++ b/src/test/ui/const-generics/type-after-const-ok.rs
@@ -1,7 +1,7 @@
// [full] run-pass
// revisions: full min
// Verifies that having generic parameters after constants is permitted
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(const_generics_defaults))]
#![cfg_attr(full, allow(incomplete_features))]
#[allow(dead_code)]
diff --git a/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs b/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs
index cd9c3ae..5dfcbba 100644
--- a/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs
+++ b/src/test/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs
@@ -1,6 +1,3 @@
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
pub struct Struct<const N: usize>(());
impl<const N: usize> Struct<N> {
diff --git a/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs b/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs
index 4997d49..e844148 100644
--- a/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs
+++ b/src/test/ui/const-generics/type-dependent/const-arg-in-const-arg.rs
@@ -1,6 +1,6 @@
// run-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![allow(incomplete_features)]
struct Foo;
diff --git a/src/test/ui/const-generics/type-dependent/issue-61936.rs b/src/test/ui/const-generics/type-dependent/issue-61936.rs
index 417fe25..7216b25 100644
--- a/src/test/ui/const-generics/type-dependent/issue-61936.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-61936.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait SliceExt<T: Clone> {
fn array_windows_example<'a, const N: usize>(&'a self) -> ArrayWindowsExample<'a, T, N>;
diff --git a/src/test/ui/const-generics/type-dependent/issue-63695.rs b/src/test/ui/const-generics/type-dependent/issue-63695.rs
index 2ece25b..08b6d4b 100644
--- a/src/test/ui/const-generics/type-dependent/issue-63695.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-63695.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait T {
fn test<const A: i32>(&self) -> i32 { A }
diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs
index 4a2c303..27dd51d 100644
--- a/src/test/ui/const-generics/type-dependent/issue-67144-1.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-67144-1.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct X;
impl X {
diff --git a/src/test/ui/const-generics/type-dependent/issue-67144-2.rs b/src/test/ui/const-generics/type-dependent/issue-67144-2.rs
index a1163fc..b26f551 100644
--- a/src/test/ui/const-generics/type-dependent/issue-67144-2.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-67144-2.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct A<const N: usize>;
struct X;
diff --git a/src/test/ui/const-generics/type-dependent/issue-69816.rs b/src/test/ui/const-generics/type-dependent/issue-69816.rs
index 75ddd83..cbb6b39 100644
--- a/src/test/ui/const-generics/type-dependent/issue-69816.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-69816.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
trait IterExt: Sized + Iterator {
fn default_for_size<const N: usize>(self) -> [Self::Item; N]
where
diff --git a/src/test/ui/const-generics/type-dependent/issue-70217.rs b/src/test/ui/const-generics/type-dependent/issue-70217.rs
index b3585d5..933ca02 100644
--- a/src/test/ui/const-generics/type-dependent/issue-70217.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-70217.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct Struct<const N: usize>;
diff --git a/src/test/ui/const-generics/type-dependent/issue-70507.rs b/src/test/ui/const-generics/type-dependent/issue-70507.rs
index df7c277..c72d9fb 100644
--- a/src/test/ui/const-generics/type-dependent/issue-70507.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-70507.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
trait ConstChunksExactTrait<T> {
fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'_, T, {N}>;
diff --git a/src/test/ui/const-generics/type-dependent/issue-70586.rs b/src/test/ui/const-generics/type-dependent/issue-70586.rs
index 5fb571f..346ac4b 100644
--- a/src/test/ui/const-generics/type-dependent/issue-70586.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-70586.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
use std::marker::PhantomData;
// This namespace is necessary for the ICE to trigger
diff --git a/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr b/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr
index f3516d1..b8fbb39 100644
--- a/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr
+++ b/src/test/ui/const-generics/type-dependent/issue-71348.min.stderr
@@ -5,7 +5,7 @@
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: `&'static str` is forbidden as the type of a const generic parameter
--> $DIR/issue-71348.rs:18:25
@@ -14,7 +14,7 @@
| ^^^^^^^^^^^^
|
= note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/const-generics/type-dependent/issue-71348.rs b/src/test/ui/const-generics/type-dependent/issue-71348.rs
index 33735ef..2ef2f06 100644
--- a/src/test/ui/const-generics/type-dependent/issue-71348.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-71348.rs
@@ -1,6 +1,6 @@
// [full] run-pass
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(adt_const_params))]
#![cfg_attr(full, allow(incomplete_features))]
struct Foo {
diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr
deleted file mode 100644
index 8ac9bab..0000000
--- a/src/test/ui/const-generics/type-dependent/issue-71382.min.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: using function pointers as const generic parameters is forbidden
- --> $DIR/issue-71382.rs:16:23
- |
-LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
- | ^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.rs b/src/test/ui/const-generics/type-dependent/issue-71382.rs
index b367761..1c4073e 100644
--- a/src/test/ui/const-generics/type-dependent/issue-71382.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-71382.rs
@@ -1,7 +1,3 @@
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct Test;
fn pass() -> u8 {
diff --git a/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr b/src/test/ui/const-generics/type-dependent/issue-71382.stderr
similarity index 86%
rename from src/test/ui/const-generics/type-dependent/issue-71382.full.stderr
rename to src/test/ui/const-generics/type-dependent/issue-71382.stderr
index 8ac9bab..ad522ae 100644
--- a/src/test/ui/const-generics/type-dependent/issue-71382.full.stderr
+++ b/src/test/ui/const-generics/type-dependent/issue-71382.stderr
@@ -1,5 +1,5 @@
error: using function pointers as const generic parameters is forbidden
- --> $DIR/issue-71382.rs:16:23
+ --> $DIR/issue-71382.rs:12:23
|
LL | fn test<const FN: fn() -> u8>(&self) -> u8 {
| ^^^^^^^^^^
diff --git a/src/test/ui/const-generics/type-dependent/issue-71805.rs b/src/test/ui/const-generics/type-dependent/issue-71805.rs
index 3701e14..060b899 100644
--- a/src/test/ui/const-generics/type-dependent/issue-71805.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-71805.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
use std::mem::MaybeUninit;
trait CollectSlice<'a>: Iterator {
diff --git a/src/test/ui/const-generics/type-dependent/issue-73730.rs b/src/test/ui/const-generics/type-dependent/issue-73730.rs
index 5d7dcb9..5e1b8c63 100644
--- a/src/test/ui/const-generics/type-dependent/issue-73730.rs
+++ b/src/test/ui/const-generics/type-dependent/issue-73730.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
trait Foo<'a, A>: Iterator<Item=A> {
fn bar<const N: usize>(&mut self) -> *const [A; N];
}
diff --git a/src/test/ui/const-generics/type-dependent/non-local.rs b/src/test/ui/const-generics/type-dependent/non-local.rs
index 9e4afba..b755de3 100644
--- a/src/test/ui/const-generics/type-dependent/non-local.rs
+++ b/src/test/ui/const-generics/type-dependent/non-local.rs
@@ -1,9 +1,5 @@
// aux-build:type_dependent_lib.rs
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
extern crate type_dependent_lib;
use type_dependent_lib::*;
diff --git a/src/test/ui/const-generics/type-dependent/qpath.rs b/src/test/ui/const-generics/type-dependent/qpath.rs
index b61e970..2d678d0 100644
--- a/src/test/ui/const-generics/type-dependent/qpath.rs
+++ b/src/test/ui/const-generics/type-dependent/qpath.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct A;
impl A {
fn foo<const N: usize>() -> usize { N + 1 }
diff --git a/src/test/ui/const-generics/type-dependent/simple.rs b/src/test/ui/const-generics/type-dependent/simple.rs
index a4776a4..1b13133 100644
--- a/src/test/ui/const-generics/type-dependent/simple.rs
+++ b/src/test/ui/const-generics/type-dependent/simple.rs
@@ -1,8 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct R;
impl R {
diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr
index a0a1455..02108d8 100644
--- a/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr
+++ b/src/test/ui/const-generics/type-dependent/type-mismatch.full.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/type-mismatch.rs:11:27
+ --> $DIR/type-mismatch.rs:8:27
|
LL | assert_eq!(R.method::<1u16>(), 1);
| ^^^^ expected `u8`, found `u16`
diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr b/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr
index a0a1455..02108d8 100644
--- a/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr
+++ b/src/test/ui/const-generics/type-dependent/type-mismatch.min.stderr
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
- --> $DIR/type-mismatch.rs:11:27
+ --> $DIR/type-mismatch.rs:8:27
|
LL | assert_eq!(R.method::<1u16>(), 1);
| ^^^^ expected `u8`, found `u16`
diff --git a/src/test/ui/const-generics/type-dependent/type-mismatch.rs b/src/test/ui/const-generics/type-dependent/type-mismatch.rs
index 7fba1af..3335ab8 100644
--- a/src/test/ui/const-generics/type-dependent/type-mismatch.rs
+++ b/src/test/ui/const-generics/type-dependent/type-mismatch.rs
@@ -1,7 +1,4 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
struct R;
impl R {
diff --git a/src/test/ui/const-generics/type_of_anon_const.rs b/src/test/ui/const-generics/type_of_anon_const.rs
index 9a2e9f0..fb0d688 100644
--- a/src/test/ui/const-generics/type_of_anon_const.rs
+++ b/src/test/ui/const-generics/type_of_anon_const.rs
@@ -1,9 +1,4 @@
// run-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
trait T<const A: usize> {
fn l<const N: bool>() -> usize;
fn r<const N: bool>() -> bool;
diff --git a/src/test/ui/const-generics/types-mismatch-const-args.full.stderr b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr
index 480ecdb..565c9ba 100644
--- a/src/test/ui/const-generics/types-mismatch-const-args.full.stderr
+++ b/src/test/ui/const-generics/types-mismatch-const-args.full.stderr
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/types-mismatch-const-args.rs:14:41
|
-LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32`
+LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {2u32 + 2u32}, {3u32}> { data: PhantomData };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32`
|
= note: expected type `2_u32`
found type `4_u32`
diff --git a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr
index c19c8db..ec9221d 100644
--- a/src/test/ui/const-generics/types-mismatch-const-args.min.stderr
+++ b/src/test/ui/const-generics/types-mismatch-const-args.min.stderr
@@ -1,8 +1,8 @@
error[E0308]: mismatched types
--> $DIR/types-mismatch-const-args.rs:14:41
|
-LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
- | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32`
+LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {2u32 + 2u32}, {3u32}> { data: PhantomData };
+ | -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2_u32`, found `4_u32`
| |
| expected due to this
|
diff --git a/src/test/ui/const-generics/types-mismatch-const-args.rs b/src/test/ui/const-generics/types-mismatch-const-args.rs
index 14cef08..c2092c4 100644
--- a/src/test/ui/const-generics/types-mismatch-const-args.rs
+++ b/src/test/ui/const-generics/types-mismatch-const-args.rs
@@ -1,5 +1,5 @@
// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
+#![cfg_attr(full, feature(generic_const_exprs))]
#![cfg_attr(full, allow(incomplete_features))]
// tests the diagnostic output of type mismatches for types that have const generics arguments.
@@ -11,7 +11,7 @@ struct A<'a, T, const X: u32, const Y: u32> {
}
fn a<'a, 'b>() {
- let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
+ let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {2u32 + 2u32}, {3u32}> { data: PhantomData };
//~^ ERROR mismatched types
let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
//~^ ERROR mismatched types
diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs
index 9592f26..c7270e8 100644
--- a/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs
+++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-1.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
use std::fmt;
diff --git a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs
index 4bab2bb..191caa7 100644
--- a/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs
+++ b/src/test/ui/const-generics/uninferred-consts-during-codegen-2.rs
@@ -1,7 +1,4 @@
// run-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
use std::fmt;
diff --git a/src/test/ui/const-generics/unknown_adt.min.stderr b/src/test/ui/const-generics/unknown_adt.min.stderr
deleted file mode 100644
index b8b2e90..0000000
--- a/src/test/ui/const-generics/unknown_adt.min.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0412]: cannot find type `UnknownStruct` in this scope
- --> $DIR/unknown_adt.rs:7:12
- |
-LL | let _: UnknownStruct<7>;
- | ^^^^^^^^^^^^^ not found in this scope
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0412`.
diff --git a/src/test/ui/const-generics/unknown_adt.rs b/src/test/ui/const-generics/unknown_adt.rs
index 977f90a..8cdd28a 100644
--- a/src/test/ui/const-generics/unknown_adt.rs
+++ b/src/test/ui/const-generics/unknown_adt.rs
@@ -1,8 +1,3 @@
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
fn main() {
let _: UnknownStruct<7>;
//~^ ERROR cannot find type `UnknownStruct`
diff --git a/src/test/ui/const-generics/unknown_adt.full.stderr b/src/test/ui/const-generics/unknown_adt.stderr
similarity index 89%
rename from src/test/ui/const-generics/unknown_adt.full.stderr
rename to src/test/ui/const-generics/unknown_adt.stderr
index b8b2e90..0f462dd 100644
--- a/src/test/ui/const-generics/unknown_adt.full.stderr
+++ b/src/test/ui/const-generics/unknown_adt.stderr
@@ -1,5 +1,5 @@
error[E0412]: cannot find type `UnknownStruct` in this scope
- --> $DIR/unknown_adt.rs:7:12
+ --> $DIR/unknown_adt.rs:2:12
|
LL | let _: UnknownStruct<7>;
| ^^^^^^^^^^^^^ not found in this scope
diff --git a/src/test/ui/const-generics/unused-const-param.rs b/src/test/ui/const-generics/unused-const-param.rs
index 2918e39..c7f74cf 100644
--- a/src/test/ui/const-generics/unused-const-param.rs
+++ b/src/test/ui/const-generics/unused-const-param.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
struct A<const N: usize>; // ok
diff --git a/src/test/ui/const-generics/unused_braces.fixed b/src/test/ui/const-generics/unused_braces.fixed
index 836f26e..d080c21 100644
--- a/src/test/ui/const-generics/unused_braces.fixed
+++ b/src/test/ui/const-generics/unused_braces.fixed
@@ -1,11 +1,7 @@
// check-pass
// run-rustfix
-
-#![allow(incomplete_features)]
#![warn(unused_braces)]
-#![feature(const_generics)]
-
struct A<const N: usize>;
fn main() {
diff --git a/src/test/ui/const-generics/unused_braces.min.stderr b/src/test/ui/const-generics/unused_braces.min.stderr
deleted file mode 100644
index 8899139..0000000
--- a/src/test/ui/const-generics/unused_braces.min.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-warning: unnecessary braces around const expression
- --> $DIR/unused_braces.rs:14:14
- |
-LL | let _: A<{ 7 }>;
- | ^^^^^ help: remove these braces
- |
-note: the lint level is defined here
- --> $DIR/unused_braces.rs:7:9
- |
-LL | #![warn(unused_braces)]
- | ^^^^^^^^^^^^^
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/const-generics/unused_braces.rs b/src/test/ui/const-generics/unused_braces.rs
index 0348bba..47f0f8c 100644
--- a/src/test/ui/const-generics/unused_braces.rs
+++ b/src/test/ui/const-generics/unused_braces.rs
@@ -1,12 +1,7 @@
// check-pass
// run-rustfix
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
#![warn(unused_braces)]
-
struct A<const N: usize>;
fn main() {
diff --git a/src/test/ui/const-generics/unused_braces.full.stderr b/src/test/ui/const-generics/unused_braces.stderr
similarity index 79%
rename from src/test/ui/const-generics/unused_braces.full.stderr
rename to src/test/ui/const-generics/unused_braces.stderr
index 8899139..5e1bace 100644
--- a/src/test/ui/const-generics/unused_braces.full.stderr
+++ b/src/test/ui/const-generics/unused_braces.stderr
@@ -1,11 +1,11 @@
warning: unnecessary braces around const expression
- --> $DIR/unused_braces.rs:14:14
+ --> $DIR/unused_braces.rs:9:14
|
LL | let _: A<{ 7 }>;
| ^^^^^ help: remove these braces
|
note: the lint level is defined here
- --> $DIR/unused_braces.rs:7:9
+ --> $DIR/unused_braces.rs:3:9
|
LL | #![warn(unused_braces)]
| ^^^^^^^^^^^^^
diff --git a/src/test/ui/const-generics/wf-misc.full.stderr b/src/test/ui/const-generics/wf-misc.full.stderr
deleted file mode 100644
index dfb593a..0000000
--- a/src/test/ui/const-generics/wf-misc.full.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error: constant expression depends on a generic parameter
- --> $DIR/wf-misc.rs:8:12
- |
-LL | let _: [u8; N + 1];
- | ^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: constant expression depends on a generic parameter
- --> $DIR/wf-misc.rs:16:12
- |
-LL | let _: Const::<{N + 1}>;
- | ^^^^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/wf-misc.min.stderr b/src/test/ui/const-generics/wf-misc.min.stderr
deleted file mode 100644
index 9967a22..0000000
--- a/src/test/ui/const-generics/wf-misc.min.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/wf-misc.rs:8:17
- |
-LL | let _: [u8; N + 1];
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: generic parameters may not be used in const operations
- --> $DIR/wf-misc.rs:16:21
- |
-LL | let _: Const::<{N + 1}>;
- | ^ cannot perform const operation using `N`
- |
- = help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/const-generics/wf-misc.rs b/src/test/ui/const-generics/wf-misc.rs
deleted file mode 100644
index 8a5b6dd..0000000
--- a/src/test/ui/const-generics/wf-misc.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Tests miscellaneous well-formedness examples.
-// revisions: full min
-
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
-pub fn arr_len<const N: usize>() {
- let _: [u8; N + 1];
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used in const operations
-}
-
-struct Const<const N: usize>;
-
-pub fn func_call<const N: usize>() {
- let _: Const::<{N + 1}>;
- //[full]~^ ERROR constant expression depends on a generic parameter
- //[min]~^^ ERROR generic parameters may not be used in const operations
-}
-
-fn main() {}
diff --git a/src/test/ui/const-generics/where-clauses.rs b/src/test/ui/const-generics/where-clauses.rs
index dc09cad..aa3ca1c 100644
--- a/src/test/ui/const-generics/where-clauses.rs
+++ b/src/test/ui/const-generics/where-clauses.rs
@@ -1,8 +1,4 @@
// check-pass
-// revisions: full min
-#![cfg_attr(full, feature(const_generics))]
-#![cfg_attr(full, allow(incomplete_features))]
-
trait Bar<const N: usize> { fn bar() {} }
trait Foo<const N: usize>: Bar<N> {}
diff --git a/src/test/ui/consts/const-eval/issue-49296.rs b/src/test/ui/consts/const-eval/issue-49296.rs
index bb8113e..80f6bbe 100644
--- a/src/test/ui/consts/const-eval/issue-49296.rs
+++ b/src/test/ui/consts/const-eval/issue-49296.rs
@@ -1,22 +1,13 @@
// issue-49296: Unsafe shenigans in constants can result in missing errors
#![feature(const_fn_trait_bound)]
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-const unsafe fn transmute<T: ?const Copy, U: ?const Copy>(t: T) -> U {
- #[repr(C)]
- union Transmute<T: Copy, U: Copy> {
- from: T,
- to: U,
- }
-
- Transmute { from: t }.to
-}
+use std::mem::transmute;
const fn wat(x: u64) -> &'static u64 {
unsafe { transmute(&x) }
}
+
const X: u64 = *wat(42);
//~^ ERROR evaluation of constant value failed
diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr
index 28fdcb7..bc3074b 100644
--- a/src/test/ui/consts/const-eval/issue-49296.stderr
+++ b/src/test/ui/consts/const-eval/issue-49296.stderr
@@ -1,5 +1,5 @@
error[E0080]: evaluation of constant value failed
- --> $DIR/issue-49296.rs:20:16
+ --> $DIR/issue-49296.rs:11:16
|
LL | const X: u64 = *wat(42);
| ^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed
diff --git a/src/test/ui/consts/const-needs_drop-monomorphic.rs b/src/test/ui/consts/const-needs_drop-monomorphic.rs
index 9f66e3c..7402c68 100644
--- a/src/test/ui/consts/const-needs_drop-monomorphic.rs
+++ b/src/test/ui/consts/const-needs_drop-monomorphic.rs
@@ -1,5 +1,5 @@
// Check that evaluation of needs_drop<T> fails when T is not monomorphic.
-#![feature(const_generics)]
+#![feature(generic_const_exprs)]
#![allow(const_evaluatable_unchecked)]
#![allow(incomplete_features)]
@@ -10,7 +10,7 @@ fn assert() {}
fn f<T>() {
Bool::<{ std::mem::needs_drop::<T>() }>::assert();
//~^ ERROR no function or associated item named `assert` found
- //~| ERROR constant expression depends on a generic parameter
+ //~| ERROR unconstrained generic constant
}
fn main() {
f::<u32>();
diff --git a/src/test/ui/consts/const-needs_drop-monomorphic.stderr b/src/test/ui/consts/const-needs_drop-monomorphic.stderr
index 0770d06..6e56d20 100644
--- a/src/test/ui/consts/const-needs_drop-monomorphic.stderr
+++ b/src/test/ui/consts/const-needs_drop-monomorphic.stderr
@@ -7,13 +7,13 @@
LL | Bool::<{ std::mem::needs_drop::<T>() }>::assert();
| ^^^^^^ function or associated item cannot be called on `Bool<{ std::mem::needs_drop::<T>() }>` due to unsatisfied trait bounds
-error: constant expression depends on a generic parameter
+error: unconstrained generic constant
--> $DIR/const-needs_drop-monomorphic.rs:11:5
|
LL | Bool::<{ std::mem::needs_drop::<T>() }>::assert();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: this may fail depending on what value the parameter takes
+ = help: try adding a `where` bound using this expression: `where [(); { std::mem::needs_drop::<T>() }]:`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr
index 58c4587..fc842fa 100644
--- a/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr
+++ b/src/test/ui/cycle-trait/cycle-trait-default-type-trait.stderr
@@ -4,7 +4,7 @@
LL | trait Foo<X = Box<dyn Foo>> {
| ^^^
|
- = note: ...which again requires computing type of `Foo::X`, completing the cycle
+ = note: ...which immediately requires computing type of `Foo::X` again
note: cycle used when collecting item types in top-level module
--> $DIR/cycle-trait-default-type-trait.rs:4:1
|
@@ -17,7 +17,7 @@
LL | trait Foo<X = Box<dyn Foo>> {
| ^^^
|
- = note: ...which again requires computing type of `Foo::X`, completing the cycle
+ = note: ...which immediately requires computing type of `Foo::X` again
note: cycle used when collecting item types in top-level module
--> $DIR/cycle-trait-default-type-trait.rs:4:1
|
diff --git a/src/test/ui/did_you_mean/issue-31424.stderr b/src/test/ui/did_you_mean/issue-31424.stderr
index 838e810..8861738 100644
--- a/src/test/ui/did_you_mean/issue-31424.stderr
+++ b/src/test/ui/did_you_mean/issue-31424.stderr
@@ -2,10 +2,18 @@
--> $DIR/issue-31424.rs:7:9
|
LL | (&mut self).bar();
+ | ^^^^^^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/issue-31424.rs:6:12
+ |
+LL | fn foo(&mut self) {
+ | ^^^^^^^^^
+help: try removing `&mut` here
+ --> $DIR/issue-31424.rs:7:9
+ |
+LL | (&mut self).bar();
| ^^^^^^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
warning: function cannot return without recursing
--> $DIR/issue-31424.rs:13:5
@@ -23,10 +31,18 @@
--> $DIR/issue-31424.rs:16:9
|
LL | (&mut self).bar();
+ | ^^^^^^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/issue-31424.rs:13:18
+ |
+LL | fn bar(self: &mut Self) {
+ | ^^^^^^^^^
+help: try removing `&mut` here
+ --> $DIR/issue-31424.rs:16:9
+ |
+LL | (&mut self).bar();
| ^^^^^^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
error: aborting due to 2 previous errors; 1 warning emitted
diff --git a/src/test/ui/did_you_mean/issue-34126.stderr b/src/test/ui/did_you_mean/issue-34126.stderr
index 669684f..6661721 100644
--- a/src/test/ui/did_you_mean/issue-34126.stderr
+++ b/src/test/ui/did_you_mean/issue-34126.stderr
@@ -2,10 +2,18 @@
--> $DIR/issue-34126.rs:6:18
|
LL | self.run(&mut self);
- | ^^^^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
+ | ^^^^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/issue-34126.rs:5:14
+ |
+LL | fn start(&mut self) {
+ | ^^^^^^^^^
+help: try removing `&mut` here
+ |
+LL - self.run(&mut self);
+LL + self.run(self);
+ |
error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable
--> $DIR/issue-34126.rs:6:18
diff --git a/src/test/ui/did_you_mean/issue-40396.stderr b/src/test/ui/did_you_mean/issue-40396.stderr
index f4bc5ae..d293843 100644
--- a/src/test/ui/did_you_mean/issue-40396.stderr
+++ b/src/test/ui/did_you_mean/issue-40396.stderr
@@ -31,11 +31,11 @@
LL | (0..13).collect::<Vec<i32>();
| ++
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
--> $DIR/issue-40396.rs:11:43
|
LL | let x = std::collections::HashMap<i128, i128>::new();
- | ^ expected one of 7 possible tokens
+ | ^ expected one of 8 possible tokens
|
help: use `::<...>` instead of `<...>` to specify type or const arguments
|
diff --git a/src/test/ui/dyn-keyword/dyn-angle-brackets.fixed b/src/test/ui/dyn-keyword/dyn-angle-brackets.fixed
new file mode 100644
index 0000000..25caa6a
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-angle-brackets.fixed
@@ -0,0 +1,23 @@
+// See https://github.com/rust-lang/rust/issues/88508
+// run-rustfix
+// edition:2018
+#![deny(bare_trait_objects)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+use std::fmt;
+
+#[derive(Debug)]
+pub struct Foo;
+
+impl fmt::Display for Foo {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ <dyn fmt::Debug>::fmt(self, f)
+ //~^ ERROR trait objects without an explicit `dyn` are deprecated
+ //~| WARNING this is accepted in the current edition
+ //~| ERROR trait objects without an explicit `dyn` are deprecated
+ //~| WARNING this is accepted in the current edition
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/dyn-keyword/dyn-angle-brackets.rs b/src/test/ui/dyn-keyword/dyn-angle-brackets.rs
new file mode 100644
index 0000000..cf72da2
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-angle-brackets.rs
@@ -0,0 +1,23 @@
+// See https://github.com/rust-lang/rust/issues/88508
+// run-rustfix
+// edition:2018
+#![deny(bare_trait_objects)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+use std::fmt;
+
+#[derive(Debug)]
+pub struct Foo;
+
+impl fmt::Display for Foo {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ <fmt::Debug>::fmt(self, f)
+ //~^ ERROR trait objects without an explicit `dyn` are deprecated
+ //~| WARNING this is accepted in the current edition
+ //~| ERROR trait objects without an explicit `dyn` are deprecated
+ //~| WARNING this is accepted in the current edition
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr b/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr
new file mode 100644
index 0000000..ef0f5b7
--- /dev/null
+++ b/src/test/ui/dyn-keyword/dyn-angle-brackets.stderr
@@ -0,0 +1,25 @@
+error: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/dyn-angle-brackets.rs:15:10
+ |
+LL | <fmt::Debug>::fmt(self, f)
+ | ^^^^^^^^^^ help: use `dyn`: `dyn fmt::Debug`
+ |
+note: the lint level is defined here
+ --> $DIR/dyn-angle-brackets.rs:4:9
+ |
+LL | #![deny(bare_trait_objects)]
+ | ^^^^^^^^^^^^^^^^^^
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+
+error: trait objects without an explicit `dyn` are deprecated
+ --> $DIR/dyn-angle-brackets.rs:15:10
+ |
+LL | <fmt::Debug>::fmt(self, f)
+ | ^^^^^^^^^^ help: use `dyn`: `dyn fmt::Debug`
+ |
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/editions/async-block-2015.rs b/src/test/ui/editions/async-block-2015.rs
index 92eae9e..24112c9 100644
--- a/src/test/ui/editions/async-block-2015.rs
+++ b/src/test/ui/editions/async-block-2015.rs
@@ -1,7 +1,7 @@
async fn foo() {
//~^ ERROR `async fn` is not permitted in Rust 2015
//~| NOTE to use `async fn`, switch to Rust 2018 or later
-//~| HELP set `edition = "2018"` in `Cargo.toml`
+//~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
let x = async {};
@@ -11,7 +11,7 @@
let x = 42;
//~^ ERROR expected identifier, found keyword `let`
//~| NOTE expected identifier, found keyword
- //~| HELP set `edition = "2018"` in `Cargo.toml`
+ //~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
42
};
@@ -19,7 +19,7 @@
42
//~^ ERROR expected identifier, found `42`
//~| NOTE expected identifier
- //~| HELP set `edition = "2018"` in `Cargo.toml`
+ //~| HELP set `edition = "2021"` in `Cargo.toml`
//~| NOTE for more on editions, read https://doc.rust-lang.org/edition-guide
};
y.await;
diff --git a/src/test/ui/editions/async-block-2015.stderr b/src/test/ui/editions/async-block-2015.stderr
index e42747c..da8412d 100644
--- a/src/test/ui/editions/async-block-2015.stderr
+++ b/src/test/ui/editions/async-block-2015.stderr
@@ -4,7 +4,7 @@
LL | async fn foo() {
| ^^^^^ to use `async fn`, switch to Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error: expected identifier, found keyword `let`
@@ -15,7 +15,7 @@
LL | let x = 42;
| ^^^ expected identifier, found keyword
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error: expected identifier, found `42`
@@ -26,7 +26,7 @@
LL | 42
| ^^ expected identifier
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0422]: cannot find struct, variant or union type `async` in this scope
diff --git a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr
index 4d57765..e4e1046 100644
--- a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr
+++ b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice-2.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr
index f89be63..7ea8a39 100644
--- a/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr
+++ b/src/test/ui/enum-discriminant/issue-70453-generics-in-discr-ice.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0392]: parameter `T` is never used
--> $DIR/issue-70453-generics-in-discr-ice.rs:7:20
diff --git a/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr b/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr
index 8c97af2..0a7a631 100644
--- a/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr
+++ b/src/test/ui/enum-discriminant/issue-70453-polymorphic-ctfe.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/enum/issue-67945-1.stderr b/src/test/ui/enum/issue-67945-1.stderr
index 227899e..8f1b5b3 100644
--- a/src/test/ui/enum/issue-67945-1.stderr
+++ b/src/test/ui/enum/issue-67945-1.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `S`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0392]: parameter `S` is never used
--> $DIR/issue-67945-1.rs:1:10
diff --git a/src/test/ui/enum/issue-67945-2.stderr b/src/test/ui/enum/issue-67945-2.stderr
index 5a90f00..4f5e236 100644
--- a/src/test/ui/enum/issue-67945-2.stderr
+++ b/src/test/ui/enum/issue-67945-2.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `S`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error[E0392]: parameter `S` is never used
--> $DIR/issue-67945-2.rs:3:10
diff --git a/src/test/ui/error-codes/E0730.rs b/src/test/ui/error-codes/E0730.rs
index 3074581..04f5e5d 100644
--- a/src/test/ui/error-codes/E0730.rs
+++ b/src/test/ui/error-codes/E0730.rs
@@ -1,6 +1,3 @@
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
-
fn is_123<const N: usize>(x: [u32; N]) -> bool {
match x {
[1, 2, ..] => true, //~ ERROR cannot pattern-match on an array without a fixed length
diff --git a/src/test/ui/error-codes/E0730.stderr b/src/test/ui/error-codes/E0730.stderr
index f915f6e..067e8c5 100644
--- a/src/test/ui/error-codes/E0730.stderr
+++ b/src/test/ui/error-codes/E0730.stderr
@@ -1,18 +1,9 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/E0730.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
error[E0730]: cannot pattern-match on an array without a fixed length
- --> $DIR/E0730.rs:6:9
+ --> $DIR/E0730.rs:3:9
|
LL | [1, 2, ..] => true,
| ^^^^^^^^^^
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error
For more information about this error, try `rustc --explain E0730`.
diff --git a/src/test/ui/error-codes/E0771.rs b/src/test/ui/error-codes/E0771.rs
index ba35927..67e7d10 100644
--- a/src/test/ui/error-codes/E0771.rs
+++ b/src/test/ui/error-codes/E0771.rs
@@ -1,5 +1,5 @@
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![feature(adt_const_params)]
+//~^ WARN the feature `adt_const_params` is incomplete
fn function_with_str<'a, const STRING: &'a str>() {} //~ ERROR E0771
diff --git a/src/test/ui/error-codes/E0771.stderr b/src/test/ui/error-codes/E0771.stderr
index 60220be..730a7ef 100644
--- a/src/test/ui/error-codes/E0771.stderr
+++ b/src/test/ui/error-codes/E0771.stderr
@@ -1,8 +1,8 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
+warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/E0771.rs:1:12
|
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
+LL | #![feature(adt_const_params)]
+ | ^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
diff --git a/src/test/ui/extern/extern-no-mangle.rs b/src/test/ui/extern/extern-no-mangle.rs
new file mode 100644
index 0000000..ab7c982
--- /dev/null
+++ b/src/test/ui/extern/extern-no-mangle.rs
@@ -0,0 +1,30 @@
+#![warn(unused_attributes)]
+
+// Tests that placing the #[no_mangle] attribute on a foreign fn or static emits
+// a specialized warning.
+// The previous warning only talks about a "function or static" but foreign fns/statics
+// are also not allowed to have #[no_mangle]
+
+// build-pass
+
+extern "C" {
+ #[no_mangle]
+ //~^ WARNING `#[no_mangle]` has no effect on a foreign static
+ //~^^ WARNING this was previously accepted by the compiler
+ pub static FOO: u8;
+
+ #[no_mangle]
+ //~^ WARNING `#[no_mangle]` has no effect on a foreign function
+ //~^^ WARNING this was previously accepted by the compiler
+ pub fn bar();
+}
+
+fn no_new_warn() {
+ // Should emit the generic "not a function or static" warning
+ #[no_mangle]
+ //~^ WARNING attribute should be applied to a free function, impl method or static
+ //~^^ WARNING this was previously accepted by the compiler
+ let x = 0_u8;
+}
+
+fn main() {}
diff --git a/src/test/ui/extern/extern-no-mangle.stderr b/src/test/ui/extern/extern-no-mangle.stderr
new file mode 100644
index 0000000..b564281
--- /dev/null
+++ b/src/test/ui/extern/extern-no-mangle.stderr
@@ -0,0 +1,42 @@
+warning: attribute should be applied to a free function, impl method or static
+ --> $DIR/extern-no-mangle.rs:24:5
+ |
+LL | #[no_mangle]
+ | ^^^^^^^^^^^^
+...
+LL | let x = 0_u8;
+ | ------------- not a free function, impl method or static
+ |
+note: the lint level is defined here
+ --> $DIR/extern-no-mangle.rs:1:9
+ |
+LL | #![warn(unused_attributes)]
+ | ^^^^^^^^^^^^^^^^^
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+
+warning: `#[no_mangle]` has no effect on a foreign static
+ --> $DIR/extern-no-mangle.rs:11:5
+ |
+LL | #[no_mangle]
+ | ^^^^^^^^^^^^ help: remove this attribute
+...
+LL | pub static FOO: u8;
+ | ------------------- foreign static
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: symbol names in extern blocks are not mangled
+
+warning: `#[no_mangle]` has no effect on a foreign function
+ --> $DIR/extern-no-mangle.rs:16:5
+ |
+LL | #[no_mangle]
+ | ^^^^^^^^^^^^ help: remove this attribute
+...
+LL | pub fn bar();
+ | ------------- foreign function
+ |
+ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+ = note: symbol names in extern blocks are not mangled
+
+warning: 3 warnings emitted
+
diff --git a/src/test/ui/feature-gates/feature-gate-adt_const_params.rs b/src/test/ui/feature-gates/feature-gate-adt_const_params.rs
new file mode 100644
index 0000000..8a3bcf2
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-adt_const_params.rs
@@ -0,0 +1,2 @@
+struct Foo<const NAME: &'static str>; //~ ERROR `&'static str` is forbidden
+fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-adt_const_params.stderr b/src/test/ui/feature-gates/feature-gate-adt_const_params.stderr
new file mode 100644
index 0000000..d8f089a
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-adt_const_params.stderr
@@ -0,0 +1,11 @@
+error: `&'static str` is forbidden as the type of a const generic parameter
+ --> $DIR/feature-gate-adt_const_params.rs:1:24
+ |
+LL | struct Foo<const NAME: &'static str>;
+ | ^^^^^^^^^^^^
+ |
+ = note: the only supported types are integers, `bool` and `char`
+ = help: more complex types are supported with `#![feature(adt_const_params)]`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr
index f24c3d6..8df5fbc 100644
--- a/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr
+++ b/src/test/ui/feature-gates/feature-gate-associated_type_bounds.stderr
@@ -142,8 +142,10 @@
note: required by a bound in `Copy`
--> $SRC_DIR/core/src/marker.rs:LL:COL
|
-LL | pub trait Copy: Clone {
- | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Copy`
+LL | / pub trait Copy: Clone {
+LL | | // Empty.
+LL | | }
+ | |_^ required by this bound in `Copy`
help: consider further restricting the associated type
|
LL | trait _Tr3 where <<Self as _Tr3>::A as Iterator>::Item: Copy {
diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.rs b/src/test/ui/feature-gates/feature-gate-const_generics.rs
deleted file mode 100644
index 06364ee..0000000
--- a/src/test/ui/feature-gates/feature-gate-const_generics.rs
+++ /dev/null
@@ -1,5 +0,0 @@
-fn foo<const X: ()>() {} //~ ERROR `()` is forbidden as the type of a const generic parameter
-
-struct Foo<const X: usize>([(); X]);
-
-fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.stderr b/src/test/ui/feature-gates/feature-gate-const_generics.stderr
deleted file mode 100644
index ed19109..0000000
--- a/src/test/ui/feature-gates/feature-gate-const_generics.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: `()` is forbidden as the type of a const generic parameter
- --> $DIR/feature-gate-const_generics.rs:1:17
- |
-LL | fn foo<const X: ()>() {}
- | ^^
- |
- = note: the only supported types are integers, `bool` and `char`
- = help: more complex types are supported with `#![feature(const_generics)]`
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/feature-gates/feature-gate-let_else.rs b/src/test/ui/feature-gates/feature-gate-let_else.rs
new file mode 100644
index 0000000..3f04a9d
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-let_else.rs
@@ -0,0 +1,5 @@
+fn main() {
+ let Some(x) = Some(1) else { //~ ERROR `let...else` statements are unstable
+ return;
+ };
+}
diff --git a/src/test/ui/feature-gates/feature-gate-let_else.stderr b/src/test/ui/feature-gates/feature-gate-let_else.stderr
new file mode 100644
index 0000000..8625260
--- /dev/null
+++ b/src/test/ui/feature-gates/feature-gate-let_else.stderr
@@ -0,0 +1,14 @@
+error[E0658]: `let...else` statements are unstable
+ --> $DIR/feature-gate-let_else.rs:2:5
+ |
+LL | / let Some(x) = Some(1) else {
+LL | | return;
+LL | | };
+ | |______^
+ |
+ = note: see issue #87335 <https://github.com/rust-lang/rust/issues/87335> for more information
+ = help: add `#![feature(let_else)]` to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/generic-associated-types/issue-87748.rs b/src/test/ui/generic-associated-types/issue-87748.rs
new file mode 100644
index 0000000..93c3b39
--- /dev/null
+++ b/src/test/ui/generic-associated-types/issue-87748.rs
@@ -0,0 +1,30 @@
+// Checks that we properly add implied bounds from unnormalized projections in
+// inputs when typechecking functions.
+
+// check-pass
+
+#![feature(generic_associated_types)]
+
+trait MyTrait {
+ type Assoc<'a, 'b> where 'b: 'a;
+ fn do_sth(arg: Self::Assoc<'_, '_>);
+}
+
+struct A;
+struct B;
+struct C;
+
+impl MyTrait for A {
+ type Assoc<'a, 'b> where 'b: 'a = u32;
+ fn do_sth(_: u32) {}
+}
+impl MyTrait for B {
+ type Assoc<'a, 'b> where 'b: 'a = u32;
+ fn do_sth(_: Self::Assoc<'_, '_>) {}
+}
+impl MyTrait for C {
+ type Assoc<'a, 'b> where 'b: 'a = u32;
+ fn do_sth(_: Self::Assoc<'static, 'static>) {}
+}
+
+fn main () {}
diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr
index 5e7e72c..2b57c43 100644
--- a/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr
+++ b/src/test/ui/generic-associated-types/projection-bound-cycle-generic.stderr
@@ -4,11 +4,11 @@
LL | type Assoc = OnlySized<<T as Foo>::Item>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: required by a bound in `Foo::Item`
- --> $DIR/projection-bound-cycle-generic.rs:11:49
+note: required by a bound in `OnlySized`
+ --> $DIR/projection-bound-cycle-generic.rs:28:18
|
-LL | type Item: Sized where <Self as Foo>::Item: Sized;
- | ^^^^^ required by this bound in `Foo::Item`
+LL | struct OnlySized<T> where T: Sized { f: T }
+ | ^ required by this bound in `OnlySized`
error: aborting due to previous error
diff --git a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr
index 1153bf5..d9d0bf4 100644
--- a/src/test/ui/generic-associated-types/projection-bound-cycle.stderr
+++ b/src/test/ui/generic-associated-types/projection-bound-cycle.stderr
@@ -4,11 +4,11 @@
LL | type Assoc = OnlySized<<T as Foo>::Item>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
-note: required by a bound in `Foo::Item`
- --> $DIR/projection-bound-cycle.rs:13:49
+note: required by a bound in `OnlySized`
+ --> $DIR/projection-bound-cycle.rs:30:18
|
-LL | type Item: Sized where <Self as Foo>::Item: Sized;
- | ^^^^^ required by this bound in `Foo::Item`
+LL | struct OnlySized<T> where T: Sized { f: T }
+ | ^ required by this bound in `OnlySized`
error: aborting due to previous error
diff --git a/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr b/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr
index 41a0a03..ab09ebc 100644
--- a/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr
+++ b/src/test/ui/generics/param-in-ct-in-ty-param-default.stderr
@@ -5,7 +5,7 @@
| ^ cannot perform const operation using `T`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/hygiene/generic_params.rs b/src/test/ui/hygiene/generic_params.rs
index d319ae6..3b6216c 100644
--- a/src/test/ui/hygiene/generic_params.rs
+++ b/src/test/ui/hygiene/generic_params.rs
@@ -3,8 +3,7 @@
// check-pass
// ignore-pretty pretty-printing is unhygienic
-#![feature(decl_macro, rustc_attrs, const_generics)]
-//~^ WARNING the feature `const_generics` is incomplete
+#![feature(decl_macro, rustc_attrs)]
mod type_params {
macro m($T:ident) {
diff --git a/src/test/ui/hygiene/generic_params.stderr b/src/test/ui/hygiene/generic_params.stderr
deleted file mode 100644
index 4ca6d19..0000000
--- a/src/test/ui/hygiene/generic_params.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_params.rs:6:37
- |
-LL | #![feature(decl_macro, rustc_attrs, const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/hygiene/issue-61574-const-parameters.rs b/src/test/ui/hygiene/issue-61574-const-parameters.rs
index 81e9b1b..3634ee0 100644
--- a/src/test/ui/hygiene/issue-61574-const-parameters.rs
+++ b/src/test/ui/hygiene/issue-61574-const-parameters.rs
@@ -3,8 +3,6 @@
// check-pass
-#![feature(const_generics)] //~ WARNING `const_generics` is incomplete
-
use std::ops::Add;
struct VectorLike<T, const SIZE: usize>([T; {SIZE}]);
diff --git a/src/test/ui/hygiene/issue-61574-const-parameters.stderr b/src/test/ui/hygiene/issue-61574-const-parameters.stderr
deleted file mode 100644
index b351b8b..0000000
--- a/src/test/ui/hygiene/issue-61574-const-parameters.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-61574-const-parameters.rs:6:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/impl-trait/issue-55872-1.full_tait.stderr b/src/test/ui/impl-trait/issue-55872-1.full_tait.stderr
deleted file mode 100644
index 50eab7d..0000000
--- a/src/test/ui/impl-trait/issue-55872-1.full_tait.stderr
+++ /dev/null
@@ -1,57 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-55872-1.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error[E0276]: impl has stricter requirements than trait
- --> $DIR/issue-55872-1.rs:17:5
- |
-LL | fn foo<T>() -> Self::E;
- | ----------------------- definition of `foo` from trait
-...
-LL | fn foo<T: Default>() -> Self::E {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: Default`
-
-error[E0277]: the trait bound `S: Copy` is not satisfied in `(S, T)`
- --> $DIR/issue-55872-1.rs:13:14
- |
-LL | type E = impl Copy;
- | ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `S`
- |
- = note: required because it appears within the type `(S, T)`
-help: consider further restricting this bound
- |
-LL | impl<S: Default + std::marker::Copy> Bar for S {
- | +++++++++++++++++++
-
-error[E0277]: the trait bound `T: Copy` is not satisfied in `(S, T)`
- --> $DIR/issue-55872-1.rs:13:14
- |
-LL | type E = impl Copy;
- | ^^^^^^^^^ within `(S, T)`, the trait `Copy` is not implemented for `T`
- |
- = note: required because it appears within the type `(S, T)`
-help: consider further restricting this bound
- |
-LL | fn foo<T: Default + std::marker::Copy>() -> Self::E {
- | +++++++++++++++++++
-
-error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias
- --> $DIR/issue-55872-1.rs:17:37
- |
-LL | fn foo<T: Default>() -> Self::E {
- | _____________________________________^
-LL | |
-LL | |
-LL | | (S::default(), T::default())
-LL | | }
- | |_____^
-
-error: aborting due to 4 previous errors; 1 warning emitted
-
-Some errors have detailed explanations: E0276, E0277.
-For more information about an error, try `rustc --explain E0276`.
diff --git a/src/test/ui/impl-trait/issues/issue-79099.stderr b/src/test/ui/impl-trait/issues/issue-79099.stderr
index 121536d..394b697 100644
--- a/src/test/ui/impl-trait/issues/issue-79099.stderr
+++ b/src/test/ui/impl-trait/issues/issue-79099.stderr
@@ -6,7 +6,7 @@
| |
| `async` blocks are only allowed in Rust 2018 or later
|
- = help: set `edition = "2018"` in `Cargo.toml`
+ = help: set `edition = "2021"` in `Cargo.toml`
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0562]: `impl Trait` not allowed outside of function and method return types
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.stderr b/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.stderr
deleted file mode 100644
index 4de872e..0000000
--- a/src/test/ui/impl-trait/multiple-lifetimes/inverse-bounds.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-warning[E0700]: hidden type for `impl Trait` captures lifetime that does not appear in bounds
- --> $DIR/inverse-bounds.rs:16:70
- |
-LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Invert<'a>, b: Invert<'b>) -> impl Trait<'d, 'e>
- | ^^^^^^^^^^^^^^^^^^
- |
- = note: hidden type `Invert<'_>` captures lifetime '_#8r
- = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
- = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
- = note: for more information, try `rustc --explain E0729`
-
-warning: the feature `pin` has been stable since 1.33.0 and no longer requires an attribute to enable
- --> $DIR/inverse-bounds.rs:4:60
- |
-LL | #![feature(arbitrary_self_types, async_await, await_macro, pin)]
- | ^^^
- |
- = note: #[warn(stable_features)] on by default
-
diff --git a/src/test/ui/infinite/infinite-struct.stderr b/src/test/ui/infinite/infinite-struct.stderr
index 7ffb510..369645f 100644
--- a/src/test/ui/infinite/infinite-struct.stderr
+++ b/src/test/ui/infinite/infinite-struct.stderr
@@ -18,7 +18,7 @@
LL | struct Take(Take);
| ^^^^^^^^^^^^^^^^^^
|
- = note: ...which again requires computing drop-check constraints for `Take`, completing the cycle
+ = note: ...which immediately requires computing drop-check constraints for `Take` again
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: Take } }`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/infinite/infinite-tag-type-recursion.stderr b/src/test/ui/infinite/infinite-tag-type-recursion.stderr
index 1f147e0..61b5e94 100644
--- a/src/test/ui/infinite/infinite-tag-type-recursion.stderr
+++ b/src/test/ui/infinite/infinite-tag-type-recursion.stderr
@@ -17,7 +17,7 @@
LL | enum MList { Cons(isize, MList), Nil }
| ^^^^^^^^^^
|
- = note: ...which again requires computing drop-check constraints for `MList`, completing the cycle
+ = note: ...which immediately requires computing drop-check constraints for `MList` again
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: MList } }`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/infinite/infinite-trait-alias-recursion.rs b/src/test/ui/infinite/infinite-trait-alias-recursion.rs
new file mode 100644
index 0000000..ec86744
--- /dev/null
+++ b/src/test/ui/infinite/infinite-trait-alias-recursion.rs
@@ -0,0 +1,10 @@
+#![feature(trait_alias)]
+
+trait T1 = T2;
+//~^ ERROR cycle detected when computing the super predicates of `T1`
+
+trait T2 = T3;
+
+trait T3 = T1 + T3;
+
+fn main() {}
diff --git a/src/test/ui/infinite/infinite-trait-alias-recursion.stderr b/src/test/ui/infinite/infinite-trait-alias-recursion.stderr
new file mode 100644
index 0000000..5ecaedb
--- /dev/null
+++ b/src/test/ui/infinite/infinite-trait-alias-recursion.stderr
@@ -0,0 +1,42 @@
+error[E0391]: cycle detected when computing the super predicates of `T1`
+ --> $DIR/infinite-trait-alias-recursion.rs:3:1
+ |
+LL | trait T1 = T2;
+ | ^^^^^^^^^^^^^^
+ |
+note: ...which requires computing the super traits of `T1`...
+ --> $DIR/infinite-trait-alias-recursion.rs:3:12
+ |
+LL | trait T1 = T2;
+ | ^^
+note: ...which requires computing the super predicates of `T2`...
+ --> $DIR/infinite-trait-alias-recursion.rs:6:1
+ |
+LL | trait T2 = T3;
+ | ^^^^^^^^^^^^^^
+note: ...which requires computing the super traits of `T2`...
+ --> $DIR/infinite-trait-alias-recursion.rs:6:12
+ |
+LL | trait T2 = T3;
+ | ^^
+note: ...which requires computing the super predicates of `T3`...
+ --> $DIR/infinite-trait-alias-recursion.rs:8:1
+ |
+LL | trait T3 = T1 + T3;
+ | ^^^^^^^^^^^^^^^^^^^
+note: ...which requires computing the super traits of `T3`...
+ --> $DIR/infinite-trait-alias-recursion.rs:8:12
+ |
+LL | trait T3 = T1 + T3;
+ | ^^
+ = note: ...which again requires computing the super predicates of `T1`, completing the cycle
+ = note: trait aliases cannot be recursive
+note: cycle used when collecting item types in top-level module
+ --> $DIR/infinite-trait-alias-recursion.rs:3:1
+ |
+LL | trait T1 = T2;
+ | ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs
new file mode 100644
index 0000000..5381eed
--- /dev/null
+++ b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.rs
@@ -0,0 +1,6 @@
+type X1 = X2;
+//~^ ERROR cycle detected when expanding type alias `X1`
+type X2 = X3;
+type X3 = X1;
+
+fn main() {}
diff --git a/src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr
new file mode 100644
index 0000000..7f82b29
--- /dev/null
+++ b/src/test/ui/infinite/infinite-type-alias-mutual-recursion.stderr
@@ -0,0 +1,34 @@
+error[E0391]: cycle detected when expanding type alias `X1`
+ --> $DIR/infinite-type-alias-mutual-recursion.rs:1:11
+ |
+LL | type X1 = X2;
+ | ^^
+ |
+note: ...which requires expanding type alias `X2`...
+ --> $DIR/infinite-type-alias-mutual-recursion.rs:3:11
+ |
+LL | type X2 = X3;
+ | ^^
+note: ...which requires expanding type alias `X3`...
+ --> $DIR/infinite-type-alias-mutual-recursion.rs:4:11
+ |
+LL | type X3 = X1;
+ | ^^
+ = note: ...which again requires expanding type alias `X1`, completing the cycle
+ = note: type aliases cannot be recursive
+ = help: consider using a struct, enum, or union instead to break the cycle
+ = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
+note: cycle used when collecting item types in top-level module
+ --> $DIR/infinite-type-alias-mutual-recursion.rs:1:1
+ |
+LL | / type X1 = X2;
+LL | |
+LL | | type X2 = X3;
+LL | | type X3 = X1;
+LL | |
+LL | | fn main() {}
+ | |____________^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/infinite/infinite-vec-type-recursion.stderr b/src/test/ui/infinite/infinite-vec-type-recursion.stderr
index 77adefe..1e487a5 100644
--- a/src/test/ui/infinite/infinite-vec-type-recursion.stderr
+++ b/src/test/ui/infinite/infinite-vec-type-recursion.stderr
@@ -1,10 +1,13 @@
-error[E0391]: cycle detected when computing type of `X`
+error[E0391]: cycle detected when expanding type alias `X`
--> $DIR/infinite-vec-type-recursion.rs:1:14
|
LL | type X = Vec<X>;
| ^
|
- = note: ...which again requires computing type of `X`, completing the cycle
+ = note: ...which immediately requires expanding type alias `X` again
+ = note: type aliases cannot be recursive
+ = help: consider using a struct, enum, or union instead to break the cycle
+ = help: see <https://doc.rust-lang.org/reference/types.html#recursive-types> for more information
note: cycle used when collecting item types in top-level module
--> $DIR/infinite-vec-type-recursion.rs:1:1
|
diff --git a/src/test/ui/inline-const/const-match-pat-generic.rs b/src/test/ui/inline-const/const-match-pat-generic.rs
new file mode 100644
index 0000000..61680d6
--- /dev/null
+++ b/src/test/ui/inline-const/const-match-pat-generic.rs
@@ -0,0 +1,16 @@
+#![allow(incomplete_features)]
+#![feature(inline_const)]
+
+// rust-lang/rust#82518: ICE with inline-const in match referencing const-generic parameter
+
+fn foo<const V: usize>() {
+ match 0 {
+ const { V } => {},
+ //~^ ERROR const parameters cannot be referenced in patterns [E0158]
+ _ => {},
+ }
+}
+
+fn main() {
+ foo::<1>();
+}
diff --git a/src/test/ui/binding/const-param.full.stderr b/src/test/ui/inline-const/const-match-pat-generic.stderr
similarity index 65%
copy from src/test/ui/binding/const-param.full.stderr
copy to src/test/ui/inline-const/const-match-pat-generic.stderr
index 0200c6d..a3ed41a 100644
--- a/src/test/ui/binding/const-param.full.stderr
+++ b/src/test/ui/inline-const/const-match-pat-generic.stderr
@@ -1,8 +1,8 @@
error[E0158]: const parameters cannot be referenced in patterns
- --> $DIR/const-param.rs:8:9
+ --> $DIR/const-match-pat-generic.rs:8:11
|
-LL | N => {}
- | ^
+LL | const { V } => {},
+ | ^^^^^
error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-20772.stderr b/src/test/ui/issues/issue-20772.stderr
index 4aecc7e..c964dc4 100644
--- a/src/test/ui/issues/issue-20772.stderr
+++ b/src/test/ui/issues/issue-20772.stderr
@@ -6,7 +6,7 @@
LL | | {}
| |__^
|
- = note: ...which again requires computing the super traits of `T` with associated type name `Item`, completing the cycle
+ = note: ...which immediately requires computing the super traits of `T` with associated type name `Item` again
note: cycle used when computing the super traits of `T`
--> $DIR/issue-20772.rs:1:1
|
diff --git a/src/test/ui/issues/issue-20825.stderr b/src/test/ui/issues/issue-20825.stderr
index ccbe06d..be2bbd4 100644
--- a/src/test/ui/issues/issue-20825.stderr
+++ b/src/test/ui/issues/issue-20825.stderr
@@ -4,7 +4,7 @@
LL | pub trait Processor: Subscriber<Input = Self::Input> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: ...which again requires computing the super traits of `Processor` with associated type name `Input`, completing the cycle
+ = note: ...which immediately requires computing the super traits of `Processor` with associated type name `Input` again
note: cycle used when computing the super traits of `Processor`
--> $DIR/issue-20825.rs:5:1
|
diff --git a/src/test/ui/issues/issue-21177.stderr b/src/test/ui/issues/issue-21177.stderr
index 59cc655..6877a18 100644
--- a/src/test/ui/issues/issue-21177.stderr
+++ b/src/test/ui/issues/issue-21177.stderr
@@ -4,7 +4,7 @@
LL | fn foo<T: Trait<A = T::B>>() { }
| ^^^^
|
- = note: ...which again requires computing the bounds for type parameter `T`, completing the cycle
+ = note: ...which immediately requires computing the bounds for type parameter `T` again
note: cycle used when computing explicit predicates of `foo`
--> $DIR/issue-21177.rs:6:21
|
diff --git a/src/test/ui/issues/issue-34373.stderr b/src/test/ui/issues/issue-34373.stderr
index e8c1e8f..8be3cfa 100644
--- a/src/test/ui/issues/issue-34373.stderr
+++ b/src/test/ui/issues/issue-34373.stderr
@@ -4,7 +4,7 @@
LL | pub struct Foo<T = Box<Trait<DefaultFoo>>>;
| ^^^^^^^^^^
|
-note: ...which requires computing type of `DefaultFoo`...
+note: ...which requires expanding type alias `DefaultFoo`...
--> $DIR/issue-34373.rs:8:19
|
LL | type DefaultFoo = Foo;
diff --git a/src/test/ui/issues/issue-39559.stderr b/src/test/ui/issues/issue-39559.stderr
index 91e31ca..7626f82 100644
--- a/src/test/ui/issues/issue-39559.stderr
+++ b/src/test/ui/issues/issue-39559.stderr
@@ -5,7 +5,7 @@
| ^^^^^^ cannot perform const operation using `D`
|
= note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to previous error
diff --git a/src/test/ui/issues/issue-59508-1.rs b/src/test/ui/issues/issue-59508-1.rs
index a687a9e..6376c42 100644
--- a/src/test/ui/issues/issue-59508-1.rs
+++ b/src/test/ui/issues/issue-59508-1.rs
@@ -1,9 +1,8 @@
#![allow(dead_code)]
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
+#![feature(const_generics_defaults)]
// This test checks that generic parameter re-ordering diagnostic suggestions mention that
-// consts come after types and lifetimes when the `const_generics` feature is enabled.
+// consts come after types and lifetimes when the `const_generics_defaults` feature is enabled.
// We cannot run rustfix on this test because of the above const generics warning.
struct A;
diff --git a/src/test/ui/issues/issue-59508-1.stderr b/src/test/ui/issues/issue-59508-1.stderr
index 5e97339..df244f0 100644
--- a/src/test/ui/issues/issue-59508-1.stderr
+++ b/src/test/ui/issues/issue-59508-1.stderr
@@ -1,17 +1,8 @@
error: lifetime parameters must be declared prior to type parameters
- --> $DIR/issue-59508-1.rs:12:25
+ --> $DIR/issue-59508-1.rs:11:25
|
LL | pub fn do_things<T, 'a, 'b: 'a>() {
| ----^^--^^----- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b: 'a, T>`
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-59508-1.rs:2:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to previous error
diff --git a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs b/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs
deleted file mode 100644
index 46ae940..0000000
--- a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-pub const fn sof<T>() -> usize {
- 10
-}
-
-fn test<T>() {
- let _: [u8; sof::<T>()];
- //~^ ERROR generic parameters may not be used in const operations
-}
-
-fn main() {}
diff --git a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr b/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr
deleted file mode 100644
index 5c167ea..0000000
--- a/src/test/ui/lazy_normalization_consts/feature-gate-lazy_normalization_consts.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error: generic parameters may not be used in const operations
- --> $DIR/feature-gate-lazy_normalization_consts.rs:6:23
- |
-LL | let _: [u8; sof::<T>()];
- | ^ cannot perform const operation using `T`
- |
- = note: type parameters may not be used in const expressions
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/lazy_normalization_consts/issue-47814.rs b/src/test/ui/lazy_normalization_consts/issue-47814.rs
deleted file mode 100644
index 1fd0c45..0000000
--- a/src/test/ui/lazy_normalization_consts/issue-47814.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// check-pass
-#![feature(lazy_normalization_consts)]
-#![allow(incomplete_features)]
-pub struct ArpIPv4<'a> {
- _s: &'a u8
-}
-
-impl<'a> ArpIPv4<'a> {
- const LENGTH: usize = 20;
-
- pub fn to_buffer() -> [u8; Self::LENGTH] {
- unimplemented!()
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/lazy_normalization_consts/issue-57739.rs b/src/test/ui/lazy_normalization_consts/issue-57739.rs
deleted file mode 100644
index 4607f3e..0000000
--- a/src/test/ui/lazy_normalization_consts/issue-57739.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-#![feature(lazy_normalization_consts)]
-//~^ WARN the feature `lazy_normalization_consts` is incomplete
-trait ArraySizeTrait {
- const SIZE: usize = 0;
-}
-
-impl<T: ?Sized> ArraySizeTrait for T {
- const SIZE: usize = 1;
-}
-
-struct SomeArray<T: ArraySizeTrait> {
- array: [u8; T::SIZE],
- //~^ ERROR constant expression depends on a generic parameter
- phantom: std::marker::PhantomData<T>,
-}
-
-fn main() {}
diff --git a/src/test/ui/lazy_normalization_consts/issue-57739.stderr b/src/test/ui/lazy_normalization_consts/issue-57739.stderr
deleted file mode 100644
index ce0495d..0000000
--- a/src/test/ui/lazy_normalization_consts/issue-57739.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-warning: the feature `lazy_normalization_consts` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-57739.rs:1:12
- |
-LL | #![feature(lazy_normalization_consts)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information
-
-error: constant expression depends on a generic parameter
- --> $DIR/issue-57739.rs:12:12
- |
-LL | array: [u8; T::SIZE],
- | ^^^^^^^^^^^^^
- |
- = note: this may fail depending on what value the parameter takes
-
-error: aborting due to previous error; 1 warning emitted
-
diff --git a/src/test/ui/lazy_normalization_consts/issue-73980.rs b/src/test/ui/lazy_normalization_consts/issue-73980.rs
deleted file mode 100644
index e100406..0000000
--- a/src/test/ui/lazy_normalization_consts/issue-73980.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// check-pass
-#![feature(lazy_normalization_consts)]
-#![allow(incomplete_features)]
-
-pub struct X<P, Q>(P, Q);
-pub struct L<T: ?Sized>(T);
-
-impl<T: ?Sized> L<T> {
- const S: usize = 1;
-}
-
-impl<T> X<T, [u8; L::<T>::S]> {}
-//~^ WARN cannot use constants which depend on generic parameters
-//~| WARN this was previously accepted by the compiler but is being phased out
-
-fn main() {}
diff --git a/src/test/ui/lazy_normalization_consts/issue-73980.stderr b/src/test/ui/lazy_normalization_consts/issue-73980.stderr
deleted file mode 100644
index 5ed1ca3..0000000
--- a/src/test/ui/lazy_normalization_consts/issue-73980.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-warning: cannot use constants which depend on generic parameters in types
- --> $DIR/issue-73980.rs:12:9
- |
-LL | impl<T> X<T, [u8; L::<T>::S]> {}
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(const_evaluatable_unchecked)]` on by default
- = warning: 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 #76200 <https://github.com/rust-lang/rust/issues/76200>
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/legacy-const-generics-bad.stderr b/src/test/ui/legacy-const-generics-bad.stderr
index 5a44b8e..3c78dd6 100644
--- a/src/test/ui/legacy-const-generics-bad.stderr
+++ b/src/test/ui/legacy-const-generics-bad.stderr
@@ -13,7 +13,7 @@
| ^ cannot perform const operation using `N`
|
= help: const parameters may only be used as standalone arguments, i.e. `N`
- = help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions
+ = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions
error: aborting due to 2 previous errors
diff --git a/src/test/ui/let-else/let-else-bool-binop-init.fixed b/src/test/ui/let-else/let-else-bool-binop-init.fixed
new file mode 100644
index 0000000..e47f7f2
--- /dev/null
+++ b/src/test/ui/let-else/let-else-bool-binop-init.fixed
@@ -0,0 +1,8 @@
+// run-rustfix
+
+#![feature(let_else)]
+
+fn main() {
+ let true = (true && false) else { return }; //~ ERROR a `&&` expression cannot be directly assigned in `let...else`
+ let true = (true || false) else { return }; //~ ERROR a `||` expression cannot be directly assigned in `let...else`
+}
diff --git a/src/test/ui/let-else/let-else-bool-binop-init.rs b/src/test/ui/let-else/let-else-bool-binop-init.rs
new file mode 100644
index 0000000..e443fb0
--- /dev/null
+++ b/src/test/ui/let-else/let-else-bool-binop-init.rs
@@ -0,0 +1,8 @@
+// run-rustfix
+
+#![feature(let_else)]
+
+fn main() {
+ let true = true && false else { return }; //~ ERROR a `&&` expression cannot be directly assigned in `let...else`
+ let true = true || false else { return }; //~ ERROR a `||` expression cannot be directly assigned in `let...else`
+}
diff --git a/src/test/ui/let-else/let-else-bool-binop-init.stderr b/src/test/ui/let-else/let-else-bool-binop-init.stderr
new file mode 100644
index 0000000..6551e24
--- /dev/null
+++ b/src/test/ui/let-else/let-else-bool-binop-init.stderr
@@ -0,0 +1,24 @@
+error: a `&&` expression cannot be directly assigned in `let...else`
+ --> $DIR/let-else-bool-binop-init.rs:6:16
+ |
+LL | let true = true && false else { return };
+ | ^^^^^^^^^^^^^
+ |
+help: wrap the expression in parenthesis
+ |
+LL | let true = (true && false) else { return };
+ | + +
+
+error: a `||` expression cannot be directly assigned in `let...else`
+ --> $DIR/let-else-bool-binop-init.rs:7:16
+ |
+LL | let true = true || false else { return };
+ | ^^^^^^^^^^^^^
+ |
+help: wrap the expression in parenthesis
+ |
+LL | let true = (true || false) else { return };
+ | + +
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/let-else/let-else-brace-before-else.fixed b/src/test/ui/let-else/let-else-brace-before-else.fixed
new file mode 100644
index 0000000..fb4fd77
--- /dev/null
+++ b/src/test/ui/let-else/let-else-brace-before-else.fixed
@@ -0,0 +1,26 @@
+// run-rustfix
+
+#![feature(let_else)]
+
+fn main() {
+ let Some(1) = ({ Some(1) }) else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+ let Some(1) = (loop { break Some(1) }) else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+ let 2 = 1 + (match 1 { n => n }) else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+ let Some(1) = (unsafe { unsafe_fn() }) else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+}
+
+unsafe fn unsafe_fn<T>() -> T {
+ unimplemented!();
+}
diff --git a/src/test/ui/let-else/let-else-brace-before-else.rs b/src/test/ui/let-else/let-else-brace-before-else.rs
new file mode 100644
index 0000000..c4c5a1c
--- /dev/null
+++ b/src/test/ui/let-else/let-else-brace-before-else.rs
@@ -0,0 +1,26 @@
+// run-rustfix
+
+#![feature(let_else)]
+
+fn main() {
+ let Some(1) = { Some(1) } else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+ let Some(1) = loop { break Some(1) } else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+ let 2 = 1 + match 1 { n => n } else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+ let Some(1) = unsafe { unsafe_fn() } else {
+ //~^ ERROR right curly brace `}` before `else` in a `let...else` statement not allowed
+ return;
+ };
+}
+
+unsafe fn unsafe_fn<T>() -> T {
+ unimplemented!();
+}
diff --git a/src/test/ui/let-else/let-else-brace-before-else.stderr b/src/test/ui/let-else/let-else-brace-before-else.stderr
new file mode 100644
index 0000000..eac029c
--- /dev/null
+++ b/src/test/ui/let-else/let-else-brace-before-else.stderr
@@ -0,0 +1,46 @@
+error: right curly brace `}` before `else` in a `let...else` statement not allowed
+ --> $DIR/let-else-brace-before-else.rs:6:29
+ |
+LL | let Some(1) = { Some(1) } else {
+ | ^
+ |
+help: try wrapping the expression in parenthesis
+ |
+LL | let Some(1) = ({ Some(1) }) else {
+ | + +
+
+error: right curly brace `}` before `else` in a `let...else` statement not allowed
+ --> $DIR/let-else-brace-before-else.rs:10:40
+ |
+LL | let Some(1) = loop { break Some(1) } else {
+ | ^
+ |
+help: try wrapping the expression in parenthesis
+ |
+LL | let Some(1) = (loop { break Some(1) }) else {
+ | + +
+
+error: right curly brace `}` before `else` in a `let...else` statement not allowed
+ --> $DIR/let-else-brace-before-else.rs:14:34
+ |
+LL | let 2 = 1 + match 1 { n => n } else {
+ | ^
+ |
+help: try wrapping the expression in parenthesis
+ |
+LL | let 2 = 1 + (match 1 { n => n }) else {
+ | + +
+
+error: right curly brace `}` before `else` in a `let...else` statement not allowed
+ --> $DIR/let-else-brace-before-else.rs:18:40
+ |
+LL | let Some(1) = unsafe { unsafe_fn() } else {
+ | ^
+ |
+help: try wrapping the expression in parenthesis
+ |
+LL | let Some(1) = (unsafe { unsafe_fn() }) else {
+ | + +
+
+error: aborting due to 4 previous errors
+
diff --git a/src/test/ui/let-else/let-else-check.rs b/src/test/ui/let-else/let-else-check.rs
new file mode 100644
index 0000000..ab76344
--- /dev/null
+++ b/src/test/ui/let-else/let-else-check.rs
@@ -0,0 +1,14 @@
+#![feature(let_else)]
+
+#![deny(unused_variables)]
+
+fn main() {
+ // type annotation, attributes
+ #[allow(unused_variables)]
+ let Some(_): Option<u32> = Some(Default::default()) else {
+ let x = 1; // OK
+ return;
+ };
+
+ let x = 1; //~ ERROR unused variable: `x`
+}
diff --git a/src/test/ui/let-else/let-else-check.stderr b/src/test/ui/let-else/let-else-check.stderr
new file mode 100644
index 0000000..50e54d3
--- /dev/null
+++ b/src/test/ui/let-else/let-else-check.stderr
@@ -0,0 +1,14 @@
+error: unused variable: `x`
+ --> $DIR/let-else-check.rs:13:9
+ |
+LL | let x = 1;
+ | ^ help: if this is intentional, prefix it with an underscore: `_x`
+ |
+note: the lint level is defined here
+ --> $DIR/let-else-check.rs:3:9
+ |
+LL | #![deny(unused_variables)]
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/let-else/let-else-irrefutable.rs b/src/test/ui/let-else/let-else-irrefutable.rs
new file mode 100644
index 0000000..b1e09a1
--- /dev/null
+++ b/src/test/ui/let-else/let-else-irrefutable.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+#![feature(let_else)]
+
+fn main() {
+ let x = 1 else { return }; //~ WARN irrefutable `let...else` pattern
+}
diff --git a/src/test/ui/let-else/let-else-irrefutable.stderr b/src/test/ui/let-else/let-else-irrefutable.stderr
new file mode 100644
index 0000000..e030c50
--- /dev/null
+++ b/src/test/ui/let-else/let-else-irrefutable.stderr
@@ -0,0 +1,12 @@
+warning: irrefutable `let...else` pattern
+ --> $DIR/let-else-irrefutable.rs:6:5
+ |
+LL | let x = 1 else { return };
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: `#[warn(irrefutable_let_patterns)]` on by default
+ = note: this pattern will always match, so the `else` clause is useless
+ = help: consider removing the `else` clause
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/let-else/let-else-missing-semicolon.rs b/src/test/ui/let-else/let-else-missing-semicolon.rs
new file mode 100644
index 0000000..ed9d79f
--- /dev/null
+++ b/src/test/ui/let-else/let-else-missing-semicolon.rs
@@ -0,0 +1,11 @@
+#![feature(let_else)]
+
+fn main() {
+ let Some(x) = Some(1) else {
+ return;
+ } //~ ERROR expected `;`, found keyword `let`
+ let _ = "";
+ let Some(x) = Some(1) else {
+ panic!();
+ } //~ ERROR expected `;`, found `}`
+}
diff --git a/src/test/ui/let-else/let-else-missing-semicolon.stderr b/src/test/ui/let-else/let-else-missing-semicolon.stderr
new file mode 100644
index 0000000..1818a0b
--- /dev/null
+++ b/src/test/ui/let-else/let-else-missing-semicolon.stderr
@@ -0,0 +1,18 @@
+error: expected `;`, found keyword `let`
+ --> $DIR/let-else-missing-semicolon.rs:6:6
+ |
+LL | }
+ | ^ help: add `;` here
+LL | let _ = "";
+ | --- unexpected token
+
+error: expected `;`, found `}`
+ --> $DIR/let-else-missing-semicolon.rs:10:6
+ |
+LL | }
+ | ^ help: add `;` here
+LL | }
+ | - unexpected token
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/let-else/let-else-non-diverging.rs b/src/test/ui/let-else/let-else-non-diverging.rs
new file mode 100644
index 0000000..a1cee33
--- /dev/null
+++ b/src/test/ui/let-else/let-else-non-diverging.rs
@@ -0,0 +1,13 @@
+#![feature(let_else)]
+
+fn main() {
+ let Some(x) = Some(1) else { //~ ERROR does not diverge
+ Some(2)
+ };
+ let Some(x) = Some(1) else { //~ ERROR does not diverge
+ if 1 == 1 {
+ panic!();
+ }
+ };
+ let Some(x) = Some(1) else { Some(2) }; //~ ERROR does not diverge
+}
diff --git a/src/test/ui/let-else/let-else-non-diverging.stderr b/src/test/ui/let-else/let-else-non-diverging.stderr
new file mode 100644
index 0000000..fd5a18c
--- /dev/null
+++ b/src/test/ui/let-else/let-else-non-diverging.stderr
@@ -0,0 +1,44 @@
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:12:32
+ |
+LL | let Some(x) = Some(1) else { Some(2) };
+ | ^^^^^^^^^^^ expected `!`, found enum `Option`
+ |
+ = note: expected type `!`
+ found type `Option<{integer}>`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:7:32
+ |
+LL | let Some(x) = Some(1) else {
+ | ________________________________^
+LL | | if 1 == 1 {
+LL | | panic!();
+LL | | }
+LL | | };
+ | |_____^ expected `!`, found `()`
+ |
+ = note: expected type `!`
+ found type `()`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error[E0308]: `else` clause of `let...else` does not diverge
+ --> $DIR/let-else-non-diverging.rs:4:32
+ |
+LL | let Some(x) = Some(1) else {
+ | ________________________________^
+LL | | Some(2)
+LL | | };
+ | |_____^ expected `!`, found enum `Option`
+ |
+ = note: expected type `!`
+ found type `Option<{integer}>`
+ = help: try adding a diverging expression, such as `return` or `panic!(..)`
+ = help: ...or use `match` instead of `let...else`
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/let-else/let-else-run-pass.rs b/src/test/ui/let-else/let-else-run-pass.rs
new file mode 100644
index 0000000..5d96623
--- /dev/null
+++ b/src/test/ui/let-else/let-else-run-pass.rs
@@ -0,0 +1,35 @@
+// run-pass
+
+#![feature(let_else)]
+
+fn main() {
+ #[allow(dead_code)]
+ enum MyEnum {
+ A(String),
+ B { f: String },
+ C,
+ }
+ // ref binding to non-copy value and or-pattern
+ let (MyEnum::A(ref x) | MyEnum::B { f: ref x }) = (MyEnum::B { f: String::new() }) else {
+ panic!();
+ };
+ assert_eq!(x, "");
+
+ // nested let-else
+ let mut x = 1;
+ loop {
+ let 4 = x else {
+ let 3 = x else {
+ x += 1;
+ continue;
+ };
+ break;
+ };
+ panic!();
+ }
+ assert_eq!(x, 3);
+
+ // else return
+ let Some(1) = Some(2) else { return };
+ panic!();
+}
diff --git a/src/test/ui/let-else/let-else-scope.rs b/src/test/ui/let-else/let-else-scope.rs
new file mode 100644
index 0000000..f17682d
--- /dev/null
+++ b/src/test/ui/let-else/let-else-scope.rs
@@ -0,0 +1,7 @@
+#![feature(let_else)]
+
+fn main() {
+ let Some(x) = Some(2) else {
+ panic!("{}", x); //~ ERROR cannot find value `x` in this scope
+ };
+}
diff --git a/src/test/ui/let-else/let-else-scope.stderr b/src/test/ui/let-else/let-else-scope.stderr
new file mode 100644
index 0000000..4b3936e
--- /dev/null
+++ b/src/test/ui/let-else/let-else-scope.stderr
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/let-else-scope.rs:5:22
+ |
+LL | panic!("{}", x);
+ | ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/lint/lint-level-macro-def-mod.rs b/src/test/ui/lint/lint-level-macro-def-mod.rs
new file mode 100644
index 0000000..79f7d12
--- /dev/null
+++ b/src/test/ui/lint/lint-level-macro-def-mod.rs
@@ -0,0 +1,17 @@
+// This checks that exported macros lint as part of their module of origin, not
+// the root module.
+//
+// check-pass
+
+//! Top level documentation
+#![deny(missing_docs)]
+
+#[allow(missing_docs)]
+mod module {
+ #[macro_export]
+ macro_rules! hello {
+ () => ()
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/lint-level-macro-def.rs b/src/test/ui/lint/lint-level-macro-def.rs
new file mode 100644
index 0000000..720f4b4
--- /dev/null
+++ b/src/test/ui/lint/lint-level-macro-def.rs
@@ -0,0 +1,17 @@
+// Checks that you can set a lint level specficially for a macro definition.
+//
+// This is a regression test for issue #59306.
+//
+// check-pass
+
+
+#[deny(missing_docs)]
+mod module {
+ #[allow(missing_docs)]
+ #[macro_export]
+ macro_rules! hello {
+ () => ()
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/lint/missing-doc-private-macro.rs b/src/test/ui/lint/missing-doc-private-macro.rs
index 8d1d5c5..0d4332e 100644
--- a/src/test/ui/lint/missing-doc-private-macro.rs
+++ b/src/test/ui/lint/missing-doc-private-macro.rs
@@ -29,13 +29,13 @@ macro_rules! old_style_mod_private_macro {
#[macro_export]
macro_rules! exported_to_top_level {
- //~^ ERROR missing documentation for macro
+ //~^ ERROR missing documentation for a macro
() => ()
}
}
pub macro top_level_pub_macro {
- //~^ ERROR missing documentation for macro
+ //~^ ERROR missing documentation for a macro
() => ()
}
diff --git a/src/test/ui/lint/missing-doc-private-macro.stderr b/src/test/ui/lint/missing-doc-private-macro.stderr
index a5d39fa..979b007 100644
--- a/src/test/ui/lint/missing-doc-private-macro.stderr
+++ b/src/test/ui/lint/missing-doc-private-macro.stderr
@@ -1,4 +1,4 @@
-error: missing documentation for macro
+error: missing documentation for a macro
--> $DIR/missing-doc-private-macro.rs:31:5
|
LL | macro_rules! exported_to_top_level {
@@ -10,7 +10,7 @@
LL | #![deny(missing_docs)]
| ^^^^^^^^^^^^
-error: missing documentation for macro
+error: missing documentation for a macro
--> $DIR/missing-doc-private-macro.rs:37:1
|
LL | pub macro top_level_pub_macro {
diff --git a/src/test/ui/macros/macro-stability-rpass.rs b/src/test/ui/macros/macro-stability-rpass.rs
index a5f538b..2d02b95 100644
--- a/src/test/ui/macros/macro-stability-rpass.rs
+++ b/src/test/ui/macros/macro-stability-rpass.rs
@@ -1,7 +1,8 @@
// run-pass
// aux-build:unstable-macros.rs
-#![feature(unstable_macros, local_unstable)]
+#![unstable(feature = "one_two_three_testing", issue = "none")]
+#![feature(staged_api, unstable_macros, local_unstable)]
#[macro_use] extern crate unstable_macros;
diff --git a/src/test/ui/mir/issue-75053.in_bindings.stderr b/src/test/ui/mir/issue-75053.in_bindings.stderr
deleted file mode 100644
index d75996b..0000000
--- a/src/test/ui/mir/issue-75053.in_bindings.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0557]: feature has been removed
- --> $DIR/issue-75053.rs:7:34
- |
-LL | #![cfg_attr(in_bindings, feature(impl_trait_in_bindings))]
- | ^^^^^^^^^^^^^^^^^^^^^^ feature has been removed
- |
- = note: removed due to being incomplete and unstable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0557`.
diff --git a/src/test/ui/nll/closure-use-spans.stderr b/src/test/ui/nll/closure-use-spans.stderr
index 8716290..ad928f1 100644
--- a/src/test/ui/nll/closure-use-spans.stderr
+++ b/src/test/ui/nll/closure-use-spans.stderr
@@ -26,7 +26,7 @@
LL | x = 0;
| ^^^^^ assignment to borrowed `x` occurs here
LL | move || *y;
- | - borrow later captured here by closure
+ | -- borrow later captured here by closure
error: aborting due to 3 previous errors
diff --git a/src/test/ui/nll/issue-51191.stderr b/src/test/ui/nll/issue-51191.stderr
index 4509934..18696f5 100644
--- a/src/test/ui/nll/issue-51191.stderr
+++ b/src/test/ui/nll/issue-51191.stderr
@@ -14,10 +14,18 @@
--> $DIR/issue-51191.rs:7:9
|
LL | (&mut self).bar();
+ | ^^^^^^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/issue-51191.rs:4:18
+ |
+LL | fn bar(self: &mut Self) {
+ | ^^^^^^^^^
+help: try removing `&mut` here
+ --> $DIR/issue-51191.rs:7:9
+ |
+LL | (&mut self).bar();
| ^^^^^^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
error[E0596]: cannot borrow `self` as mutable, as it is not declared as mutable
--> $DIR/issue-51191.rs:13:9
@@ -43,10 +51,18 @@
--> $DIR/issue-51191.rs:28:9
|
LL | (&mut self).bar();
+ | ^^^^^^^^^^^ cannot borrow as mutable
+ |
+note: the binding is already a mutable borrow
+ --> $DIR/issue-51191.rs:27:16
+ |
+LL | fn mtblref(&mut self) {
+ | ^^^^^^^^^
+help: try removing `&mut` here
+ --> $DIR/issue-51191.rs:28:9
+ |
+LL | (&mut self).bar();
| ^^^^^^^^^^^
- | |
- | cannot borrow as mutable
- | help: try removing `&mut` here
error: aborting due to 5 previous errors; 1 warning emitted
diff --git a/src/test/ui/obsolete-in-place/bad.bad.stderr b/src/test/ui/obsolete-in-place/bad.bad.stderr
deleted file mode 100644
index d895981..0000000
--- a/src/test/ui/obsolete-in-place/bad.bad.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error: expected expression, found keyword `in`
- --> $DIR/bad.rs:10:5
- |
-LL | in(foo) { bar };
- | ^^ expected expression
-
-error[E0282]: type annotations needed
- --> $DIR/bad.rs:9:8
- |
-LL | let (x, y, foo, bar);
- | ---------------- consider giving the pattern a type
-LL | x <- y;
- | ^^^ cannot infer type
- |
- = note: type must be known at this point
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr
index 6dfe7aa..cec6980 100644
--- a/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr
+++ b/src/test/ui/parser/attr-stmt-expr-attr-bad.stderr
@@ -12,11 +12,11 @@
LL | #[cfg(FALSE)] fn e() { let _ = [#[attr]]; }
| ^ expected expression
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `#`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:9:35
|
LL | #[cfg(FALSE)] fn e() { let _ = foo#[attr](); }
- | ^ expected one of 7 possible tokens
+ | ^ expected one of 8 possible tokens
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:11:36
@@ -70,11 +70,11 @@
|
= note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like `#[test]`, annotate the item following them.
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `#`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:23:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; }
- | ^ expected one of 7 possible tokens
+ | ^ expected one of 8 possible tokens
error: an inner attribute is not permitted in this context
--> $DIR/attr-stmt-expr-attr-bad.rs:25:35
@@ -372,11 +372,11 @@
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
| ^
-error: expected one of `.`, `;`, `?`, or an operator, found `#`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:100:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); }
- | ^ expected one of `.`, `;`, `?`, or an operator
+ | ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: unexpected token: `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:103:34
@@ -384,11 +384,11 @@
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
| ^
-error: expected one of `.`, `;`, `?`, or an operator, found `#`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#`
--> $DIR/attr-stmt-expr-attr-bad.rs:103:34
|
LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); }
- | ^ expected one of `.`, `;`, `?`, or an operator
+ | ^ expected one of `.`, `;`, `?`, `else`, or an operator
error: expected statement after outer attribute
--> $DIR/attr-stmt-expr-attr-bad.rs:108:37
diff --git a/src/test/ui/parser/bounds-type.rs b/src/test/ui/parser/bounds-type.rs
index 7a187a0..4ae4549 100644
--- a/src/test/ui/parser/bounds-type.rs
+++ b/src/test/ui/parser/bounds-type.rs
@@ -9,10 +9,10 @@ struct S<
T: Tr +, // OK
T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds
- T: ?const Tr, // OK
- T: ?const ?Tr, // OK
- T: ?const Tr + 'a, // OK
- T: ?const 'a, //~ ERROR `?const` may only modify trait bounds, not lifetime bounds
+ T: ~const Tr, // OK
+ T: ~const ?Tr, // OK
+ T: ~const Tr + 'a, // OK
+ T: ~const 'a, //~ ERROR `~const` may only modify trait bounds, not lifetime bounds
>;
fn main() {}
diff --git a/src/test/ui/parser/bounds-type.stderr b/src/test/ui/parser/bounds-type.stderr
index 9a1f2ed..005bc1e 100644
--- a/src/test/ui/parser/bounds-type.stderr
+++ b/src/test/ui/parser/bounds-type.stderr
@@ -4,10 +4,10 @@
LL | T: ?'a,
| ^
-error: `?const` may only modify trait bounds, not lifetime bounds
+error: `~const` may only modify trait bounds, not lifetime bounds
--> $DIR/bounds-type.rs:15:8
|
-LL | T: ?const 'a,
+LL | T: ~const 'a,
| ^^^^^^
error: aborting due to 2 previous errors
diff --git a/src/test/ui/parser/issue-72253.rs b/src/test/ui/parser/issue-72253.rs
index 6f9af73..1446a79 100644
--- a/src/test/ui/parser/issue-72253.rs
+++ b/src/test/ui/parser/issue-72253.rs
@@ -1,6 +1,6 @@
fn main() {
let a = std::process::Command::new("echo")
.arg("1")
- ,arg("2") //~ ERROR expected one of `.`, `;`, `?`, or an operator, found `,`
+ ,arg("2") //~ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `,`
.output();
}
diff --git a/src/test/ui/parser/issue-72253.stderr b/src/test/ui/parser/issue-72253.stderr
index 3819fd9..477fa09 100644
--- a/src/test/ui/parser/issue-72253.stderr
+++ b/src/test/ui/parser/issue-72253.stderr
@@ -1,8 +1,8 @@
-error: expected one of `.`, `;`, `?`, or an operator, found `,`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `,`
--> $DIR/issue-72253.rs:4:9
|
LL | .arg("1")
- | - expected one of `.`, `;`, `?`, or an operator
+ | - expected one of `.`, `;`, `?`, `else`, or an operator
LL | ,arg("2")
| ^ unexpected token
diff --git a/src/test/ui/parser/issue-84117.rs b/src/test/ui/parser/issue-84117.rs
index 0f20073..9195858 100644
--- a/src/test/ui/parser/issue-84117.rs
+++ b/src/test/ui/parser/issue-84117.rs
@@ -2,8 +2,8 @@
let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
//~^ ERROR expected one of `>`, a const expression
//~| ERROR expected one of `>`, a const expression, lifetime, or type, found `}`
- //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
- //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
- //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
+ //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
+ //~| ERROR expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
}
//~^ ERROR expected one of `,`, `:`, `=`, or `>`, found `}`
diff --git a/src/test/ui/parser/issue-84117.stderr b/src/test/ui/parser/issue-84117.stderr
index d667a49..5b9cc53 100644
--- a/src/test/ui/parser/issue-84117.stderr
+++ b/src/test/ui/parser/issue-84117.stderr
@@ -7,11 +7,11 @@
| | help: use `=` if you meant to assign
| while parsing the type for `inner_local`
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
--> $DIR/issue-84117.rs:2:65
|
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ^ expected one of 7 possible tokens
+ | ^ expected one of 8 possible tokens
error: expected one of `,`, `:`, `=`, or `>`, found `}`
--> $DIR/issue-84117.rs:8:1
@@ -33,17 +33,17 @@
| | help: use `=` if you meant to assign
| while parsing the type for `inner_local`
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
--> $DIR/issue-84117.rs:2:65
|
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ^ expected one of 7 possible tokens
+ | ^ expected one of 8 possible tokens
-error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, or an operator, found `,`
+error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `,`
--> $DIR/issue-84117.rs:2:33
|
LL | let outer_local:e_outer<&str, { let inner_local:e_inner<&str, }
- | ^ expected one of 7 possible tokens
+ | ^ expected one of 8 possible tokens
error: aborting due to 6 previous errors
diff --git a/src/test/ui/parser/issue-87812-path.rs b/src/test/ui/parser/issue-87812-path.rs
new file mode 100644
index 0000000..b887808
--- /dev/null
+++ b/src/test/ui/parser/issue-87812-path.rs
@@ -0,0 +1,11 @@
+macro_rules! foo {
+ ( $f:path ) => {{
+ let _: usize = $f; //~ERROR
+ }};
+}
+
+struct Baz;
+
+fn main() {
+ foo!(Baz);
+}
diff --git a/src/test/ui/parser/issue-87812-path.stderr b/src/test/ui/parser/issue-87812-path.stderr
new file mode 100644
index 0000000..0c8e6fd
--- /dev/null
+++ b/src/test/ui/parser/issue-87812-path.stderr
@@ -0,0 +1,16 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-87812-path.rs:3:24
+ |
+LL | let _: usize = $f;
+ | ----- ^^ expected `usize`, found struct `Baz`
+ | |
+ | expected due to this
+...
+LL | foo!(Baz);
+ | ---------- in this macro invocation
+ |
+ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/parser/issue-87812.rs b/src/test/ui/parser/issue-87812.rs
new file mode 100644
index 0000000..0ba87b9
--- /dev/null
+++ b/src/test/ui/parser/issue-87812.rs
@@ -0,0 +1,13 @@
+#![deny(break_with_label_and_loop)]
+
+macro_rules! foo {
+ ( $f:block ) => {
+ '_l: loop {
+ break '_l $f; //~ERROR
+ }
+ };
+}
+
+fn main() {
+ let x = foo!({ 3 });
+}
diff --git a/src/test/ui/parser/issue-87812.stderr b/src/test/ui/parser/issue-87812.stderr
new file mode 100644
index 0000000..d61ee23
--- /dev/null
+++ b/src/test/ui/parser/issue-87812.stderr
@@ -0,0 +1,22 @@
+error: this labeled break expression is easy to confuse with an unlabeled break with a labeled value expression
+ --> $DIR/issue-87812.rs:6:13
+ |
+LL | break '_l $f;
+ | ^^^^^^^^^^^^
+...
+LL | let x = foo!({ 3 });
+ | ----------- in this macro invocation
+ |
+note: the lint level is defined here
+ --> $DIR/issue-87812.rs:1:9
+ |
+LL | #![deny(break_with_label_and_loop)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^
+ = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: wrap this expression in parentheses
+ |
+LL | break '_l ($f);
+ | + +
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/parser/macro/issue-37234.stderr b/src/test/ui/parser/macro/issue-37234.stderr
index f0ec79e..8d9636d 100644
--- a/src/test/ui/parser/macro/issue-37234.stderr
+++ b/src/test/ui/parser/macro/issue-37234.stderr
@@ -1,8 +1,8 @@
-error: expected one of `.`, `;`, `?`, or an operator, found `""`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `""`
--> $DIR/issue-37234.rs:3:19
|
LL | let x = 5 "";
- | ^^ expected one of `.`, `;`, `?`, or an operator
+ | ^^ expected one of `.`, `;`, `?`, `else`, or an operator
...
LL | failed!();
| ---------- in this macro invocation
diff --git a/src/test/ui/parser/missing-semicolon.rs b/src/test/ui/parser/missing-semicolon.rs
index a24dfa7..f68d177 100644
--- a/src/test/ui/parser/missing-semicolon.rs
+++ b/src/test/ui/parser/missing-semicolon.rs
@@ -1,6 +1,6 @@
macro_rules! m {
($($e1:expr),*; $($e2:expr),*) => {
- $( let x = $e1 )*; //~ ERROR expected one of `.`, `;`, `?`, or
+ $( let x = $e1 )*; //~ ERROR expected one of `.`, `;`, `?`, `else`, or
$( println!("{}", $e2) )*;
}
}
diff --git a/src/test/ui/parser/missing-semicolon.stderr b/src/test/ui/parser/missing-semicolon.stderr
index 68f0f44..72f76b6 100644
--- a/src/test/ui/parser/missing-semicolon.stderr
+++ b/src/test/ui/parser/missing-semicolon.stderr
@@ -1,8 +1,8 @@
-error: expected one of `.`, `;`, `?`, or an operator, found keyword `let`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found keyword `let`
--> $DIR/missing-semicolon.rs:3:12
|
LL | $( let x = $e1 )*;
- | ^^^ expected one of `.`, `;`, `?`, or an operator
+ | ^^^ expected one of `.`, `;`, `?`, `else`, or an operator
...
LL | fn main() { m!(0, 0; 0, 0); }
| --------------- in this macro invocation
diff --git a/src/test/ui/parser/range-3.rs b/src/test/ui/parser/range-3.rs
index 931839f..2c917a2 100644
--- a/src/test/ui/parser/range-3.rs
+++ b/src/test/ui/parser/range-3.rs
@@ -2,5 +2,5 @@
pub fn main() {
let r = 1..2..3;
- //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..`
+ //~^ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `..`
}
diff --git a/src/test/ui/parser/range-3.stderr b/src/test/ui/parser/range-3.stderr
index f866ea5..340167f 100644
--- a/src/test/ui/parser/range-3.stderr
+++ b/src/test/ui/parser/range-3.stderr
@@ -1,8 +1,8 @@
-error: expected one of `.`, `;`, `?`, or an operator, found `..`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `..`
--> $DIR/range-3.rs:4:17
|
LL | let r = 1..2..3;
- | ^^ expected one of `.`, `;`, `?`, or an operator
+ | ^^ expected one of `.`, `;`, `?`, `else`, or an operator
error: aborting due to previous error
diff --git a/src/test/ui/parser/range-4.rs b/src/test/ui/parser/range-4.rs
index 20af956..c970c96 100644
--- a/src/test/ui/parser/range-4.rs
+++ b/src/test/ui/parser/range-4.rs
@@ -2,5 +2,5 @@
pub fn main() {
let r = ..1..2;
- //~^ ERROR expected one of `.`, `;`, `?`, or an operator, found `..`
+ //~^ ERROR expected one of `.`, `;`, `?`, `else`, or an operator, found `..`
}
diff --git a/src/test/ui/parser/range-4.stderr b/src/test/ui/parser/range-4.stderr
index dcb8517..720d489 100644
--- a/src/test/ui/parser/range-4.stderr
+++ b/src/test/ui/parser/range-4.stderr
@@ -1,8 +1,8 @@
-error: expected one of `.`, `;`, `?`, or an operator, found `..`
+error: expected one of `.`, `;`, `?`, `else`, or an operator, found `..`
--> $DIR/range-4.rs:4:16
|
LL | let r = ..1..2;
- | ^^ expected one of `.`, `;`, `?`, or an operator
+ | ^^ expected one of `.`, `;`, `?`, `else`, or an operator
error: aborting due to previous error
diff --git a/src/test/ui/parser/trait-object-delimiters.rs b/src/test/ui/parser/trait-object-delimiters.rs
index 650ab57..b5258ee 100644
--- a/src/test/ui/parser/trait-object-delimiters.rs
+++ b/src/test/ui/parser/trait-object-delimiters.rs
@@ -6,7 +6,7 @@ fn foo1(_: &dyn Drop + AsRef<str>) {} //~ ERROR ambiguous `+` in a type
fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect braces around trait bounds
fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{`
-//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `for`, lifetime, or path, found `{`
+//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
//~| ERROR at least one trait is required for an object type
fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<`
diff --git a/src/test/ui/parser/trait-object-delimiters.stderr b/src/test/ui/parser/trait-object-delimiters.stderr
index 1ae0205..ee638d8 100644
--- a/src/test/ui/parser/trait-object-delimiters.stderr
+++ b/src/test/ui/parser/trait-object-delimiters.stderr
@@ -22,11 +22,11 @@
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
| ^ expected parameter name
-error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, lifetime, or path, found `{`
+error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `{`
--> $DIR/trait-object-delimiters.rs:8:17
|
LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {}
- | -^ expected one of 8 possible tokens
+ | -^ expected one of 9 possible tokens
| |
| help: missing `,`
diff --git a/src/test/ui/pattern/usefulness/top-level-alternation.rs b/src/test/ui/pattern/usefulness/top-level-alternation.rs
index 4b47b97..076de84 100644
--- a/src/test/ui/pattern/usefulness/top-level-alternation.rs
+++ b/src/test/ui/pattern/usefulness/top-level-alternation.rs
@@ -1,3 +1,5 @@
+#![feature(let_else)]
+
#![deny(unreachable_patterns)]
fn main() {
@@ -53,4 +55,5 @@ fn main() {
1..=2 => {}, //~ ERROR unreachable pattern
_ => {},
}
+ let (0 | 0) = 0 else { return }; //~ ERROR unreachable pattern
}
diff --git a/src/test/ui/pattern/usefulness/top-level-alternation.stderr b/src/test/ui/pattern/usefulness/top-level-alternation.stderr
index 76bc4f8..dd5936f 100644
--- a/src/test/ui/pattern/usefulness/top-level-alternation.stderr
+++ b/src/test/ui/pattern/usefulness/top-level-alternation.stderr
@@ -1,68 +1,74 @@
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:4:23
+ --> $DIR/top-level-alternation.rs:6:23
|
LL | while let 0..=2 | 1 = 0 {}
| ^
|
note: the lint level is defined here
- --> $DIR/top-level-alternation.rs:1:9
+ --> $DIR/top-level-alternation.rs:3:9
|
LL | #![deny(unreachable_patterns)]
| ^^^^^^^^^^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:5:20
+ --> $DIR/top-level-alternation.rs:7:20
|
LL | if let 0..=2 | 1 = 0 {}
| ^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:9:15
+ --> $DIR/top-level-alternation.rs:11:15
|
LL | | 0 => {}
| ^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:14:15
+ --> $DIR/top-level-alternation.rs:16:15
|
LL | | Some(0) => {}
| ^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:19:9
+ --> $DIR/top-level-alternation.rs:21:9
|
LL | (0, 0) => {}
| ^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:39:9
+ --> $DIR/top-level-alternation.rs:41:9
|
LL | _ => {}
| ^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:43:9
+ --> $DIR/top-level-alternation.rs:45:9
|
LL | Some(_) => {}
| ^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:44:9
+ --> $DIR/top-level-alternation.rs:46:9
|
LL | None => {}
| ^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:49:9
+ --> $DIR/top-level-alternation.rs:51:9
|
LL | None | Some(_) => {}
| ^^^^^^^^^^^^^^
error: unreachable pattern
- --> $DIR/top-level-alternation.rs:53:9
+ --> $DIR/top-level-alternation.rs:55:9
|
LL | 1..=2 => {},
| ^^^^^
-error: aborting due to 10 previous errors
+error: unreachable pattern
+ --> $DIR/top-level-alternation.rs:58:14
+ |
+LL | let (0 | 0) = 0 else { return };
+ | ^
+
+error: aborting due to 11 previous errors
diff --git a/src/test/ui/polymorphization/const_parameters/closures.rs b/src/test/ui/polymorphization/const_parameters/closures.rs
index f20605e..2f41beeb 100644
--- a/src/test/ui/polymorphization/const_parameters/closures.rs
+++ b/src/test/ui/polymorphization/const_parameters/closures.rs
@@ -1,7 +1,7 @@
// build-fail
// compile-flags:-Zpolymorphize=on
-#![feature(const_generics, rustc_attrs)]
-//~^ WARN the feature `const_generics` is incomplete
+#![feature(generic_const_exprs, rustc_attrs)]
+//~^ WARN the feature `generic_const_exprs` is incomplete
// This test checks that the polymorphization analysis correctly detects unused const
// parameters in closures.
diff --git a/src/test/ui/polymorphization/const_parameters/closures.stderr b/src/test/ui/polymorphization/const_parameters/closures.stderr
index 266b6e6..d0ee893 100644
--- a/src/test/ui/polymorphization/const_parameters/closures.stderr
+++ b/src/test/ui/polymorphization/const_parameters/closures.stderr
@@ -1,11 +1,11 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/closures.rs:3:12
|
-LL | #![feature(const_generics, rustc_attrs)]
- | ^^^^^^^^^^^^^^
+LL | #![feature(generic_const_exprs, rustc_attrs)]
+ | ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
error: item has unused generic parameters
--> $DIR/closures.rs:19:19
diff --git a/src/test/ui/polymorphization/const_parameters/functions.rs b/src/test/ui/polymorphization/const_parameters/functions.rs
index 04c279d..cbc1b63 100644
--- a/src/test/ui/polymorphization/const_parameters/functions.rs
+++ b/src/test/ui/polymorphization/const_parameters/functions.rs
@@ -1,7 +1,7 @@
// build-fail
// compile-flags:-Zpolymorphize=on
-#![feature(const_generics, rustc_attrs)]
-//~^ WARN the feature `const_generics` is incomplete
+#![feature(generic_const_exprs, rustc_attrs)]
+//~^ WARN the feature `generic_const_exprs` is incomplete
// This test checks that the polymorphization analysis correctly detects unused const
// parameters in functions.
diff --git a/src/test/ui/polymorphization/const_parameters/functions.stderr b/src/test/ui/polymorphization/const_parameters/functions.stderr
index e379e32..03d0bbb 100644
--- a/src/test/ui/polymorphization/const_parameters/functions.stderr
+++ b/src/test/ui/polymorphization/const_parameters/functions.stderr
@@ -1,11 +1,11 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/functions.rs:3:12
|
-LL | #![feature(const_generics, rustc_attrs)]
- | ^^^^^^^^^^^^^^
+LL | #![feature(generic_const_exprs, rustc_attrs)]
+ | ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
error: item has unused generic parameters
--> $DIR/functions.rs:15:8
diff --git a/src/test/ui/polymorphization/generators.rs b/src/test/ui/polymorphization/generators.rs
index 9eb34fb..f295cf1 100644
--- a/src/test/ui/polymorphization/generators.rs
+++ b/src/test/ui/polymorphization/generators.rs
@@ -1,7 +1,7 @@
// build-fail
// compile-flags:-Zpolymorphize=on
-#![feature(const_generics, generators, generator_trait, rustc_attrs)]
-//~^ WARN the feature `const_generics` is incomplete
+#![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)]
+//~^ WARN the feature `generic_const_exprs` is incomplete
use std::marker::Unpin;
use std::ops::{Generator, GeneratorState};
diff --git a/src/test/ui/polymorphization/generators.stderr b/src/test/ui/polymorphization/generators.stderr
index c59055b..c4e566a 100644
--- a/src/test/ui/polymorphization/generators.stderr
+++ b/src/test/ui/polymorphization/generators.stderr
@@ -1,11 +1,11 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/generators.rs:3:12
|
-LL | #![feature(const_generics, generators, generator_trait, rustc_attrs)]
- | ^^^^^^^^^^^^^^
+LL | #![feature(generic_const_exprs, generators, generator_trait, rustc_attrs)]
+ | ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
error: item has unused generic parameters
--> $DIR/generators.rs:36:5
diff --git a/src/test/ui/polymorphization/promoted-function-2.rs b/src/test/ui/polymorphization/promoted-function-2.rs
index 2831f86..d2d0f33 100644
--- a/src/test/ui/polymorphization/promoted-function-2.rs
+++ b/src/test/ui/polymorphization/promoted-function-2.rs
@@ -1,8 +1,8 @@
// build-fail
// compile-flags:-Zpolymorphize=on
#![crate_type = "lib"]
-#![feature(lazy_normalization_consts, rustc_attrs)]
-//~^ WARN the feature `lazy_normalization_consts` is incomplete
+#![feature(generic_const_exprs, rustc_attrs)]
+//~^ WARN the feature `generic_const_exprs` is incomplete
#[rustc_polymorphize_error]
fn test<T>() {
diff --git a/src/test/ui/polymorphization/promoted-function-2.stderr b/src/test/ui/polymorphization/promoted-function-2.stderr
index 38d4808..4d7bab6 100644
--- a/src/test/ui/polymorphization/promoted-function-2.stderr
+++ b/src/test/ui/polymorphization/promoted-function-2.stderr
@@ -1,11 +1,11 @@
-warning: the feature `lazy_normalization_consts` is incomplete and may not be safe to use and/or cause compiler crashes
+warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/promoted-function-2.rs:4:12
|
-LL | #![feature(lazy_normalization_consts, rustc_attrs)]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #![feature(generic_const_exprs, rustc_attrs)]
+ | ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
- = note: see issue #72219 <https://github.com/rust-lang/rust/issues/72219> for more information
+ = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
error: item has unused generic parameters
--> $DIR/promoted-function-2.rs:8:4
diff --git a/src/test/ui/proc-macro/crt-static.rs b/src/test/ui/proc-macro/crt-static.rs
index 4f11f81..8c1a9dc 100644
--- a/src/test/ui/proc-macro/crt-static.rs
+++ b/src/test/ui/proc-macro/crt-static.rs
@@ -1,12 +1,19 @@
// Test proc-macro crate can be built without additional RUSTFLAGS
// on musl target
// override -Ctarget-feature=-crt-static from compiletest
-// compile-flags: -Ctarget-feature=
+// compile-flags: --crate-type proc-macro -Ctarget-feature=
// ignore-wasm32
// ignore-sgx no support for proc-macro crate type
// build-pass
#![crate_type = "proc-macro"]
+// FIXME: This don't work when crate-type is specified by attribute
+// `#![crate_type = "proc-macro"]`, not by `--crate-type=proc-macro`
+// command line flag. This is beacuse the list of `cfg` symbols is generated
+// before attributes are parsed. See rustc_interface::util::add_configuration
+#[cfg(target_feature = "crt-static")]
+compile_error!("crt-static is enabled");
+
extern crate proc_macro;
use proc_macro::TokenStream;
diff --git a/src/test/ui/resolve/issue-23305.stderr b/src/test/ui/resolve/issue-23305.stderr
index 525b5cf..0dcf018 100644
--- a/src/test/ui/resolve/issue-23305.stderr
+++ b/src/test/ui/resolve/issue-23305.stderr
@@ -4,7 +4,7 @@
LL | impl dyn ToNbt<Self> {}
| ^^^^
|
- = note: ...which again requires computing type of `<impl at $DIR/issue-23305.rs:5:1: 5:24>`, completing the cycle
+ = note: ...which immediately requires computing type of `<impl at $DIR/issue-23305.rs:5:1: 5:24>` again
note: cycle used when collecting item types in top-level module
--> $DIR/issue-23305.rs:1:1
|
diff --git a/src/test/ui/resolve/issue-65035-static-with-parent-generics.rs b/src/test/ui/resolve/issue-65035-static-with-parent-generics.rs
index f09ab3b..f96c048 100644
--- a/src/test/ui/resolve/issue-65035-static-with-parent-generics.rs
+++ b/src/test/ui/resolve/issue-65035-static-with-parent-generics.rs
@@ -1,6 +1,3 @@
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
-
fn f<T>() {
extern "C" {
static a: *const T;
diff --git a/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr b/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr
index 7f8151d..7ed572f 100644
--- a/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr
+++ b/src/test/ui/resolve/issue-65035-static-with-parent-generics.stderr
@@ -1,5 +1,5 @@
error[E0401]: can't use generic parameters from outer function
- --> $DIR/issue-65035-static-with-parent-generics.rs:6:26
+ --> $DIR/issue-65035-static-with-parent-generics.rs:3:26
|
LL | fn f<T>() {
| - type parameter from outer function
@@ -8,7 +8,7 @@
| ^ use of generic parameter from outer function
error[E0401]: can't use generic parameters from outer function
- --> $DIR/issue-65035-static-with-parent-generics.rs:12:22
+ --> $DIR/issue-65035-static-with-parent-generics.rs:9:22
|
LL | fn g<T: Default>() {
| - type parameter from outer function
@@ -16,7 +16,7 @@
| ^ use of generic parameter from outer function
error[E0401]: can't use generic parameters from outer function
- --> $DIR/issue-65035-static-with-parent-generics.rs:18:24
+ --> $DIR/issue-65035-static-with-parent-generics.rs:15:24
|
LL | fn h<const N: usize>() {
| - const parameter from outer function
@@ -25,7 +25,7 @@
| ^ use of generic parameter from outer function
error[E0401]: can't use generic parameters from outer function
- --> $DIR/issue-65035-static-with-parent-generics.rs:24:20
+ --> $DIR/issue-65035-static-with-parent-generics.rs:21:20
|
LL | fn i<const N: usize>() {
| - const parameter from outer function
@@ -33,22 +33,13 @@
| ^ use of generic parameter from outer function
error[E0401]: can't use generic parameters from outer function
- --> $DIR/issue-65035-static-with-parent-generics.rs:24:29
+ --> $DIR/issue-65035-static-with-parent-generics.rs:21:29
|
LL | fn i<const N: usize>() {
| - const parameter from outer function
LL | static a: [u8; N] = [0; N];
| ^ use of generic parameter from outer function
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-65035-static-with-parent-generics.rs:1:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-error: aborting due to 5 previous errors; 1 warning emitted
+error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0401`.
diff --git a/src/test/ui/resolve/resolve-self-in-impl.stderr b/src/test/ui/resolve/resolve-self-in-impl.stderr
index 5b5c183..7f623e4 100644
--- a/src/test/ui/resolve/resolve-self-in-impl.stderr
+++ b/src/test/ui/resolve/resolve-self-in-impl.stderr
@@ -4,7 +4,7 @@
LL | impl Tr for Self {}
| ^^^^
|
- = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:14:1: 14:20>`, completing the cycle
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:14:1: 14:20>` again
note: cycle used when collecting item types in top-level module
--> $DIR/resolve-self-in-impl.rs:1:1
|
@@ -23,7 +23,7 @@
LL | impl Tr for S<Self> {}
| ^^^^
|
- = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:15:1: 15:23>`, completing the cycle
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:15:1: 15:23>` again
note: cycle used when collecting item types in top-level module
--> $DIR/resolve-self-in-impl.rs:1:1
|
@@ -42,7 +42,7 @@
LL | impl Self {}
| ^^^^
|
- = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:16:1: 16:13>`, completing the cycle
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:16:1: 16:13>` again
note: cycle used when collecting item types in top-level module
--> $DIR/resolve-self-in-impl.rs:1:1
|
@@ -61,7 +61,7 @@
LL | impl S<Self> {}
| ^^^^
|
- = note: ...which again requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:17:1: 17:16>`, completing the cycle
+ = note: ...which immediately requires computing type of `<impl at $DIR/resolve-self-in-impl.rs:17:1: 17:16>` again
note: cycle used when collecting item types in top-level module
--> $DIR/resolve-self-in-impl.rs:1:1
|
@@ -80,7 +80,7 @@
LL | impl Tr<Self::A> for S {}
| ^^^^^^^^^^^^^^^^^^^^^^
|
- = note: ...which again requires computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:18:1: 18:26>`, completing the cycle
+ = note: ...which immediately requires computing trait implemented by `<impl at $DIR/resolve-self-in-impl.rs:18:1: 18:26>` again
note: cycle used when collecting item types in top-level module
--> $DIR/resolve-self-in-impl.rs:1:1
|
diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs
index b3c9246..b0b3464 100644
--- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs
+++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs
@@ -17,8 +17,6 @@
//
// To that end, we check some positions which is not part of the language above.
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
#![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test.
//~^ WARN the feature `let_chains` is incomplete
diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
index b48915a..5ec4352 100644
--- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
+++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
@@ -1,5 +1,5 @@
error: expressions must be enclosed in braces to be used as const generic arguments
- --> $DIR/disallowed-positions.rs:235:9
+ --> $DIR/disallowed-positions.rs:233:9
|
LL | true && let 1 = 1
| ^^^^^^^^^^^^^^^^^
@@ -10,7 +10,7 @@
| + +
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:32:9
+ --> $DIR/disallowed-positions.rs:30:9
|
LL | if &let 0 = 0 {}
| ^^^^^^^^^
@@ -19,7 +19,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:35:9
+ --> $DIR/disallowed-positions.rs:33:9
|
LL | if !let 0 = 0 {}
| ^^^^^^^^^
@@ -28,7 +28,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:36:9
+ --> $DIR/disallowed-positions.rs:34:9
|
LL | if *let 0 = 0 {}
| ^^^^^^^^^
@@ -37,7 +37,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:38:9
+ --> $DIR/disallowed-positions.rs:36:9
|
LL | if -let 0 = 0 {}
| ^^^^^^^^^
@@ -46,7 +46,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:46:9
+ --> $DIR/disallowed-positions.rs:44:9
|
LL | if (let 0 = 0)? {}
| ^^^^^^^^^
@@ -55,7 +55,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:50:16
+ --> $DIR/disallowed-positions.rs:48:16
|
LL | if true || let 0 = 0 {}
| ^^^^^^^^^
@@ -64,7 +64,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:51:17
+ --> $DIR/disallowed-positions.rs:49:17
|
LL | if (true || let 0 = 0) {}
| ^^^^^^^^^
@@ -73,7 +73,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:52:25
+ --> $DIR/disallowed-positions.rs:50:25
|
LL | if true && (true || let 0 = 0) {}
| ^^^^^^^^^
@@ -82,7 +82,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:53:25
+ --> $DIR/disallowed-positions.rs:51:25
|
LL | if true || (true && let 0 = 0) {}
| ^^^^^^^^^
@@ -91,7 +91,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:56:12
+ --> $DIR/disallowed-positions.rs:54:12
|
LL | if x = let 0 = 0 {}
| ^^^^^^^^^
@@ -100,7 +100,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:59:15
+ --> $DIR/disallowed-positions.rs:57:15
|
LL | if true..(let 0 = 0) {}
| ^^^^^^^^^
@@ -109,7 +109,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:61:11
+ --> $DIR/disallowed-positions.rs:59:11
|
LL | if ..(let 0 = 0) {}
| ^^^^^^^^^
@@ -118,7 +118,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:63:9
+ --> $DIR/disallowed-positions.rs:61:9
|
LL | if (let 0 = 0).. {}
| ^^^^^^^^^
@@ -127,7 +127,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:67:8
+ --> $DIR/disallowed-positions.rs:65:8
|
LL | if let Range { start: _, end: _ } = true..true && false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -136,7 +136,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:71:8
+ --> $DIR/disallowed-positions.rs:69:8
|
LL | if let Range { start: _, end: _ } = true..true || false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -145,7 +145,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:78:8
+ --> $DIR/disallowed-positions.rs:76:8
|
LL | if let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -154,7 +154,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:86:8
+ --> $DIR/disallowed-positions.rs:84:8
|
LL | if let Range { start: true, end } = t..&&false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -163,7 +163,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:92:19
+ --> $DIR/disallowed-positions.rs:90:19
|
LL | if let true = let true = true {}
| ^^^^^^^^^^^^^^^
@@ -172,7 +172,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:96:12
+ --> $DIR/disallowed-positions.rs:94:12
|
LL | while &let 0 = 0 {}
| ^^^^^^^^^
@@ -181,7 +181,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:99:12
+ --> $DIR/disallowed-positions.rs:97:12
|
LL | while !let 0 = 0 {}
| ^^^^^^^^^
@@ -190,7 +190,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:100:12
+ --> $DIR/disallowed-positions.rs:98:12
|
LL | while *let 0 = 0 {}
| ^^^^^^^^^
@@ -199,7 +199,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:102:12
+ --> $DIR/disallowed-positions.rs:100:12
|
LL | while -let 0 = 0 {}
| ^^^^^^^^^
@@ -208,7 +208,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:110:12
+ --> $DIR/disallowed-positions.rs:108:12
|
LL | while (let 0 = 0)? {}
| ^^^^^^^^^
@@ -217,7 +217,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:114:19
+ --> $DIR/disallowed-positions.rs:112:19
|
LL | while true || let 0 = 0 {}
| ^^^^^^^^^
@@ -226,7 +226,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:115:20
+ --> $DIR/disallowed-positions.rs:113:20
|
LL | while (true || let 0 = 0) {}
| ^^^^^^^^^
@@ -235,7 +235,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:116:28
+ --> $DIR/disallowed-positions.rs:114:28
|
LL | while true && (true || let 0 = 0) {}
| ^^^^^^^^^
@@ -244,7 +244,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:117:28
+ --> $DIR/disallowed-positions.rs:115:28
|
LL | while true || (true && let 0 = 0) {}
| ^^^^^^^^^
@@ -253,7 +253,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:120:15
+ --> $DIR/disallowed-positions.rs:118:15
|
LL | while x = let 0 = 0 {}
| ^^^^^^^^^
@@ -262,7 +262,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:123:18
+ --> $DIR/disallowed-positions.rs:121:18
|
LL | while true..(let 0 = 0) {}
| ^^^^^^^^^
@@ -271,7 +271,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:125:14
+ --> $DIR/disallowed-positions.rs:123:14
|
LL | while ..(let 0 = 0) {}
| ^^^^^^^^^
@@ -280,7 +280,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:127:12
+ --> $DIR/disallowed-positions.rs:125:12
|
LL | while (let 0 = 0).. {}
| ^^^^^^^^^
@@ -289,7 +289,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:131:11
+ --> $DIR/disallowed-positions.rs:129:11
|
LL | while let Range { start: _, end: _ } = true..true && false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -298,7 +298,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:135:11
+ --> $DIR/disallowed-positions.rs:133:11
|
LL | while let Range { start: _, end: _ } = true..true || false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -307,7 +307,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:142:11
+ --> $DIR/disallowed-positions.rs:140:11
|
LL | while let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -316,7 +316,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:150:11
+ --> $DIR/disallowed-positions.rs:148:11
|
LL | while let Range { start: true, end } = t..&&false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -325,7 +325,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:156:22
+ --> $DIR/disallowed-positions.rs:154:22
|
LL | while let true = let true = true {}
| ^^^^^^^^^^^^^^^
@@ -334,7 +334,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:170:6
+ --> $DIR/disallowed-positions.rs:168:6
|
LL | &let 0 = 0;
| ^^^^^^^^^
@@ -343,7 +343,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:172:6
+ --> $DIR/disallowed-positions.rs:170:6
|
LL | !let 0 = 0;
| ^^^^^^^^^
@@ -352,7 +352,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:173:6
+ --> $DIR/disallowed-positions.rs:171:6
|
LL | *let 0 = 0;
| ^^^^^^^^^
@@ -361,7 +361,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:175:6
+ --> $DIR/disallowed-positions.rs:173:6
|
LL | -let 0 = 0;
| ^^^^^^^^^
@@ -370,7 +370,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:183:6
+ --> $DIR/disallowed-positions.rs:181:6
|
LL | (let 0 = 0)?;
| ^^^^^^^^^
@@ -379,7 +379,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:187:13
+ --> $DIR/disallowed-positions.rs:185:13
|
LL | true || let 0 = 0;
| ^^^^^^^^^
@@ -388,7 +388,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:188:14
+ --> $DIR/disallowed-positions.rs:186:14
|
LL | (true || let 0 = 0);
| ^^^^^^^^^
@@ -397,7 +397,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:189:22
+ --> $DIR/disallowed-positions.rs:187:22
|
LL | true && (true || let 0 = 0);
| ^^^^^^^^^
@@ -406,7 +406,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:192:9
+ --> $DIR/disallowed-positions.rs:190:9
|
LL | x = let 0 = 0;
| ^^^^^^^^^
@@ -415,7 +415,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:194:12
+ --> $DIR/disallowed-positions.rs:192:12
|
LL | true..(let 0 = 0);
| ^^^^^^^^^
@@ -424,7 +424,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:195:8
+ --> $DIR/disallowed-positions.rs:193:8
|
LL | ..(let 0 = 0);
| ^^^^^^^^^
@@ -433,7 +433,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:196:6
+ --> $DIR/disallowed-positions.rs:194:6
|
LL | (let 0 = 0)..;
| ^^^^^^^^^
@@ -442,7 +442,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:198:6
+ --> $DIR/disallowed-positions.rs:196:6
|
LL | (let Range { start: _, end: _ } = true..true || false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -451,7 +451,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:202:6
+ --> $DIR/disallowed-positions.rs:200:6
|
LL | (let true = let true = true);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -460,7 +460,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:206:6
+ --> $DIR/disallowed-positions.rs:204:6
|
LL | &let 0 = 0
| ^^^^^^^^^
@@ -469,7 +469,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:217:17
+ --> $DIR/disallowed-positions.rs:215:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
@@ -478,7 +478,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:221:17
+ --> $DIR/disallowed-positions.rs:219:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
@@ -487,7 +487,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:225:17
+ --> $DIR/disallowed-positions.rs:223:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
@@ -496,7 +496,7 @@
= note: as well as when nested within `&&` and parenthesis in those conditions
error: `let` expressions are not supported here
- --> $DIR/disallowed-positions.rs:235:17
+ --> $DIR/disallowed-positions.rs:233:17
|
LL | true && let 1 = 1
| ^^^^^^^^^
@@ -504,25 +504,17 @@
= note: only supported directly in conditions of `if`- and `while`-expressions
= note: as well as when nested within `&&` and parenthesis in those conditions
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/disallowed-positions.rs:20:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
warning: the feature `let_chains` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/disallowed-positions.rs:22:12
+ --> $DIR/disallowed-positions.rs:20:12
|
LL | #![feature(let_chains)] // Avoid inflating `.stderr` with overzealous gates in this test.
| ^^^^^^^^^^
|
+ = note: `#[warn(incomplete_features)]` on by default
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:32:8
+ --> $DIR/disallowed-positions.rs:30:8
|
LL | if &let 0 = 0 {}
| ^^^^^^^^^^ expected `bool`, found `&bool`
@@ -534,19 +526,19 @@
|
error[E0614]: type `bool` cannot be dereferenced
- --> $DIR/disallowed-positions.rs:36:8
+ --> $DIR/disallowed-positions.rs:34:8
|
LL | if *let 0 = 0 {}
| ^^^^^^^^^^
error[E0600]: cannot apply unary operator `-` to type `bool`
- --> $DIR/disallowed-positions.rs:38:8
+ --> $DIR/disallowed-positions.rs:36:8
|
LL | if -let 0 = 0 {}
| ^^^^^^^^^^ cannot apply unary operator `-`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/disallowed-positions.rs:46:8
+ --> $DIR/disallowed-positions.rs:44:8
|
LL | if (let 0 = 0)? {}
| ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
@@ -559,7 +551,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
- --> $DIR/disallowed-positions.rs:46:19
+ --> $DIR/disallowed-positions.rs:44:19
|
LL | / fn nested_within_if_expr() {
LL | | if &let 0 = 0 {}
@@ -581,7 +573,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:56:8
+ --> $DIR/disallowed-positions.rs:54:8
|
LL | if x = let 0 = 0 {}
| ^^^^^^^^^^^^^ expected `bool`, found `()`
@@ -592,7 +584,7 @@
| ~~
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:59:8
+ --> $DIR/disallowed-positions.rs:57:8
|
LL | if true..(let 0 = 0) {}
| ^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -601,7 +593,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:61:8
+ --> $DIR/disallowed-positions.rs:59:8
|
LL | if ..(let 0 = 0) {}
| ^^^^^^^^^^^^^ expected `bool`, found struct `RangeTo`
@@ -610,7 +602,7 @@
found struct `RangeTo<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:63:8
+ --> $DIR/disallowed-positions.rs:61:8
|
LL | if (let 0 = 0).. {}
| ^^^^^^^^^^^^^ expected `bool`, found struct `RangeFrom`
@@ -619,7 +611,7 @@
found struct `RangeFrom<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:67:12
+ --> $DIR/disallowed-positions.rs:65:12
|
LL | if let Range { start: _, end: _ } = true..true && false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
@@ -630,7 +622,7 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:67:8
+ --> $DIR/disallowed-positions.rs:65:8
|
LL | if let Range { start: _, end: _ } = true..true && false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -639,7 +631,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:71:12
+ --> $DIR/disallowed-positions.rs:69:12
|
LL | if let Range { start: _, end: _ } = true..true || false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
@@ -650,7 +642,7 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:71:8
+ --> $DIR/disallowed-positions.rs:69:8
|
LL | if let Range { start: _, end: _ } = true..true || false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -659,7 +651,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:78:12
+ --> $DIR/disallowed-positions.rs:76:12
|
LL | if let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found struct `std::ops::Range`
@@ -668,16 +660,16 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:78:41
+ --> $DIR/disallowed-positions.rs:76:41
|
LL | if let Range { start: F, end } = F..|| true {}
| ^^^^^^^ expected `bool`, found closure
|
= note: expected type `bool`
- found closure `[closure@$DIR/disallowed-positions.rs:78:41: 78:48]`
+ found closure `[closure@$DIR/disallowed-positions.rs:76:41: 76:48]`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:78:8
+ --> $DIR/disallowed-positions.rs:76:8
|
LL | if let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -686,7 +678,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:86:12
+ --> $DIR/disallowed-positions.rs:84:12
|
LL | if let Range { start: true, end } = t..&&false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool`
@@ -697,13 +689,13 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:86:44
+ --> $DIR/disallowed-positions.rs:84:44
|
LL | if let Range { start: true, end } = t..&&false {}
| ^^^^^^^ expected `bool`, found `&&bool`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:86:8
+ --> $DIR/disallowed-positions.rs:84:8
|
LL | if let Range { start: true, end } = t..&&false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -712,7 +704,7 @@
found struct `std::ops::Range<bool>`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/disallowed-positions.rs:42:20
+ --> $DIR/disallowed-positions.rs:40:20
|
LL | if let 0 = 0? {}
| ^^ the `?` operator cannot be applied to type `{integer}`
@@ -725,7 +717,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:96:11
+ --> $DIR/disallowed-positions.rs:94:11
|
LL | while &let 0 = 0 {}
| ^^^^^^^^^^ expected `bool`, found `&bool`
@@ -737,19 +729,19 @@
|
error[E0614]: type `bool` cannot be dereferenced
- --> $DIR/disallowed-positions.rs:100:11
+ --> $DIR/disallowed-positions.rs:98:11
|
LL | while *let 0 = 0 {}
| ^^^^^^^^^^
error[E0600]: cannot apply unary operator `-` to type `bool`
- --> $DIR/disallowed-positions.rs:102:11
+ --> $DIR/disallowed-positions.rs:100:11
|
LL | while -let 0 = 0 {}
| ^^^^^^^^^^ cannot apply unary operator `-`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/disallowed-positions.rs:110:11
+ --> $DIR/disallowed-positions.rs:108:11
|
LL | while (let 0 = 0)? {}
| ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
@@ -762,7 +754,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
- --> $DIR/disallowed-positions.rs:110:22
+ --> $DIR/disallowed-positions.rs:108:22
|
LL | / fn nested_within_while_expr() {
LL | | while &let 0 = 0 {}
@@ -784,7 +776,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:120:11
+ --> $DIR/disallowed-positions.rs:118:11
|
LL | while x = let 0 = 0 {}
| ^^^^^^^^^^^^^ expected `bool`, found `()`
@@ -795,7 +787,7 @@
| ~~
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:123:11
+ --> $DIR/disallowed-positions.rs:121:11
|
LL | while true..(let 0 = 0) {}
| ^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -804,7 +796,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:125:11
+ --> $DIR/disallowed-positions.rs:123:11
|
LL | while ..(let 0 = 0) {}
| ^^^^^^^^^^^^^ expected `bool`, found struct `RangeTo`
@@ -813,7 +805,7 @@
found struct `RangeTo<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:127:11
+ --> $DIR/disallowed-positions.rs:125:11
|
LL | while (let 0 = 0).. {}
| ^^^^^^^^^^^^^ expected `bool`, found struct `RangeFrom`
@@ -822,7 +814,7 @@
found struct `RangeFrom<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:131:15
+ --> $DIR/disallowed-positions.rs:129:15
|
LL | while let Range { start: _, end: _ } = true..true && false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
@@ -833,7 +825,7 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:131:11
+ --> $DIR/disallowed-positions.rs:129:11
|
LL | while let Range { start: _, end: _ } = true..true && false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -842,7 +834,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:135:15
+ --> $DIR/disallowed-positions.rs:133:15
|
LL | while let Range { start: _, end: _ } = true..true || false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
@@ -853,7 +845,7 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:135:11
+ --> $DIR/disallowed-positions.rs:133:11
|
LL | while let Range { start: _, end: _ } = true..true || false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -862,7 +854,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:142:15
+ --> $DIR/disallowed-positions.rs:140:15
|
LL | while let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found struct `std::ops::Range`
@@ -871,16 +863,16 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:142:44
+ --> $DIR/disallowed-positions.rs:140:44
|
LL | while let Range { start: F, end } = F..|| true {}
| ^^^^^^^ expected `bool`, found closure
|
= note: expected type `bool`
- found closure `[closure@$DIR/disallowed-positions.rs:142:44: 142:51]`
+ found closure `[closure@$DIR/disallowed-positions.rs:140:44: 140:51]`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:142:11
+ --> $DIR/disallowed-positions.rs:140:11
|
LL | while let Range { start: F, end } = F..|| true {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -889,7 +881,7 @@
found struct `std::ops::Range<bool>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:150:15
+ --> $DIR/disallowed-positions.rs:148:15
|
LL | while let Range { start: true, end } = t..&&false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool`
@@ -900,13 +892,13 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:150:47
+ --> $DIR/disallowed-positions.rs:148:47
|
LL | while let Range { start: true, end } = t..&&false {}
| ^^^^^^^ expected `bool`, found `&&bool`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:150:11
+ --> $DIR/disallowed-positions.rs:148:11
|
LL | while let Range { start: true, end } = t..&&false {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found struct `std::ops::Range`
@@ -915,7 +907,7 @@
found struct `std::ops::Range<bool>`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/disallowed-positions.rs:106:23
+ --> $DIR/disallowed-positions.rs:104:23
|
LL | while let 0 = 0? {}
| ^^ the `?` operator cannot be applied to type `{integer}`
@@ -928,19 +920,19 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0614]: type `bool` cannot be dereferenced
- --> $DIR/disallowed-positions.rs:173:5
+ --> $DIR/disallowed-positions.rs:171:5
|
LL | *let 0 = 0;
| ^^^^^^^^^^
error[E0600]: cannot apply unary operator `-` to type `bool`
- --> $DIR/disallowed-positions.rs:175:5
+ --> $DIR/disallowed-positions.rs:173:5
|
LL | -let 0 = 0;
| ^^^^^^^^^^ cannot apply unary operator `-`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/disallowed-positions.rs:183:5
+ --> $DIR/disallowed-positions.rs:181:5
|
LL | (let 0 = 0)?;
| ^^^^^^^^^^^^ the `?` operator cannot be applied to type `bool`
@@ -953,7 +945,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
- --> $DIR/disallowed-positions.rs:183:16
+ --> $DIR/disallowed-positions.rs:181:16
|
LL | / fn outside_if_and_while_expr() {
LL | | &let 0 = 0;
@@ -975,7 +967,7 @@
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:198:10
+ --> $DIR/disallowed-positions.rs:196:10
|
LL | (let Range { start: _, end: _ } = true..true || false);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool`
@@ -986,7 +978,7 @@
found struct `std::ops::Range<_>`
error[E0308]: mismatched types
- --> $DIR/disallowed-positions.rs:206:5
+ --> $DIR/disallowed-positions.rs:204:5
|
LL | fn outside_if_and_while_expr() {
| - help: try adding a return type: `-> &bool`
@@ -995,7 +987,7 @@
| ^^^^^^^^^^ expected `()`, found `&bool`
error[E0277]: the `?` operator can only be applied to values that implement `Try`
- --> $DIR/disallowed-positions.rs:179:17
+ --> $DIR/disallowed-positions.rs:177:17
|
LL | let 0 = 0?;
| ^^ the `?` operator cannot be applied to type `{integer}`
@@ -1007,7 +999,7 @@
LL | fn branch(self) -> ControlFlow<Self::Residual, Self::Output>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 103 previous errors; 2 warnings emitted
+error: aborting due to 103 previous errors; 1 warning emitted
Some errors have detailed explanations: E0277, E0308, E0600, E0614.
For more information about an error, try `rustc --explain E0277`.
diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs
index 1dbd000..228b5ed 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.rs
@@ -1,7 +1,5 @@
// FIXME(fee1-dead): this should have a better error message
#![feature(const_trait_impl)]
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
struct NonConstAdd(i32);
@@ -14,7 +12,7 @@ fn add(self, rhs: Self) -> Self {
}
trait Foo {
- type Bar: std::ops::Add;
+ type Bar: ~const std::ops::Add;
}
impl const Foo for NonConstAdd {
@@ -23,7 +21,7 @@ impl const Foo for NonConstAdd {
}
trait Baz {
- type Qux: ?const std::ops::Add;
+ type Qux: std::ops::Add;
}
impl const Baz for NonConstAdd {
diff --git a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr
index ada29ba..b894092 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr
+++ b/src/test/ui/rfc-2632-const-trait-impl/assoc-type.stderr
@@ -1,15 +1,15 @@
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd`
- --> $DIR/assoc-type.rs:21:5
+ --> $DIR/assoc-type.rs:19:5
|
LL | type Bar = NonConstAdd;
| ^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
|
= help: the trait `Add` is not implemented for `NonConstAdd`
note: required by a bound in `Foo::Bar`
- --> $DIR/assoc-type.rs:17:15
+ --> $DIR/assoc-type.rs:15:15
|
-LL | type Bar: std::ops::Add;
- | ^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
+LL | type Bar: ~const std::ops::Add;
+ | ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
|
LL | impl const Foo for NonConstAdd where NonConstAdd: Add {
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs
index 536c1d7..4b706a1 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-in-impl.rs
@@ -6,7 +6,7 @@ trait MyPartialEq {
fn eq(&self, other: &Self) -> bool;
}
-impl<T: PartialEq> const MyPartialEq for T {
+impl<T: ~const PartialEq> const MyPartialEq for T {
fn eq(&self, other: &Self) -> bool {
PartialEq::eq(self, other)
}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs
index f3391aa..adf8d4f 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-chain.rs
@@ -16,11 +16,11 @@ fn ne(&self, other: &S) -> bool {
}
}
-const fn equals_self<T: PartialEq>(t: &T) -> bool {
+const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
*t == *t
}
-const fn equals_self_wrapper<T: PartialEq>(t: &T) -> bool {
+const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool {
equals_self(t)
}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs
index 00a3c7f..7185376 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-dup-bound.rs
@@ -1,9 +1,7 @@
// check-pass
#![feature(const_trait_impl)]
-#![feature(const_trait_bound_opt_out)]
#![feature(const_fn_trait_bound)]
-#![allow(incomplete_features)]
struct S;
@@ -16,9 +14,11 @@ fn ne(&self, other: &S) -> bool {
}
}
-// This duplicate bound should not result in ambiguities. It should be equivalent to a single const
+// This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const
// bound.
-const fn equals_self<T: PartialEq + ?const PartialEq>(t: &T) -> bool {
+// const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool {
+// FIXME(fee1-dead)^ why should the order matter here?
+const fn equals_self<T: ~const PartialEq + PartialEq>(t: &T) -> bool {
*t == *t
}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs
index dc4d556..e96249f 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.rs
@@ -1,9 +1,7 @@
#![feature(const_fn_trait_bound)]
#![feature(const_trait_impl)]
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-pub const fn equals_self<T: ?const PartialEq>(t: &T) -> bool {
+pub const fn equals_self<T: PartialEq>(t: &T) -> bool {
*t == *t
//~^ ERROR calls in constant functions are limited to constant functions
}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr
index 4b2fc56..818c582 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-fail.stderr
@@ -1,5 +1,5 @@
error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
- --> $DIR/call-generic-method-fail.rs:7:5
+ --> $DIR/call-generic-method-fail.rs:5:5
|
LL | *t == *t
| ^^^^^^^^
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs
new file mode 100644
index 0000000..585b659
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-bound.rs
@@ -0,0 +1,19 @@
+// check-pass
+
+#![feature(const_fn_trait_bound)]
+
+struct S;
+
+impl PartialEq for S {
+ fn eq(&self, _: &S) -> bool {
+ true
+ }
+}
+
+const fn equals_self<T: PartialEq>(t: &T) -> bool {
+ true
+}
+
+pub const EQ: bool = equals_self(&S);
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-opt-out.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-opt-out.rs
deleted file mode 100644
index 1fc2c4f..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst-opt-out.rs
+++ /dev/null
@@ -1,24 +0,0 @@
-// check-pass
-
-#![feature(const_fn_trait_bound)]
-#![feature(const_trait_impl)]
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-
-struct S;
-
-impl PartialEq for S {
- fn eq(&self, _: &S) -> bool {
- true
- }
-}
-
-const fn equals_self<T: ?const PartialEq>(t: &T) -> bool {
- true
-}
-
-pub const EQ: bool = equals_self(&S);
-
-// Calling `equals_self` with a type that only has a non-const impl is fine, because we opted out.
-
-fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs
index 8343974..6881db0 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.rs
@@ -9,7 +9,7 @@ fn eq(&self, _: &S) -> bool {
}
}
-const fn equals_self<T: PartialEq>(t: &T) -> bool {
+const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
true
}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr
index 7cc54e0..9b9bda7 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr
@@ -8,8 +8,8 @@
note: required by a bound in `equals_self`
--> $DIR/call-generic-method-nonconst.rs:12:25
|
-LL | const fn equals_self<T: PartialEq>(t: &T) -> bool {
- | ^^^^^^^^^ required by this bound in `equals_self`
+LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
+ | ^^^^^^^^^^^^^^^^ required by this bound in `equals_self`
error: aborting due to previous error
diff --git a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs
index aee88d6..aa9bd4d 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/call-generic-method-pass.rs
@@ -16,7 +16,7 @@ fn ne(&self, other: &S) -> bool {
}
}
-const fn equals_self<T: PartialEq>(t: &T) -> bool {
+const fn equals_self<T: ~const PartialEq>(t: &T) -> bool {
*t == *t
}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr
deleted file mode 100644
index 5804145..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.gated.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: fatal error triggered by #[rustc_error]
- --> $DIR/feature-gate.rs:17:1
- |
-LL | fn main() {}
- | ^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs
deleted file mode 100644
index 4452ad7..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.rs
+++ /dev/null
@@ -1,17 +0,0 @@
-// revisions: stock gated
-// gate-test-const_trait_bound_opt_out
-
-#![cfg_attr(gated, feature(const_trait_bound_opt_out))]
-#![allow(incomplete_features)]
-#![feature(rustc_attrs)]
-#![feature(const_fn_trait_bound)]
-
-trait T {
- const CONST: i32;
-}
-
-const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST }
-//[stock]~^ ERROR `?const` on trait bounds is experimental
-
-#[rustc_error]
-fn main() {} //[gated]~ ERROR fatal error triggered by #[rustc_error]
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.stock.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.stock.stderr
deleted file mode 100644
index 8ae8b88..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/feature-gate.stock.stderr
+++ /dev/null
@@ -1,12 +0,0 @@
-error[E0658]: `?const` on trait bounds is experimental
- --> $DIR/feature-gate.rs:13:29
- |
-LL | const fn get_assoc_const<S: ?const T>() -> i32 { <S as T>::CONST }
- | ^^^^^^
- |
- = note: see issue #67794 <https://github.com/rust-lang/rust/issues/67794> for more information
- = help: add `#![feature(const_trait_bound_opt_out)]` to the crate attributes to enable
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0658`.
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.rs
deleted file mode 100644
index f5561a9..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.rs
+++ /dev/null
@@ -1,21 +0,0 @@
-#![feature(const_trait_bound_opt_out)]
-#![feature(associated_type_bounds)]
-#![allow(incomplete_features)]
-
-trait T {}
-struct S;
-impl T for S {}
-
-fn rpit() -> impl ?const T { S }
-//~^ ERROR `?const` is not permitted in `impl Trait`
-
-fn apit(_: impl ?const T) {}
-//~^ ERROR `?const` is not permitted in `impl Trait`
-
-fn rpit_assoc_bound() -> impl IntoIterator<Item: ?const T> { Some(S) }
-//~^ ERROR `?const` is not permitted in `impl Trait`
-
-fn apit_assoc_bound(_: impl IntoIterator<Item: ?const T>) {}
-//~^ ERROR `?const` is not permitted in `impl Trait`
-
-fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.stderr
deleted file mode 100644
index 06cd00a..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-impl-trait.stderr
+++ /dev/null
@@ -1,26 +0,0 @@
-error: `?const` is not permitted in `impl Trait`
- --> $DIR/in-impl-trait.rs:9:19
- |
-LL | fn rpit() -> impl ?const T { S }
- | ^^^^^^^^
-
-error: `?const` is not permitted in `impl Trait`
- --> $DIR/in-impl-trait.rs:12:17
- |
-LL | fn apit(_: impl ?const T) {}
- | ^^^^^^^^
-
-error: `?const` is not permitted in `impl Trait`
- --> $DIR/in-impl-trait.rs:15:50
- |
-LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ?const T> { Some(S) }
- | ^^^^^^^^
-
-error: `?const` is not permitted in `impl Trait`
- --> $DIR/in-impl-trait.rs:18:48
- |
-LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ?const T>) {}
- | ^^^^^^^^
-
-error: aborting due to 4 previous errors
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.rs
deleted file mode 100644
index fc9ed5b..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-
-trait Super {}
-trait T: ?const Super {}
-//~^ ERROR `?const` is not permitted in supertraits
-
-fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.stderr
deleted file mode 100644
index a0d8f95..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-bounds.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: `?const` is not permitted in supertraits
- --> $DIR/in-trait-bounds.rs:5:10
- |
-LL | trait T: ?const Super {}
- | ^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.rs
deleted file mode 100644
index b3d1f48..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.rs
+++ /dev/null
@@ -1,19 +0,0 @@
-#![feature(const_trait_bound_opt_out)]
-#![allow(bare_trait_objects)]
-#![allow(incomplete_features)]
-
-struct S;
-trait T {}
-impl T for S {}
-
-// An inherent impl for the trait object `?const T`.
-impl ?const T {}
-//~^ ERROR `?const` is not permitted in trait objects
-
-fn trait_object() -> &'static dyn ?const T { &S }
-//~^ ERROR `?const` is not permitted in trait objects
-
-fn trait_object_in_apit(_: impl IntoIterator<Item = Box<dyn ?const T>>) {}
-//~^ ERROR `?const` is not permitted in trait objects
-
-fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.stderr
deleted file mode 100644
index 331fe04..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/in-trait-object.stderr
+++ /dev/null
@@ -1,20 +0,0 @@
-error: `?const` is not permitted in trait objects
- --> $DIR/in-trait-object.rs:10:6
- |
-LL | impl ?const T {}
- | ^^^^^^^^
-
-error: `?const` is not permitted in trait objects
- --> $DIR/in-trait-object.rs:13:35
- |
-LL | fn trait_object() -> &'static dyn ?const T { &S }
- | ^^^^^^^^
-
-error: `?const` is not permitted in trait objects
- --> $DIR/in-trait-object.rs:16:61
- |
-LL | fn trait_object_in_apit(_: impl IntoIterator<Item = Box<dyn ?const T>>) {}
- | ^^^^^^^^
-
-error: aborting due to 3 previous errors
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.rs
deleted file mode 100644
index 01e941a..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-// compile-flags: -Z parse-only
-
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-
-struct S<T: ?const ?const Tr>;
-//~^ ERROR expected identifier, found keyword `const`
-//~| ERROR expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.stderr
deleted file mode 100644
index f7924b3..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/opt-out-twice.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error: expected identifier, found keyword `const`
- --> $DIR/opt-out-twice.rs:6:21
- |
-LL | struct S<T: ?const ?const Tr>;
- | ^^^^^ expected identifier, found keyword
-
-error: expected one of `(`, `+`, `,`, `::`, `<`, `=`, or `>`, found `Tr`
- --> $DIR/opt-out-twice.rs:6:27
- |
-LL | struct S<T: ?const ?const Tr>;
- | ^^ expected one of 7 possible tokens
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/syntax.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/syntax.rs
deleted file mode 100644
index a0d9610..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/syntax.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// compile-flags: -Z parse-only
-// check-pass
-
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-
-struct S<
- T: ?const ?for<'a> Tr<'a> + 'static + ?const std::ops::Add,
- T: ?const ?for<'a: 'b> m::Trait<'a>,
->;
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/with-maybe-sized.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/with-maybe-sized.rs
deleted file mode 100644
index c2c8689..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/with-maybe-sized.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-
-struct S<T: ?const ?Sized>(std::marker::PhantomData<T>);
-//~^ ERROR `?const` and `?` are mutually exclusive
-
-fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/with-maybe-sized.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/with-maybe-sized.stderr
deleted file mode 100644
index e8e9d6c..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/with-maybe-sized.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: `?const` and `?` are mutually exclusive
- --> $DIR/with-maybe-sized.rs:4:13
- |
-LL | struct S<T: ?const ?Sized>(std::marker::PhantomData<T>);
- | ^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.rs b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.rs
deleted file mode 100644
index b904a2e..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-// compile-flags: -Z parse-only
-
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
-
-struct S<T: const Tr>;
-//~^ ERROR expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, lifetime, or path
diff --git a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.stderr b/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.stderr
deleted file mode 100644
index 0dbca95..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/const-trait-bound-opt-out/without-question-mark.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, lifetime, or path, found keyword `const`
- --> $DIR/without-question-mark.rs:6:13
- |
-LL | struct S<T: const Tr>;
- | ^^^^^ expected one of 9 possible tokens
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.rs b/src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.rs
deleted file mode 100644
index 98d3a22..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-#![feature(const_trait_bound_opt_out)]
-#![feature(const_trait_impl)]
-#![allow(incomplete_features)]
-
-struct S;
-trait T {}
-
-impl ?const T for S {}
-//~^ ERROR expected a trait, found type
-
-fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.stderr b/src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.stderr
deleted file mode 100644
index 8f923ef..0000000
--- a/src/test/ui/rfc-2632-const-trait-impl/impl-opt-out-trait.stderr
+++ /dev/null
@@ -1,8 +0,0 @@
-error: expected a trait, found type
- --> $DIR/impl-opt-out-trait.rs:8:6
- |
-LL | impl ?const T for S {}
- | ^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs b/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs
new file mode 100644
index 0000000..05b2646
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.rs
@@ -0,0 +1,9 @@
+#![feature(const_trait_impl)]
+
+struct S;
+trait T {}
+
+impl ~const T for S {}
+//~^ ERROR expected a trait, found type
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr b/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr
new file mode 100644
index 0000000..0a91719
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/impl-tilde-const-trait.stderr
@@ -0,0 +1,8 @@
+error: expected a trait, found type
+ --> $DIR/impl-tilde-const-trait.rs:6:6
+ |
+LL | impl ~const T for S {}
+ | ^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.rs b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.rs
index 04123a5..afd0d13 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.rs
@@ -1,6 +1,4 @@
#![feature(const_trait_impl)]
-#![feature(const_trait_bound_opt_out)]
-#![allow(incomplete_features)]
#![allow(bare_trait_objects)]
struct S;
diff --git a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr
index 834f6a4..8c55627 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr
+++ b/src/test/ui/rfc-2632-const-trait-impl/inherent-impl.stderr
@@ -1,5 +1,5 @@
error: inherent impls cannot be `const`
- --> $DIR/inherent-impl.rs:9:12
+ --> $DIR/inherent-impl.rs:7:12
|
LL | impl const S {}
| ----- ^ inherent impl for this type
@@ -9,7 +9,7 @@
= note: only trait implementations may be annotated with `const`
error: inherent impls cannot be `const`
- --> $DIR/inherent-impl.rs:12:12
+ --> $DIR/inherent-impl.rs:10:12
|
LL | impl const T {}
| ----- ^ inherent impl for this type
diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-88155.rs b/src/test/ui/rfc-2632-const-trait-impl/issue-88155.rs
new file mode 100644
index 0000000..157005b
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/issue-88155.rs
@@ -0,0 +1,13 @@
+#![feature(const_fn_trait_bound)]
+#![feature(const_trait_impl)]
+
+pub trait A {
+ fn assoc() -> bool;
+}
+
+pub const fn foo<T: A>() -> bool {
+ T::assoc()
+ //~^ ERROR calls in constant functions are limited
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/issue-88155.stderr b/src/test/ui/rfc-2632-const-trait-impl/issue-88155.stderr
new file mode 100644
index 0000000..931baac
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/issue-88155.stderr
@@ -0,0 +1,9 @@
+error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
+ --> $DIR/issue-88155.rs:9:5
+ |
+LL | T::assoc()
+ | ^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0015`.
diff --git a/src/test/ui/rfc-2632-const-trait-impl/syntax.rs b/src/test/ui/rfc-2632-const-trait-impl/syntax.rs
index 82a1275..7ac2458 100644
--- a/src/test/ui/rfc-2632-const-trait-impl/syntax.rs
+++ b/src/test/ui/rfc-2632-const-trait-impl/syntax.rs
@@ -5,4 +5,4 @@
#![feature(const_trait_impl)]
// For now, this parses since an error does not occur until AST lowering.
-impl ?const T {}
+impl ~const T {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
new file mode 100644
index 0000000..b4302f3
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.rs
@@ -0,0 +1,29 @@
+#![feature(const_trait_impl)]
+#![feature(associated_type_bounds)]
+
+trait T {}
+struct S;
+impl T for S {}
+
+fn rpit() -> impl ~const T { S }
+//~^ ERROR `~const` is not allowed
+
+fn apit(_: impl ~const T) {}
+//~^ ERROR `~const` is not allowed
+
+fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
+//~^ ERROR `~const` is not allowed
+
+fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {}
+//~^ ERROR `~const` is not allowed
+
+fn generic<P: ~const T>() {}
+//~^ ERROR `~const` is not allowed
+
+fn where_clause<P>() where P: ~const T {}
+//~^ ERROR `~const` is not allowed
+
+struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
+//~^ ERROR `~const` and `?` are mutually exclusive
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr
new file mode 100644
index 0000000..033ec21
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-invalid-places.stderr
@@ -0,0 +1,56 @@
+error: `~const` is not allowed here
+ --> $DIR/tilde-const-invalid-places.rs:8:19
+ |
+LL | fn rpit() -> impl ~const T { S }
+ | ^^^^^^^^
+ |
+ = note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
+
+error: `~const` is not allowed here
+ --> $DIR/tilde-const-invalid-places.rs:11:17
+ |
+LL | fn apit(_: impl ~const T) {}
+ | ^^^^^^^^
+ |
+ = note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
+
+error: `~const` is not allowed here
+ --> $DIR/tilde-const-invalid-places.rs:14:50
+ |
+LL | fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { Some(S) }
+ | ^^^^^^^^
+ |
+ = note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
+
+error: `~const` is not allowed here
+ --> $DIR/tilde-const-invalid-places.rs:17:48
+ |
+LL | fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T>) {}
+ | ^^^^^^^^
+ |
+ = note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
+
+error: `~const` is not allowed here
+ --> $DIR/tilde-const-invalid-places.rs:20:15
+ |
+LL | fn generic<P: ~const T>() {}
+ | ^^^^^^^^
+ |
+ = note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
+
+error: `~const` is not allowed here
+ --> $DIR/tilde-const-invalid-places.rs:23:31
+ |
+LL | fn where_clause<P>() where P: ~const T {}
+ | ^^^^^^^^
+ |
+ = note: only allowed on bounds on traits' associated types and functions, const fns, const impls and its associated functions
+
+error: `~const` and `?` are mutually exclusive
+ --> $DIR/tilde-const-invalid-places.rs:26:25
+ |
+LL | struct TildeQuestion<T: ~const ?Sized>(std::marker::PhantomData<T>);
+ | ^^^^^^^^^^^^^
+
+error: aborting due to 7 previous errors
+
diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs
new file mode 100644
index 0000000..9b3c2cf
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-const-syntax.rs
@@ -0,0 +1,9 @@
+// compile-flags: -Z parse-only
+// check-pass
+
+#![feature(const_trait_impl)]
+
+struct S<
+ T: ~const ?for<'a> Tr<'a> + 'static + ~const std::ops::Add,
+ T: ~const ?for<'a: 'b> m::Trait<'a>,
+>;
diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-twice.rs b/src/test/ui/rfc-2632-const-trait-impl/tilde-twice.rs
new file mode 100644
index 0000000..06e4ede
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-twice.rs
@@ -0,0 +1,6 @@
+// compile-flags: -Z parse-only
+
+#![feature(const_trait_impl)]
+
+struct S<T: ~const ~const Tr>;
+//~^ ERROR expected identifier, found `~`
diff --git a/src/test/ui/rfc-2632-const-trait-impl/tilde-twice.stderr b/src/test/ui/rfc-2632-const-trait-impl/tilde-twice.stderr
new file mode 100644
index 0000000..928d23e
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/tilde-twice.stderr
@@ -0,0 +1,8 @@
+error: expected identifier, found `~`
+ --> $DIR/tilde-twice.rs:5:20
+ |
+LL | struct S<T: ~const ~const Tr>;
+ | ^ expected identifier
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs
new file mode 100644
index 0000000..0cde5b6
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-run.rs
@@ -0,0 +1,41 @@
+// run-pass
+
+#![feature(const_trait_impl)]
+#![feature(const_fn_trait_bound)]
+
+trait Bar {
+ fn bar() -> u8;
+}
+
+trait Foo {
+ #[default_method_body_is_const]
+ fn foo() -> u8 where Self: ~const Bar {
+ <Self as Bar>::bar() * 6
+ }
+}
+
+struct NonConst;
+struct Const;
+
+impl Bar for NonConst {
+ fn bar() -> u8 {
+ 3
+ }
+}
+
+impl Foo for NonConst {}
+
+impl const Bar for Const {
+ fn bar() -> u8 {
+ 4
+ }
+}
+
+impl const Foo for Const {}
+
+fn main() {
+ const ANS1: u8 = Const::foo();
+ let ans2 = NonConst::foo();
+
+ assert_eq!(ANS1 + ans2, 42);
+}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs
new file mode 100644
index 0000000..ae9ab26
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause-self-referential.rs
@@ -0,0 +1,24 @@
+// check-pass
+
+#![feature(const_trait_impl)]
+#![feature(const_fn_trait_bound)]
+
+trait Foo {
+ fn bar() where Self: ~const Foo;
+}
+
+struct S;
+
+impl Foo for S {
+ fn bar() {}
+}
+
+fn baz<T: Foo>() {
+ T::bar();
+}
+
+const fn qux<T: ~const Foo>() {
+ T::bar();
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs
new file mode 100644
index 0000000..d64822d
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.rs
@@ -0,0 +1,40 @@
+#![feature(const_fn_trait_bound)]
+#![feature(const_trait_impl)]
+
+trait Bar {}
+
+trait Foo {
+ fn a();
+ fn b() where Self: ~const Bar;
+ fn c<T: ~const Bar>();
+}
+
+const fn test1<T: ~const Foo + Bar>() {
+ T::a();
+ T::b();
+ //~^ ERROR the trait bound
+ T::c::<T>();
+ //~^ ERROR the trait bound
+}
+
+const fn test2<T: ~const Foo + ~const Bar>() {
+ T::a();
+ T::b();
+ T::c::<T>();
+}
+
+fn test3<T: Foo>() {
+ T::a();
+ T::b();
+ //~^ ERROR the trait bound
+ T::c::<T>();
+ //~^ ERROR the trait bound
+}
+
+fn test4<T: Foo + Bar>() {
+ T::a();
+ T::b();
+ T::c::<T>();
+}
+
+fn main() {}
diff --git a/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr
new file mode 100644
index 0000000..fffb91f
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/trait-where-clause.stderr
@@ -0,0 +1,67 @@
+error[E0277]: the trait bound `T: Bar` is not satisfied
+ --> $DIR/trait-where-clause.rs:14:5
+ |
+LL | T::b();
+ | ^^^^ the trait `Bar` is not implemented for `T`
+ |
+note: required by `Foo::b`
+ --> $DIR/trait-where-clause.rs:8:5
+ |
+LL | fn b() where Self: ~const Bar;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: consider further restricting this bound
+ |
+LL | const fn test1<T: ~const Foo + Bar + Bar>() {
+ | +++++
+
+error[E0277]: the trait bound `T: Bar` is not satisfied
+ --> $DIR/trait-where-clause.rs:16:5
+ |
+LL | T::c::<T>();
+ | ^^^^^^^^^ the trait `Bar` is not implemented for `T`
+ |
+note: required by `Foo::c`
+ --> $DIR/trait-where-clause.rs:9:5
+ |
+LL | fn c<T: ~const Bar>();
+ | ^^^^^^^^^^^^^^^^^^^^^^
+help: consider further restricting this bound
+ |
+LL | const fn test1<T: ~const Foo + Bar + Bar>() {
+ | +++++
+
+error[E0277]: the trait bound `T: Bar` is not satisfied
+ --> $DIR/trait-where-clause.rs:28:5
+ |
+LL | T::b();
+ | ^^^^ the trait `Bar` is not implemented for `T`
+ |
+note: required by `Foo::b`
+ --> $DIR/trait-where-clause.rs:8:5
+ |
+LL | fn b() where Self: ~const Bar;
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: consider further restricting this bound
+ |
+LL | fn test3<T: Foo + Bar>() {
+ | +++++
+
+error[E0277]: the trait bound `T: Bar` is not satisfied
+ --> $DIR/trait-where-clause.rs:30:5
+ |
+LL | T::c::<T>();
+ | ^^^^^^^^^ the trait `Bar` is not implemented for `T`
+ |
+note: required by `Foo::c`
+ --> $DIR/trait-where-clause.rs:9:5
+ |
+LL | fn c<T: ~const Bar>();
+ | ^^^^^^^^^^^^^^^^^^^^^^
+help: consider further restricting this bound
+ |
+LL | fn test3<T: Foo + Bar>() {
+ | +++++
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/rfc-2632-const-trait-impl/without-tilde.rs b/src/test/ui/rfc-2632-const-trait-impl/without-tilde.rs
new file mode 100644
index 0000000..96ba393
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/without-tilde.rs
@@ -0,0 +1,6 @@
+// compiler-flags: -Z parse-only
+
+#![feature(const_trait_impl)]
+
+struct S<T: const Tr>;
+//~^ ERROR expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path
diff --git a/src/test/ui/rfc-2632-const-trait-impl/without-tilde.stderr b/src/test/ui/rfc-2632-const-trait-impl/without-tilde.stderr
new file mode 100644
index 0000000..b6b77ac
--- /dev/null
+++ b/src/test/ui/rfc-2632-const-trait-impl/without-tilde.stderr
@@ -0,0 +1,8 @@
+error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found keyword `const`
+ --> $DIR/without-tilde.rs:5:13
+ |
+LL | struct S<T: const Tr>;
+ | ^^^^^ expected one of 10 possible tokens
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/rust-2021/array-into-iter-ambiguous.fixed b/src/test/ui/rust-2021/array-into-iter-ambiguous.fixed
new file mode 100644
index 0000000..76f661b
--- /dev/null
+++ b/src/test/ui/rust-2021/array-into-iter-ambiguous.fixed
@@ -0,0 +1,27 @@
+// See https://github.com/rust-lang/rust/issues/88475
+// run-rustfix
+// edition:2018
+// check-pass
+#![warn(array_into_iter)]
+#![allow(unused)]
+
+struct FooIter;
+
+trait MyIntoIter {
+ fn into_iter(self) -> FooIter;
+}
+
+impl<T, const N: usize> MyIntoIter for [T; N] {
+ fn into_iter(self) -> FooIter {
+ FooIter
+ }
+}
+
+struct Point;
+
+pub fn main() {
+ let points: [Point; 1] = [Point];
+ let y = MyIntoIter::into_iter(points);
+ //~^ WARNING trait method `into_iter` will become ambiguous in Rust 2021
+ //~| WARNING this changes meaning in Rust 2021
+}
diff --git a/src/test/ui/rust-2021/array-into-iter-ambiguous.rs b/src/test/ui/rust-2021/array-into-iter-ambiguous.rs
new file mode 100644
index 0000000..83fbf8f
--- /dev/null
+++ b/src/test/ui/rust-2021/array-into-iter-ambiguous.rs
@@ -0,0 +1,27 @@
+// See https://github.com/rust-lang/rust/issues/88475
+// run-rustfix
+// edition:2018
+// check-pass
+#![warn(array_into_iter)]
+#![allow(unused)]
+
+struct FooIter;
+
+trait MyIntoIter {
+ fn into_iter(self) -> FooIter;
+}
+
+impl<T, const N: usize> MyIntoIter for [T; N] {
+ fn into_iter(self) -> FooIter {
+ FooIter
+ }
+}
+
+struct Point;
+
+pub fn main() {
+ let points: [Point; 1] = [Point];
+ let y = points.into_iter();
+ //~^ WARNING trait method `into_iter` will become ambiguous in Rust 2021
+ //~| WARNING this changes meaning in Rust 2021
+}
diff --git a/src/test/ui/rust-2021/array-into-iter-ambiguous.stderr b/src/test/ui/rust-2021/array-into-iter-ambiguous.stderr
new file mode 100644
index 0000000..fac8d21
--- /dev/null
+++ b/src/test/ui/rust-2021/array-into-iter-ambiguous.stderr
@@ -0,0 +1,16 @@
+warning: trait method `into_iter` will become ambiguous in Rust 2021
+ --> $DIR/array-into-iter-ambiguous.rs:24:13
+ |
+LL | let y = points.into_iter();
+ | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyIntoIter::into_iter(points)`
+ |
+note: the lint level is defined here
+ --> $DIR/array-into-iter-ambiguous.rs:5:9
+ |
+LL | #![warn(array_into_iter)]
+ | ^^^^^^^^^^^^^^^
+ = warning: this changes meaning in Rust 2021
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/IntoIterator-for-arrays.html>
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/rust-2021/future-prelude-collision-generic-trait.fixed b/src/test/ui/rust-2021/future-prelude-collision-generic-trait.fixed
new file mode 100644
index 0000000..a1b6f5b
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-generic-trait.fixed
@@ -0,0 +1,30 @@
+// See https://github.com/rust-lang/rust/issues/88470
+// run-rustfix
+// edition:2018
+// check-pass
+#![warn(rust_2021_prelude_collisions)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+pub trait PyTryFrom<'v, T>: Sized {
+ fn try_from<V>(value: V) -> Result<&'v Self, T>;
+}
+
+pub trait PyTryInto<T>: Sized {
+ fn try_into(&self) -> Result<&T, i32>;
+}
+
+struct Foo;
+
+impl<U> PyTryInto<U> for Foo
+where
+ U: for<'v> PyTryFrom<'v, i32>,
+{
+ fn try_into(&self) -> Result<&U, i32> {
+ <U as PyTryFrom<'_, _>>::try_from(self)
+ //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
+ //~| this is accepted in the current edition (Rust 2018)
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-generic-trait.rs b/src/test/ui/rust-2021/future-prelude-collision-generic-trait.rs
new file mode 100644
index 0000000..142ba55
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-generic-trait.rs
@@ -0,0 +1,30 @@
+// See https://github.com/rust-lang/rust/issues/88470
+// run-rustfix
+// edition:2018
+// check-pass
+#![warn(rust_2021_prelude_collisions)]
+#![allow(dead_code)]
+#![allow(unused_imports)]
+
+pub trait PyTryFrom<'v, T>: Sized {
+ fn try_from<V>(value: V) -> Result<&'v Self, T>;
+}
+
+pub trait PyTryInto<T>: Sized {
+ fn try_into(&self) -> Result<&T, i32>;
+}
+
+struct Foo;
+
+impl<U> PyTryInto<U> for Foo
+where
+ U: for<'v> PyTryFrom<'v, i32>,
+{
+ fn try_into(&self) -> Result<&U, i32> {
+ U::try_from(self)
+ //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
+ //~| this is accepted in the current edition (Rust 2018)
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-generic-trait.stderr b/src/test/ui/rust-2021/future-prelude-collision-generic-trait.stderr
new file mode 100644
index 0000000..14ad9b0
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-generic-trait.stderr
@@ -0,0 +1,16 @@
+warning: trait-associated function `try_from` will become ambiguous in Rust 2021
+ --> $DIR/future-prelude-collision-generic-trait.rs:24:9
+ |
+LL | U::try_from(self)
+ | ^^^^^^^^^^^ help: disambiguate the associated function: `<U as PyTryFrom<'_, _>>::try_from`
+ |
+note: the lint level is defined here
+ --> $DIR/future-prelude-collision-generic-trait.rs:5:9
+ |
+LL | #![warn(rust_2021_prelude_collisions)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
+
+warning: 1 warning emitted
+
diff --git a/src/test/ui/rust-2021/future-prelude-collision-generic.fixed b/src/test/ui/rust-2021/future-prelude-collision-generic.fixed
index f0d8cb9..1bb9ba3 100644
--- a/src/test/ui/rust-2021/future-prelude-collision-generic.fixed
+++ b/src/test/ui/rust-2021/future-prelude-collision-generic.fixed
@@ -6,32 +6,32 @@
#![allow(dead_code)]
#![allow(unused_imports)]
-struct Generic<T, U>(T, U);
+struct Generic<'a, U>(&'a U);
trait MyFromIter {
fn from_iter(_: i32) -> Self;
}
-impl MyFromIter for Generic<i32, i32> {
- fn from_iter(x: i32) -> Self {
- Self(x, x)
+impl MyFromIter for Generic<'static, i32> {
+ fn from_iter(_: i32) -> Self {
+ todo!()
}
}
-impl std::iter::FromIterator<i32> for Generic<i32, i32> {
+impl std::iter::FromIterator<i32> for Generic<'static, i32> {
fn from_iter<T: IntoIterator<Item = i32>>(_: T) -> Self {
todo!()
}
}
fn main() {
- <Generic<_, _> as MyFromIter>::from_iter(1);
+ <Generic<'_, _> as MyFromIter>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
- <Generic::<i32, i32> as MyFromIter>::from_iter(1);
+ <Generic::<'static, i32> as MyFromIter>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
- <Generic::<_, _> as MyFromIter>::from_iter(1);
+ <Generic::<'_, _> as MyFromIter>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-generic.rs b/src/test/ui/rust-2021/future-prelude-collision-generic.rs
index 1984053..d7f8aff 100644
--- a/src/test/ui/rust-2021/future-prelude-collision-generic.rs
+++ b/src/test/ui/rust-2021/future-prelude-collision-generic.rs
@@ -6,19 +6,19 @@
#![allow(dead_code)]
#![allow(unused_imports)]
-struct Generic<T, U>(T, U);
+struct Generic<'a, U>(&'a U);
trait MyFromIter {
fn from_iter(_: i32) -> Self;
}
-impl MyFromIter for Generic<i32, i32> {
- fn from_iter(x: i32) -> Self {
- Self(x, x)
+impl MyFromIter for Generic<'static, i32> {
+ fn from_iter(_: i32) -> Self {
+ todo!()
}
}
-impl std::iter::FromIterator<i32> for Generic<i32, i32> {
+impl std::iter::FromIterator<i32> for Generic<'static, i32> {
fn from_iter<T: IntoIterator<Item = i32>>(_: T) -> Self {
todo!()
}
@@ -28,10 +28,10 @@ fn main() {
Generic::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
- Generic::<i32, i32>::from_iter(1);
+ Generic::<'static, i32>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
- Generic::<_, _>::from_iter(1);
+ Generic::<'_, _>::from_iter(1);
//~^ WARNING trait-associated function `from_iter` will become ambiguous in Rust 2021
//~| this is accepted in the current edition (Rust 2018)
}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-generic.stderr b/src/test/ui/rust-2021/future-prelude-collision-generic.stderr
index 0a722ba..e1d3f3c 100644
--- a/src/test/ui/rust-2021/future-prelude-collision-generic.stderr
+++ b/src/test/ui/rust-2021/future-prelude-collision-generic.stderr
@@ -2,7 +2,7 @@
--> $DIR/future-prelude-collision-generic.rs:28:5
|
LL | Generic::from_iter(1);
- | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic<_, _> as MyFromIter>::from_iter`
+ | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic<'_, _> as MyFromIter>::from_iter`
|
note: the lint level is defined here
--> $DIR/future-prelude-collision-generic.rs:5:9
@@ -15,8 +15,8 @@
warning: trait-associated function `from_iter` will become ambiguous in Rust 2021
--> $DIR/future-prelude-collision-generic.rs:31:5
|
-LL | Generic::<i32, i32>::from_iter(1);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic::<i32, i32> as MyFromIter>::from_iter`
+LL | Generic::<'static, i32>::from_iter(1);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic::<'static, i32> as MyFromIter>::from_iter`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
@@ -24,8 +24,8 @@
warning: trait-associated function `from_iter` will become ambiguous in Rust 2021
--> $DIR/future-prelude-collision-generic.rs:34:5
|
-LL | Generic::<_, _>::from_iter(1);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic::<_, _> as MyFromIter>::from_iter`
+LL | Generic::<'_, _>::from_iter(1);
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Generic::<'_, _> as MyFromIter>::from_iter`
|
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.fixed b/src/test/ui/rust-2021/future-prelude-collision-imported.fixed
index c5ff0b4..15ccff7 100644
--- a/src/test/ui/rust-2021/future-prelude-collision-imported.fixed
+++ b/src/test/ui/rust-2021/future-prelude-collision-imported.fixed
@@ -56,4 +56,15 @@
}
}
+mod d {
+ use super::m::*;
+
+ fn main() {
+ // See https://github.com/rust-lang/rust/issues/88471
+ let _: u32 = TryIntoU32::try_into(3u8).unwrap();
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~^^ WARNING this is accepted in the current edition
+ }
+}
+
fn main() {}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.rs b/src/test/ui/rust-2021/future-prelude-collision-imported.rs
index cd39eec..cdffcaf 100644
--- a/src/test/ui/rust-2021/future-prelude-collision-imported.rs
+++ b/src/test/ui/rust-2021/future-prelude-collision-imported.rs
@@ -56,4 +56,15 @@ fn main() {
}
}
+mod d {
+ use super::m::*;
+
+ fn main() {
+ // See https://github.com/rust-lang/rust/issues/88471
+ let _: u32 = 3u8.try_into().unwrap();
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~^^ WARNING this is accepted in the current edition
+ }
+}
+
fn main() {}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-imported.stderr b/src/test/ui/rust-2021/future-prelude-collision-imported.stderr
index fbda5d6..56abb8a 100644
--- a/src/test/ui/rust-2021/future-prelude-collision-imported.stderr
+++ b/src/test/ui/rust-2021/future-prelude-collision-imported.stderr
@@ -30,5 +30,14 @@
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
-warning: 3 warnings emitted
+warning: trait method `try_into` will become ambiguous in Rust 2021
+ --> $DIR/future-prelude-collision-imported.rs:64:22
+ |
+LL | let _: u32 = 3u8.try_into().unwrap();
+ | ^^^^^^^^^^^^^^ help: disambiguate the associated function: `TryIntoU32::try_into(3u8)`
+ |
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
+
+warning: 4 warnings emitted
diff --git a/src/test/ui/rust-2021/future-prelude-collision-macros.fixed b/src/test/ui/rust-2021/future-prelude-collision-macros.fixed
new file mode 100644
index 0000000..a97dc17
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-macros.fixed
@@ -0,0 +1,45 @@
+// run-rustfix
+// edition:2018
+// check-pass
+#![warn(rust_2021_prelude_collisions)]
+#![allow(unreachable_code)]
+
+macro_rules! foo {
+ () => {{
+ 123;
+ S
+ }};
+}
+
+trait MyTry<T> {
+ fn try_into(self, _: u8);
+}
+
+struct S;
+
+impl MyTry<i32> for S {
+ fn try_into(self, _: u8) {}
+}
+
+trait TryFromU8: Sized {
+ fn try_from(_: u8);
+}
+
+impl TryFromU8 for u32 {
+ fn try_from(_: u8) {}
+}
+
+macro_rules! bar {
+ () => {
+ u32
+ };
+}
+
+fn main() {
+ MyTry::try_into(foo!(), todo!());
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition
+ <bar!() as TryFromU8>::try_from(0);
+ //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition
+}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-macros.rs b/src/test/ui/rust-2021/future-prelude-collision-macros.rs
new file mode 100644
index 0000000..82484b5
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-macros.rs
@@ -0,0 +1,45 @@
+// run-rustfix
+// edition:2018
+// check-pass
+#![warn(rust_2021_prelude_collisions)]
+#![allow(unreachable_code)]
+
+macro_rules! foo {
+ () => {{
+ 123;
+ S
+ }};
+}
+
+trait MyTry<T> {
+ fn try_into(self, _: u8);
+}
+
+struct S;
+
+impl MyTry<i32> for S {
+ fn try_into(self, _: u8) {}
+}
+
+trait TryFromU8: Sized {
+ fn try_from(_: u8);
+}
+
+impl TryFromU8 for u32 {
+ fn try_from(_: u8) {}
+}
+
+macro_rules! bar {
+ () => {
+ u32
+ };
+}
+
+fn main() {
+ foo!().try_into(todo!());
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition
+ <bar!()>::try_from(0);
+ //~^ WARNING trait-associated function `try_from` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition
+}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-macros.stderr b/src/test/ui/rust-2021/future-prelude-collision-macros.stderr
new file mode 100644
index 0000000..4c3543c
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-macros.stderr
@@ -0,0 +1,25 @@
+warning: trait method `try_into` will become ambiguous in Rust 2021
+ --> $DIR/future-prelude-collision-macros.rs:39:5
+ |
+LL | foo!().try_into(todo!());
+ | ^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `MyTry::try_into(foo!(), todo!())`
+ |
+note: the lint level is defined here
+ --> $DIR/future-prelude-collision-macros.rs:4:9
+ |
+LL | #![warn(rust_2021_prelude_collisions)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
+
+warning: trait-associated function `try_from` will become ambiguous in Rust 2021
+ --> $DIR/future-prelude-collision-macros.rs:42:5
+ |
+LL | <bar!()>::try_from(0);
+ | ^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<bar!() as TryFromU8>::try_from`
+ |
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
+
+warning: 2 warnings emitted
+
diff --git a/src/test/ui/rust-2021/future-prelude-collision-turbofish.fixed b/src/test/ui/rust-2021/future-prelude-collision-turbofish.fixed
new file mode 100644
index 0000000..3e76fce
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-turbofish.fixed
@@ -0,0 +1,28 @@
+// See https://github.com/rust-lang/rust/issues/88442
+// run-rustfix
+// edition:2018
+// check-pass
+#![allow(unused)]
+#![warn(rust_2021_prelude_collisions)]
+
+trait AnnotatableTryInto {
+ fn try_into<T>(self) -> Result<T, Self::Error>
+ where Self: std::convert::TryInto<T> {
+ std::convert::TryInto::try_into(self)
+ }
+}
+
+impl<T> AnnotatableTryInto for T where T: From<u8> {}
+
+fn main() -> Result<(), &'static str> {
+ let x: u64 = 1;
+ AnnotatableTryInto::try_into::<usize>(x).or(Err("foo"))?.checked_sub(1);
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+
+ AnnotatableTryInto::try_into::<usize>(x).or(Err("foo"))?;
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+
+ Ok(())
+}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-turbofish.rs b/src/test/ui/rust-2021/future-prelude-collision-turbofish.rs
new file mode 100644
index 0000000..abb292e
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-turbofish.rs
@@ -0,0 +1,28 @@
+// See https://github.com/rust-lang/rust/issues/88442
+// run-rustfix
+// edition:2018
+// check-pass
+#![allow(unused)]
+#![warn(rust_2021_prelude_collisions)]
+
+trait AnnotatableTryInto {
+ fn try_into<T>(self) -> Result<T, Self::Error>
+ where Self: std::convert::TryInto<T> {
+ std::convert::TryInto::try_into(self)
+ }
+}
+
+impl<T> AnnotatableTryInto for T where T: From<u8> {}
+
+fn main() -> Result<(), &'static str> {
+ let x: u64 = 1;
+ x.try_into::<usize>().or(Err("foo"))?.checked_sub(1);
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+
+ x.try_into::<usize>().or(Err("foo"))?;
+ //~^ WARNING trait method `try_into` will become ambiguous in Rust 2021
+ //~| WARNING this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+
+ Ok(())
+}
diff --git a/src/test/ui/rust-2021/future-prelude-collision-turbofish.stderr b/src/test/ui/rust-2021/future-prelude-collision-turbofish.stderr
new file mode 100644
index 0000000..2de9020
--- /dev/null
+++ b/src/test/ui/rust-2021/future-prelude-collision-turbofish.stderr
@@ -0,0 +1,25 @@
+warning: trait method `try_into` will become ambiguous in Rust 2021
+ --> $DIR/future-prelude-collision-turbofish.rs:19:5
+ |
+LL | x.try_into::<usize>().or(Err("foo"))?.checked_sub(1);
+ | ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `AnnotatableTryInto::try_into::<usize>(x)`
+ |
+note: the lint level is defined here
+ --> $DIR/future-prelude-collision-turbofish.rs:6:9
+ |
+LL | #![warn(rust_2021_prelude_collisions)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
+
+warning: trait method `try_into` will become ambiguous in Rust 2021
+ --> $DIR/future-prelude-collision-turbofish.rs:23:5
+ |
+LL | x.try_into::<usize>().or(Err("foo"))?;
+ | ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `AnnotatableTryInto::try_into::<usize>(x)`
+ |
+ = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/prelude.html>
+
+warning: 2 warnings emitted
+
diff --git a/src/test/ui/rust-2021/reserved-prefixes.rs b/src/test/ui/rust-2021/reserved-prefixes.rs
index 5882c7d..1994f25 100644
--- a/src/test/ui/rust-2021/reserved-prefixes.rs
+++ b/src/test/ui/rust-2021/reserved-prefixes.rs
@@ -1,4 +1,4 @@
-// compile-flags: -Z unstable-options --edition 2021
+// edition:2021
macro_rules! demo2 {
( $a:tt $b:tt ) => { println!("two tokens") };
diff --git a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr b/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
deleted file mode 100644
index 353da8f..0000000
--- a/src/test/ui/self/arbitrary-self-types-not-object-safe.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/arbitrary-self-types-not-object-safe.rs:29:32
- |
-LL | fn foo(self: &Rc<Self>) -> usize;
- | --- method `foo`'s `self` parameter cannot be dispatched on
-...
-LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
- | ^^^^^^^^^^^ the trait `Foo` cannot be made into an object
-
-error[E0038]: the trait `Foo` cannot be made into an object
- --> $DIR/arbitrary-self-types-not-object-safe.rs:29:13
- |
-LL | fn foo(self: &Rc<Self>) -> usize;
- | --- method `foo`'s `self` parameter cannot be dispatched on
-...
-LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
- | ^^^^^^^^^^^^^^^ the trait `Foo` cannot be made into an object
- |
- = note: required because of the requirements on the impl of `std::ops::CoerceUnsized<std::rc::Rc<dyn Foo>>` for `std::rc::Rc<usize>`
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0038`.
diff --git a/src/test/ui/simd/simd-array-trait.rs b/src/test/ui/simd/simd-array-trait.rs
index d6ed5f6..45c10b3 100644
--- a/src/test/ui/simd/simd-array-trait.rs
+++ b/src/test/ui/simd/simd-array-trait.rs
@@ -4,7 +4,7 @@
// pretty-expanded FIXME #23616
-#![feature(repr_simd, platform_intrinsics, const_generics)]
+#![feature(repr_simd, platform_intrinsics, generic_const_exprs)]
#![allow(non_camel_case_types, incomplete_features)]
pub trait Simd {
@@ -21,7 +21,7 @@ impl Simd for i32x4 {
#[repr(simd)]
#[derive(Copy, Clone)]
pub struct T<S: Simd>([S::Lane; S::SIZE]);
-//~^ ERROR constant expression depends on a generic parameter
+//~^ ERROR unconstrained generic constant
extern "platform-intrinsic" {
fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T;
diff --git a/src/test/ui/simd/simd-array-trait.stderr b/src/test/ui/simd/simd-array-trait.stderr
index c100e02..0e02883 100644
--- a/src/test/ui/simd/simd-array-trait.stderr
+++ b/src/test/ui/simd/simd-array-trait.stderr
@@ -1,10 +1,10 @@
-error: constant expression depends on a generic parameter
+error: unconstrained generic constant
--> $DIR/simd-array-trait.rs:23:23
|
LL | pub struct T<S: Simd>([S::Lane; S::SIZE]);
| ^^^^^^^^^^^^^^^^^^
|
- = note: this may fail depending on what value the parameter takes
+ = help: try adding a `where` bound using this expression: `where [(); S::SIZE]:`
error: aborting due to previous error
diff --git a/src/test/ui/specialization/issue-51892.rs b/src/test/ui/specialization/issue-51892.rs
index 3cd0711..5c06254 100644
--- a/src/test/ui/specialization/issue-51892.rs
+++ b/src/test/ui/specialization/issue-51892.rs
@@ -1,6 +1,5 @@
#![allow(incomplete_features)]
-#![feature(const_generics)]
-#![feature(const_evaluatable_checked)]
+#![feature(generic_const_exprs)]
#![feature(specialization)]
pub trait Trait {
diff --git a/src/test/ui/specialization/issue-51892.stderr b/src/test/ui/specialization/issue-51892.stderr
index 10a39a4..cb46db8 100644
--- a/src/test/ui/specialization/issue-51892.stderr
+++ b/src/test/ui/specialization/issue-51892.stderr
@@ -1,5 +1,5 @@
error: unconstrained generic constant
- --> $DIR/issue-51892.rs:15:17
+ --> $DIR/issue-51892.rs:14:17
|
LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/src/test/ui/suggestions/if-let-typo.rs b/src/test/ui/suggestions/if-let-typo.rs
index 688b6e8..b9714b6 100644
--- a/src/test/ui/suggestions/if-let-typo.rs
+++ b/src/test/ui/suggestions/if-let-typo.rs
@@ -10,4 +10,5 @@
if Some(3) = foo {} //~ ERROR mismatched types
//~^ ERROR destructuring assignments are unstable
//~^^ ERROR invalid left-hand side of assignment
+ if x = 5 {} //~ ERROR cannot find value `x` in this scope
}
diff --git a/src/test/ui/suggestions/if-let-typo.stderr b/src/test/ui/suggestions/if-let-typo.stderr
index 1e23ede..7f71cb4 100644
--- a/src/test/ui/suggestions/if-let-typo.stderr
+++ b/src/test/ui/suggestions/if-let-typo.stderr
@@ -9,6 +9,17 @@
LL | if let Some(x) = foo {}
| +++
+error[E0425]: cannot find value `x` in this scope
+ --> $DIR/if-let-typo.rs:13:8
+ |
+LL | if x = 5 {}
+ | ^ not found in this scope
+ |
+help: you might have meant to use pattern matching
+ |
+LL | if let x = 5 {}
+ | +++
+
error[E0658]: destructuring assignments are unstable
--> $DIR/if-let-typo.rs:4:16
|
@@ -79,7 +90,7 @@
LL | if Some(3) = foo {}
| ^^^^^^^^^^^^^ expected `bool`, found `()`
-error: aborting due to 9 previous errors
+error: aborting due to 10 previous errors
Some errors have detailed explanations: E0070, E0308, E0425, E0658.
For more information about an error, try `rustc --explain E0070`.
diff --git a/src/test/ui/symbol-names/basic.stderr b/src/test/ui/symbol-names/basic.stderr
deleted file mode 100644
index 7539cba..0000000
--- a/src/test/ui/symbol-names/basic.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error: symbol-name(_ZN5basic4main17hd72940ef9669d526E)
- --> $DIR/basic.rs:3:1
- |
-LL | #[rustc_symbol_name]
- | ^^^^^^^^^^^^^^^^^^^^
-
-error: def-path(main)
- --> $DIR/basic.rs:4:1
- |
-LL | #[rustc_def_path]
- | ^^^^^^^^^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/symbol-names/const-generics-str-demangling.rs b/src/test/ui/symbol-names/const-generics-str-demangling.rs
index af111dd..f450dfe 100644
--- a/src/test/ui/symbol-names/const-generics-str-demangling.rs
+++ b/src/test/ui/symbol-names/const-generics-str-demangling.rs
@@ -1,6 +1,6 @@
// build-fail
// compile-flags: -Z symbol-mangling-version=v0 --crate-name=c
-#![feature(const_generics, rustc_attrs)]
+#![feature(adt_const_params, rustc_attrs)]
#![allow(incomplete_features)]
pub struct Str<const S: &'static str>;
diff --git a/src/test/ui/symbol-names/const-generics-structural-demangling.rs b/src/test/ui/symbol-names/const-generics-structural-demangling.rs
index 9da6a0f..fa38848 100644
--- a/src/test/ui/symbol-names/const-generics-structural-demangling.rs
+++ b/src/test/ui/symbol-names/const-generics-structural-demangling.rs
@@ -6,7 +6,7 @@
// normalize-stderr-test: "Cs[0-9a-zA-Z]+_4core" -> "Cs$$HASH_4core"
// normalize-stderr-test: "core\[[0-9a-f]+\]" -> "core[$$HASH_HEX]"
-#![feature(const_generics, decl_macro, rustc_attrs)]
+#![feature(adt_const_params, decl_macro, rustc_attrs)]
#![allow(incomplete_features)]
pub struct RefByte<const RB: &'static u8>;
diff --git a/src/test/ui/traits/issue-85735.stderr b/src/test/ui/traits/issue-85735.stderr
index 7d7f6ea..1f81fa7 100644
--- a/src/test/ui/traits/issue-85735.stderr
+++ b/src/test/ui/traits/issue-85735.stderr
@@ -8,8 +8,12 @@
note: required by a bound in `FnMut`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
-LL | pub trait FnMut<Args>: FnOnce<Args> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `FnMut`
+LL | / pub trait FnMut<Args>: FnOnce<Args> {
+LL | | /// Performs the call operation.
+LL | | #[unstable(feature = "fn_traits", issue = "29625")]
+LL | | extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
+LL | | }
+ | |_^ required by this bound in `FnMut`
error: aborting due to previous error
diff --git a/src/test/ui/type-alias-impl-trait/assoc-type-const.rs b/src/test/ui/type-alias-impl-trait/assoc-type-const.rs
index d53f562..0ade36d 100644
--- a/src/test/ui/type-alias-impl-trait/assoc-type-const.rs
+++ b/src/test/ui/type-alias-impl-trait/assoc-type-const.rs
@@ -3,8 +3,6 @@
// check-pass
#![feature(type_alias_impl_trait)]
-#![feature(const_generics)]
-//~^ WARN the feature `const_generics` is incomplete
trait UnwrapItemsExt<'a, const C: usize> {
type Iter;
diff --git a/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr b/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr
deleted file mode 100644
index e0c1b02..0000000
--- a/src/test/ui/type-alias-impl-trait/assoc-type-const.stderr
+++ /dev/null
@@ -1,11 +0,0 @@
-warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/assoc-type-const.rs:6:12
- |
-LL | #![feature(const_generics)]
- | ^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
-
-warning: 1 warning emitted
-
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs
new file mode 100644
index 0000000..a158458
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+mod m {
+ type Foo = impl std::fmt::Debug;
+
+ pub fn foo() -> Foo {
+ 22_u32
+ }
+}
+
+fn is_send<T: Send>(_: T) {}
+
+fn main() {
+ is_send(m::foo());
+}
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs
new file mode 100644
index 0000000..745379e
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.rs
@@ -0,0 +1,19 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+mod m {
+ use std::rc::Rc;
+
+ type Foo = impl std::fmt::Debug;
+
+ pub fn foo() -> Foo {
+ Rc::new(22_u32)
+ }
+}
+
+fn is_send<T: Send>(_: T) {}
+
+fn main() {
+ is_send(m::foo());
+ //~^ ERROR: `Rc<u32>` cannot be sent between threads safely [E0277]
+}
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
new file mode 100644
index 0000000..d60be4b
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage2.stderr
@@ -0,0 +1,20 @@
+error[E0277]: `Rc<u32>` cannot be sent between threads safely
+ --> $DIR/auto-trait-leakage2.rs:17:5
+ |
+LL | type Foo = impl std::fmt::Debug;
+ | -------------------- within this `impl Debug`
+...
+LL | is_send(m::foo());
+ | ^^^^^^^ `Rc<u32>` cannot be sent between threads safely
+ |
+ = help: within `impl Debug`, the trait `Send` is not implemented for `Rc<u32>`
+ = note: required because it appears within the type `impl Debug`
+note: required by a bound in `is_send`
+ --> $DIR/auto-trait-leakage2.rs:14:15
+ |
+LL | fn is_send<T: Send>(_: T) {}
+ | ^^^^ required by this bound in `is_send`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs
new file mode 100644
index 0000000..5fb7a94
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.rs
@@ -0,0 +1,21 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+// FIXME This should compile, but it currently doesn't
+
+mod m {
+ type Foo = impl std::fmt::Debug;
+ //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
+
+ pub fn foo() -> Foo {
+ 22_u32
+ }
+
+ pub fn bar() {
+ is_send(foo());
+ }
+
+ fn is_send<T: Send>(_: T) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
new file mode 100644
index 0000000..ac7bbd2
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/auto-trait-leakage3.stderr
@@ -0,0 +1,22 @@
+error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
+ --> $DIR/auto-trait-leakage3.rs:7:16
+ |
+LL | type Foo = impl std::fmt::Debug;
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+note: ...which requires type-checking `m::bar`...
+ --> $DIR/auto-trait-leakage3.rs:14:5
+ |
+LL | pub fn bar() {
+ | ^^^^^^^^^^^^
+ = note: ...which requires evaluating trait selection obligation `impl std::fmt::Debug: std::marker::Send`...
+ = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
+note: cycle used when checking item types in module `m`
+ --> $DIR/auto-trait-leakage3.rs:6:1
+ |
+LL | mod m {
+ | ^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.full_tait.stderr b/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.full_tait.stderr
deleted file mode 100644
index 3ba04af..0000000
--- a/src/test/ui/type-alias-impl-trait/bounds-are-checked-2.full_tait.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/bounds-are-checked-2.rs:6:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error[E0277]: the trait bound `T: Clone` is not satisfied
- --> $DIR/bounds-are-checked-2.rs:9:13
- |
-LL | type X<T> = impl Clone;
- | ^^^^^^^^^^ the trait `Clone` is not implemented for `T`
- |
-help: consider restricting type parameter `T`
- |
-LL | type X<T: std::clone::Clone> = impl Clone;
- | +++++++++++++++++++
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
index e45950c..a4e40f5 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
@@ -1,6 +1,4 @@
-#![feature(const_generics)]
#![feature(type_alias_impl_trait)]
-#![allow(incomplete_features)]
use std::fmt::Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
index 7ea5efd..641cce2 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
@@ -1,35 +1,35 @@
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:14:30
+ --> $DIR/generic_duplicate_param_use.rs:12:30
|
LL | fn one_ty<T: Debug>(t: T) -> TwoTys<T, T> {
| ^^^^^^^^^^^^
|
note: type used multiple times
- --> $DIR/generic_duplicate_param_use.rs:10:13
+ --> $DIR/generic_duplicate_param_use.rs:8:13
|
LL | type TwoTys<T, U> = impl Debug;
| ^ ^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:19:36
+ --> $DIR/generic_duplicate_param_use.rs:17:36
|
LL | fn one_lifetime<'a>(t: &'a u32) -> TwoLifetimes<'a, 'a> {
| ^^^^^^^^^^^^^^^^^^^^
|
note: lifetime used multiple times
- --> $DIR/generic_duplicate_param_use.rs:11:19
+ --> $DIR/generic_duplicate_param_use.rs:9:19
|
LL | type TwoLifetimes<'a, 'b> = impl Debug;
| ^^ ^^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:24:50
+ --> $DIR/generic_duplicate_param_use.rs:22:50
|
LL | fn one_const<const N: usize>(t: *mut [u8; N]) -> TwoConsts<N, N> {
| ^^^^^^^^^^^^^^^
|
note: constant used multiple times
- --> $DIR/generic_duplicate_param_use.rs:12:22
+ --> $DIR/generic_duplicate_param_use.rs:10:22
|
LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug;
| ^ ^
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.full_tait.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.full_tait.stderr
deleted file mode 100644
index 918121c..0000000
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.full_tait.stderr
+++ /dev/null
@@ -1,48 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_duplicate_param_use5.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error: concrete type differs from previous defining opaque type use
- --> $DIR/generic_duplicate_param_use5.rs:19:1
- |
-LL | fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, U)`, got `(U, T)`
- |
-note: previous use here
- --> $DIR/generic_duplicate_param_use5.rs:15:1
- |
-LL | fn two<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0277]: `T` doesn't implement `Debug`
- --> $DIR/generic_duplicate_param_use5.rs:11:18
- |
-LL | type Two<T, U> = impl Debug;
- | ^^^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = note: required because of the requirements on the impl of `Debug` for `(T, U)`
-help: consider restricting type parameter `T`
- |
-LL | type Two<T: std::fmt::Debug, U> = impl Debug;
- | +++++++++++++++++
-
-error[E0277]: `U` doesn't implement `Debug`
- --> $DIR/generic_duplicate_param_use5.rs:11:18
- |
-LL | type Two<T, U> = impl Debug;
- | ^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = note: required because of the requirements on the impl of `Debug` for `(T, U)`
-help: consider restricting type parameter `U`
- |
-LL | type Two<T, U: std::fmt::Debug> = impl Debug;
- | +++++++++++++++++
-
-error: aborting due to 3 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.full_tait.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.full_tait.stderr
deleted file mode 100644
index 394b428..0000000
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.full_tait.stderr
+++ /dev/null
@@ -1,36 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_duplicate_param_use6.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error: concrete type differs from previous defining opaque type use
- --> $DIR/generic_duplicate_param_use6.rs:18:1
- |
-LL | fn three<T: Copy + Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, T)`, got `(U, T)`
- |
-note: previous use here
- --> $DIR/generic_duplicate_param_use6.rs:14:1
- |
-LL | fn two<T: Copy + Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0277]: `T` doesn't implement `Debug`
- --> $DIR/generic_duplicate_param_use6.rs:11:18
- |
-LL | type Two<T, U> = impl Debug;
- | ^^^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = note: required because of the requirements on the impl of `Debug` for `(T, T)`
-help: consider restricting type parameter `T`
- |
-LL | type Two<T: std::fmt::Debug, U> = impl Debug;
- | +++++++++++++++++
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.full_tait.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.full_tait.stderr
deleted file mode 100644
index 8c6ea3b..0000000
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.full_tait.stderr
+++ /dev/null
@@ -1,36 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_duplicate_param_use8.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error: concrete type differs from previous defining opaque type use
- --> $DIR/generic_duplicate_param_use8.rs:17:1
- |
-LL | fn three<T: Debug, U: Debug>(_: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(T, u32)`, got `(U, u32)`
- |
-note: previous use here
- --> $DIR/generic_duplicate_param_use8.rs:13:1
- |
-LL | fn two<T: Debug, U: Debug>(t: T, _: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0277]: `T` doesn't implement `Debug`
- --> $DIR/generic_duplicate_param_use8.rs:10:18
- |
-LL | type Two<T, U> = impl Debug;
- | ^^^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = note: required because of the requirements on the impl of `Debug` for `(T, u32)`
-help: consider restricting type parameter `T`
- |
-LL | type Two<T: std::fmt::Debug, U> = impl Debug;
- | +++++++++++++++++
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.full_tait.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.full_tait.stderr
deleted file mode 100644
index d0176b1..0000000
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.full_tait.stderr
+++ /dev/null
@@ -1,60 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_duplicate_param_use9.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error: concrete type differs from previous defining opaque type use
- --> $DIR/generic_duplicate_param_use9.rs:24:1
- |
-LL | fn three<T: Debug, U: Debug>(t: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `(A, B, <A as Foo>::Bar)`, got `(A, B, i32)`
- |
-note: previous use here
- --> $DIR/generic_duplicate_param_use9.rs:20:1
- |
-LL | fn two<T: Debug + Foo, U: Debug>(t: T, u: U) -> Two<T, U> {
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0277]: the trait bound `A: Foo` is not satisfied in `(A, B, <A as Foo>::Bar)`
- --> $DIR/generic_duplicate_param_use9.rs:10:18
- |
-LL | type Two<A, B> = impl Debug;
- | ^^^^^^^^^^ within `(A, B, <A as Foo>::Bar)`, the trait `Foo` is not implemented for `A`
- |
- = note: required because it appears within the type `(A, B, <A as Foo>::Bar)`
-help: consider restricting type parameter `A`
- |
-LL | type Two<A: Foo, B> = impl Debug;
- | +++++
-
-error[E0277]: `A` doesn't implement `Debug`
- --> $DIR/generic_duplicate_param_use9.rs:10:18
- |
-LL | type Two<A, B> = impl Debug;
- | ^^^^^^^^^^ `A` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = note: required because of the requirements on the impl of `Debug` for `(A, B, <A as Foo>::Bar)`
-help: consider restricting type parameter `A`
- |
-LL | type Two<A: std::fmt::Debug, B> = impl Debug;
- | +++++++++++++++++
-
-error[E0277]: `B` doesn't implement `Debug`
- --> $DIR/generic_duplicate_param_use9.rs:10:18
- |
-LL | type Two<A, B> = impl Debug;
- | ^^^^^^^^^^ `B` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
- = note: required because of the requirements on the impl of `Debug` for `(A, B, <A as Foo>::Bar)`
-help: consider restricting type parameter `B`
- |
-LL | type Two<A, B: std::fmt::Debug> = impl Debug;
- | +++++++++++++++++
-
-error: aborting due to 4 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs
index 9f1bfff..7ee5f7b 100644
--- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.rs
@@ -1,6 +1,4 @@
-#![feature(const_generics)]
#![feature(type_alias_impl_trait)]
-#![allow(incomplete_features)]
use std::fmt::Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr
index eb0c296..5b42f10 100644
--- a/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_nondefining_use.stderr
@@ -1,17 +1,17 @@
error: non-defining opaque type use in defining scope
- --> $DIR/generic_nondefining_use.rs:15:21
+ --> $DIR/generic_nondefining_use.rs:13:21
|
LL | fn concrete_ty() -> OneTy<u32> {
| ^^^^^^^^^^
|
note: used non-generic type `u32` for generic parameter
- --> $DIR/generic_nondefining_use.rs:9:12
+ --> $DIR/generic_nondefining_use.rs:7:12
|
LL | type OneTy<T> = impl Debug;
| ^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_nondefining_use.rs:20:27
+ --> $DIR/generic_nondefining_use.rs:18:27
|
LL | type OneLifetime<'a> = impl Debug;
| -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
@@ -20,13 +20,13 @@
| ^^^^^^^^^^^^^^^^^^^^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_nondefining_use.rs:25:24
+ --> $DIR/generic_nondefining_use.rs:23:24
|
LL | fn concrete_const() -> OneConst<{ 123 }> {
| ^^^^^^^^^^^^^^^^^
|
-note: used non-generic constant `{ 123 }` for generic parameter
- --> $DIR/generic_nondefining_use.rs:11:21
+note: used non-generic constant `123_usize` for generic parameter
+ --> $DIR/generic_nondefining_use.rs:9:21
|
LL | type OneConst<const X: usize> = impl Debug;
| ^
diff --git a/src/test/ui/type-alias-impl-trait/generic_underconstrained.full_tait.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained.full_tait.stderr
deleted file mode 100644
index 74d5c0c..0000000
--- a/src/test/ui/type-alias-impl-trait/generic_underconstrained.full_tait.stderr
+++ /dev/null
@@ -1,32 +0,0 @@
-error: at least one trait must be specified
- --> $DIR/generic_underconstrained.rs:9:35
- |
-LL | type Underconstrained<T: Trait> = impl 'static;
- | ^^^^^^^^^^^^
-
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_underconstrained.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error[E0277]: the trait bound `T: Trait` is not satisfied
- --> $DIR/generic_underconstrained.rs:13:31
- |
-LL | type Underconstrained<T: Trait> = impl 'static;
- | ----- required by this bound in `Underconstrained`
-...
-LL | fn underconstrain<T>(_: T) -> Underconstrained<T> {
- | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `T`
- |
-help: consider restricting type parameter `T`
- |
-LL | fn underconstrain<T: Trait>(_: T) -> Underconstrained<T> {
- | +++++++
-
-error: aborting due to 2 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/generic_underconstrained2.full_tait.stderr b/src/test/ui/type-alias-impl-trait/generic_underconstrained2.full_tait.stderr
deleted file mode 100644
index 348563b..0000000
--- a/src/test/ui/type-alias-impl-trait/generic_underconstrained2.full_tait.stderr
+++ /dev/null
@@ -1,52 +0,0 @@
-error: at least one trait must be specified
- --> $DIR/generic_underconstrained2.rs:8:45
- |
-LL | type Underconstrained<T: std::fmt::Debug> = impl 'static;
- | ^^^^^^^^^^^^
-
-error: at least one trait must be specified
- --> $DIR/generic_underconstrained2.rs:17:46
- |
-LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static;
- | ^^^^^^^^^^^^
-
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/generic_underconstrained2.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error[E0277]: `U` doesn't implement `Debug`
- --> $DIR/generic_underconstrained2.rs:12:33
- |
-LL | type Underconstrained<T: std::fmt::Debug> = impl 'static;
- | --------------- required by this bound in `Underconstrained`
-...
-LL | fn underconstrained<U>(_: U) -> Underconstrained<U> {
- | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
-help: consider restricting type parameter `U`
- |
-LL | fn underconstrained<U: std::fmt::Debug>(_: U) -> Underconstrained<U> {
- | +++++++++++++++++
-
-error[E0277]: `V` doesn't implement `Debug`
- --> $DIR/generic_underconstrained2.rs:21:43
- |
-LL | type Underconstrained2<T: std::fmt::Debug> = impl 'static;
- | --------------- required by this bound in `Underconstrained2`
-...
-LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> {
- | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug`
- |
-help: consider restricting type parameter `V`
- |
-LL | fn underconstrained2<U, V: std::fmt::Debug>(_: U, _: V) -> Underconstrained2<V> {
- | +++++++++++++++++
-
-error: aborting due to 4 previous errors; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/inference-cycle.rs b/src/test/ui/type-alias-impl-trait/inference-cycle.rs
new file mode 100644
index 0000000..c781e20
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/inference-cycle.rs
@@ -0,0 +1,26 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+mod m {
+ type Foo = impl std::fmt::Debug;
+ //~^ ERROR: cycle detected when computing type of `m::Foo::{opaque#0}` [E0391]
+
+ // Cycle: error today, but it'd be nice if it eventually worked
+
+ pub fn foo() -> Foo {
+ is_send(bar())
+ }
+
+ pub fn bar() {
+ is_send(foo()); // Today: error
+ }
+
+ fn baz() {
+ let f: Foo = 22_u32;
+ //~^ ERROR: mismatched types [E0308]
+ }
+
+ fn is_send<T: Send>(_: T) {}
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/inference-cycle.stderr b/src/test/ui/type-alias-impl-trait/inference-cycle.stderr
new file mode 100644
index 0000000..ac0ca8e
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/inference-cycle.stderr
@@ -0,0 +1,37 @@
+error[E0391]: cycle detected when computing type of `m::Foo::{opaque#0}`
+ --> $DIR/inference-cycle.rs:5:16
+ |
+LL | type Foo = impl std::fmt::Debug;
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+note: ...which requires type-checking `m::bar`...
+ --> $DIR/inference-cycle.rs:14:5
+ |
+LL | pub fn bar() {
+ | ^^^^^^^^^^^^
+ = note: ...which requires evaluating trait selection obligation `impl std::fmt::Debug: std::marker::Send`...
+ = note: ...which again requires computing type of `m::Foo::{opaque#0}`, completing the cycle
+note: cycle used when checking item types in module `m`
+ --> $DIR/inference-cycle.rs:4:1
+ |
+LL | mod m {
+ | ^^^^^
+
+error[E0308]: mismatched types
+ --> $DIR/inference-cycle.rs:19:22
+ |
+LL | type Foo = impl std::fmt::Debug;
+ | -------------------- the expected opaque type
+...
+LL | let f: Foo = 22_u32;
+ | --- ^^^^^^ expected opaque type, found `u32`
+ | |
+ | expected due to this
+ |
+ = note: expected opaque type `impl Debug`
+ found type `u32`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0391.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type-alias-impl-trait/issue-52843.full_tait.stderr b/src/test/ui/type-alias-impl-trait/issue-52843.full_tait.stderr
deleted file mode 100644
index 16b1830..0000000
--- a/src/test/ui/type-alias-impl-trait/issue-52843.full_tait.stderr
+++ /dev/null
@@ -1,23 +0,0 @@
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/issue-52843.rs:3:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error[E0277]: the trait bound `T: Default` is not satisfied
- --> $DIR/issue-52843.rs:6:15
- |
-LL | type Foo<T> = impl Default;
- | ^^^^^^^^^^^^ the trait `Default` is not implemented for `T`
- |
-help: consider restricting type parameter `T`
- |
-LL | type Foo<T: std::default::Default> = impl Default;
- | +++++++++++++++++++++++
-
-error: aborting due to previous error; 1 warning emitted
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs
new file mode 100644
index 0000000..efb88da
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+use std::fmt::Debug;
+
+type FooX = impl Debug;
+
+trait Foo<A> { }
+
+impl Foo<()> for () { }
+
+fn foo() -> impl Foo<FooX> {
+ ()
+}
+
+fn main() { }
diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs
new file mode 100644
index 0000000..9b26a65
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.rs
@@ -0,0 +1,19 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+use std::fmt::Debug;
+
+type FooX = impl Debug;
+//~^ ERROR: could not find defining uses
+
+trait Foo<A> {}
+
+impl Foo<()> for () {}
+impl Foo<u32> for () {}
+
+fn foo() -> impl Foo<FooX> {
+ //~^ ERROR: the trait bound `(): Foo<impl Debug>` is not satisfied [E0277]
+ ()
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr
new file mode 100644
index 0000000..7e24ee6
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/nested-tait-inference2.stderr
@@ -0,0 +1,19 @@
+error[E0277]: the trait bound `(): Foo<impl Debug>` is not satisfied
+ --> $DIR/nested-tait-inference2.rs:14:13
+ |
+LL | fn foo() -> impl Foo<FooX> {
+ | ^^^^^^^^^^^^^^ the trait `Foo<impl Debug>` is not implemented for `()`
+ |
+ = help: the following implementations were found:
+ <() as Foo<()>>
+ <() as Foo<u32>>
+
+error: could not find defining uses
+ --> $DIR/nested-tait-inference2.rs:6:13
+ |
+LL | type FooX = impl Debug;
+ | ^^^^^^^^^^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/type-alias-impl-trait/static-const-types.rs b/src/test/ui/type-alias-impl-trait/static-const-types.rs
new file mode 100644
index 0000000..f630d27
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/static-const-types.rs
@@ -0,0 +1,16 @@
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+// FIXME: This should compile, but it currently doesn't
+
+use std::fmt::Debug;
+
+type Foo = impl Debug;
+//~^ ERROR: could not find defining uses
+
+static FOO1: Foo = 22_u32;
+//~^ ERROR: mismatched types [E0308]
+const FOO2: Foo = 22_u32;
+//~^ ERROR: mismatched types [E0308]
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/static-const-types.stderr b/src/test/ui/type-alias-impl-trait/static-const-types.stderr
new file mode 100644
index 0000000..72083d0
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/static-const-types.stderr
@@ -0,0 +1,33 @@
+error[E0308]: mismatched types
+ --> $DIR/static-const-types.rs:11:20
+ |
+LL | type Foo = impl Debug;
+ | ---------- the expected opaque type
+...
+LL | static FOO1: Foo = 22_u32;
+ | ^^^^^^ expected opaque type, found `u32`
+ |
+ = note: expected opaque type `impl Debug`
+ found type `u32`
+
+error[E0308]: mismatched types
+ --> $DIR/static-const-types.rs:13:19
+ |
+LL | type Foo = impl Debug;
+ | ---------- the expected opaque type
+...
+LL | const FOO2: Foo = 22_u32;
+ | ^^^^^^ expected opaque type, found `u32`
+ |
+ = note: expected opaque type `impl Debug`
+ found type `u32`
+
+error: could not find defining uses
+ --> $DIR/static-const-types.rs:8:12
+ |
+LL | type Foo = impl Debug;
+ | ^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type-alias-impl-trait/weird-return-types.rs b/src/test/ui/type-alias-impl-trait/weird-return-types.rs
new file mode 100644
index 0000000..faad5ee
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/weird-return-types.rs
@@ -0,0 +1,16 @@
+// edition:2018
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+use std::future::Future;
+use std::fmt::Debug;
+
+type Foo = impl Debug;
+
+fn f() -> impl Future<Output = Foo> {
+ async move { 22_u32 }
+}
+
+fn main() {}
diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.full_tait.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.full_tait.stderr
deleted file mode 100644
index 6ba28c3..0000000
--- a/src/test/ui/typeck/typeck_type_placeholder_item.full_tait.stderr
+++ /dev/null
@@ -1,647 +0,0 @@
-error: expected identifier, found reserved identifier `_`
- --> $DIR/typeck_type_placeholder_item.rs:157:18
- |
-LL | struct BadStruct<_>(_);
- | ^ expected identifier, found reserved identifier
-
-error: expected identifier, found reserved identifier `_`
- --> $DIR/typeck_type_placeholder_item.rs:160:16
- |
-LL | trait BadTrait<_> {}
- | ^ expected identifier, found reserved identifier
-
-error: expected identifier, found reserved identifier `_`
- --> $DIR/typeck_type_placeholder_item.rs:170:19
- |
-LL | struct BadStruct1<_, _>(_);
- | ^ expected identifier, found reserved identifier
-
-error: expected identifier, found reserved identifier `_`
- --> $DIR/typeck_type_placeholder_item.rs:170:22
- |
-LL | struct BadStruct1<_, _>(_);
- | ^ expected identifier, found reserved identifier
-
-error: expected identifier, found reserved identifier `_`
- --> $DIR/typeck_type_placeholder_item.rs:175:19
- |
-LL | struct BadStruct2<_, T>(_, T);
- | ^ expected identifier, found reserved identifier
-
-error: associated constant in `impl` without body
- --> $DIR/typeck_type_placeholder_item.rs:208:5
- |
-LL | const C: _;
- | ^^^^^^^^^^-
- | |
- | help: provide a definition for the constant: `= <expr>;`
-
-error[E0403]: the name `_` is already used for a generic parameter in this item's generic parameters
- --> $DIR/typeck_type_placeholder_item.rs:170:22
- |
-LL | struct BadStruct1<_, _>(_);
- | - ^ already used
- | |
- | first use of `_`
-
-warning: the feature `type_alias_impl_trait` is incomplete and may not be safe to use and/or cause compiler crashes
- --> $DIR/typeck_type_placeholder_item.rs:5:32
- |
-LL | #![cfg_attr(full_tait, feature(type_alias_impl_trait))]
- | ^^^^^^^^^^^^^^^^^^^^^
- |
- = note: `#[warn(incomplete_features)]` on by default
- = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:10:14
- |
-LL | fn test() -> _ { 5 }
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct return type: `i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:13:16
- |
-LL | fn test2() -> (_, _) { (5, 5) }
- | -^--^-
- | || |
- | || not allowed in type signatures
- | |not allowed in type signatures
- | help: replace with the correct return type: `(i32, i32)`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:16:15
- |
-LL | static TEST3: _ = "test";
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `&str`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:19:15
- |
-LL | static TEST4: _ = 145;
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:22:15
- |
-LL | static TEST5: (_, _) = (1, 2);
- | ^^^^^^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:25:13
- |
-LL | fn test6(_: _) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test6<T>(_: T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:28:18
- |
-LL | fn test6_b<T>(_: _, _: T) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test6_b<T, U>(_: U, _: T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:31:30
- |
-LL | fn test6_c<T, K, L, A, B>(_: _, _: (T, K, L, A, B)) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test6_c<T, K, L, A, B, U>(_: U, _: (T, K, L, A, B)) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:34:13
- |
-LL | fn test7(x: _) { let _x: usize = x; }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test7<T>(x: T) { let _x: usize = x; }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:37:22
- |
-LL | fn test8(_f: fn() -> _) { }
- | ^
- | |
- | not allowed in type signatures
- | help: use type parameters instead: `T`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:37:22
- |
-LL | fn test8(_f: fn() -> _) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test8<T>(_f: fn() -> T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:51:26
- |
-LL | fn test11(x: &usize) -> &_ {
- | -^
- | ||
- | |not allowed in type signatures
- | help: replace with the correct return type: `&'static &'static usize`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:56:52
- |
-LL | unsafe fn test12(x: *const usize) -> *const *const _ {
- | --------------^
- | | |
- | | not allowed in type signatures
- | help: replace with the correct return type: `*const *const usize`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs
- --> $DIR/typeck_type_placeholder_item.rs:70:8
- |
-LL | a: _,
- | ^ not allowed in type signatures
-LL |
-LL | b: (_, _),
- | ^ ^ not allowed in type signatures
- | |
- | not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL ~ struct Test10<T> {
-LL ~ a: T,
-LL |
-LL ~ b: (T, T),
- |
-
-error: missing type for `static` item
- --> $DIR/typeck_type_placeholder_item.rs:76:12
- |
-LL | static A = 42;
- | ^ help: provide a type for the static variable: `A: i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:78:15
- |
-LL | static B: _ = 42;
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:80:15
- |
-LL | static C: Option<_> = Some(42);
- | ^^^^^^^^^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:82:21
- |
-LL | fn fn_test() -> _ { 5 }
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct return type: `i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:85:23
- |
-LL | fn fn_test2() -> (_, _) { (5, 5) }
- | -^--^-
- | || |
- | || not allowed in type signatures
- | |not allowed in type signatures
- | help: replace with the correct return type: `(i32, i32)`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:88:22
- |
-LL | static FN_TEST3: _ = "test";
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `&str`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:91:22
- |
-LL | static FN_TEST4: _ = 145;
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for static variables
- --> $DIR/typeck_type_placeholder_item.rs:94:22
- |
-LL | static FN_TEST5: (_, _) = (1, 2);
- | ^^^^^^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:97:20
- |
-LL | fn fn_test6(_: _) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test6<T>(_: T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:100:20
- |
-LL | fn fn_test7(x: _) { let _x: usize = x; }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test7<T>(x: T) { let _x: usize = x; }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:103:29
- |
-LL | fn fn_test8(_f: fn() -> _) { }
- | ^
- | |
- | not allowed in type signatures
- | help: use type parameters instead: `T`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:103:29
- |
-LL | fn fn_test8(_f: fn() -> _) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test8<T>(_f: fn() -> T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs
- --> $DIR/typeck_type_placeholder_item.rs:126:12
- |
-LL | a: _,
- | ^ not allowed in type signatures
-LL |
-LL | b: (_, _),
- | ^ ^ not allowed in type signatures
- | |
- | not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL ~ struct FnTest10<T> {
-LL ~ a: T,
-LL |
-LL ~ b: (T, T),
- |
-
-error[E0282]: type annotations needed
- --> $DIR/typeck_type_placeholder_item.rs:131:18
- |
-LL | fn fn_test11(_: _) -> (_, _) { panic!() }
- | ^ cannot infer type
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:131:28
- |
-LL | fn fn_test11(_: _) -> (_, _) { panic!() }
- | ^ ^ not allowed in type signatures
- | |
- | not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:135:30
- |
-LL | fn fn_test12(x: i32) -> (_, _) { (x, x) }
- | -^--^-
- | || |
- | || not allowed in type signatures
- | |not allowed in type signatures
- | help: replace with the correct return type: `(i32, i32)`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:138:33
- |
-LL | fn fn_test13(x: _) -> (i32, _) { (x, x) }
- | ------^-
- | | |
- | | not allowed in type signatures
- | help: replace with the correct return type: `(i32, i32)`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs
- --> $DIR/typeck_type_placeholder_item.rs:157:21
- |
-LL | struct BadStruct<_>(_);
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | struct BadStruct<T>(T);
- | ~ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for implementations
- --> $DIR/typeck_type_placeholder_item.rs:162:15
- |
-LL | impl BadTrait<_> for BadStruct<_> {}
- | ^ ^ not allowed in type signatures
- | |
- | not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | impl<T> BadTrait<T> for BadStruct<T> {}
- | +++ ~ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for opaque types
- --> $DIR/typeck_type_placeholder_item.rs:165:34
- |
-LL | fn impl_trait() -> impl BadTrait<_> {
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs
- --> $DIR/typeck_type_placeholder_item.rs:170:25
- |
-LL | struct BadStruct1<_, _>(_);
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | struct BadStruct1<T, _>(T);
- | ~ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for structs
- --> $DIR/typeck_type_placeholder_item.rs:175:25
- |
-LL | struct BadStruct2<_, T>(_, T);
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | struct BadStruct2<U, T>(U, T);
- | ~ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for type aliases
- --> $DIR/typeck_type_placeholder_item.rs:179:14
- |
-LL | type X = Box<_>;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for opaque types
- --> $DIR/typeck_type_placeholder_item.rs:185:21
- |
-LL | type Y = impl Trait<_>;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:219:31
- |
-LL | fn value() -> Option<&'static _> {
- | ----------------^-
- | | |
- | | not allowed in type signatures
- | help: replace with the correct return type: `Option<&'static u8>`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants
- --> $DIR/typeck_type_placeholder_item.rs:224:10
- |
-LL | const _: Option<_> = map(value);
- | ^^^^^^^^^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `Option<u8>`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:143:31
- |
-LL | fn method_test1(&self, x: _);
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn method_test1<T>(&self, x: T);
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:145:31
- |
-LL | fn method_test2(&self, x: _) -> _;
- | ^ ^ not allowed in type signatures
- | |
- | not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn method_test2<T>(&self, x: T) -> T;
- | +++ ~ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:147:31
- |
-LL | fn method_test3(&self) -> _;
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn method_test3<T>(&self) -> T;
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:149:26
- |
-LL | fn assoc_fn_test1(x: _);
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn assoc_fn_test1<T>(x: T);
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:151:26
- |
-LL | fn assoc_fn_test2(x: _) -> _;
- | ^ ^ not allowed in type signatures
- | |
- | not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn assoc_fn_test2<T>(x: T) -> T;
- | +++ ~ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:153:28
- |
-LL | fn assoc_fn_test3() -> _;
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn assoc_fn_test3<T>() -> T;
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types
- --> $DIR/typeck_type_placeholder_item.rs:193:14
- |
-LL | type B = _;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants
- --> $DIR/typeck_type_placeholder_item.rs:195:14
- |
-LL | const C: _;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants
- --> $DIR/typeck_type_placeholder_item.rs:197:14
- |
-LL | const D: _ = 42;
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `i32`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types
- --> $DIR/typeck_type_placeholder_item.rs:200:26
- |
-LL | type F: std::ops::Fn(_);
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:44:24
- |
-LL | fn test9(&self) -> _ { () }
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct return type: `()`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:47:27
- |
-LL | fn test10(&self, _x : _) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn test10<T>(&self, _x : T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:62:24
- |
-LL | fn clone(&self) -> _ { Test9 }
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct return type: `Test9`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:65:37
- |
-LL | fn clone_from(&mut self, other: _) { *self = Test9; }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn clone_from<T>(&mut self, other: T) { *self = Test9; }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:110:31
- |
-LL | fn fn_test9(&self) -> _ { () }
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct return type: `()`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:113:34
- |
-LL | fn fn_test10(&self, _x : _) { }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn fn_test10<T>(&self, _x : T) { }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
- --> $DIR/typeck_type_placeholder_item.rs:118:28
- |
-LL | fn clone(&self) -> _ { FnTest9 }
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct return type: `FnTest9`
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for functions
- --> $DIR/typeck_type_placeholder_item.rs:121:41
- |
-LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
- | ^ not allowed in type signatures
- |
-help: use type parameters instead
- |
-LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
- | +++ ~
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types
- --> $DIR/typeck_type_placeholder_item.rs:204:14
- |
-LL | type A = _;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for associated types
- --> $DIR/typeck_type_placeholder_item.rs:206:14
- |
-LL | type B = _;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants
- --> $DIR/typeck_type_placeholder_item.rs:208:14
- |
-LL | const C: _;
- | ^ not allowed in type signatures
-
-error[E0121]: the type placeholder `_` is not allowed within types on item signatures for constants
- --> $DIR/typeck_type_placeholder_item.rs:211:14
- |
-LL | const D: _ = 42;
- | ^
- | |
- | not allowed in type signatures
- | help: replace with the correct type: `i32`
-
-error: aborting due to 69 previous errors; 1 warning emitted
-
-Some errors have detailed explanations: E0121, E0282, E0403.
-For more information about an error, try `rustc --explain E0121`.
diff --git a/src/test/ui/unsized/param-mentioned-by-different-field.rs b/src/test/ui/unsized/param-mentioned-by-different-field.rs
new file mode 100644
index 0000000..cda94b3
--- /dev/null
+++ b/src/test/ui/unsized/param-mentioned-by-different-field.rs
@@ -0,0 +1,10 @@
+// We must not allow this with our current setup as `T`
+// is mentioned both in the tail of `Foo` and by another
+// field.
+struct Foo<T: ?Sized>(Box<T>, T);
+
+fn main() {
+ let x: Foo<[u8; 1]> = Foo(Box::new([2]), [3]);
+ let y: &Foo<[u8]> = &x; //~ ERROR mismatched types
+ assert_eq!(y.0.len(), 1);
+}
diff --git a/src/test/ui/unsized/param-mentioned-by-different-field.stderr b/src/test/ui/unsized/param-mentioned-by-different-field.stderr
new file mode 100644
index 0000000..d18fa64
--- /dev/null
+++ b/src/test/ui/unsized/param-mentioned-by-different-field.stderr
@@ -0,0 +1,14 @@
+error[E0308]: mismatched types
+ --> $DIR/param-mentioned-by-different-field.rs:8:25
+ |
+LL | let y: &Foo<[u8]> = &x;
+ | ---------- ^^ expected slice `[u8]`, found array `[u8; 1]`
+ | |
+ | expected due to this
+ |
+ = note: expected reference `&Foo<[u8]>`
+ found reference `&Foo<[u8; 1]>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/tools/clippy/clippy_lints/src/missing_doc.rs b/src/tools/clippy/clippy_lints/src/missing_doc.rs
index d358e9f..940eee7 100644
--- a/src/tools/clippy/clippy_lints/src/missing_doc.rs
+++ b/src/tools/clippy/clippy_lints/src/missing_doc.rs
@@ -122,6 +122,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
},
hir::ItemKind::Const(..)
| hir::ItemKind::Enum(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::Struct(..)
diff --git a/src/tools/clippy/clippy_lints/src/missing_inline.rs b/src/tools/clippy/clippy_lints/src/missing_inline.rs
index 977e6d9..667cdd8 100644
--- a/src/tools/clippy/clippy_lints/src/missing_inline.rs
+++ b/src/tools/clippy/clippy_lints/src/missing_inline.rs
@@ -118,6 +118,7 @@ fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
},
hir::ItemKind::Const(..)
| hir::ItemKind::Enum(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::Struct(..)
diff --git a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs
index ac21eb5..2ffc00b 100644
--- a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs
+++ b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs
@@ -316,8 +316,11 @@ fn apply<F: for<'c> Fn(&'c mut Self)>(&mut self, f: F) {
impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> {
fn visit_local(&mut self, local: &'tcx Local) {
- if let Some(ref init) = local.init {
- self.apply(|this| walk_expr(this, &**init));
+ if let Some((init, els)) = &local.kind.init_else_opt() {
+ self.apply(|this| walk_expr(this, init));
+ if let Some(els) = els {
+ self.apply(|this| walk_block(this, els));
+ }
}
// add the pattern after the expression because the bindings aren't available
// yet in the init
diff --git a/src/tools/clippy/clippy_lints/src/utils/inspector.rs b/src/tools/clippy/clippy_lints/src/utils/inspector.rs
index 6bf216c..e97983a 100644
--- a/src/tools/clippy/clippy_lints/src/utils/inspector.rs
+++ b/src/tools/clippy/clippy_lints/src/utils/inspector.rs
@@ -381,6 +381,13 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
let item_ty = cx.tcx.type_of(did);
println!("function of type {:#?}", item_ty);
},
+ hir::ItemKind::Macro(ref macro_def) => {
+ if macro_def.macro_rules {
+ println!("macro introduced by `macro_rules!`");
+ } else {
+ println!("macro introduced by `macro`");
+ }
+ },
hir::ItemKind::Mod(..) => println!("module"),
hir::ItemKind::ForeignMod { abi, .. } => println!("foreign module with abi: {}", abi),
hir::ItemKind::GlobalAsm(asm) => println!("global asm: {:?}", asm),
diff --git a/src/tools/clippy/clippy_utils/src/ast_utils.rs b/src/tools/clippy/clippy_utils/src/ast_utils.rs
index 7ea07a1..133f6c2 100644
--- a/src/tools/clippy/clippy_utils/src/ast_utils.rs
+++ b/src/tools/clippy/clippy_utils/src/ast_utils.rs
@@ -221,7 +221,7 @@ pub fn eq_stmt(l: &Stmt, r: &Stmt) -> bool {
(Local(l), Local(r)) => {
eq_pat(&l.pat, &r.pat)
&& both(&l.ty, &r.ty, |l, r| eq_ty(l, r))
- && eq_expr_opt(&l.init, &r.init)
+ && eq_local_kind(&l.kind, &r.kind)
&& over(&l.attrs, &r.attrs, |l, r| eq_attr(l, r))
},
(Item(l), Item(r)) => eq_item(l, r, eq_item_kind),
@@ -234,6 +234,16 @@ pub fn eq_stmt(l: &Stmt, r: &Stmt) -> bool {
}
}
+pub fn eq_local_kind(l: &LocalKind, r: &LocalKind) -> bool {
+ use LocalKind::*;
+ match (l, r) {
+ (Decl, Decl) => true,
+ (Init(l), Init(r)) => eq_expr(l, r),
+ (InitElse(li, le), InitElse(ri, re)) => eq_expr(li, ri) && eq_block(le, re),
+ _ => false,
+ }
+}
+
pub fn eq_item<K>(l: &Item<K>, r: &Item<K>, mut eq_kind: impl FnMut(&K, &K) -> bool) -> bool {
eq_id(l.ident, r.ident)
&& over(&l.attrs, &r.attrs, |l, r| eq_attr(l, r))
diff --git a/src/tools/clippy/tests/ui/crashes/ice-4775.rs b/src/tools/clippy/tests/ui/crashes/ice-4775.rs
index 31e53e8..405e303 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-4775.rs
+++ b/src/tools/clippy/tests/ui/crashes/ice-4775.rs
@@ -1,6 +1,3 @@
-#![feature(const_generics)]
-#![allow(incomplete_features)]
-
pub struct ArrayWrapper<const N: usize>([usize; N]);
impl<const N: usize> ArrayWrapper<{ N }> {
diff --git a/src/tools/clippy/tests/ui/crashes/ice-5223.rs b/src/tools/clippy/tests/ui/crashes/ice-5223.rs
index 9bb2e22..e3b3b27 100644
--- a/src/tools/clippy/tests/ui/crashes/ice-5223.rs
+++ b/src/tools/clippy/tests/ui/crashes/ice-5223.rs
@@ -1,7 +1,4 @@
// Regression test for #5233
-
-#![feature(const_generics)]
-#![allow(incomplete_features)]
#![warn(clippy::indexing_slicing, clippy::iter_cloned_collect)]
pub struct KotomineArray<T, const N: usize> {
diff --git a/src/tools/clippy/tests/ui/doc/doc.rs b/src/tools/clippy/tests/ui/doc/doc.rs
index 8afef6b..8b0c0f3 100644
--- a/src/tools/clippy/tests/ui/doc/doc.rs
+++ b/src/tools/clippy/tests/ui/doc/doc.rs
@@ -2,7 +2,7 @@
#![allow(dead_code, incomplete_features)]
#![warn(clippy::doc_markdown)]
-#![feature(custom_inner_attributes, const_generics, const_evaluatable_checked, const_option)]
+#![feature(custom_inner_attributes, generic_const_exprs, const_option)]
#![rustfmt::skip]
/// The foo_bar function does _nothing_. See also foo::bar. (note the dot there)
@@ -203,7 +203,7 @@ fn issue_2343() {}
/// __|_ _|__||_|
fn pulldown_cmark_crash() {}
-// issue #7033 - const_evaluatable_checked ICE
+// issue #7033 - generic_const_exprs ICE
struct S<T, const N: usize>
where [(); N.checked_next_power_of_two().unwrap()]: {
arr: [T; N.checked_next_power_of_two().unwrap()],
diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs
index 6d2cbb6..aa60d05 100644
--- a/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs
+++ b/src/tools/clippy/tests/ui/missing_const_for_fn/cant_be_const.rs
@@ -5,8 +5,7 @@
// aux-build:helper.rs
#![warn(clippy::missing_const_for_fn)]
-#![allow(incomplete_features)]
-#![feature(start, const_generics)]
+#![feature(start)]
#![feature(custom_inner_attributes)]
extern crate helper;
diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs
index 0accb51..baa7eec 100644
--- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs
+++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.rs
@@ -1,6 +1,5 @@
#![warn(clippy::missing_const_for_fn)]
#![allow(incomplete_features, clippy::let_and_return)]
-#![feature(const_generics)]
#![feature(custom_inner_attributes)]
use std::mem::transmute;
diff --git a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr
index 63c211f..b89cc64 100644
--- a/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr
+++ b/src/tools/clippy/tests/ui/missing_const_for_fn/could_be_const.stderr
@@ -1,5 +1,5 @@
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:14:5
+ --> $DIR/could_be_const.rs:13:5
|
LL | / pub fn new() -> Self {
LL | | Self { guess: 42 }
@@ -9,7 +9,7 @@
= note: `-D clippy::missing-const-for-fn` implied by `-D warnings`
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:18:5
+ --> $DIR/could_be_const.rs:17:5
|
LL | / fn const_generic_params<'a, T, const N: usize>(&self, b: &'a [T; N]) -> &'a [T; N] {
LL | | b
@@ -17,7 +17,7 @@
| |_____^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:24:1
+ --> $DIR/could_be_const.rs:23:1
|
LL | / fn one() -> i32 {
LL | | 1
@@ -25,7 +25,7 @@
| |_^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:29:1
+ --> $DIR/could_be_const.rs:28:1
|
LL | / fn two() -> i32 {
LL | | let abc = 2;
@@ -34,7 +34,7 @@
| |_^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:35:1
+ --> $DIR/could_be_const.rs:34:1
|
LL | / fn string() -> String {
LL | | String::new()
@@ -42,7 +42,7 @@
| |_^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:40:1
+ --> $DIR/could_be_const.rs:39:1
|
LL | / unsafe fn four() -> i32 {
LL | | 4
@@ -50,7 +50,7 @@
| |_^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:45:1
+ --> $DIR/could_be_const.rs:44:1
|
LL | / fn generic<T>(t: T) -> T {
LL | | t
@@ -58,7 +58,7 @@
| |_^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:68:9
+ --> $DIR/could_be_const.rs:67:9
|
LL | / pub fn b(self, a: &A) -> B {
LL | | B
@@ -66,7 +66,7 @@
| |_________^
error: this could be a `const fn`
- --> $DIR/could_be_const.rs:78:5
+ --> $DIR/could_be_const.rs:77:5
|
LL | / fn const_fn_stabilized_before_msrv(byte: u8) {
LL | | byte.is_ascii_digit();
diff --git a/src/tools/miri b/src/tools/miri
index 042cbf1..09cadcb 160000
--- a/src/tools/miri
+++ b/src/tools/miri
@@ -1 +1 @@
-Subproject commit 042cbf175bfdad6524fd00d7570b2297a0426063
+Subproject commit 09cadcbb62a3529801d0463d9878db3f0b5060c7
diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs
index 0542358..2483d05 100644
--- a/src/tools/rustfmt/src/items.rs
+++ b/src/tools/rustfmt/src/items.rs
@@ -48,7 +48,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
skip_out_of_file_lines_range!(context, self.span);
- if contains_skip(&self.attrs) {
+ if contains_skip(&self.attrs) || matches!(self.kind, ast::LocalKind::InitElse(..)) {
return None;
}
@@ -97,7 +97,7 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
infix.push_str(&rewrite);
}
- if self.init.is_some() {
+ if self.kind.init().is_some() {
infix.push_str(" =");
}
@@ -106,11 +106,12 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
result.push_str(&infix);
- if let Some(ref ex) = self.init {
+ if let Some((init, _els)) = self.kind.init_else_opt() {
// 1 = trailing semicolon;
let nested_shape = shape.sub_width(1)?;
- result = rewrite_assign_rhs(context, result, &**ex, nested_shape)?;
+ result = rewrite_assign_rhs(context, result, init, nested_shape)?;
+ // todo else
}
result.push(';');
diff --git a/src/tools/rustfmt/src/types.rs b/src/tools/rustfmt/src/types.rs
index c6f89c3..640d127 100644
--- a/src/tools/rustfmt/src/types.rs
+++ b/src/tools/rustfmt/src/types.rs
@@ -537,10 +537,10 @@ fn rewrite(&self, context: &RewriteContext<'_>, shape: Shape) -> Option<String>
.map(|s| format!("?{}", s)),
ast::TraitBoundModifier::MaybeConst => poly_trait_ref
.rewrite(context, shape.offset_left(7)?)
- .map(|s| format!("?const {}", s)),
+ .map(|s| format!("~const {}", s)),
ast::TraitBoundModifier::MaybeConstMaybe => poly_trait_ref
.rewrite(context, shape.offset_left(8)?)
- .map(|s| format!("?const ?{}", s)),
+ .map(|s| format!("~const ?{}", s)),
};
rewrite.map(|s| if has_paren { format!("({})", s) } else { s })
}
diff --git a/src/tools/rustfmt/tests/source/let_else.rs b/src/tools/rustfmt/tests/source/let_else.rs
new file mode 100644
index 0000000..a6e816f
--- /dev/null
+++ b/src/tools/rustfmt/tests/source/let_else.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let Some(1) = Some(1) else { return };
+}
diff --git a/src/tools/rustfmt/tests/source/type.rs b/src/tools/rustfmt/tests/source/type.rs
index 57f31dc..61ef73a 100644
--- a/src/tools/rustfmt/tests/source/type.rs
+++ b/src/tools/rustfmt/tests/source/type.rs
@@ -140,29 +140,23 @@ fn foo(a: SomeLongComplexType, b: SomeOtherLongComplexType) -> Box<Future<Item =
type MyFn = fn(a: SomeLongComplexType, b: SomeOtherLongComplexType,) -> Box<Future<Item = AnotherLongType, Error = ALongErrorType>>;
-// Const opt-out
+// Const bound
-trait T: ? const Super {}
+trait T: ~ const Super {}
-const fn maybe_const<S: ? const T>() -> i32 { <S as T>::CONST }
+const fn not_quite_const<S: ~ const T>() -> i32 { <S as T>::CONST }
-struct S<T:? const ? Sized>(std::marker::PhantomData<T>);
+struct S<T:~ const ? Sized>(std::marker::PhantomData<T>);
-impl ? const T {}
+impl ~ const T {}
-fn trait_object() -> &'static dyn ? const T { &S }
+fn apit(_: impl ~ const T) {}
-fn i(_: impl IntoIterator<Item = Box<dyn ? const T>>) {}
-
-fn apit(_: impl ?const T) {}
-
-fn rpit() -> impl ? const T { S }
+fn rpit() -> impl ~ const T { S }
pub struct Foo<T: Trait>(T);
-impl<T: ? const Trait> Foo<T> {
+impl<T: ~ const Trait> Foo<T> {
fn new(t: T) -> Self {
- // not calling methods on `t`, so we opt out of requiring
- // `<T as Trait>` to have const methods via `?const`
Self(t)
}
}
@@ -171,4 +165,4 @@ fn new(t: T) -> Self {
type T = typeof(
1);
impl T for .. {
-}
\ No newline at end of file
+}
diff --git a/src/tools/rustfmt/tests/target/let_else.rs b/src/tools/rustfmt/tests/target/let_else.rs
new file mode 100644
index 0000000..a6e816f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/let_else.rs
@@ -0,0 +1,3 @@
+fn main() {
+ let Some(1) = Some(1) else { return };
+}
diff --git a/src/tools/rustfmt/tests/target/type.rs b/src/tools/rustfmt/tests/target/type.rs
index e776125..38cf909 100644
--- a/src/tools/rustfmt/tests/target/type.rs
+++ b/src/tools/rustfmt/tests/target/type.rs
@@ -145,35 +145,27 @@ fn foo(
b: SomeOtherLongComplexType,
) -> Box<Future<Item = AnotherLongType, Error = ALongErrorType>>;
-// Const opt-out
+// Const bound
-trait T: ?const Super {}
+trait T: ~const Super {}
-const fn maybe_const<S: ?const T>() -> i32 {
+const fn not_quite_const<S: ~const T>() -> i32 {
<S as T>::CONST
}
-struct S<T: ?const ?Sized>(std::marker::PhantomData<T>);
+struct S<T: ~const ?Sized>(std::marker::PhantomData<T>);
-impl ?const T {}
+impl ~const T {}
-fn trait_object() -> &'static dyn ?const T {
- &S
-}
+fn apit(_: impl ~const T) {}
-fn i(_: impl IntoIterator<Item = Box<dyn ?const T>>) {}
-
-fn apit(_: impl ?const T) {}
-
-fn rpit() -> impl ?const T {
+fn rpit() -> impl ~const T {
S
}
pub struct Foo<T: Trait>(T);
-impl<T: ?const Trait> Foo<T> {
+impl<T: ~const Trait> Foo<T> {
fn new(t: T) -> Self {
- // not calling methods on `t`, so we opt out of requiring
- // `<T as Trait>` to have const methods via `?const`
Self(t)
}
}
diff --git a/triagebot.toml b/triagebot.toml
index 81c6719..1e4df4d 100644
--- a/triagebot.toml
+++ b/triagebot.toml
@@ -102,6 +102,8 @@
- Needs `I-nominated`?
"""
message_on_remove = "Issue #{number}'s prioritization request has been removed."
+message_on_close = "Issue #{number} has been closed while requested for prioritization."
+message_on_reopen = "Issue #{number} has been reopened."
[notify-zulip."T-rustdoc"]
required_labels = ["I-nominated"]