Rollup merge of #141495 - compiler-errors:rename-unpack, r=fmease
Rename `{GenericArg,Term}::unpack()` to `kind()`
A well-deserved rename IMO.
r? `@oli-obk` or `@lcnr` (or anyone)
cc `@rust-lang/types,` but I'd be surprised if this is controversial.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 566ae22..12da136 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -79,9 +79,8 @@
# This also ensures that PR CI (which doesn't get write access to S3) works, as it cannot
# access the environment.
#
- # We only enable the environment for the rust-lang/rust repository, so that rust-lang-ci/rust
- # CI works until we migrate off it (since that repository doesn't contain the environment).
- environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/auto')) && 'bors') || '' }}
+ # We only enable the environment for the rust-lang/rust repository, so that CI works on forks.
+ environment: ${{ ((github.repository == 'rust-lang/rust' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf' || github.ref == 'refs/heads/auto')) && 'bors') || '' }}
env:
CI_JOB_NAME: ${{ matrix.name }}
CI_JOB_DOC_URL: ${{ matrix.doc_url }}
@@ -234,8 +233,8 @@
fi
exit ${STATUS}
env:
- AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_ACCESS_KEY_ID) || env.CACHES_AWS_ACCESS_KEY_ID }}
- AWS_SECRET_ACCESS_KEY: ${{ (github.repository == 'rust-lang/rust' && secrets.CACHES_AWS_SECRET_ACCESS_KEY) || secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.CACHES_AWS_ACCESS_KEY_ID)] }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.CACHES_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.CACHES_AWS_SECRET_ACCESS_KEY }}
- name: create github artifacts
run: src/ci/scripts/create-doc-artifacts.sh
@@ -257,8 +256,8 @@
- name: upload artifacts to S3
run: src/ci/scripts/upload-artifacts.sh
env:
- AWS_ACCESS_KEY_ID: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_ACCESS_KEY_ID) || env.ARTIFACTS_AWS_ACCESS_KEY_ID }}
- AWS_SECRET_ACCESS_KEY: ${{ (github.repository == 'rust-lang/rust' && secrets.ARTIFACTS_AWS_SECRET_ACCESS_KEY) || secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}
+ AWS_ACCESS_KEY_ID: ${{ secrets.ARTIFACTS_AWS_ACCESS_KEY_ID }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.ARTIFACTS_AWS_SECRET_ACCESS_KEY }}
# Adding a condition on DEPLOY=1 or DEPLOY_ALT=1 is not needed as all deploy
# builders *should* have the AWS credentials available. Still, explicitly
# adding the condition is helpful as this way CI will not silently skip
diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs
index 6770fd5..1b8c0ee 100644
--- a/compiler/rustc_ast/src/mut_visit.rs
+++ b/compiler/rustc_ast/src/mut_visit.rs
@@ -40,12 +40,6 @@ pub trait MutVisitor: Sized {
// fn flat_map_t(&mut self, t: T) -> SmallVec<[T; 1]>; // rare
// fn filter_map_t(&mut self, t: T) -> Option<T>; // rarest
//
- // Any additions to this trait should happen in form of a call to a public
- // `noop_*` function that only calls out to the visitor again, not other
- // `noop_*` functions. This is a necessary API workaround to the problem of
- // not being able to call out to the super default method in an overridden
- // default method.
- //
// When writing these methods, it is better to use destructuring like this:
//
// fn visit_abc(&mut self, ABC { a, b, c: _ }: &mut ABC) {
@@ -179,7 +173,7 @@ fn visit_method_receiver_expr(&mut self, ex: &mut P<Expr>) {
}
fn filter_map_expr(&mut self, e: P<Expr>) -> Option<P<Expr>> {
- noop_filter_map_expr(self, e)
+ walk_filter_map_expr(self, e)
}
fn visit_generic_arg(&mut self, arg: &mut GenericArg) {
@@ -381,14 +375,11 @@ fn visit_fn_ret_ty(&mut self, fn_ret_ty: &mut FnRetTy) {
/// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
/// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
/// method.
-//
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
pub fn visit_clobber<T: DummyAstNode>(t: &mut T, f: impl FnOnce(T) -> T) {
let old_t = std::mem::replace(t, T::dummy());
*t = f(old_t);
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline]
fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
where
@@ -399,7 +390,6 @@ fn visit_vec<T, F>(elems: &mut Vec<T>, mut visit_elem: F)
}
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline]
fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
where
@@ -410,7 +400,6 @@ fn visit_thin_vec<T, F>(elems: &mut ThinVec<T>, mut visit_elem: F)
}
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[inline]
fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
where
@@ -421,25 +410,21 @@ fn visit_opt<T, F>(opt: &mut Option<T>, mut visit_elem: F)
}
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_attrs<T: MutVisitor>(vis: &mut T, attrs: &mut AttrVec) {
for attr in attrs.iter_mut() {
vis.visit_attribute(attr);
}
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
#[allow(unused)]
fn visit_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut Vec<P<Expr>>) {
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_thin_exprs<T: MutVisitor>(vis: &mut T, exprs: &mut ThinVec<P<Expr>>) {
exprs.flat_map_in_place(|expr| vis.filter_map_expr(expr))
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
match args {
AttrArgs::Empty => {}
@@ -451,7 +436,6 @@ fn visit_attr_args<T: MutVisitor>(vis: &mut T, args: &mut AttrArgs) {
}
}
-// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
fn visit_delim_args<T: MutVisitor>(vis: &mut T, args: &mut DelimArgs) {
let DelimArgs { dspan, delim: _, tokens: _ } = args;
let DelimSpan { open, close } = dspan;
@@ -1041,78 +1025,6 @@ pub fn walk_item_kind<K: WalkItemKind>(
kind.walk(span, id, visibility, ctxt, vis)
}
-impl WalkItemKind for AssocItemKind {
- type Ctxt = AssocCtxt;
- fn walk<V: MutVisitor>(
- &mut self,
- span: Span,
- id: NodeId,
- visibility: &mut Visibility,
- ctxt: Self::Ctxt,
- visitor: &mut V,
- ) {
- match self {
- AssocItemKind::Const(item) => {
- walk_const_item(visitor, item);
- }
- AssocItemKind::Fn(func) => {
- visitor.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), visibility, &mut *func), span, id);
- }
- AssocItemKind::Type(box TyAlias {
- defaultness,
- ident,
- generics,
- where_clauses,
- bounds,
- ty,
- }) => {
- visit_defaultness(visitor, defaultness);
- visitor.visit_ident(ident);
- visitor.visit_generics(generics);
- visit_bounds(visitor, bounds, BoundKind::Bound);
- visit_opt(ty, |ty| visitor.visit_ty(ty));
- walk_ty_alias_where_clauses(visitor, where_clauses);
- }
- AssocItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
- AssocItemKind::Delegation(box Delegation {
- id,
- qself,
- path,
- ident,
- rename,
- body,
- from_glob: _,
- }) => {
- visitor.visit_id(id);
- visitor.visit_qself(qself);
- visitor.visit_path(path);
- visitor.visit_ident(ident);
- if let Some(rename) = rename {
- visitor.visit_ident(rename);
- }
- if let Some(body) = body {
- visitor.visit_block(body);
- }
- }
- AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
- visitor.visit_qself(qself);
- visitor.visit_path(prefix);
- if let Some(suffixes) = suffixes {
- for (ident, rename) in suffixes {
- visitor.visit_ident(ident);
- if let Some(rename) = rename {
- visitor.visit_ident(rename);
- }
- }
- }
- if let Some(body) = body {
- visitor.visit_block(body);
- }
- }
- }
- }
-}
-
pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
let Crate { attrs, items, spans, id, is_placeholder: _ } = krate;
vis.visit_id(id);
@@ -1123,14 +1035,6 @@ pub fn walk_crate<T: MutVisitor>(vis: &mut T, krate: &mut Crate) {
vis.visit_span(inject_use_span);
}
-pub fn walk_item(visitor: &mut impl MutVisitor, item: &mut P<Item<impl WalkItemKind<Ctxt = ()>>>) {
- walk_item_ctxt(visitor, item, ())
-}
-
-pub fn walk_assoc_item(visitor: &mut impl MutVisitor, item: &mut P<AssocItem>, ctxt: AssocCtxt) {
- walk_item_ctxt(visitor, item, ctxt)
-}
-
pub fn walk_flat_map_item(vis: &mut impl MutVisitor, mut item: P<Item>) -> SmallVec<[P<Item>; 1]> {
vis.visit_item(&mut item);
smallvec![item]
@@ -1153,53 +1057,6 @@ pub fn walk_flat_map_assoc_item(
smallvec![item]
}
-impl WalkItemKind for ForeignItemKind {
- type Ctxt = ();
- fn walk<V: MutVisitor>(
- &mut self,
- span: Span,
- id: NodeId,
- visibility: &mut Visibility,
- _ctxt: Self::Ctxt,
- visitor: &mut V,
- ) {
- match self {
- ForeignItemKind::Static(box StaticItem {
- ident,
- ty,
- mutability: _,
- expr,
- safety: _,
- define_opaque,
- }) => {
- visitor.visit_ident(ident);
- visitor.visit_ty(ty);
- visit_opt(expr, |expr| visitor.visit_expr(expr));
- walk_define_opaques(visitor, define_opaque);
- }
- ForeignItemKind::Fn(func) => {
- visitor.visit_fn(FnKind::Fn(FnCtxt::Foreign, visibility, &mut *func), span, id);
- }
- ForeignItemKind::TyAlias(box TyAlias {
- defaultness,
- ident,
- generics,
- where_clauses,
- bounds,
- ty,
- }) => {
- visit_defaultness(visitor, defaultness);
- visitor.visit_ident(ident);
- visitor.visit_generics(generics);
- visit_bounds(visitor, bounds, BoundKind::Bound);
- visit_opt(ty, |ty| visitor.visit_ty(ty));
- walk_ty_alias_where_clauses(visitor, where_clauses);
- }
- ForeignItemKind::MacCall(mac) => visitor.visit_mac_call(mac),
- }
- }
-}
-
pub fn walk_pat<T: MutVisitor>(vis: &mut T, pat: &mut P<Pat>) {
let Pat { id, kind, span, tokens: _ } = pat.deref_mut();
vis.visit_id(id);
@@ -1500,11 +1357,9 @@ pub fn walk_expr<T: MutVisitor>(vis: &mut T, Expr { kind, id, span, attrs, token
vis.visit_span(span);
}
-pub fn noop_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: P<Expr>) -> Option<P<Expr>> {
- Some({
- vis.visit_expr(&mut e);
- e
- })
+pub fn walk_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: P<Expr>) -> Option<P<Expr>> {
+ vis.visit_expr(&mut e);
+ Some(e)
}
pub fn walk_flat_map_stmt<T: MutVisitor>(
diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs
index c069425..bf5c402 100644
--- a/compiler/rustc_ast/src/visit.rs
+++ b/compiler/rustc_ast/src/visit.rs
@@ -393,9 +393,7 @@ pub fn walk_label<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, Label { ident
pub fn walk_fn_header<$($lt,)? V: $Visitor$(<$lt>)?>(visitor: &mut V, header: &$($lt)? $($mut)? FnHeader) $(-> <V as Visitor<$lt>>::Result)? {
let FnHeader { safety, coroutine_kind, constness, ext: _ } = header;
try_visit!(visit_constness(visitor, constness));
- if let Some(coroutine_kind) = coroutine_kind {
- try_visit!(visitor.visit_coroutine_kind(coroutine_kind));
- }
+ visit_opt!(visitor, visit_coroutine_kind, coroutine_kind);
visit_safety(visitor, safety)
}
@@ -417,6 +415,21 @@ fn walk_item_ctxt<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind>(
visit_span(visitor, span)
}
+ pub fn walk_item<$($lt,)? V: $Visitor$(<$lt>)?, K: WalkItemKind<Ctxt = ()>>(
+ visitor: &mut V,
+ item: &$($mut P<Item<K>>)? $($lt Item<K>)?,
+ ) $(-> <V as Visitor<$lt>>::Result)? {
+ walk_item_ctxt(visitor, item, ())
+ }
+
+ pub fn walk_assoc_item<$($lt,)? V: $Visitor$(<$lt>)?>(
+ visitor: &mut V,
+ item: &$($mut P<AssocItem>)? $($lt AssocItem)?,
+ ctxt: AssocCtxt,
+ ) $(-> <V as Visitor<$lt>>::Result)? {
+ walk_item_ctxt(visitor, item, ctxt)
+ }
+
impl WalkItemKind for ItemKind {
type Ctxt = ();
fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
@@ -580,12 +593,8 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
try_visit!(vis.visit_qself(qself));
try_visit!(vis.visit_path(path$(${ignore($lt)}, *id)?));
try_visit!(vis.visit_ident(ident));
- if let Some(rename) = rename {
- try_visit!(vis.visit_ident(rename));
- }
- if let Some(body) = body {
- try_visit!(vis.visit_block(body));
- }
+ visit_opt!(vis, visit_ident, rename);
+ visit_opt!(vis, visit_block, body);
$(<V as Visitor<$lt>>::Result::output())?
}
ItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
@@ -594,14 +603,10 @@ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
if let Some(suffixes) = suffixes {
for (ident, rename) in suffixes {
try_visit!(vis.visit_ident(ident));
- if let Some(rename) = rename {
- try_visit!(vis.visit_ident(rename));
- }
+ visit_opt!(vis, visit_ident, rename);
}
}
- if let Some(body) = body {
- try_visit!(vis.visit_block(body));
- }
+ visit_opt!(vis, visit_block, body);
$(<V as Visitor<$lt>>::Result::output())?
}
}
@@ -643,6 +648,131 @@ fn walk_define_opaques<$($lt,)? V: $Visitor$(<$lt>)?>(
}
$(<V as Visitor<$lt>>::Result::output())?
}
+
+ impl WalkItemKind for AssocItemKind {
+ type Ctxt = AssocCtxt;
+ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
+ &$($lt)? $($mut)? self,
+ span: Span,
+ id: NodeId,
+ visibility: &$($lt)? $($mut)? Visibility,
+ ctxt: Self::Ctxt,
+ vis: &mut V,
+ ) $(-> <V as Visitor<$lt>>::Result)? {
+ match self {
+ AssocItemKind::Const(item) => {
+ walk_const_item(vis, item)
+ }
+ AssocItemKind::Fn(func) => {
+ vis.visit_fn(FnKind::Fn(FnCtxt::Assoc(ctxt), visibility, &$($mut)? *func), span, id)
+ }
+ AssocItemKind::Type(box TyAlias {
+ generics,
+ ident,
+ bounds,
+ ty,
+ defaultness,
+ $(${ignore($lt)} #[expect(unused)])?
+ where_clauses,
+ }) => {
+ try_visit!(visit_defaultness(vis, defaultness));
+ try_visit!(vis.visit_ident(ident));
+ try_visit!(vis.visit_generics(generics));
+ try_visit!(visit_bounds(vis, bounds, BoundKind::Bound));
+ visit_opt!(vis, visit_ty, ty);
+ $(${ignore($mut)}
+ walk_ty_alias_where_clauses(vis, where_clauses);
+ )?
+ $(<V as Visitor<$lt>>::Result::output())?
+ }
+ AssocItemKind::MacCall(mac) => {
+ vis.visit_mac_call(mac)
+ }
+ AssocItemKind::Delegation(box Delegation {
+ id,
+ qself,
+ path,
+ ident,
+ rename,
+ body,
+ from_glob: _,
+ }) => {
+ try_visit!(visit_id(vis, id));
+ try_visit!(vis.visit_qself(qself));
+ try_visit!(vis.visit_path(path $(${ignore($lt)}, *id)?));
+ try_visit!(vis.visit_ident(ident));
+ visit_opt!(vis, visit_ident, rename);
+ visit_opt!(vis, visit_block, body);
+ $(<V as Visitor<$lt>>::Result::output())?
+ }
+ AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
+ try_visit!(vis.visit_qself(qself));
+ try_visit!(vis.visit_path(prefix$(${ignore($lt)}, id)?));
+ if let Some(suffixes) = suffixes {
+ for (ident, rename) in suffixes {
+ try_visit!(vis.visit_ident(ident));
+ visit_opt!(vis, visit_ident, rename);
+ }
+ }
+ visit_opt!(vis, visit_block, body);
+ $(<V as Visitor<$lt>>::Result::output())?
+ }
+ }
+ }
+ }
+
+ impl WalkItemKind for ForeignItemKind {
+ type Ctxt = ();
+ fn walk<$($lt,)? V: $Visitor$(<$lt>)?>(
+ &$($lt)? $($mut)? self,
+ span: Span,
+ id: NodeId,
+ visibility: &$($lt)? $($mut)? Visibility,
+ _ctxt: Self::Ctxt,
+ vis: &mut V,
+ ) $(-> <V as Visitor<$lt>>::Result)? {
+ match self {
+ ForeignItemKind::Static(box StaticItem {
+ ident,
+ ty,
+ mutability: _,
+ expr,
+ safety: _,
+ define_opaque,
+ }) => {
+ try_visit!(vis.visit_ident(ident));
+ try_visit!(vis.visit_ty(ty));
+ visit_opt!(vis, visit_expr, expr);
+ walk_define_opaques(vis, define_opaque)
+ }
+ ForeignItemKind::Fn(func) => {
+ vis.visit_fn(FnKind::Fn(FnCtxt::Foreign, visibility, &$($mut)?*func), span, id)
+ }
+ ForeignItemKind::TyAlias(box TyAlias {
+ defaultness,
+ ident,
+ generics,
+ bounds,
+ ty,
+ $(${ignore($lt)} #[expect(unused)])?
+ where_clauses,
+ }) => {
+ try_visit!(visit_defaultness(vis, defaultness));
+ try_visit!(vis.visit_ident(ident));
+ try_visit!(vis.visit_generics(generics));
+ try_visit!(visit_bounds(vis, bounds, BoundKind::Bound));
+ visit_opt!(vis, visit_ty, ty);
+ $(${ignore($mut)}
+ walk_ty_alias_where_clauses(vis, where_clauses);
+ )?
+ $(<V as Visitor<$lt>>::Result::output())?
+ }
+ ForeignItemKind::MacCall(mac) => {
+ vis.visit_mac_call(mac)
+ }
+ }
+ }
+ }
};
}
@@ -928,55 +1058,6 @@ pub fn walk_pat<'a, V: Visitor<'a>>(visitor: &mut V, pattern: &'a Pat) -> V::Res
V::Result::output()
}
-impl WalkItemKind for ForeignItemKind {
- type Ctxt = ();
- fn walk<'a, V: Visitor<'a>>(
- &'a self,
- span: Span,
- id: NodeId,
- vis: &'a Visibility,
- _ctxt: Self::Ctxt,
- visitor: &mut V,
- ) -> V::Result {
- match self {
- ForeignItemKind::Static(box StaticItem {
- ident,
- ty,
- mutability: _,
- expr,
- safety: _,
- define_opaque,
- }) => {
- try_visit!(visitor.visit_ident(ident));
- try_visit!(visitor.visit_ty(ty));
- visit_opt!(visitor, visit_expr, expr);
- try_visit!(walk_define_opaques(visitor, define_opaque));
- }
- ForeignItemKind::Fn(func) => {
- let kind = FnKind::Fn(FnCtxt::Foreign, vis, &*func);
- try_visit!(visitor.visit_fn(kind, span, id));
- }
- ForeignItemKind::TyAlias(box TyAlias {
- generics,
- ident,
- bounds,
- ty,
- defaultness: _,
- where_clauses: _,
- }) => {
- try_visit!(visitor.visit_ident(ident));
- try_visit!(visitor.visit_generics(generics));
- walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
- visit_opt!(visitor, visit_ty, ty);
- }
- ForeignItemKind::MacCall(mac) => {
- try_visit!(visitor.visit_mac_call(mac));
- }
- }
- V::Result::output()
- }
-}
-
pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) -> V::Result {
match bound {
GenericBound::Trait(trait_ref) => visitor.visit_poly_trait_ref(trait_ref),
@@ -1135,99 +1216,6 @@ pub fn walk_fn<'a, V: Visitor<'a>>(visitor: &mut V, kind: FnKind<'a>) -> V::Resu
V::Result::output()
}
-impl WalkItemKind for AssocItemKind {
- type Ctxt = AssocCtxt;
- fn walk<'a, V: Visitor<'a>>(
- &'a self,
- span: Span,
- id: NodeId,
- vis: &'a Visibility,
- ctxt: Self::Ctxt,
- visitor: &mut V,
- ) -> V::Result {
- match self {
- AssocItemKind::Const(box ConstItem {
- defaultness: _,
- ident,
- generics,
- ty,
- expr,
- define_opaque,
- }) => {
- try_visit!(visitor.visit_ident(ident));
- try_visit!(visitor.visit_generics(generics));
- try_visit!(visitor.visit_ty(ty));
- visit_opt!(visitor, visit_expr, expr);
- try_visit!(walk_define_opaques(visitor, define_opaque));
- }
- AssocItemKind::Fn(func) => {
- let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), vis, &*func);
- try_visit!(visitor.visit_fn(kind, span, id));
- }
- AssocItemKind::Type(box TyAlias {
- generics,
- ident,
- bounds,
- ty,
- defaultness: _,
- where_clauses: _,
- }) => {
- try_visit!(visitor.visit_generics(generics));
- try_visit!(visitor.visit_ident(ident));
- walk_list!(visitor, visit_param_bound, bounds, BoundKind::Bound);
- visit_opt!(visitor, visit_ty, ty);
- }
- AssocItemKind::MacCall(mac) => {
- try_visit!(visitor.visit_mac_call(mac));
- }
- AssocItemKind::Delegation(box Delegation {
- id,
- qself,
- path,
- ident,
- rename,
- body,
- from_glob: _,
- }) => {
- try_visit!(visitor.visit_qself(qself));
- try_visit!(visitor.visit_path(path, *id));
- try_visit!(visitor.visit_ident(ident));
- visit_opt!(visitor, visit_ident, rename);
- visit_opt!(visitor, visit_block, body);
- }
- AssocItemKind::DelegationMac(box DelegationMac { qself, prefix, suffixes, body }) => {
- try_visit!(visitor.visit_qself(qself));
- try_visit!(visitor.visit_path(prefix, id));
- if let Some(suffixes) = suffixes {
- for (ident, rename) in suffixes {
- visitor.visit_ident(ident);
- if let Some(rename) = rename {
- visitor.visit_ident(rename);
- }
- }
- }
- visit_opt!(visitor, visit_block, body);
- }
- }
- V::Result::output()
- }
-}
-
-pub fn walk_item<'a, V: Visitor<'a>>(
- visitor: &mut V,
- item: &'a Item<impl WalkItemKind<Ctxt = ()>>,
-) -> V::Result {
- walk_item_ctxt(visitor, item, ())
-}
-
-pub fn walk_assoc_item<'a, V: Visitor<'a>>(
- visitor: &mut V,
- item: &'a AssocItem,
- ctxt: AssocCtxt,
-) -> V::Result {
- walk_item_ctxt(visitor, item, ctxt)
-}
-
pub fn walk_struct_def<'a, V: Visitor<'a>>(
visitor: &mut V,
struct_definition: &'a VariantData,
diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs
index c216f0f..b91b6ef 100644
--- a/compiler/rustc_codegen_llvm/src/va_arg.rs
+++ b/compiler/rustc_codegen_llvm/src/va_arg.rs
@@ -63,14 +63,33 @@ fn emit_direct_ptr_va_arg<'ll, 'tcx>(
}
}
+enum PassMode {
+ Direct,
+ Indirect,
+}
+
+enum SlotSize {
+ Bytes8 = 8,
+ Bytes4 = 4,
+}
+
+enum AllowHigherAlign {
+ No,
+ Yes,
+}
+
fn emit_ptr_va_arg<'ll, 'tcx>(
bx: &mut Builder<'_, 'll, 'tcx>,
list: OperandRef<'tcx, &'ll Value>,
target_ty: Ty<'tcx>,
- indirect: bool,
- slot_size: Align,
- allow_higher_align: bool,
+ pass_mode: PassMode,
+ slot_size: SlotSize,
+ allow_higher_align: AllowHigherAlign,
) -> &'ll Value {
+ let indirect = matches!(pass_mode, PassMode::Indirect);
+ let allow_higher_align = matches!(allow_higher_align, AllowHigherAlign::Yes);
+ let slot_size = Align::from_bytes(slot_size as u64).unwrap();
+
let layout = bx.cx.layout_of(target_ty);
let (llty, size, align) = if indirect {
(
@@ -179,8 +198,14 @@ fn emit_aapcs_va_arg<'ll, 'tcx>(
// On Stack block
bx.switch_to_block(on_stack);
- let stack_value =
- emit_ptr_va_arg(bx, list, target_ty, false, Align::from_bytes(8).unwrap(), true);
+ let stack_value = emit_ptr_va_arg(
+ bx,
+ list,
+ target_ty,
+ PassMode::Direct,
+ SlotSize::Bytes8,
+ AllowHigherAlign::Yes,
+ );
bx.br(end);
bx.switch_to_block(end);
@@ -386,29 +411,43 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
// Determine the va_arg implementation to use. The LLVM va_arg instruction
// is lacking in some instances, so we should only use it as a fallback.
let target = &bx.cx.tcx.sess.target;
- let arch = &bx.cx.tcx.sess.target.arch;
- match &**arch {
- // Windows x86
- "x86" if target.is_like_windows => {
- emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), false)
- }
- // Generic x86
- "x86" => emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(4).unwrap(), true),
- // Windows AArch64
- "aarch64" | "arm64ec" if target.is_like_windows => {
- emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), false)
- }
- // macOS / iOS AArch64
- "aarch64" if target.is_like_darwin => {
- emit_ptr_va_arg(bx, addr, target_ty, false, Align::from_bytes(8).unwrap(), true)
+
+ match &*target.arch {
+ "x86" => emit_ptr_va_arg(
+ bx,
+ addr,
+ target_ty,
+ PassMode::Direct,
+ SlotSize::Bytes4,
+ if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
+ ),
+ "aarch64" | "arm64ec" if target.is_like_windows || target.is_like_darwin => {
+ emit_ptr_va_arg(
+ bx,
+ addr,
+ target_ty,
+ PassMode::Direct,
+ SlotSize::Bytes8,
+ if target.is_like_windows { AllowHigherAlign::No } else { AllowHigherAlign::Yes },
+ )
}
"aarch64" => emit_aapcs_va_arg(bx, addr, target_ty),
"s390x" => emit_s390x_va_arg(bx, addr, target_ty),
// Windows x86_64
"x86_64" if target.is_like_windows => {
let target_ty_size = bx.cx.size_of(target_ty).bytes();
- let indirect: bool = target_ty_size > 8 || !target_ty_size.is_power_of_two();
- emit_ptr_va_arg(bx, addr, target_ty, indirect, Align::from_bytes(8).unwrap(), false)
+ emit_ptr_va_arg(
+ bx,
+ addr,
+ target_ty,
+ if target_ty_size > 8 || !target_ty_size.is_power_of_two() {
+ PassMode::Indirect
+ } else {
+ PassMode::Direct
+ },
+ SlotSize::Bytes8,
+ AllowHigherAlign::No,
+ )
}
"xtensa" => emit_xtensa_va_arg(bx, addr, target_ty),
// For all other architecture/OS combinations fall back to using
diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs
index 36da903..3975516 100644
--- a/compiler/rustc_const_eval/src/interpret/operand.rs
+++ b/compiler/rustc_const_eval/src/interpret/operand.rs
@@ -310,7 +310,7 @@ pub fn from_ordering(c: std::cmp::Ordering, tcx: TyCtxt<'tcx>) -> Self {
let ty = tcx.ty_ordering_enum(None);
let layout =
tcx.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(ty)).unwrap();
- Self::from_scalar(Scalar::from_i8(c as i8), layout)
+ Self::from_scalar(Scalar::Int(c.into()), layout)
}
pub fn from_pair(a: Self, b: Self, cx: &(impl HasTypingEnv<'tcx> + HasTyCtxt<'tcx>)) -> Self {
diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs
index 539ecfb..a11f81b 100644
--- a/compiler/rustc_errors/src/diagnostic.rs
+++ b/compiler/rustc_errors/src/diagnostic.rs
@@ -1325,7 +1325,7 @@ fn take_diag(&mut self) -> DiagInner {
));
self.note("consider using `--verbose` to print the full type name to the console");
}
- Box::into_inner(self.diag.take().unwrap())
+ *self.diag.take().unwrap()
}
/// This method allows us to access the path of the file where "long types" are written to.
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index f8e19e5..bd421a4 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -12,7 +12,6 @@
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(associated_type_defaults)]
-#![feature(box_into_inner)]
#![feature(box_patterns)]
#![feature(default_field_values)]
#![feature(error_reporter)]
diff --git a/compiler/rustc_expand/src/placeholders.rs b/compiler/rustc_expand/src/placeholders.rs
index 0136292..3dcb20c 100644
--- a/compiler/rustc_expand/src/placeholders.rs
+++ b/compiler/rustc_expand/src/placeholders.rs
@@ -349,7 +349,7 @@ fn visit_method_receiver_expr(&mut self, expr: &mut P<ast::Expr>) {
fn filter_map_expr(&mut self, expr: P<ast::Expr>) -> Option<P<ast::Expr>> {
match expr.kind {
ast::ExprKind::MacCall(_) => self.remove(expr.id).make_opt_expr(),
- _ => noop_filter_map_expr(self, expr),
+ _ => walk_filter_map_expr(self, expr),
}
}
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs
index f5206d9..8a2edd8 100644
--- a/compiler/rustc_hir_analysis/src/collect.rs
+++ b/compiler/rustc_hir_analysis/src/collect.rs
@@ -31,7 +31,7 @@
use rustc_hir::intravisit::{self, InferKind, Visitor, VisitorExt, walk_generics};
use rustc_hir::{self as hir, GenericParamKind, HirId, Node, PreciseCapturingArgKind};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
-use rustc_infer::traits::ObligationCause;
+use rustc_infer::traits::{DynCompatibilityViolation, ObligationCause};
use rustc_middle::hir::nested_filter;
use rustc_middle::query::Providers;
use rustc_middle::ty::util::{Discr, IntTypeExt};
@@ -40,7 +40,7 @@
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
use rustc_trait_selection::error_reporting::traits::suggestions::NextTypeParamName;
use rustc_trait_selection::infer::InferCtxtExt;
-use rustc_trait_selection::traits::ObligationCtxt;
+use rustc_trait_selection::traits::{ObligationCtxt, hir_ty_lowering_dyn_compatibility_violations};
use tracing::{debug, instrument};
use crate::errors;
@@ -625,6 +625,10 @@ fn lower_fn_sig(
(input_tys, output_ty)
}
+
+ fn dyn_compatibility_violations(&self, trait_def_id: DefId) -> Vec<DynCompatibilityViolation> {
+ hir_ty_lowering_dyn_compatibility_violations(self.tcx, trait_def_id)
+ }
}
/// Synthesize a new lifetime name that doesn't clash with any of the lifetimes already present.
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
index e75c307..c7cdf1d 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/dyn_compatibility.rs
@@ -11,7 +11,7 @@
};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::traits::report_dyn_incompatibility;
-use rustc_trait_selection::traits::{self, hir_ty_lowering_dyn_compatibility_violations};
+use rustc_trait_selection::traits;
use smallvec::{SmallVec, smallvec};
use tracing::{debug, instrument};
@@ -97,8 +97,7 @@ pub(super) fn lower_trait_object_ty(
// to avoid ICEs.
for (clause, span) in user_written_bounds {
if let Some(trait_pred) = clause.as_trait_clause() {
- let violations =
- hir_ty_lowering_dyn_compatibility_violations(tcx, trait_pred.def_id());
+ let violations = self.dyn_compatibility_violations(trait_pred.def_id());
if !violations.is_empty() {
let reported = report_dyn_incompatibility(
tcx,
diff --git a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
index 9eaa836..2a37a8b 100644
--- a/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
+++ b/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
@@ -33,7 +33,7 @@
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, AnonConst, GenericArg, GenericArgs, HirId};
use rustc_infer::infer::{InferCtxt, TyCtxtInferExt};
-use rustc_infer::traits::ObligationCause;
+use rustc_infer::traits::{DynCompatibilityViolation, ObligationCause};
use rustc_middle::middle::stability::AllowUnstable;
use rustc_middle::mir::interpret::LitToConstInput;
use rustc_middle::ty::print::PrintPolyTraitRefExt as _;
@@ -200,6 +200,10 @@ fn lowerer(&self) -> &dyn HirTyLowerer<'tcx>
{
self
}
+
+ /// Performs minimalistic dyn compat checks outside of bodies, but full within bodies.
+ /// Outside of bodies we could end up in cycles, so we delay most checks to later phases.
+ fn dyn_compatibility_violations(&self, trait_def_id: DefId) -> Vec<DynCompatibilityViolation>;
}
/// The "qualified self" of an associated item path.
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
index 786d763..59aba6f 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
@@ -1556,25 +1556,20 @@ enum SuggestionText {
SuggestionText::Reorder => Some("reorder these arguments".to_string()),
SuggestionText::DidYouMean => Some("did you mean".to_string()),
};
- if let Some(suggestion_text) = suggestion_text {
+ if let Some(suggestion_text) = suggestion_text
+ && !full_call_span.in_external_macro(self.sess().source_map())
+ {
let source_map = self.sess().source_map();
- let (mut suggestion, suggestion_span) = if let Some(call_span) =
- full_call_span.find_ancestor_inside_same_ctxt(error_span)
- {
- ("(".to_string(), call_span.shrink_to_hi().to(error_span.shrink_to_hi()))
+ let suggestion_span = if let Some(args_span) = error_span.trim_start(full_call_span) {
+ // Span of the braces, e.g. `(a, b, c)`.
+ args_span
} else {
- (
- format!(
- "{}(",
- source_map.span_to_snippet(full_call_span).unwrap_or_else(|_| {
- fn_def_id.map_or("".to_string(), |fn_def_id| {
- tcx.item_name(fn_def_id).to_string()
- })
- })
- ),
- error_span,
- )
+ // The arg span of a function call that wasn't even given braces
+ // like what might happen with delegation reuse.
+ // e.g. `reuse HasSelf::method;` should suggest `reuse HasSelf::method($args);`.
+ full_call_span.shrink_to_hi()
};
+ let mut suggestion = "(".to_owned();
let mut needs_comma = false;
for (expected_idx, provided_idx) in matched_inputs.iter_enumerated() {
if needs_comma {
diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
index ea0adf1..cfb25de 100644
--- a/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
+++ b/compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs
@@ -14,7 +14,7 @@
use rustc_hir::{self as hir, HirId, ItemLocalMap};
use rustc_hir_analysis::hir_ty_lowering::{HirTyLowerer, RegionInferReason};
use rustc_infer::infer;
-use rustc_infer::traits::Obligation;
+use rustc_infer::traits::{DynCompatibilityViolation, Obligation};
use rustc_middle::ty::{self, Const, Ty, TyCtxt, TypeVisitableExt};
use rustc_session::Session;
use rustc_span::{self, DUMMY_SP, ErrorGuaranteed, Ident, Span, sym};
@@ -388,6 +388,10 @@ fn lower_fn_sig(
};
(input_tys, output_ty)
}
+
+ fn dyn_compatibility_violations(&self, trait_def_id: DefId) -> Vec<DynCompatibilityViolation> {
+ self.tcx.dyn_compatibility_violations(trait_def_id).to_vec()
+ }
}
/// The `ty` representation of a user-provided type. Depending on the use-site
diff --git a/compiler/rustc_lint/messages.ftl b/compiler/rustc_lint/messages.ftl
index 7fdf26b..b470dea 100644
--- a/compiler/rustc_lint/messages.ftl
+++ b/compiler/rustc_lint/messages.ftl
@@ -13,6 +13,8 @@
lint_ambiguous_wide_pointer_comparisons = ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
.addr_metadata_suggestion = use explicit `std::ptr::eq` method to compare metadata and addresses
.addr_suggestion = use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+ .cast_suggestion = use untyped pointers to only compare their addresses
+ .expect_suggestion = or expect the lint to compare the pointers metadata and addresses
lint_associated_const_elided_lifetime = {$elided ->
[true] `&` without an explicit lifetime name cannot be used here
diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs
index af8fa8f..caad269 100644
--- a/compiler/rustc_lint/src/lints.rs
+++ b/compiler/rustc_lint/src/lints.rs
@@ -1782,13 +1782,20 @@ pub(crate) enum InvalidNanComparisonsSuggestion {
#[derive(LintDiagnostic)]
pub(crate) enum AmbiguousWidePointerComparisons<'a> {
#[diag(lint_ambiguous_wide_pointer_comparisons)]
- Spanful {
+ SpanfulEq {
#[subdiagnostic]
addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion<'a>,
#[subdiagnostic]
addr_metadata_suggestion: Option<AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a>>,
},
#[diag(lint_ambiguous_wide_pointer_comparisons)]
+ SpanfulCmp {
+ #[subdiagnostic]
+ cast_suggestion: AmbiguousWidePointerComparisonsCastSuggestion<'a>,
+ #[subdiagnostic]
+ expect_suggestion: AmbiguousWidePointerComparisonsExpectSuggestion<'a>,
+ },
+ #[diag(lint_ambiguous_wide_pointer_comparisons)]
#[help(lint_addr_metadata_suggestion)]
#[help(lint_addr_suggestion)]
Spanless,
@@ -1816,48 +1823,67 @@ pub(crate) struct AmbiguousWidePointerComparisonsAddrMetadataSuggestion<'a> {
}
#[derive(Subdiagnostic)]
-pub(crate) enum AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
- #[multipart_suggestion(
- lint_addr_suggestion,
- style = "verbose",
- // FIXME(#53934): make machine-applicable again
- applicability = "maybe-incorrect"
+#[multipart_suggestion(
+ lint_addr_suggestion,
+ style = "verbose",
+ // FIXME(#53934): make machine-applicable again
+ applicability = "maybe-incorrect"
+)]
+pub(crate) struct AmbiguousWidePointerComparisonsAddrSuggestion<'a> {
+ pub(crate) ne: &'a str,
+ pub(crate) deref_left: &'a str,
+ pub(crate) deref_right: &'a str,
+ pub(crate) l_modifiers: &'a str,
+ pub(crate) r_modifiers: &'a str,
+ #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
+ pub(crate) left: Span,
+ #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
+ pub(crate) middle: Span,
+ #[suggestion_part(code = "{r_modifiers})")]
+ pub(crate) right: Span,
+}
+
+#[derive(Subdiagnostic)]
+#[multipart_suggestion(
+ lint_cast_suggestion,
+ style = "verbose",
+ // FIXME(#53934): make machine-applicable again
+ applicability = "maybe-incorrect"
+)]
+pub(crate) struct AmbiguousWidePointerComparisonsCastSuggestion<'a> {
+ pub(crate) deref_left: &'a str,
+ pub(crate) deref_right: &'a str,
+ pub(crate) paren_left: &'a str,
+ pub(crate) paren_right: &'a str,
+ pub(crate) l_modifiers: &'a str,
+ pub(crate) r_modifiers: &'a str,
+ #[suggestion_part(code = "({deref_left}")]
+ pub(crate) left_before: Option<Span>,
+ #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
+ pub(crate) left_after: Span,
+ #[suggestion_part(code = "({deref_right}")]
+ pub(crate) right_before: Option<Span>,
+ #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
+ pub(crate) right_after: Span,
+}
+
+#[derive(Subdiagnostic)]
+#[multipart_suggestion(
+ lint_expect_suggestion,
+ style = "verbose",
+ // FIXME(#53934): make machine-applicable again
+ applicability = "maybe-incorrect"
+)]
+pub(crate) struct AmbiguousWidePointerComparisonsExpectSuggestion<'a> {
+ pub(crate) paren_left: &'a str,
+ pub(crate) paren_right: &'a str,
+ // FIXME(#127436): Adjust once resolved
+ #[suggestion_part(
+ code = r#"{{ #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] {paren_left}"#
)]
- AddrEq {
- ne: &'a str,
- deref_left: &'a str,
- deref_right: &'a str,
- l_modifiers: &'a str,
- r_modifiers: &'a str,
- #[suggestion_part(code = "{ne}std::ptr::addr_eq({deref_left}")]
- left: Span,
- #[suggestion_part(code = "{l_modifiers}, {deref_right}")]
- middle: Span,
- #[suggestion_part(code = "{r_modifiers})")]
- right: Span,
- },
- #[multipart_suggestion(
- lint_addr_suggestion,
- style = "verbose",
- // FIXME(#53934): make machine-applicable again
- applicability = "maybe-incorrect"
- )]
- Cast {
- deref_left: &'a str,
- deref_right: &'a str,
- paren_left: &'a str,
- paren_right: &'a str,
- l_modifiers: &'a str,
- r_modifiers: &'a str,
- #[suggestion_part(code = "({deref_left}")]
- left_before: Option<Span>,
- #[suggestion_part(code = "{l_modifiers}{paren_left}.cast::<()>()")]
- left_after: Span,
- #[suggestion_part(code = "({deref_right}")]
- right_before: Option<Span>,
- #[suggestion_part(code = "{r_modifiers}{paren_right}.cast::<()>()")]
- right_after: Span,
- },
+ pub(crate) before: Span,
+ #[suggestion_part(code = "{paren_right} }}")]
+ pub(crate) after: Span,
}
#[derive(LintDiagnostic)]
diff --git a/compiler/rustc_lint/src/types.rs b/compiler/rustc_lint/src/types.rs
index f1c06df..af13462 100644
--- a/compiler/rustc_lint/src/types.rs
+++ b/compiler/rustc_lint/src/types.rs
@@ -24,7 +24,8 @@
use crate::lints::{
AmbiguousWidePointerComparisons, AmbiguousWidePointerComparisonsAddrMetadataSuggestion,
- AmbiguousWidePointerComparisonsAddrSuggestion, AtomicOrderingFence, AtomicOrderingLoad,
+ AmbiguousWidePointerComparisonsAddrSuggestion, AmbiguousWidePointerComparisonsCastSuggestion,
+ AmbiguousWidePointerComparisonsExpectSuggestion, AtomicOrderingFence, AtomicOrderingLoad,
AtomicOrderingStore, ImproperCTypes, InvalidAtomicOrderingDiag, InvalidNanComparisons,
InvalidNanComparisonsSuggestion, UnpredictableFunctionPointerComparisons,
UnpredictableFunctionPointerComparisonsSuggestion, UnusedComparisons, UsesPowerAlignment,
@@ -362,6 +363,7 @@ fn lint_wide_pointer<'tcx>(
let ne = if cmpop == ComparisonOp::BinOp(hir::BinOpKind::Ne) { "!" } else { "" };
let is_eq_ne = matches!(cmpop, ComparisonOp::BinOp(hir::BinOpKind::Eq | hir::BinOpKind::Ne));
let is_dyn_comparison = l_inner_ty_is_dyn && r_inner_ty_is_dyn;
+ let via_method_call = matches!(&e.kind, ExprKind::MethodCall(..) | ExprKind::Call(..));
let left = e.span.shrink_to_lo().until(l_span.shrink_to_lo());
let middle = l_span.shrink_to_hi().until(r_span.shrink_to_lo());
@@ -376,9 +378,21 @@ fn lint_wide_pointer<'tcx>(
cx.emit_span_lint(
AMBIGUOUS_WIDE_POINTER_COMPARISONS,
e.span,
- AmbiguousWidePointerComparisons::Spanful {
- addr_metadata_suggestion: (is_eq_ne && !is_dyn_comparison).then(|| {
- AmbiguousWidePointerComparisonsAddrMetadataSuggestion {
+ if is_eq_ne {
+ AmbiguousWidePointerComparisons::SpanfulEq {
+ addr_metadata_suggestion: (!is_dyn_comparison).then(|| {
+ AmbiguousWidePointerComparisonsAddrMetadataSuggestion {
+ ne,
+ deref_left,
+ deref_right,
+ l_modifiers,
+ r_modifiers,
+ left,
+ middle,
+ right,
+ }
+ }),
+ addr_suggestion: AmbiguousWidePointerComparisonsAddrSuggestion {
ne,
deref_left,
deref_right,
@@ -387,21 +401,11 @@ fn lint_wide_pointer<'tcx>(
left,
middle,
right,
- }
- }),
- addr_suggestion: if is_eq_ne {
- AmbiguousWidePointerComparisonsAddrSuggestion::AddrEq {
- ne,
- deref_left,
- deref_right,
- l_modifiers,
- r_modifiers,
- left,
- middle,
- right,
- }
- } else {
- AmbiguousWidePointerComparisonsAddrSuggestion::Cast {
+ },
+ }
+ } else {
+ AmbiguousWidePointerComparisons::SpanfulCmp {
+ cast_suggestion: AmbiguousWidePointerComparisonsCastSuggestion {
deref_left,
deref_right,
l_modifiers,
@@ -412,8 +416,14 @@ fn lint_wide_pointer<'tcx>(
left_after: l_span.shrink_to_hi(),
right_before: (r_ty_refs != 0).then_some(r_span.shrink_to_lo()),
right_after: r_span.shrink_to_hi(),
- }
- },
+ },
+ expect_suggestion: AmbiguousWidePointerComparisonsExpectSuggestion {
+ paren_left: if via_method_call { "" } else { "(" },
+ paren_right: if via_method_call { "" } else { ")" },
+ before: e.span.shrink_to_lo(),
+ after: e.span.shrink_to_hi(),
+ },
+ }
},
);
}
diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs
index 9d46209..7ba0e5b 100644
--- a/compiler/rustc_middle/src/mir/interpret/value.rs
+++ b/compiler/rustc_middle/src/mir/interpret/value.rs
@@ -180,27 +180,27 @@ pub fn from_int(i: impl Into<i128>, size: Size) -> Self {
#[inline]
pub fn from_i8(i: i8) -> Self {
- Self::from_int(i, Size::from_bits(8))
+ Self::Int(i.into())
}
#[inline]
pub fn from_i16(i: i16) -> Self {
- Self::from_int(i, Size::from_bits(16))
+ Self::Int(i.into())
}
#[inline]
pub fn from_i32(i: i32) -> Self {
- Self::from_int(i, Size::from_bits(32))
+ Self::Int(i.into())
}
#[inline]
pub fn from_i64(i: i64) -> Self {
- Self::from_int(i, Size::from_bits(64))
+ Self::Int(i.into())
}
#[inline]
pub fn from_i128(i: i128) -> Self {
- Self::from_int(i, Size::from_bits(128))
+ Self::Int(i.into())
}
#[inline]
diff --git a/compiler/rustc_middle/src/ty/consts/int.rs b/compiler/rustc_middle/src/ty/consts/int.rs
index 9f5e31d..9c9cd69 100644
--- a/compiler/rustc_middle/src/ty/consts/int.rs
+++ b/compiler/rustc_middle/src/ty/consts/int.rs
@@ -422,9 +422,9 @@ macro_rules! from_scalar_int_for_x {
impl From<ScalarInt> for $ty {
#[inline]
fn from(int: ScalarInt) -> Self {
- // The `unwrap` cannot fail because to_bits (if it succeeds)
+ // The `unwrap` cannot fail because to_uint (if it succeeds)
// is guaranteed to return a value that fits into the size.
- int.to_bits(Size::from_bytes(size_of::<$ty>()))
+ int.to_uint(Size::from_bytes(size_of::<$ty>()))
.try_into().unwrap()
}
}
@@ -450,6 +450,49 @@ fn from(c: char) -> Self {
}
}
+macro_rules! from_x_for_scalar_int_signed {
+ ($($ty:ty),*) => {
+ $(
+ impl From<$ty> for ScalarInt {
+ #[inline]
+ fn from(u: $ty) -> Self {
+ Self {
+ data: u128::from(u.cast_unsigned()), // go via the unsigned type of the same size
+ size: NonZero::new(size_of::<$ty>() as u8).unwrap(),
+ }
+ }
+ }
+ )*
+ }
+}
+
+macro_rules! from_scalar_int_for_x_signed {
+ ($($ty:ty),*) => {
+ $(
+ impl From<ScalarInt> for $ty {
+ #[inline]
+ fn from(int: ScalarInt) -> Self {
+ // The `unwrap` cannot fail because to_int (if it succeeds)
+ // is guaranteed to return a value that fits into the size.
+ int.to_int(Size::from_bytes(size_of::<$ty>()))
+ .try_into().unwrap()
+ }
+ }
+ )*
+ }
+}
+
+from_x_for_scalar_int_signed!(i8, i16, i32, i64, i128);
+from_scalar_int_for_x_signed!(i8, i16, i32, i64, i128);
+
+impl From<std::cmp::Ordering> for ScalarInt {
+ #[inline]
+ fn from(c: std::cmp::Ordering) -> Self {
+ // Here we rely on `Ordering` having the same values in host and target!
+ ScalarInt::from(c as i8)
+ }
+}
+
/// Error returned when a conversion from ScalarInt to char fails.
#[derive(Debug)]
pub struct CharTryFromScalarInt;
diff --git a/compiler/rustc_ty_utils/src/opaque_types.rs b/compiler/rustc_ty_utils/src/opaque_types.rs
index 841f602..3b44821 100644
--- a/compiler/rustc_ty_utils/src/opaque_types.rs
+++ b/compiler/rustc_ty_utils/src/opaque_types.rs
@@ -321,7 +321,10 @@ fn opaque_types_defined_by<'tcx>(
collector.collect_taits_declared_in_body();
}
// Closures and coroutines are type checked with their parent
- DefKind::Closure | DefKind::InlineConst => {
+ // Note that we also support `SyntheticCoroutineBody` since we create
+ // a MIR body for the def kind, and some MIR passes (like promotion)
+ // may require doing analysis using its typing env.
+ DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => {
collector.opaques.extend(tcx.opaque_types_defined_by(tcx.local_parent(item)));
}
DefKind::AssocTy | DefKind::TyAlias | DefKind::GlobalAsm => {}
@@ -343,8 +346,7 @@ fn opaque_types_defined_by<'tcx>(
| DefKind::ForeignMod
| DefKind::Field
| DefKind::LifetimeParam
- | DefKind::Impl { .. }
- | DefKind::SyntheticCoroutineBody => {
+ | DefKind::Impl { .. } => {
span_bug!(
tcx.def_span(item),
"`opaque_types_defined_by` not defined for {} `{item:?}`",
diff --git a/library/core/src/intrinsics/mod.rs b/library/core/src/intrinsics/mod.rs
index 23bafa7..439c8c1 100644
--- a/library/core/src/intrinsics/mod.rs
+++ b/library/core/src/intrinsics/mod.rs
@@ -1,7 +1,10 @@
//! Compiler intrinsics.
//!
-//! The corresponding definitions are in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/intrinsic.rs>.
-//! The corresponding const implementations are in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs>.
+//! These are the imports making intrinsics available to Rust code. The actual implementations live in the compiler.
+//! Some of these intrinsics are lowered to MIR in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_transform/src/lower_intrinsics.rs>.
+//! The remaining intrinsics are implemented for the LLVM backend in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs>
+//! and <https://github.com/rust-lang/rust/blob/master/compiler/rustc_codegen_llvm/src/intrinsic.rs>,
+//! and for const evaluation in <https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs>.
//!
//! # Const intrinsics
//!
@@ -20,28 +23,14 @@
//!
//! The volatile intrinsics provide operations intended to act on I/O
//! memory, which are guaranteed to not be reordered by the compiler
-//! across other volatile intrinsics. See the LLVM documentation on
-//! [[volatile]].
-//!
-//! [volatile]: https://llvm.org/docs/LangRef.html#volatile-memory-accesses
+//! across other volatile intrinsics. See [`read_volatile`][ptr::read_volatile]
+//! and [`write_volatile`][ptr::write_volatile].
//!
//! # Atomics
//!
//! The atomic intrinsics provide common atomic operations on machine
-//! words, with multiple possible memory orderings. They obey the same
-//! semantics as C++11. See the LLVM documentation on [[atomics]].
-//!
-//! [atomics]: https://llvm.org/docs/Atomics.html
-//!
-//! A quick refresher on memory ordering:
-//!
-//! * Acquire - a barrier for acquiring a lock. Subsequent reads and writes
-//! take place after the barrier.
-//! * Release - a barrier for releasing a lock. Preceding reads and writes
-//! take place before the barrier.
-//! * Sequentially consistent - sequentially consistent operations are
-//! guaranteed to happen in order. This is the standard mode for working
-//! with atomic types and is equivalent to Java's `volatile`.
+//! words, with multiple possible memory orderings. See the
+//! [atomic types][crate::sync::atomic] docs for details.
//!
//! # Unwinding
//!
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs
index 8047c0c0..8ed5800 100644
--- a/library/std/src/fs.rs
+++ b/library/std/src/fs.rs
@@ -391,6 +391,16 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
}
}
+#[unstable(feature = "file_lock", issue = "130994")]
+impl From<TryLockError> for io::Error {
+ fn from(err: TryLockError) -> io::Error {
+ match err {
+ TryLockError::Error(err) => err,
+ TryLockError::WouldBlock => io::ErrorKind::WouldBlock.into(),
+ }
+ }
+}
+
impl File {
/// Attempts to open a file in read-only mode.
///
@@ -820,11 +830,14 @@ pub fn lock_shared(&self) -> io::Result<()> {
///
/// fn main() -> std::io::Result<()> {
/// let f = File::create("foo.txt")?;
+ /// // Explicit handling of the WouldBlock error
/// match f.try_lock() {
/// Ok(_) => (),
/// Err(TryLockError::WouldBlock) => (), // Lock not acquired
/// Err(TryLockError::Error(err)) => return Err(err),
/// }
+ /// // Alternately, propagate the error as an io::Error
+ /// f.try_lock()?;
/// Ok(())
/// }
/// ```
@@ -881,11 +894,14 @@ pub fn try_lock(&self) -> Result<(), TryLockError> {
///
/// fn main() -> std::io::Result<()> {
/// let f = File::open("foo.txt")?;
+ /// // Explicit handling of the WouldBlock error
/// match f.try_lock_shared() {
/// Ok(_) => (),
/// Err(TryLockError::WouldBlock) => (), // Lock not acquired
/// Err(TryLockError::Error(err)) => return Err(err),
/// }
+ /// // Alternately, propagate the error as an io::Error
+ /// f.try_lock_shared()?;
///
/// Ok(())
/// }
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs
index c81a5ff..8da6d75 100644
--- a/library/std/src/fs/tests.rs
+++ b/library/std/src/fs/tests.rs
@@ -367,6 +367,28 @@ fn file_lock_blocking_async() {
}
#[test]
+#[cfg(windows)]
+fn file_try_lock_async() {
+ const FILE_FLAG_OVERLAPPED: u32 = 0x40000000;
+
+ let tmpdir = tmpdir();
+ let filename = &tmpdir.join("file_try_lock_async.txt");
+ let f1 = check!(File::create(filename));
+ let f2 =
+ check!(OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).write(true).open(filename));
+
+ // Check that shared locks block exclusive locks
+ check!(f1.lock_shared());
+ assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
+ check!(f1.unlock());
+
+ // Check that exclusive locks block all locks
+ check!(f1.lock());
+ assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
+ assert_matches!(f2.try_lock_shared(), Err(TryLockError::WouldBlock));
+}
+
+#[test]
fn file_test_io_seek_shakedown() {
// 01234567890123
let initial_msg = "qwer-asdf-zxcv";
diff --git a/library/std/src/sys/fs/windows.rs b/library/std/src/sys/fs/windows.rs
index 9039fd0..d01a572 100644
--- a/library/std/src/sys/fs/windows.rs
+++ b/library/std/src/sys/fs/windows.rs
@@ -415,10 +415,7 @@ pub fn try_lock(&self) -> Result<(), TryLockError> {
match result {
Ok(_) => Ok(()),
- Err(err)
- if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
- || err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
- {
+ Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
Err(TryLockError::WouldBlock)
}
Err(err) => Err(TryLockError::Error(err)),
@@ -440,10 +437,7 @@ pub fn try_lock_shared(&self) -> Result<(), TryLockError> {
match result {
Ok(_) => Ok(()),
- Err(err)
- if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
- || err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
- {
+ Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
Err(TryLockError::WouldBlock)
}
Err(err) => Err(TryLockError::Error(err)),
diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs
index 253fa22..7b5393a 100644
--- a/src/bootstrap/src/core/build_steps/dist.rs
+++ b/src/bootstrap/src/core/build_steps/dist.rs
@@ -2282,6 +2282,10 @@ fn tools_to_install(paths: &[PathBuf]) -> Vec<&'static str> {
}
}
+ if !builder.config.dry_run() {
+ builder.require_submodule("src/llvm-project", None);
+ }
+
builder.ensure(crate::core::build_steps::llvm::Llvm { target });
let mut tarball = Tarball::new(builder, "llvm-tools", &target.triple);
@@ -2400,6 +2404,10 @@ fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
}
}
+ if !builder.config.dry_run() {
+ builder.require_submodule("src/llvm-project", None);
+ }
+
let mut tarball = Tarball::new(builder, "rust-dev", &target.triple);
tarball.set_overlay(OverlayKind::Llvm);
// LLVM requires a shared object symlink to exist on some platforms.
diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs
index 585adf9..5419540 100644
--- a/src/bootstrap/src/core/build_steps/install.rs
+++ b/src/bootstrap/src/core/build_steps/install.rs
@@ -38,7 +38,9 @@ fn change_drive(s: &str) -> Option<String> {
if ch.next() != Some('/') {
return None;
}
- Some(format!("/{}/{}", drive, &s[drive.len_utf8() + 2..]))
+ // The prefix for Windows drives in Cygwin/MSYS2 is configurable, but
+ // /proc/cygdrive is available regardless of configuration since 1.7.33
+ Some(format!("/proc/cygdrive/{}/{}", drive, &s[drive.len_utf8() + 2..]))
}
}
diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile b/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
index 05c90af..e770c58 100644
--- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
+++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/Dockerfile
@@ -1,4 +1,4 @@
-FROM ubuntu:22.04
+FROM ghcr.io/rust-lang/ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
diff --git a/src/doc/rustc/src/check-cfg/cargo-specifics.md b/src/doc/rustc/src/check-cfg/cargo-specifics.md
index 371bbd2..62a4dd1 100644
--- a/src/doc/rustc/src/check-cfg/cargo-specifics.md
+++ b/src/doc/rustc/src/check-cfg/cargo-specifics.md
@@ -9,8 +9,8 @@
-->
This document is intended to summarize the principal ways Cargo interacts with
-the `unexpected_cfgs` lint and `--check-cfg` flag. It is not intended to provide
-individual details, for that refer to the [`--check-cfg` documentation](../check-cfg.md) and
+the `unexpected_cfgs` lint and `--check-cfg` flag.
+For individual details, refer to the [`--check-cfg` documentation](../check-cfg.md) and
to the [Cargo book](../../cargo/index.html).
> The full list of well known cfgs (aka builtins) can be found under [Checking conditional configurations / Well known names and values](../check-cfg.md#well-known-names-and-values).
diff --git a/src/tools/rustbook/Cargo.lock b/src/tools/rustbook/Cargo.lock
index 5c862e9..07c5106 100644
--- a/src/tools/rustbook/Cargo.lock
+++ b/src/tools/rustbook/Cargo.lock
@@ -885,9 +885,9 @@
[[package]]
name = "mdbook"
-version = "0.4.50"
+version = "0.4.51"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f72bc08f096e1fb15cfc382babe218317c2897d2040f967c4db40d156ca28e21"
+checksum = "a87e65420ab45ca9c1b8cdf698f95b710cc826d373fa550f0f7fad82beac9328"
dependencies = [
"ammonia",
"anyhow",
diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml
index ee2ada5..69c0cfa 100644
--- a/src/tools/rustbook/Cargo.toml
+++ b/src/tools/rustbook/Cargo.toml
@@ -15,6 +15,6 @@
mdbook-spec = { path = "../../doc/reference/mdbook-spec" }
[dependencies.mdbook]
-version = "0.4.50"
+version = "0.4.51"
default-features = false
features = ["search"]
diff --git a/tests/ui/async-await/async-closures/promote-in-body.rs b/tests/ui/async-await/async-closures/promote-in-body.rs
new file mode 100644
index 0000000..ea95d68
--- /dev/null
+++ b/tests/ui/async-await/async-closures/promote-in-body.rs
@@ -0,0 +1,13 @@
+//@ build-pass
+//@ compile-flags: --crate-type=lib
+//@ edition: 2024
+
+union U {
+ f: i32,
+}
+
+fn foo() {
+ async || {
+ &U { f: 1 }
+ };
+}
diff --git a/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs b/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs
index d222ddc..60a7dff 100644
--- a/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs
+++ b/tests/ui/async-await/async-fn/edition-2015-not-async-bound.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
//@ check-pass
// Make sure that we don't eagerly recover `async ::Bound` in edition 2015.
diff --git a/tests/ui/async-await/async-fn/edition-2015.rs b/tests/ui/async-await/async-fn/edition-2015.rs
index 341b9b1..5a81df3 100644
--- a/tests/ui/async-await/async-fn/edition-2015.rs
+++ b/tests/ui/async-await/async-fn/edition-2015.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
fn foo(x: impl async Fn()) -> impl async Fn() { x }
//~^ ERROR `async` trait bounds are only allowed in Rust 2018 or later
//~| ERROR `async` trait bounds are only allowed in Rust 2018 or later
diff --git a/tests/ui/async-await/async-fn/edition-2015.stderr b/tests/ui/async-await/async-fn/edition-2015.stderr
index ca9e64c..0bec00c 100644
--- a/tests/ui/async-await/async-fn/edition-2015.stderr
+++ b/tests/ui/async-await/async-fn/edition-2015.stderr
@@ -1,5 +1,5 @@
error: `async` trait bounds are only allowed in Rust 2018 or later
- --> $DIR/edition-2015.rs:1:16
+ --> $DIR/edition-2015.rs:2:16
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
@@ -8,7 +8,7 @@
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error: `async` trait bounds are only allowed in Rust 2018 or later
- --> $DIR/edition-2015.rs:1:36
+ --> $DIR/edition-2015.rs:2:36
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
@@ -17,7 +17,7 @@
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0658]: `async` trait bounds are unstable
- --> $DIR/edition-2015.rs:1:16
+ --> $DIR/edition-2015.rs:2:16
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
@@ -28,7 +28,7 @@
= help: use the desugared name of the async trait, such as `AsyncFn`
error[E0658]: `async` trait bounds are unstable
- --> $DIR/edition-2015.rs:1:36
+ --> $DIR/edition-2015.rs:2:36
|
LL | fn foo(x: impl async Fn()) -> impl async Fn() { x }
| ^^^^^
diff --git a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs
index 50c1639..714a332 100644
--- a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs
+++ b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
#![allow(non_camel_case_types)]
#![deny(keyword_idents)]
diff --git a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr
index 8cea73f..70900e6 100644
--- a/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr
+++ b/tests/ui/async-await/await-keyword/2015-edition-error-various-positions.stderr
@@ -1,5 +1,5 @@
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:5:13
+ --> $DIR/2015-edition-error-various-positions.rs:6:13
|
LL | pub mod await {
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -7,14 +7,14 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
note: the lint level is defined here
- --> $DIR/2015-edition-error-various-positions.rs:2:9
+ --> $DIR/2015-edition-error-various-positions.rs:3:9
|
LL | #![deny(keyword_idents)]
| ^^^^^^^^^^^^^^
= note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]`
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:7:20
+ --> $DIR/2015-edition-error-various-positions.rs:8:20
|
LL | pub struct await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -23,7 +23,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:11:16
+ --> $DIR/2015-edition-error-various-positions.rs:12:16
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -32,7 +32,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:11:23
+ --> $DIR/2015-edition-error-various-positions.rs:12:23
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -41,7 +41,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:16:14
+ --> $DIR/2015-edition-error-various-positions.rs:17:14
|
LL | struct Foo { await: () }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -50,7 +50,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:20:15
+ --> $DIR/2015-edition-error-various-positions.rs:21:15
|
LL | impl Foo { fn await() {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -59,7 +59,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:24:14
+ --> $DIR/2015-edition-error-various-positions.rs:25:14
|
LL | macro_rules! await {
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -68,7 +68,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:31:5
+ --> $DIR/2015-edition-error-various-positions.rs:32:5
|
LL | await!();
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -77,7 +77,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:34:11
+ --> $DIR/2015-edition-error-various-positions.rs:35:11
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -86,7 +86,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-error-various-positions.rs:34:19
+ --> $DIR/2015-edition-error-various-positions.rs:35:19
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.fixed b/tests/ui/async-await/await-keyword/2015-edition-warning.fixed
index 4cb8017..45758cb 100644
--- a/tests/ui/async-await/await-keyword/2015-edition-warning.fixed
+++ b/tests/ui/async-await/await-keyword/2015-edition-warning.fixed
@@ -1,3 +1,4 @@
+//@ edition:2015
//@ run-rustfix
#![allow(non_camel_case_types)]
diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.rs b/tests/ui/async-await/await-keyword/2015-edition-warning.rs
index d591a5a..ea26abe 100644
--- a/tests/ui/async-await/await-keyword/2015-edition-warning.rs
+++ b/tests/ui/async-await/await-keyword/2015-edition-warning.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
//@ run-rustfix
#![allow(non_camel_case_types)]
diff --git a/tests/ui/async-await/await-keyword/2015-edition-warning.stderr b/tests/ui/async-await/await-keyword/2015-edition-warning.stderr
index 70b7fa5..9d19a09 100644
--- a/tests/ui/async-await/await-keyword/2015-edition-warning.stderr
+++ b/tests/ui/async-await/await-keyword/2015-edition-warning.stderr
@@ -1,5 +1,5 @@
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-warning.rs:7:13
+ --> $DIR/2015-edition-warning.rs:8:13
|
LL | pub mod await {
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -7,14 +7,14 @@
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018!
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
note: the lint level is defined here
- --> $DIR/2015-edition-warning.rs:4:9
+ --> $DIR/2015-edition-warning.rs:5:9
|
LL | #![deny(keyword_idents)]
| ^^^^^^^^^^^^^^
= note: `#[deny(keyword_idents_2018)]` implied by `#[deny(keyword_idents)]`
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-warning.rs:10:20
+ --> $DIR/2015-edition-warning.rs:11:20
|
LL | pub struct await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -23,7 +23,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-warning.rs:15:16
+ --> $DIR/2015-edition-warning.rs:16:16
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -32,7 +32,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-warning.rs:15:23
+ --> $DIR/2015-edition-warning.rs:16:23
|
LL | use outer_mod::await::await;
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -41,7 +41,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-warning.rs:22:11
+ --> $DIR/2015-edition-warning.rs:23:11
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
@@ -50,7 +50,7 @@
= note: for more information, see issue #49716 <https://github.com/rust-lang/rust/issues/49716>
error: `await` is a keyword in the 2018 edition
- --> $DIR/2015-edition-warning.rs:22:19
+ --> $DIR/2015-edition-warning.rs:23:19
|
LL | match await { await => {} }
| ^^^^^ help: you can use a raw identifier to stay compatible: `r#await`
diff --git a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr
index 9b818a1..6689539 100644
--- a/tests/ui/async-await/dyn/mut-is-pointer-like.stderr
+++ b/tests/ui/async-await/dyn/mut-is-pointer-like.stderr
@@ -8,10 +8,10 @@
= note: `#[warn(incomplete_features)]` on by default
error[E0038]: the trait `AsyncTrait` is not dyn compatible
- --> $DIR/mut-is-pointer-like.rs:35:16
+ --> $DIR/mut-is-pointer-like.rs:35:29
|
LL | let x: Pin<&mut dyn AsyncTrait<Output = ()>> = f;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
+ | ^^^^^^^^^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/async-await/dyn/works.stderr b/tests/ui/async-await/dyn/works.stderr
index 5d2cc38..338479d 100644
--- a/tests/ui/async-await/dyn/works.stderr
+++ b/tests/ui/async-await/dyn/works.stderr
@@ -8,10 +8,10 @@
= note: `#[warn(incomplete_features)]` on by default
error[E0038]: the trait `AsyncTrait` is not dyn compatible
- --> $DIR/works.rs:27:16
+ --> $DIR/works.rs:27:21
|
LL | let x: &dyn AsyncTrait = &"hello, world!";
- | ^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
+ | ^^^^^^^^^^ `AsyncTrait` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/async-await/dyn/wrong-size.stderr b/tests/ui/async-await/dyn/wrong-size.stderr
index 930ca57..a465f91 100644
--- a/tests/ui/async-await/dyn/wrong-size.stderr
+++ b/tests/ui/async-await/dyn/wrong-size.stderr
@@ -8,10 +8,10 @@
= note: `#[warn(incomplete_features)]` on by default
error[E0038]: the trait `AsyncTrait` is not dyn compatible
- --> $DIR/wrong-size.rs:21:12
+ --> $DIR/wrong-size.rs:21:17
|
LL | let x: &dyn AsyncTrait = &"hello, world!";
- | ^^^^^^^^^^^^^^^ `AsyncTrait` is not dyn compatible
+ | ^^^^^^^^^^ `AsyncTrait` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/async-await/for-await-2015.rs b/tests/ui/async-await/for-await-2015.rs
index 89ff256..c2bd39c 100644
--- a/tests/ui/async-await/for-await-2015.rs
+++ b/tests/ui/async-await/for-await-2015.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
//@ check-pass
#![feature(async_for_loop)]
diff --git a/tests/ui/async-await/in-trait/dyn-compatibility.stderr b/tests/ui/async-await/in-trait/dyn-compatibility.stderr
index 553bcbf..f0c5dc5 100644
--- a/tests/ui/async-await/in-trait/dyn-compatibility.stderr
+++ b/tests/ui/async-await/in-trait/dyn-compatibility.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/dyn-compatibility.rs:9:12
+ --> $DIR/dyn-compatibility.rs:9:17
|
LL | let x: &dyn Foo = todo!();
- | ^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr
index 2bdc134..8ce4d4e 100644
--- a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr
+++ b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2015.stderr
@@ -1,16 +1,16 @@
error[E0034]: multiple applicable items in scope
- --> $DIR/issue-65634-raw-ident-suggestion.rs:24:13
+ --> $DIR/issue-65634-raw-ident-suggestion.rs:25:13
|
LL | r#fn {}.r#struct();
| ^^^^^^^^ multiple `r#struct` found
|
note: candidate #1 is defined in an impl of the trait `async` for the type `r#fn`
- --> $DIR/issue-65634-raw-ident-suggestion.rs:7:5
+ --> $DIR/issue-65634-raw-ident-suggestion.rs:8:5
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `await` for the type `r#fn`
- --> $DIR/issue-65634-raw-ident-suggestion.rs:13:5
+ --> $DIR/issue-65634-raw-ident-suggestion.rs:14:5
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr
index ab10ab7..d910ef9 100644
--- a/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr
+++ b/tests/ui/async-await/issue-65634-raw-ident-suggestion.edition2018.stderr
@@ -1,16 +1,16 @@
error[E0034]: multiple applicable items in scope
- --> $DIR/issue-65634-raw-ident-suggestion.rs:24:13
+ --> $DIR/issue-65634-raw-ident-suggestion.rs:25:13
|
LL | r#fn {}.r#struct();
| ^^^^^^^^ multiple `r#struct` found
|
note: candidate #1 is defined in an impl of the trait `r#async` for the type `r#fn`
- --> $DIR/issue-65634-raw-ident-suggestion.rs:7:5
+ --> $DIR/issue-65634-raw-ident-suggestion.rs:8:5
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `r#await` for the type `r#fn`
- --> $DIR/issue-65634-raw-ident-suggestion.rs:13:5
+ --> $DIR/issue-65634-raw-ident-suggestion.rs:14:5
|
LL | fn r#struct(&self) {
| ^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs b/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs
index ef5760f..98f5b6d 100644
--- a/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs
+++ b/tests/ui/async-await/issue-65634-raw-ident-suggestion.rs
@@ -1,4 +1,5 @@
//@ revisions: edition2015 edition2018
+//@[edition2015]edition:2015
//@[edition2018]edition:2018
#![allow(non_camel_case_types)]
diff --git a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs
index bcb5cb9..555b011 100644
--- a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs
+++ b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
//@ rustc-env:CARGO_CRATE_NAME=foo
use std::pin::Pin;
diff --git a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr
index 11f5825..c5f1793 100644
--- a/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr
+++ b/tests/ui/async-await/suggest-switching-edition-on-await-cargo.stderr
@@ -1,5 +1,5 @@
error[E0609]: no field `await` on type `await_on_struct_missing::S`
- --> $DIR/suggest-switching-edition-on-await-cargo.rs:11:7
+ --> $DIR/suggest-switching-edition-on-await-cargo.rs:12:7
|
LL | x.await;
| ^^^^^ unknown field
@@ -9,7 +9,7 @@
= 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`
- --> $DIR/suggest-switching-edition-on-await-cargo.rs:24:7
+ --> $DIR/suggest-switching-edition-on-await-cargo.rs:25:7
|
LL | x.await;
| ^^^^^ unknown field
@@ -24,7 +24,7 @@
|
error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>`
- --> $DIR/suggest-switching-edition-on-await-cargo.rs:34:7
+ --> $DIR/suggest-switching-edition-on-await-cargo.rs:35:7
|
LL | x.await;
| ^^^^^ unknown field
@@ -34,7 +34,7 @@
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0609]: no field `await` on type `impl Future<Output = ()>`
- --> $DIR/suggest-switching-edition-on-await-cargo.rs:43:7
+ --> $DIR/suggest-switching-edition-on-await-cargo.rs:44:7
|
LL | x.await;
| ^^^^^ unknown field
diff --git a/tests/ui/async-await/suggest-switching-edition-on-await.rs b/tests/ui/async-await/suggest-switching-edition-on-await.rs
index 0907a87..6b639fa 100644
--- a/tests/ui/async-await/suggest-switching-edition-on-await.rs
+++ b/tests/ui/async-await/suggest-switching-edition-on-await.rs
@@ -1,3 +1,4 @@
+//@ edition:2015
use std::pin::Pin;
use std::future::Future;
diff --git a/tests/ui/async-await/suggest-switching-edition-on-await.stderr b/tests/ui/async-await/suggest-switching-edition-on-await.stderr
index 2ede8d5..bf03016 100644
--- a/tests/ui/async-await/suggest-switching-edition-on-await.stderr
+++ b/tests/ui/async-await/suggest-switching-edition-on-await.stderr
@@ -1,5 +1,5 @@
error[E0609]: no field `await` on type `await_on_struct_missing::S`
- --> $DIR/suggest-switching-edition-on-await.rs:9:7
+ --> $DIR/suggest-switching-edition-on-await.rs:10:7
|
LL | x.await;
| ^^^^^ unknown field
@@ -9,7 +9,7 @@
= 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`
- --> $DIR/suggest-switching-edition-on-await.rs:22:7
+ --> $DIR/suggest-switching-edition-on-await.rs:23:7
|
LL | x.await;
| ^^^^^ unknown field
@@ -24,7 +24,7 @@
|
error[E0609]: no field `await` on type `Pin<&mut dyn Future<Output = ()>>`
- --> $DIR/suggest-switching-edition-on-await.rs:32:7
+ --> $DIR/suggest-switching-edition-on-await.rs:33:7
|
LL | x.await;
| ^^^^^ unknown field
@@ -34,7 +34,7 @@
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
error[E0609]: no field `await` on type `impl Future<Output = ()>`
- --> $DIR/suggest-switching-edition-on-await.rs:41:7
+ --> $DIR/suggest-switching-edition-on-await.rs:42:7
|
LL | x.await;
| ^^^^^ unknown field
diff --git a/tests/ui/auxiliary/delegate_macro.rs b/tests/ui/auxiliary/delegate_macro.rs
new file mode 100644
index 0000000..0d752e1
--- /dev/null
+++ b/tests/ui/auxiliary/delegate_macro.rs
@@ -0,0 +1,6 @@
+#[macro_export]
+macro_rules! delegate {
+ ($method:ident) => {
+ <Self>::$method(8)
+ };
+}
diff --git a/tests/ui/cfg/cfg-version/syntax.rs b/tests/ui/cfg/cfg-version/syntax.rs
new file mode 100644
index 0000000..22aab47
--- /dev/null
+++ b/tests/ui/cfg/cfg-version/syntax.rs
@@ -0,0 +1,152 @@
+//! Check `#[cfg(version(..))]` parsing.
+
+#![feature(cfg_version)]
+
+// Overall grammar
+// ===============
+//
+// `#[cfg(version(..))]` accepts only the `version(VERSION_STRING_LITERAL)` predicate form, where
+// only a single string literal is permitted.
+
+#[cfg(version(42))]
+//~^ ERROR expected a version literal
+fn not_a_string_literal_simple() {}
+
+#[cfg(version(1.20))]
+//~^ ERROR expected a version literal
+fn not_a_string_literal_semver_like() {}
+
+#[cfg(version(false))]
+//~^ ERROR expected a version literal
+fn not_a_string_literal_other() {}
+
+#[cfg(version("1.43", "1.44", "1.45"))]
+//~^ ERROR expected single version literal
+fn multiple_version_literals() {}
+
+// The key-value form `cfg(version = "..")` is not considered a valid `cfg(version(..))` usage, but
+// it will only trigger the `unexpected_cfgs` lint and not a hard error.
+
+#[cfg(version = "1.43")]
+//~^ WARN unexpected `cfg` condition name: `version`
+fn key_value_form() {}
+
+// Additional version string literal constraints
+// =============================================
+//
+// The `VERSION_STRING_LITERAL` ("version literal") has additional constraints on its syntactical
+// well-formedness.
+
+// 1. A valid version literal can only constitute of numbers and periods (a "simple" semver version
+// string). Non-semver strings or "complex" semver strings (such as build metadata) are not
+// considered valid version literals, and will emit a non-lint warning "unknown version literal
+// format".
+
+#[cfg(version("1.43.0"))]
+fn valid_major_minor_patch() {}
+
+#[cfg(version("0.0.0"))]
+fn valid_zero_zero_zero_major_minor_patch() {}
+
+#[cfg(version("foo"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn not_numbers_or_periods() {}
+
+#[cfg(version("1.20.0-stable"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn complex_semver_with_metadata() {}
+
+// 2. "Shortened" version strings are permitted but *only* for the omission of the patch number.
+
+#[cfg(version("1.0"))]
+fn valid_major_minor_1() {}
+
+#[cfg(version("1.43"))]
+fn valid_major_minor_2() {}
+
+#[cfg(not(version("1.44")))]
+fn valid_major_minor_negated_smoke_test() {}
+
+#[cfg(version("0.0"))]
+fn valid_zero_zero_major_minor() {}
+
+#[cfg(version("0.7"))]
+fn valid_zero_major_minor() {}
+
+// 3. Major-only, or other non-Semver-like strings are not permitted.
+
+#[cfg(version("1"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn invalid_major_only() {}
+
+#[cfg(version("0"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn invalid_major_only_zero() {}
+
+#[cfg(version(".7"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn invalid_decimal_like() {}
+
+// Misc parsing overflow/underflow edge cases
+// ==========================================
+//
+// Check that we report "unknown version literal format" user-facing warnings and not ICEs.
+
+#[cfg(version("-1"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn invalid_major_only_negative() {}
+
+// Implementation detail: we store rustc version as `{ major: u16, minor: u16, patch: u16 }`.
+
+#[cfg(version("65536"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn exceed_u16_major() {}
+
+#[cfg(version("1.65536.0"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn exceed_u16_minor() {}
+
+#[cfg(version("1.0.65536"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn exceed_u16_patch() {}
+
+#[cfg(version("65536.0.65536"))]
+//~^ WARN unknown version literal format, assuming it refers to a future version
+fn exceed_u16_mixed() {}
+
+// Usage as `cfg!()`
+// =================
+
+fn cfg_usage() {
+ assert!(cfg!(version("1.0")));
+ assert!(cfg!(version("1.43")));
+ assert!(cfg!(version("1.43.0")));
+
+ assert!(cfg!(version("foo")));
+ //~^ WARN unknown version literal format, assuming it refers to a future version
+ assert!(cfg!(version("1.20.0-stable")));
+ //~^ WARN unknown version literal format, assuming it refers to a future version
+
+ assert!(cfg!(version = "1.43"));
+ //~^ WARN unexpected `cfg` condition name: `version`
+}
+
+fn main() {
+ cfg_usage();
+
+ // `cfg(version = "..")` is not a valid `cfg_version` form, but it only triggers
+ // `unexpected_cfgs` lint, and `cfg(version = "..")` eval to `false`.
+ key_value_form(); //~ ERROR cannot find function
+
+ // Invalid version literal formats within valid `cfg(version(..))` form should also cause
+ // `cfg(version(..))` eval to `false`.
+ not_numbers_or_periods(); //~ ERROR cannot find function
+ complex_semver_with_metadata(); //~ ERROR cannot find function
+ invalid_major_only(); //~ ERROR cannot find function
+ invalid_major_only_zero(); //~ ERROR cannot find function
+ invalid_major_only_negative(); //~ ERROR cannot find function
+ exceed_u16_major(); //~ ERROR cannot find function
+ exceed_u16_minor(); //~ ERROR cannot find function
+ exceed_u16_patch(); //~ ERROR cannot find function
+ exceed_u16_mixed(); //~ ERROR cannot find function
+}
diff --git a/tests/ui/cfg/cfg-version/syntax.stderr b/tests/ui/cfg/cfg-version/syntax.stderr
new file mode 100644
index 0000000..2facd96
--- /dev/null
+++ b/tests/ui/cfg/cfg-version/syntax.stderr
@@ -0,0 +1,188 @@
+error: expected a version literal
+ --> $DIR/syntax.rs:11:15
+ |
+LL | #[cfg(version(42))]
+ | ^^
+
+error: expected a version literal
+ --> $DIR/syntax.rs:15:15
+ |
+LL | #[cfg(version(1.20))]
+ | ^^^^
+
+error: expected a version literal
+ --> $DIR/syntax.rs:19:15
+ |
+LL | #[cfg(version(false))]
+ | ^^^^^
+
+error: expected single version literal
+ --> $DIR/syntax.rs:23:7
+ |
+LL | #[cfg(version("1.43", "1.44", "1.45"))]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:51:15
+ |
+LL | #[cfg(version("foo"))]
+ | ^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:55:15
+ |
+LL | #[cfg(version("1.20.0-stable"))]
+ | ^^^^^^^^^^^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:78:15
+ |
+LL | #[cfg(version("1"))]
+ | ^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:82:15
+ |
+LL | #[cfg(version("0"))]
+ | ^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:86:15
+ |
+LL | #[cfg(version(".7"))]
+ | ^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:95:15
+ |
+LL | #[cfg(version("-1"))]
+ | ^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:101:15
+ |
+LL | #[cfg(version("65536"))]
+ | ^^^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:105:15
+ |
+LL | #[cfg(version("1.65536.0"))]
+ | ^^^^^^^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:109:15
+ |
+LL | #[cfg(version("1.0.65536"))]
+ | ^^^^^^^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:113:15
+ |
+LL | #[cfg(version("65536.0.65536"))]
+ | ^^^^^^^^^^^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:125:26
+ |
+LL | assert!(cfg!(version("foo")));
+ | ^^^^^
+
+warning: unknown version literal format, assuming it refers to a future version
+ --> $DIR/syntax.rs:127:26
+ |
+LL | assert!(cfg!(version("1.20.0-stable")));
+ | ^^^^^^^^^^^^^^^
+
+warning: unexpected `cfg` condition name: `version`
+ --> $DIR/syntax.rs:30:7
+ |
+LL | #[cfg(version = "1.43")]
+ | ^^^^^^^^^^^^^^^^
+ |
+ = help: to expect this configuration use `--check-cfg=cfg(version, values("1.43"))`
+ = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
+ = note: `#[warn(unexpected_cfgs)]` on by default
+help: there is a similar config predicate: `version("..")`
+ |
+LL - #[cfg(version = "1.43")]
+LL + #[cfg(version("1.43"))]
+ |
+
+warning: unexpected `cfg` condition name: `version`
+ --> $DIR/syntax.rs:130:18
+ |
+LL | assert!(cfg!(version = "1.43"));
+ | ^^^^^^^^^^^^^^^^
+ |
+ = help: to expect this configuration use `--check-cfg=cfg(version, values("1.43"))`
+ = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
+help: there is a similar config predicate: `version("..")`
+ |
+LL - assert!(cfg!(version = "1.43"));
+LL + assert!(cfg!(version("1.43")));
+ |
+
+error[E0425]: cannot find function `key_value_form` in this scope
+ --> $DIR/syntax.rs:139:5
+ |
+LL | key_value_form();
+ | ^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `not_numbers_or_periods` in this scope
+ --> $DIR/syntax.rs:143:5
+ |
+LL | not_numbers_or_periods();
+ | ^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `complex_semver_with_metadata` in this scope
+ --> $DIR/syntax.rs:144:5
+ |
+LL | complex_semver_with_metadata();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `invalid_major_only` in this scope
+ --> $DIR/syntax.rs:145:5
+ |
+LL | invalid_major_only();
+ | ^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `invalid_major_only_zero` in this scope
+ --> $DIR/syntax.rs:146:5
+ |
+LL | invalid_major_only_zero();
+ | ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `invalid_major_only_negative` in this scope
+ --> $DIR/syntax.rs:147:5
+ |
+LL | invalid_major_only_negative();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `exceed_u16_major` in this scope
+ --> $DIR/syntax.rs:148:5
+ |
+LL | exceed_u16_major();
+ | ^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `exceed_u16_minor` in this scope
+ --> $DIR/syntax.rs:149:5
+ |
+LL | exceed_u16_minor();
+ | ^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `exceed_u16_patch` in this scope
+ --> $DIR/syntax.rs:150:5
+ |
+LL | exceed_u16_patch();
+ | ^^^^^^^^^^^^^^^^ not found in this scope
+
+error[E0425]: cannot find function `exceed_u16_mixed` in this scope
+ --> $DIR/syntax.rs:151:5
+ |
+LL | exceed_u16_mixed();
+ | ^^^^^^^^^^^^^^^^ not found in this scope
+
+error: aborting due to 14 previous errors; 14 warnings emitted
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs
index 9cd32ff..b747086 100644
--- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs
+++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.rs
@@ -4,4 +4,5 @@ fn main() {
let _: &Copy + 'static; //~ ERROR expected a path
//~^ ERROR is not dyn compatible
let _: &'static Copy + 'static; //~ ERROR expected a path
+ //~^ ERROR is not dyn compatible
}
diff --git a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr
index 762b37b..57dbc79 100644
--- a/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr
+++ b/tests/ui/did_you_mean/trait-object-reference-without-parens-suggestion.stderr
@@ -21,16 +21,26 @@
| + +
error[E0038]: the trait `Copy` is not dyn compatible
- --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:12
+ --> $DIR/trait-object-reference-without-parens-suggestion.rs:4:13
|
LL | let _: &Copy + 'static;
- | ^^^^^ `Copy` is not dyn compatible
+ | ^^^^ `Copy` is not dyn compatible
|
= note: the trait is not dyn compatible because it requires `Self: Sized`
= note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
-error: aborting due to 3 previous errors
+error[E0038]: the trait `Copy` is not dyn compatible
+ --> $DIR/trait-object-reference-without-parens-suggestion.rs:6:21
+ |
+LL | let _: &'static Copy + 'static;
+ | ^^^^ `Copy` is not dyn compatible
+ |
+ = note: the trait is not dyn compatible because it requires `Self: Sized`
+ = note: for a trait to be dyn compatible it needs to allow building a vtable
+ for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
+
+error: aborting due to 4 previous errors
Some errors have detailed explanations: E0038, E0178.
For more information about an error, try `rustc --explain E0038`.
diff --git a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr
index d3022b5..acd6dbe 100644
--- a/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr
+++ b/tests/ui/dyn-compatibility/almost-supertrait-associated-type.stderr
@@ -16,10 +16,10 @@
= help: consider moving `transmute` to another trait
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/almost-supertrait-associated-type.rs:7:27
+ --> $DIR/almost-supertrait-associated-type.rs:7:32
|
LL | (&PhantomData::<T> as &dyn Foo<T, U>).transmute(t)
- | ^^^^^^^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/dyn-compatibility/generics.stderr b/tests/ui/dyn-compatibility/generics.stderr
index aec5197..79dccc4 100644
--- a/tests/ui/dyn-compatibility/generics.stderr
+++ b/tests/ui/dyn-compatibility/generics.stderr
@@ -31,10 +31,10 @@
= help: consider moving `bar` to another trait
error[E0038]: the trait `Bar` is not dyn compatible
- --> $DIR/generics.rs:22:10
+ --> $DIR/generics.rs:22:15
|
LL | t as &dyn Bar
- | ^^^^^^^^ `Bar` is not dyn compatible
+ | ^^^ `Bar` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr
index 5bc1847..dd7b31a 100644
--- a/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr
+++ b/tests/ui/dyn-compatibility/mention-correct-dyn-incompatible-trait.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Bar` is not dyn compatible
- --> $DIR/mention-correct-dyn-incompatible-trait.rs:19:15
+ --> $DIR/mention-correct-dyn-incompatible-trait.rs:19:24
|
LL | let test: &mut dyn Bar = &mut thing;
- | ^^^^^^^^^^^^ `Bar` is not dyn compatible
+ | ^^^ `Bar` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/dyn-compatibility/no-static.stderr b/tests/ui/dyn-compatibility/no-static.stderr
index 8e4f109..c1d5dd6 100644
--- a/tests/ui/dyn-compatibility/no-static.stderr
+++ b/tests/ui/dyn-compatibility/no-static.stderr
@@ -23,10 +23,10 @@
| +++++++++++++++++
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/no-static.rs:18:12
+ --> $DIR/no-static.rs:18:20
|
LL | let b: Box<dyn Foo> = Box::new(Bar);
- | ^^^^^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.rs b/tests/ui/feature-gates/feature-gate-cfg-version.rs
index e35784a..ec2446c 100644
--- a/tests/ui/feature-gates/feature-gate-cfg-version.rs
+++ b/tests/ui/feature-gates/feature-gate-cfg-version.rs
@@ -1,49 +1,12 @@
-#[cfg(version(42))] //~ ERROR: expected a version literal
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn foo() {}
-#[cfg(version(1.20))] //~ ERROR: expected a version literal
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn foo() -> bool { true }
-#[cfg(version("1.44"))]
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn foo() -> bool { true }
-#[cfg(not(version("1.44")))]
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn foo() -> bool { false }
+//! Feature gate test for `cfg_version`.
+//!
+//! Tracking issue: #64796.
-#[cfg(version("1.43", "1.44", "1.45"))] //~ ERROR: expected single version literal
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version(false))] //~ ERROR: expected a version literal
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version("foo"))] //~ WARNING: unknown version literal format
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version("999"))] //~ WARNING: unknown version literal format
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version("-1"))] //~ WARNING: unknown version literal format
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version("65536"))] //~ WARNING: unknown version literal format
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version("0"))] //~ WARNING: unknown version literal format
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { true }
-#[cfg(version("1.0"))]
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { true }
-#[cfg(version("1.65536.2"))] //~ WARNING: unknown version literal format
-//~^ ERROR `cfg(version)` is experimental and subject to change
-fn bar() -> bool { false }
-#[cfg(version("1.20.0-stable"))] //~ WARNING: unknown version literal format
+#[cfg(version("1.42"))]
//~^ ERROR `cfg(version)` is experimental and subject to change
fn bar() {}
fn main() {
- assert!(foo());
- assert!(bar());
- assert!(cfg!(version("1.42"))); //~ ERROR `cfg(version)` is experimental and subject to change
+ assert!(cfg!(version("1.42")));
+ //~^ ERROR `cfg(version)` is experimental and subject to change
}
diff --git a/tests/ui/feature-gates/feature-gate-cfg-version.stderr b/tests/ui/feature-gates/feature-gate-cfg-version.stderr
index c1c3e8e..7cb2f1e 100644
--- a/tests/ui/feature-gates/feature-gate-cfg-version.stderr
+++ b/tests/ui/feature-gates/feature-gate-cfg-version.stderr
@@ -1,39 +1,7 @@
error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:1:7
+ --> $DIR/feature-gate-cfg-version.rs:5:7
|
-LL | #[cfg(version(42))]
- | ^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: expected a version literal
- --> $DIR/feature-gate-cfg-version.rs:1:15
- |
-LL | #[cfg(version(42))]
- | ^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:4:7
- |
-LL | #[cfg(version(1.20))]
- | ^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: expected a version literal
- --> $DIR/feature-gate-cfg-version.rs:4:15
- |
-LL | #[cfg(version(1.20))]
- | ^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:7:7
- |
-LL | #[cfg(version("1.44"))]
+LL | #[cfg(version("1.42"))]
| ^^^^^^^^^^^^^^^
|
= note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
@@ -41,171 +9,7 @@
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:10:11
- |
-LL | #[cfg(not(version("1.44")))]
- | ^^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:14:7
- |
-LL | #[cfg(version("1.43", "1.44", "1.45"))]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: expected single version literal
- --> $DIR/feature-gate-cfg-version.rs:14:7
- |
-LL | #[cfg(version("1.43", "1.44", "1.45"))]
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:17:7
- |
-LL | #[cfg(version(false))]
- | ^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error: expected a version literal
- --> $DIR/feature-gate-cfg-version.rs:17:15
- |
-LL | #[cfg(version(false))]
- | ^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:20:7
- |
-LL | #[cfg(version("foo"))]
- | ^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:20:15
- |
-LL | #[cfg(version("foo"))]
- | ^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:23:7
- |
-LL | #[cfg(version("999"))]
- | ^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:23:15
- |
-LL | #[cfg(version("999"))]
- | ^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:26:7
- |
-LL | #[cfg(version("-1"))]
- | ^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:26:15
- |
-LL | #[cfg(version("-1"))]
- | ^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:29:7
- |
-LL | #[cfg(version("65536"))]
- | ^^^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:29:15
- |
-LL | #[cfg(version("65536"))]
- | ^^^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:32:7
- |
-LL | #[cfg(version("0"))]
- | ^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:32:15
- |
-LL | #[cfg(version("0"))]
- | ^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:35:7
- |
-LL | #[cfg(version("1.0"))]
- | ^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:38:7
- |
-LL | #[cfg(version("1.65536.2"))]
- | ^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:38:15
- |
-LL | #[cfg(version("1.65536.2"))]
- | ^^^^^^^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:41:7
- |
-LL | #[cfg(version("1.20.0-stable"))]
- | ^^^^^^^^^^^^^^^^^^^^^^^^
- |
- = note: see issue #64796 <https://github.com/rust-lang/rust/issues/64796> for more information
- = help: add `#![feature(cfg_version)]` to the crate attributes to enable
- = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-
-warning: unknown version literal format, assuming it refers to a future version
- --> $DIR/feature-gate-cfg-version.rs:41:15
- |
-LL | #[cfg(version("1.20.0-stable"))]
- | ^^^^^^^^^^^^^^^
-
-error[E0658]: `cfg(version)` is experimental and subject to change
- --> $DIR/feature-gate-cfg-version.rs:48:18
+ --> $DIR/feature-gate-cfg-version.rs:10:18
|
LL | assert!(cfg!(version("1.42")));
| ^^^^^^^^^^^^^^^
@@ -214,6 +18,6 @@
= help: add `#![feature(cfg_version)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
-error: aborting due to 19 previous errors; 7 warnings emitted
+error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0658`.
diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr
index 18b99d2..c70ab65 100644
--- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr
+++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr
@@ -1,11 +1,11 @@
error[E0038]: the trait `Trait` is not dyn compatible
- --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:25
+ --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:33
|
LL | fn ptr(self: Ptr<Self>);
| --------- help: consider changing method `ptr`'s `self` parameter to be `&self`: `&Self`
...
LL | Ptr(Box::new(4)) as Ptr<dyn Trait>;
- | ^^^^^^^^^^^^^^ `Trait` is not dyn compatible
+ | ^^^^^ `Trait` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/generic-associated-types/issue-76535.stderr b/tests/ui/generic-associated-types/issue-76535.stderr
index 9bac331..2daf9d8 100644
--- a/tests/ui/generic-associated-types/issue-76535.stderr
+++ b/tests/ui/generic-associated-types/issue-76535.stderr
@@ -15,10 +15,10 @@
| ++++
error[E0038]: the trait `SuperTrait` is not dyn compatible
- --> $DIR/issue-76535.rs:34:14
+ --> $DIR/issue-76535.rs:34:22
|
LL | let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/generic-associated-types/issue-78671.stderr b/tests/ui/generic-associated-types/issue-78671.stderr
index c6da137..fff061a 100644
--- a/tests/ui/generic-associated-types/issue-78671.stderr
+++ b/tests/ui/generic-associated-types/issue-78671.stderr
@@ -15,10 +15,10 @@
| +++
error[E0038]: the trait `CollectionFamily` is not dyn compatible
- --> $DIR/issue-78671.rs:5:25
+ --> $DIR/issue-78671.rs:5:30
|
LL | Box::new(Family) as &dyn CollectionFamily<Member=usize>
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/generic-associated-types/issue-79422.stderr b/tests/ui/generic-associated-types/issue-79422.stderr
index 403cb67..dcf3a90 100644
--- a/tests/ui/generic-associated-types/issue-79422.stderr
+++ b/tests/ui/generic-associated-types/issue-79422.stderr
@@ -15,10 +15,10 @@
| ++++
error[E0038]: the trait `MapLike` is not dyn compatible
- --> $DIR/issue-79422.rs:45:12
+ --> $DIR/issue-79422.rs:45:20
|
LL | as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs
index 949c49a..cc81343 100644
--- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs
+++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.rs
@@ -15,5 +15,4 @@ fn main() {
//~^ ERROR the trait `Foo` is not dyn compatible
needs_bar(x);
- //~^ ERROR mismatched types
}
diff --git a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr
index 10a9e2c..d35394a4 100644
--- a/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr
+++ b/tests/ui/higher-ranked/trait-bounds/span-bug-issue-121597.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/span-bug-issue-121597.rs:14:12
+ --> $DIR/span-bug-issue-121597.rs:14:17
|
LL | let x: &dyn Foo = &();
- | ^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -13,23 +13,6 @@
| |
| this trait is not dyn compatible...
-error[E0308]: mismatched types
- --> $DIR/span-bug-issue-121597.rs:17:15
- |
-LL | needs_bar(x);
- | --------- ^ types differ in mutability
- | |
- | arguments to this function are incorrect
- |
- = note: expected raw pointer `*mut Type2`
- found reference `&dyn Foo`
-note: function defined here
- --> $DIR/span-bug-issue-121597.rs:11:4
- |
-LL | fn needs_bar(_: *mut Type2) {}
- | ^^^^^^^^^ -------------
+error: aborting due to 1 previous error
-error: aborting due to 2 previous errors
-
-Some errors have detailed explanations: E0038, E0308.
-For more information about an error, try `rustc --explain E0038`.
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs
index c3dc417..accd173 100644
--- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs
+++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs
@@ -21,6 +21,8 @@ fn foo() -> Self {
fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not dyn compatible
//~^ ERROR return type cannot be a trait object without pointer indirection
+//~| ERROR the trait `DynIncompatible` is not dyn compatible
+//~| ERROR the trait `DynIncompatible` is not dyn compatible
if true {
return A;
}
diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr
index a230090..a8787a0 100644
--- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr
+++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr
@@ -41,6 +41,7 @@
|
LL ~ fn car() -> Box<dyn DynIncompatible> {
LL |
+...
LL | if true {
LL ~ return Box::new(A);
LL | }
@@ -48,7 +49,7 @@
|
error[E0038]: the trait `DynIncompatible` is not dyn compatible
- --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:30:17
+ --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:17
|
LL | fn cat() -> Box<dyn DynIncompatible> {
| ^^^^^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
@@ -75,7 +76,74 @@
LL | fn foo() -> Self where Self: Sized;
| +++++++++++++++++
-error: aborting due to 3 previous errors
+error[E0038]: the trait `DynIncompatible` is not dyn compatible
+ --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:17
+ |
+LL | fn car() -> dyn DynIncompatible {
+ | ^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
+ |
+note: for a trait to be dyn compatible it needs to allow building a vtable
+ for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
+ --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8
+ |
+LL | trait DynIncompatible {
+ | --------------- this trait is not dyn compatible...
+LL | fn foo() -> Self;
+ | ^^^ ...because associated function `foo` has no `self` parameter
+ = help: the following types implement `DynIncompatible`:
+ A
+ B
+ consider defining an enum where each variant holds one of these types,
+ implementing `DynIncompatible` for this new enum and using it instead
+help: consider using an opaque type instead
+ |
+LL - fn car() -> dyn DynIncompatible {
+LL + fn car() -> impl DynIncompatible {
+ |
+help: consider turning `foo` into a method by giving it a `&self` argument
+ |
+LL | fn foo(&self) -> Self;
+ | +++++
+help: alternatively, consider constraining `foo` so it does not apply to trait objects
+ |
+LL | fn foo() -> Self where Self: Sized;
+ | +++++++++++++++++
+
+error[E0038]: the trait `DynIncompatible` is not dyn compatible
+ --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:17
+ |
+LL | fn car() -> dyn DynIncompatible {
+ | ^^^^^^^^^^^^^^^ `DynIncompatible` is not dyn compatible
+ |
+note: for a trait to be dyn compatible it needs to allow building a vtable
+ for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
+ --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:4:8
+ |
+LL | trait DynIncompatible {
+ | --------------- this trait is not dyn compatible...
+LL | fn foo() -> Self;
+ | ^^^ ...because associated function `foo` has no `self` parameter
+ = help: the following types implement `DynIncompatible`:
+ A
+ B
+ consider defining an enum where each variant holds one of these types,
+ implementing `DynIncompatible` for this new enum and using it instead
+ = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+help: consider using an opaque type instead
+ |
+LL - fn car() -> dyn DynIncompatible {
+LL + fn car() -> impl DynIncompatible {
+ |
+help: consider turning `foo` into a method by giving it a `&self` argument
+ |
+LL | fn foo(&self) -> Self;
+ | +++++
+help: alternatively, consider constraining `foo` so it does not apply to trait objects
+ |
+LL | fn foo() -> Self where Self: Sized;
+ | +++++++++++++++++
+
+error: aborting due to 5 previous errors
Some errors have detailed explanations: E0038, E0746.
For more information about an error, try `rustc --explain E0038`.
diff --git a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr
index d65ed6b..8cdb380 100644
--- a/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr
+++ b/tests/ui/impl-trait/in-trait/dyn-compatibility.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/dyn-compatibility.rs:14:33
+ --> $DIR/dyn-compatibility.rs:14:41
|
LL | let i = Box::new(42_u32) as Box<dyn Foo>;
- | ^^^^^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
index 29235ca..68ac765 100644
--- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
+++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/foreign-dyn-error.rs:6:12
+ --> $DIR/foreign-dyn-error.rs:6:17
|
LL | let _: &dyn rpitit::Foo = todo!();
- | ^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^^^^^^^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/issues/issue-18959.rs b/tests/ui/issues/issue-18959.rs
index 4fe669a..415fe81 100644
--- a/tests/ui/issues/issue-18959.rs
+++ b/tests/ui/issues/issue-18959.rs
@@ -18,4 +18,5 @@ fn main() {
let test: &dyn Bar = &mut thing;
//~^ ERROR E0038
foo(test);
+ //~^ ERROR E0038
}
diff --git a/tests/ui/issues/issue-18959.stderr b/tests/ui/issues/issue-18959.stderr
index 5345046..df47d50 100644
--- a/tests/ui/issues/issue-18959.stderr
+++ b/tests/ui/issues/issue-18959.stderr
@@ -15,10 +15,10 @@
= help: consider moving `foo` to another trait
error[E0038]: the trait `Bar` is not dyn compatible
- --> $DIR/issue-18959.rs:18:15
+ --> $DIR/issue-18959.rs:18:20
|
LL | let test: &dyn Bar = &mut thing;
- | ^^^^^^^^ `Bar` is not dyn compatible
+ | ^^^ `Bar` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -30,6 +30,22 @@
| --- this trait is not dyn compatible...
= help: consider moving `foo` to another trait
-error: aborting due to 2 previous errors
+error[E0038]: the trait `Bar` is not dyn compatible
+ --> $DIR/issue-18959.rs:20:9
+ |
+LL | foo(test);
+ | ^^^^ `Bar` is not dyn compatible
+ |
+note: for a trait to be dyn compatible it needs to allow building a vtable
+ for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
+ --> $DIR/issue-18959.rs:1:20
+ |
+LL | pub trait Foo { fn foo<T>(&self, ext_thing: &T); }
+ | ^^^ ...because method `foo` has generic type parameters
+LL | pub trait Bar: Foo { }
+ | --- this trait is not dyn compatible...
+ = help: consider moving `foo` to another trait
+
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/issues/issue-50781.stderr b/tests/ui/issues/issue-50781.stderr
index be65194..4ba3166 100644
--- a/tests/ui/issues/issue-50781.stderr
+++ b/tests/ui/issues/issue-50781.stderr
@@ -16,10 +16,10 @@
= help: only type `()` implements `X`; consider using it directly instead.
error[E0038]: the trait `X` is not dyn compatible
- --> $DIR/issue-50781.rs:16:6
+ --> $DIR/issue-50781.rs:16:10
|
LL | <dyn X as X>::foo(&());
- | ^^^^^ `X` is not dyn compatible
+ | ^ `X` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/issues/issue-58734.rs b/tests/ui/issues/issue-58734.rs
index ee23be8..e5b371f 100644
--- a/tests/ui/issues/issue-58734.rs
+++ b/tests/ui/issues/issue-58734.rs
@@ -18,8 +18,7 @@ fn main() {
Trait::exists(());
// no dyn-compatibility error
Trait::nonexistent(());
- //~^ ERROR no function or associated item named `nonexistent` found
- //~| WARN trait objects without an explicit `dyn` are deprecated
+ //~^ WARN trait objects without an explicit `dyn` are deprecated
//~| WARN this is accepted in the current edition
//~| ERROR the trait `Trait` is not dyn compatible
}
diff --git a/tests/ui/issues/issue-58734.stderr b/tests/ui/issues/issue-58734.stderr
index c4624ce..e5dad00 100644
--- a/tests/ui/issues/issue-58734.stderr
+++ b/tests/ui/issues/issue-58734.stderr
@@ -37,13 +37,6 @@
LL | fn dyn_incompatible() -> Self where Self: Sized;
| +++++++++++++++++
-error[E0599]: no function or associated item named `nonexistent` found for trait object `dyn Trait` in the current scope
- --> $DIR/issue-58734.rs:20:12
- |
-LL | Trait::nonexistent(());
- | ^^^^^^^^^^^ function or associated item not found in `dyn Trait`
+error: aborting due to 1 previous error; 1 warning emitted
-error: aborting due to 2 previous errors; 1 warning emitted
-
-Some errors have detailed explanations: E0038, E0599.
-For more information about an error, try `rustc --explain E0038`.
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.stderr
index 05d31f4..c15aaba 100644
--- a/tests/ui/kindck/kindck-inherited-copy-bound.stderr
+++ b/tests/ui/kindck/kindck-inherited-copy-bound.stderr
@@ -20,10 +20,10 @@
| ^^^ required by this bound in `take_param`
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/kindck-inherited-copy-bound.rs:23:19
+ --> $DIR/kindck-inherited-copy-bound.rs:23:24
|
LL | let z = &x as &dyn Foo;
- | ^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/lint/wide_pointer_comparisons.stderr b/tests/ui/lint/wide_pointer_comparisons.stderr
index 5a0b914..4f5238e 100644
--- a/tests/ui/lint/wide_pointer_comparisons.stderr
+++ b/tests/ui/lint/wide_pointer_comparisons.stderr
@@ -29,10 +29,14 @@
LL | let _ = a < b;
| ^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() < b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a < b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:26:13
@@ -40,10 +44,14 @@
LL | let _ = a <= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() <= b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a <= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:28:13
@@ -51,10 +59,14 @@
LL | let _ = a > b;
| ^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() > b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a > b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:30:13
@@ -62,10 +74,14 @@
LL | let _ = a >= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() >= b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:33:13
@@ -121,10 +137,14 @@
LL | let _ = a.cmp(&b);
| ^^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>().cmp(&b.cast::<()>());
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.cmp(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:43:13
@@ -132,10 +152,14 @@
LL | let _ = a.partial_cmp(&b);
| ^^^^^^^^^^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>().partial_cmp(&b.cast::<()>());
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.partial_cmp(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:45:13
@@ -143,10 +167,14 @@
LL | let _ = a.le(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>().le(&b.cast::<()>());
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.le(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:47:13
@@ -154,10 +182,14 @@
LL | let _ = a.lt(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>().lt(&b.cast::<()>());
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.lt(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:49:13
@@ -165,10 +197,14 @@
LL | let _ = a.ge(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>().ge(&b.cast::<()>());
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.ge(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:51:13
@@ -176,10 +212,14 @@
LL | let _ = a.gt(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>().gt(&b.cast::<()>());
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.gt(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:57:17
@@ -199,10 +239,14 @@
LL | let _ = a >= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.as_ptr().cast::<()>() >= b.as_ptr().cast::<()>();
| ++++++++++++++++++++++ ++++++++++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:61:17
@@ -246,10 +290,14 @@
LL | let _ = a < b;
| ^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>() < (*b).cast::<()>();
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a < b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:76:17
@@ -257,10 +305,14 @@
LL | let _ = a <= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>() <= (*b).cast::<()>();
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a <= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:78:17
@@ -268,10 +320,14 @@
LL | let _ = a > b;
| ^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>() > (*b).cast::<()>();
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a > b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:80:17
@@ -279,10 +335,14 @@
LL | let _ = a >= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>() >= (*b).cast::<()>();
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:83:17
@@ -362,10 +422,14 @@
LL | let _ = a.cmp(&b);
| ^^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>().cmp(&(*b).cast::<()>());
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.cmp(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:97:17
@@ -373,10 +437,14 @@
LL | let _ = a.partial_cmp(&b);
| ^^^^^^^^^^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>().partial_cmp(&(*b).cast::<()>());
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.partial_cmp(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:99:17
@@ -384,10 +452,14 @@
LL | let _ = a.le(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>().le(&(*b).cast::<()>());
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.le(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:101:17
@@ -395,10 +467,14 @@
LL | let _ = a.lt(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>().lt(&(*b).cast::<()>());
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.lt(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:103:17
@@ -406,10 +482,14 @@
LL | let _ = a.ge(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>().ge(&(*b).cast::<()>());
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.ge(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:105:17
@@ -417,10 +497,14 @@
LL | let _ = a.gt(&b);
| ^^^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = (*a).cast::<()>().gt(&(*b).cast::<()>());
| ++ ++++++++++++++ ++ ++++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] a.gt(&b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:110:13
@@ -496,10 +580,14 @@
LL | let _ = a < b;
| ^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() < b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a < b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:124:17
@@ -507,10 +595,14 @@
LL | let _ = a <= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() <= b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a <= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:126:17
@@ -518,10 +610,14 @@
LL | let _ = a > b;
| ^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() > b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a > b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:128:17
@@ -529,10 +625,14 @@
LL | let _ = a >= b;
| ^^^^^^
|
-help: use `std::ptr::addr_eq` or untyped pointers to only compare their addresses
+help: use untyped pointers to only compare their addresses
|
LL | let _ = a.cast::<()>() >= b.cast::<()>();
| +++++++++++++ +++++++++++++
+help: or expect the lint to compare the pointers metadata and addresses
+ |
+LL | let _ = { #[expect(ambiguous_wide_pointer_comparisons, reason = "...")] (a >= b) };
+ | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++
warning: ambiguous wide pointer comparison, the comparison includes metadata which may not be expected
--> $DIR/wide_pointer_comparisons.rs:131:17
diff --git a/tests/ui/not-enough-arguments.rs b/tests/ui/not-enough-arguments.rs
index 4a2ea5e..ec660a1 100644
--- a/tests/ui/not-enough-arguments.rs
+++ b/tests/ui/not-enough-arguments.rs
@@ -1,20 +1,16 @@
+//@ aux-build: delegate_macro.rs
+extern crate delegate_macro;
+use delegate_macro::delegate;
+
// Check that the only error msg we report is the
// mismatch between the # of params, and not other
// unrelated errors.
-
-fn foo(a: isize, b: isize, c: isize, d:isize) {
- panic!();
+fn foo(a: isize, b: isize, c: isize, d: isize) {
+ panic!();
}
// Check that all arguments are shown in the error message, even if they're across multiple lines.
-fn bar(
- a: i32,
- b: i32,
- c: i32,
- d: i32,
- e: i32,
- f: i32,
-) {
+fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
println!("{}", a);
println!("{}", b);
println!("{}", c);
@@ -23,9 +19,35 @@ fn bar(
println!("{}", f);
}
+macro_rules! delegate_local {
+ ($method:ident) => {
+ <Self>::$method(8)
+ //~^ ERROR function takes 2 arguments but 1
+ };
+}
+
+macro_rules! delegate_from {
+ ($from:ident, $method:ident) => {
+ <$from>::$method(8)
+ //~^ ERROR function takes 2 arguments but 1
+ };
+}
+
+struct Bar;
+
+impl Bar {
+ fn foo(a: u8, b: u8) {}
+ fn bar() {
+ delegate_local!(foo);
+ delegate!(foo);
+ //~^ ERROR function takes 2 arguments but 1
+ delegate_from!(Bar, foo);
+ }
+}
+
fn main() {
- foo(1, 2, 3);
- //~^ ERROR function takes 4 arguments but 3
- bar(1, 2, 3);
- //~^ ERROR function takes 6 arguments but 3
+ foo(1, 2, 3);
+ //~^ ERROR function takes 4 arguments but 3
+ bar(1, 2, 3);
+ //~^ ERROR function takes 6 arguments but 3
}
diff --git a/tests/ui/not-enough-arguments.stderr b/tests/ui/not-enough-arguments.stderr
index 099d82e..908d027 100644
--- a/tests/ui/not-enough-arguments.stderr
+++ b/tests/ui/not-enough-arguments.stderr
@@ -1,42 +1,88 @@
-error[E0061]: this function takes 4 arguments but 3 arguments were supplied
- --> $DIR/not-enough-arguments.rs:27:3
+error[E0061]: this function takes 2 arguments but 1 argument was supplied
+ --> $DIR/not-enough-arguments.rs:24:9
|
-LL | foo(1, 2, 3);
- | ^^^--------- argument #4 of type `isize` is missing
+LL | <Self>::$method(8)
+ | ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
+...
+LL | delegate_local!(foo);
+ | -------------------- in this macro invocation
|
-note: function defined here
- --> $DIR/not-enough-arguments.rs:5:4
+note: associated function defined here
+ --> $DIR/not-enough-arguments.rs:39:8
|
-LL | fn foo(a: isize, b: isize, c: isize, d:isize) {
- | ^^^ -------
+LL | fn foo(a: u8, b: u8) {}
+ | ^^^ -----
+ = note: this error originates in the macro `delegate_local` (in Nightly builds, run with -Z macro-backtrace for more info)
help: provide the argument
|
-LL | foo(1, 2, 3, /* isize */);
- | +++++++++++++
+LL | <Self>::$method(8, /* u8 */)
+ | ++++++++++
-error[E0061]: this function takes 6 arguments but 3 arguments were supplied
- --> $DIR/not-enough-arguments.rs:29:3
+error[E0061]: this function takes 2 arguments but 1 argument was supplied
+ --> $DIR/not-enough-arguments.rs:42:9
|
-LL | bar(1, 2, 3);
- | ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
+LL | delegate!(foo);
+ | ^^^^^^^^^^^^^^ argument #2 of type `u8` is missing
+ |
+note: associated function defined here
+ --> $DIR/not-enough-arguments.rs:39:8
+ |
+LL | fn foo(a: u8, b: u8) {}
+ | ^^^ -----
+ = note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0061]: this function takes 2 arguments but 1 argument was supplied
+ --> $DIR/not-enough-arguments.rs:31:9
+ |
+LL | <$from>::$method(8)
+ | ^^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
+...
+LL | delegate_from!(Bar, foo);
+ | ------------------------ in this macro invocation
+ |
+note: associated function defined here
+ --> $DIR/not-enough-arguments.rs:39:8
+ |
+LL | fn foo(a: u8, b: u8) {}
+ | ^^^ -----
+ = note: this error originates in the macro `delegate_from` (in Nightly builds, run with -Z macro-backtrace for more info)
+help: provide the argument
+ |
+LL | <$from>::$method(8, /* u8 */)
+ | ++++++++++
+
+error[E0061]: this function takes 4 arguments but 3 arguments were supplied
+ --> $DIR/not-enough-arguments.rs:49:5
+ |
+LL | foo(1, 2, 3);
+ | ^^^--------- argument #4 of type `isize` is missing
|
note: function defined here
- --> $DIR/not-enough-arguments.rs:10:4
+ --> $DIR/not-enough-arguments.rs:8:4
|
-LL | fn bar(
- | ^^^
-...
-LL | d: i32,
- | ------
-LL | e: i32,
- | ------
-LL | f: i32,
- | ------
+LL | fn foo(a: isize, b: isize, c: isize, d: isize) {
+ | ^^^ --------
+help: provide the argument
+ |
+LL | foo(1, 2, 3, /* isize */);
+ | +++++++++++++
+
+error[E0061]: this function takes 6 arguments but 3 arguments were supplied
+ --> $DIR/not-enough-arguments.rs:51:5
+ |
+LL | bar(1, 2, 3);
+ | ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
+ |
+note: function defined here
+ --> $DIR/not-enough-arguments.rs:13:4
+ |
+LL | fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
+ | ^^^ ------ ------ ------
help: provide the arguments
|
-LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */);
- | +++++++++++++++++++++++++++++++++
+LL | bar(1, 2, 3, /* i32 */, /* i32 */, /* i32 */);
+ | +++++++++++++++++++++++++++++++++
-error: aborting due to 2 previous errors
+error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0061`.
diff --git a/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs
new file mode 100644
index 0000000..b9d123c
--- /dev/null
+++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.rs
@@ -0,0 +1,11 @@
+#![feature(generic_arg_infer)]
+
+// Test that we enforce repeat expr element types are `Copy` even
+// when the repeat count is only inferred at a later point in type
+// checking.
+
+fn main() {
+ let a = [String::new(); _];
+ //~^ ERROR: the trait bound `String: Copy` is not satisfied
+ let b: [_; 2] = a;
+}
diff --git a/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr
new file mode 100644
index 0000000..d974f5a
--- /dev/null
+++ b/tests/ui/repeat-expr/copy-check-when-count-inferred-later.stderr
@@ -0,0 +1,14 @@
+error[E0277]: the trait bound `String: Copy` is not satisfied
+ --> $DIR/copy-check-when-count-inferred-later.rs:8:14
+ |
+LL | let a = [String::new(); _];
+ | ^^^^^^^^^^^^^
+ | |
+ | the trait `Copy` is not implemented for `String`
+ | help: create an inline `const` block: `const { String::new() }`
+ |
+ = note: the `Copy` trait is required because this value will be copied for each element of the array
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr b/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr
index 977ccec..fe4802c 100644
--- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr
+++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr
@@ -1,11 +1,11 @@
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:32
+ --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:39
|
LL | fn foo(self: &Rc<Self>) -> usize;
| --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self`
...
LL | let x = Rc::new(5usize) as Rc<dyn Foo>;
- | ^^^^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/traits/issue-20692.stderr b/tests/ui/traits/issue-20692.stderr
index e902a58..d4a1889 100644
--- a/tests/ui/traits/issue-20692.stderr
+++ b/tests/ui/traits/issue-20692.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Array` is not dyn compatible
- --> $DIR/issue-20692.rs:6:5
+ --> $DIR/issue-20692.rs:6:10
|
LL | &dyn Array;
- | ^^^^^^^^^^ `Array` is not dyn compatible
+ | ^^^^^ `Array` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/traits/issue-38604.stderr b/tests/ui/traits/issue-38604.stderr
index 0455230..0f39dc5 100644
--- a/tests/ui/traits/issue-38604.stderr
+++ b/tests/ui/traits/issue-38604.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/issue-38604.rs:14:13
+ --> $DIR/issue-38604.rs:14:21
|
LL | let _f: Box<dyn Foo> =
- | ^^^^^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/traits/item-privacy.rs b/tests/ui/traits/item-privacy.rs
index cdfd667..9f75e6e 100644
--- a/tests/ui/traits/item-privacy.rs
+++ b/tests/ui/traits/item-privacy.rs
@@ -99,9 +99,7 @@ fn check_assoc_const() {
S::C; // OK
// A, B, C are resolved as inherent items, their traits don't need to be in scope
<dyn C>::A;
- //~^ ERROR associated constant `A` is private
- //~| ERROR the trait `assoc_const::C` is not dyn compatible
- //~| ERROR the trait `assoc_const::C` is not dyn compatible
+ //~^ ERROR the trait `assoc_const::C` is not dyn compatible
<dyn C>::B;
//~^ ERROR the trait `assoc_const::C` is not dyn compatible
C::C; // OK
diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr
index 1d3d8cb..bf59cd0 100644
--- a/tests/ui/traits/item-privacy.stderr
+++ b/tests/ui/traits/item-privacy.stderr
@@ -131,44 +131,10 @@
|
error[E0038]: the trait `assoc_const::C` is not dyn compatible
- --> $DIR/item-privacy.rs:101:6
+ --> $DIR/item-privacy.rs:101:10
|
LL | <dyn C>::A;
- | ^^^^^ `assoc_const::C` is not dyn compatible
- |
-note: for a trait to be dyn compatible it needs to allow building a vtable
- for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
- --> $DIR/item-privacy.rs:25:15
- |
-LL | const A: u8 = 0;
- | ^ ...because it contains this associated `const`
-...
-LL | const B: u8 = 0;
- | ^ ...because it contains this associated `const`
-...
-LL | pub trait C: A + B {
- | - this trait is not dyn compatible...
-LL | const C: u8 = 0;
- | ^ ...because it contains this associated `const`
- = help: consider moving `C` to another trait
- = help: consider moving `A` to another trait
- = help: consider moving `B` to another trait
- = help: only type `S` implements `assoc_const::C`; consider using it directly instead.
-
-error[E0624]: associated constant `A` is private
- --> $DIR/item-privacy.rs:101:14
- |
-LL | const A: u8 = 0;
- | ----------- private associated constant defined here
-...
-LL | <dyn C>::A;
- | ^ private associated constant
-
-error[E0038]: the trait `assoc_const::C` is not dyn compatible
- --> $DIR/item-privacy.rs:101:5
- |
-LL | <dyn C>::A;
- | ^^^^^^^^^^ `assoc_const::C` is not dyn compatible
+ | ^ `assoc_const::C` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -190,10 +156,10 @@
= help: only type `S` implements `assoc_const::C`; consider using it directly instead.
error[E0038]: the trait `assoc_const::C` is not dyn compatible
- --> $DIR/item-privacy.rs:105:5
+ --> $DIR/item-privacy.rs:103:10
|
LL | <dyn C>::B;
- | ^^^^^^^^^^ `assoc_const::C` is not dyn compatible
+ | ^ `assoc_const::C` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -215,7 +181,7 @@
= help: only type `S` implements `assoc_const::C`; consider using it directly instead.
error[E0223]: ambiguous associated type
- --> $DIR/item-privacy.rs:118:12
+ --> $DIR/item-privacy.rs:116:12
|
LL | let _: S::A;
| ^^^^
@@ -227,7 +193,7 @@
|
error[E0223]: ambiguous associated type
- --> $DIR/item-privacy.rs:119:12
+ --> $DIR/item-privacy.rs:117:12
|
LL | let _: S::B;
| ^^^^
@@ -239,7 +205,7 @@
|
error[E0223]: ambiguous associated type
- --> $DIR/item-privacy.rs:120:12
+ --> $DIR/item-privacy.rs:118:12
|
LL | let _: S::C;
| ^^^^
@@ -251,7 +217,7 @@
|
error[E0624]: associated type `A` is private
- --> $DIR/item-privacy.rs:122:12
+ --> $DIR/item-privacy.rs:120:12
|
LL | type A = u8;
| ------ the associated type is defined here
@@ -260,7 +226,7 @@
| ^^^^ private associated type
error[E0624]: associated type `A` is private
- --> $DIR/item-privacy.rs:131:9
+ --> $DIR/item-privacy.rs:129:9
|
LL | type A = u8;
| ------ the associated type is defined here
@@ -268,7 +234,7 @@
LL | A = u8,
| ^^^^^^ private associated type
-error: aborting due to 17 previous errors
+error: aborting due to 15 previous errors
Some errors have detailed explanations: E0038, E0223, E0599, E0624.
For more information about an error, try `rustc --explain E0038`.
diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs
index 2945b28..9634573 100644
--- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs
+++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.rs
@@ -19,5 +19,4 @@ fn main() {
let x: &dyn Foo = &();
//~^ ERROR the trait `Foo` is not dyn compatible
needs_bar(x);
- //~^ ERROR the trait `Foo` is not dyn compatible
}
diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr
index 2cf6329..aead19c 100644
--- a/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr
+++ b/tests/ui/traits/non_lifetime_binders/supertrait-dyn-compatibility.stderr
@@ -8,10 +8,10 @@
= note: `#[warn(incomplete_features)]` on by default
error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/supertrait-dyn-compatibility.rs:19:12
+ --> $DIR/supertrait-dyn-compatibility.rs:19:17
|
LL | let x: &dyn Foo = &();
- | ^^^^^^^^ `Foo` is not dyn compatible
+ | ^^^ `Foo` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -23,22 +23,6 @@
| this trait is not dyn compatible...
= help: only type `()` implements `Foo`; consider using it directly instead.
-error[E0038]: the trait `Foo` is not dyn compatible
- --> $DIR/supertrait-dyn-compatibility.rs:21:5
- |
-LL | needs_bar(x);
- | ^^^^^^^^^ `Foo` is not dyn compatible
- |
-note: for a trait to be dyn compatible it needs to allow building a vtable
- for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
- --> $DIR/supertrait-dyn-compatibility.rs:4:12
- |
-LL | trait Foo: for<T> Bar<T> {}
- | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
- | |
- | this trait is not dyn compatible...
- = help: only type `()` implements `Foo`; consider using it directly instead.
-
-error: aborting due to 2 previous errors; 1 warning emitted
+error: aborting due to 1 previous error; 1 warning emitted
For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs
index 415b050..9ac3b84 100644
--- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs
+++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.rs
@@ -9,7 +9,6 @@ trait Try {
fn w<'a, T: 'a, F: Fn(&'a T)>() {
let b: &dyn FromResidual = &();
//~^ ERROR: the trait `FromResidual` is not dyn compatible
- //~| ERROR the type parameter `R` must be explicitly specified
}
fn main() {}
diff --git a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr
index 0f872df..707aa9e 100644
--- a/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr
+++ b/tests/ui/traits/object/canonicalize-fresh-infer-vars-issue-103626.stderr
@@ -1,23 +1,8 @@
-error[E0393]: the type parameter `R` must be explicitly specified
+error[E0038]: the trait `FromResidual` is not dyn compatible
--> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:17
|
-LL | trait FromResidual<R = <Self as Try>::Residual> {
- | ----------------------------------------------- type parameter `R` must be specified for this
-...
LL | let b: &dyn FromResidual = &();
- | ^^^^^^^^^^^^
- |
- = note: because the parameter default references `Self`, the parameter must be specified on the object type
-help: set the type parameter to the desired type
- |
-LL | let b: &dyn FromResidual<R> = &();
- | +++
-
-error[E0038]: the trait `FromResidual` is not dyn compatible
- --> $DIR/canonicalize-fresh-infer-vars-issue-103626.rs:10:12
- |
-LL | let b: &dyn FromResidual = &();
- | ^^^^^^^^^^^^^^^^^ `FromResidual` is not dyn compatible
+ | ^^^^^^^^^^^^ `FromResidual` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -36,7 +21,6 @@
LL | fn from_residual(residual: R) -> Self where Self: Sized;
| +++++++++++++++++
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
-Some errors have detailed explanations: E0038, E0393.
-For more information about an error, try `rustc --explain E0038`.
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/traits/object/macro-matcher.stderr b/tests/ui/traits/object/macro-matcher.stderr
index 3c668ce..94d5c18 100644
--- a/tests/ui/traits/object/macro-matcher.stderr
+++ b/tests/ui/traits/object/macro-matcher.stderr
@@ -1,19 +1,19 @@
+error[E0038]: the trait `Copy` is not dyn compatible
+ --> $DIR/macro-matcher.rs:8:12
+ |
+LL | m!(dyn Copy + Send + 'static);
+ | ^^^^ `Copy` is not dyn compatible
+ |
+ = note: the trait is not dyn compatible because it requires `Self: Sized`
+ = note: for a trait to be dyn compatible it needs to allow building a vtable
+ for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
+
error[E0224]: at least one trait is required for an object type
--> $DIR/macro-matcher.rs:11:8
|
LL | m!(dyn 'static +);
| ^^^^^^^^^^^^^
-error[E0038]: the trait `Copy` is not dyn compatible
- --> $DIR/macro-matcher.rs:8:8
- |
-LL | m!(dyn Copy + Send + 'static);
- | ^^^^^^^^^^^^^^^^^^^^^^^^^ `Copy` is not dyn compatible
- |
- = note: the trait is not dyn compatible because it requires `Self: Sized`
- = note: for a trait to be dyn compatible it needs to allow building a vtable
- for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
-
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0038, E0224.
diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr
index a3671d9..c5637b4 100644
--- a/tests/ui/traits/object/safety.stderr
+++ b/tests/ui/traits/object/safety.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `Tr` is not dyn compatible
- --> $DIR/safety.rs:15:12
+ --> $DIR/safety.rs:15:17
|
LL | let _: &dyn Tr = &St;
- | ^^^^^^^ `Tr` is not dyn compatible
+ | ^^ `Tr` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr
index e4e39e9..6a81092 100644
--- a/tests/ui/traits/test-2.stderr
+++ b/tests/ui/traits/test-2.stderr
@@ -27,10 +27,10 @@
| ^^^^ -
error[E0038]: the trait `bar` is not dyn compatible
- --> $DIR/test-2.rs:13:22
+ --> $DIR/test-2.rs:13:30
|
LL | (Box::new(10) as Box<dyn bar>).dup();
- | ^^^^^^^^^^^^ `bar` is not dyn compatible
+ | ^^^ `bar` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs
index 444453d..b877ef5 100644
--- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs
+++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.rs
@@ -13,5 +13,4 @@ fn main() {
let x: i32 = 5;
let y = x as dyn MyAdd<i32>;
//~^ ERROR E0038
- //~| ERROR cast to unsized type: `i32` as `dyn MyAdd<i32>`
}
diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
index eea2e75..3347874 100644
--- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
+++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr
@@ -1,20 +1,8 @@
-error[E0620]: cast to unsized type: `i32` as `dyn MyAdd<i32>`
- --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13
- |
-LL | let y = x as dyn MyAdd<i32>;
- | ^^^^^^^^^^^^^^^^^^^
- |
-help: consider using a box or reference as appropriate
- --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:13
- |
-LL | let y = x as dyn MyAdd<i32>;
- | ^
-
error[E0038]: the trait `MyAdd` is not dyn compatible
- --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:18
+ --> $DIR/type-parameter-defaults-referencing-Self-ppaux.rs:14:22
|
LL | let y = x as dyn MyAdd<i32>;
- | ^^^^^^^^^^^^^^ `MyAdd` is not dyn compatible
+ | ^^^^^^^^^^ `MyAdd` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
@@ -25,7 +13,6 @@
= help: consider moving `add` to another trait
= help: only type `i32` implements `MyAdd`; consider using it directly instead.
-error: aborting due to 2 previous errors
+error: aborting due to 1 previous error
-Some errors have detailed explanations: E0038, E0620.
-For more information about an error, try `rustc --explain E0038`.
+For more information about this error, try `rustc --explain E0038`.
diff --git a/tests/ui/wf/wf-dyn-incompatible.stderr b/tests/ui/wf/wf-dyn-incompatible.stderr
index e61b37d..2ba17b7 100644
--- a/tests/ui/wf/wf-dyn-incompatible.stderr
+++ b/tests/ui/wf/wf-dyn-incompatible.stderr
@@ -1,8 +1,8 @@
error[E0038]: the trait `A` is not dyn compatible
- --> $DIR/wf-dyn-incompatible.rs:9:13
+ --> $DIR/wf-dyn-incompatible.rs:9:18
|
LL | let _x: &dyn A;
- | ^^^^^^ `A` is not dyn compatible
+ | ^ `A` is not dyn compatible
|
note: for a trait to be dyn compatible it needs to allow building a vtable
for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
diff --git a/triagebot.toml b/triagebot.toml
index 9d7a0ef..308e8db 100644
--- a/triagebot.toml
+++ b/triagebot.toml
@@ -1170,7 +1170,6 @@
users_on_vacation = [
"fmease",
"jyn514",
- "spastorino",
]
[[assign.warn_non_default_branch.exceptions]]